Package org.geoserver.wms

Examples of org.geoserver.wms.MapLayerInfo


        // Map<String, String> namespaces = new HashMap<String, String>();
        // namespaces.put("atom", "http://purl.org/atom/ns#");
        // XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(namespaces));

        MapLayerInfo layer = mockData.addFeatureTypeLayer("TestPoints", Point.class);
        request = mockData.createRequest();
        request.setLayers(Collections.singletonList(layer));

        request.setFormatOptions(Collections.singletonMap("relLinks", "true"));
        request.setBaseUrl("http://geoserver.org:8181/geoserver");

        mapContent = new WMSMapContent(request);
        FeatureSource source = layer.getFeatureSource(true);
        Style layerStyle = mockData.getDefaultStyle().getStyle();
        Layer Layer = new FeatureLayer(source, layerStyle);
        mapContent.addLayer(Layer);
    }
View Full Code Here


     */
    private void addLayer(List<FeatureType> layers,
            LayerInfo layerInfo, GetLegendGraphicRequest req) throws FactoryRegistryException, IOException, TransformException, SchemaException {
        FeatureType featureType=getLayerFeatureType(layerInfo);
        if(featureType != null) {
            MapLayerInfo mli=new MapLayerInfo(layerInfo);
            // maps a title, if label is defined on layer
            if(mli.getLabel() != null) {
                req.setTitle(featureType.getName(),mli.getLabel());
            }
            layers.add(featureType);
        } else {
            throw new ServiceException("Cannot get FeatureType for Layer",
                    "MissingFeatureType");
View Full Code Here

       
        // Map<String, String> namespaces = new HashMap<String, String>();
        // namespaces.put("atom", "http://purl.org/atom/ns#");
        // XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(namespaces));

        MapLayerInfo layer = mockData.addFeatureTypeLayer("TestPoints", Point.class);
        mapContent = new WMSMapContent();
        GetMapRequest request = mockData.createRequest();
        request.setLayers(Collections.singletonList(layer));

        SimpleFeatureSource featureSource;
        featureSource = (SimpleFeatureSource) ((FeatureTypeInfo)layer.getFeature()).getFeatureSource(null, null);
       
        Layer = new FeatureLayer(featureSource, mockData.getDefaultStyle().getStyle());

        httpreq.setScheme("http");
        httpreq.setServerName("geoserver.org");
View Full Code Here

     * @throws FactoryRegistryException
     * @throws TransformException
     * @throws SchemaException
     */
    private FeatureType getLayerFeatureType(LayerInfo layerInfo) throws IOException, FactoryRegistryException, TransformException, SchemaException {
        MapLayerInfo mli=new MapLayerInfo(layerInfo);
        if (layerInfo.getType() == Type.VECTOR) {
            FeatureType featureType = mli.getFeature().getFeatureType();
            return featureType;
        } else if (layerInfo.getType() == Type.RASTER) {
            CoverageInfo coverageInfo = mli.getCoverage();
            // it much safer to wrap a reader rather than a coverage in most cases, OOM can
            // occur otherwise
            final GridCoverage2DReader reader;
            reader = (GridCoverage2DReader) coverageInfo.getGridCoverageReader(
                    new NullProgressListener(), GeoTools.getDefaultHints());
View Full Code Here

     * Gets the default style for the given layer
     * @param layerInfo layer requested
     * @return default style of the layer
     */
    private Style getStyleFromLayer(LayerInfo layerInfo) {
        MapLayerInfo mli=new MapLayerInfo(layerInfo);
        return mli.getDefaultStyle();
    }
View Full Code Here

     * @see GetMapRequest#getMaxFeatures()
     * @see GetMapRequest#getStartIndex()
     */
    @Test
    public void testEncodeWithPaging() throws Exception {
        MapLayerInfo mli = mockData.addFeatureTypeLayer("TestPoints", Point.class);
        FeatureTypeInfo typeInfo = mli.getFeature();
        SimpleFeatureType featureType = (SimpleFeatureType) typeInfo.getFeatureType();
        mockData.addFeature(featureType, new Object[] { "name1", "POINT(1 1)" });
        mockData.addFeature(featureType, new Object[] { "name2", "POINT(2 2)" });
        mockData.addFeature(featureType, new Object[] { "name3", "POINT(3 3)" });
        mockData.addFeature(featureType, new Object[] { "name4", "POINT(4 4)" });
View Full Code Here

                // Ensure the Layer is present
                if (layerInfo == null) {
                    throw new ServiceException("Layer not found: " + layername);
                }

                layers.add(new MapLayerInfo(layerInfo));
            }

            request.setLayers(layers);

            // Generate the bounding box if not present
View Full Code Here

        int type = layer.getType();
        return type == MapLayerInfo.TYPE_RASTER;
    }

    public List<FeatureCollection> identify(FeatureInfoRequestParameters params, int maxFeatures) throws Exception {
        final MapLayerInfo layer = params.getLayer();
        final Filter filter = params.getFilter();
        final CoverageInfo cinfo = layer.getCoverage();
        final GridCoverage2DReader reader = (GridCoverage2DReader) cinfo
                .getGridCoverageReader(new NullProgressListener(),
                        GeoTools.getDefaultHints());
       
       
View Full Code Here

    private List<String> styleNames(WMSMapContent mapContent) {
        if (mapContent.layers().size() != 1 || mapContent.getRequest() == null)
            return Collections.emptyList();

        MapLayerInfo info = mapContent.getRequest().getLayers().get(0);
        return info.getOtherStyleNames();
    }
View Full Code Here

    public List<FeatureCollection> identify(FeatureInfoRequestParameters params, int maxFeatures) throws Exception {
        LOGGER.log(Level.FINER, "Appliying bbox based feature info identifier");

       
        final MapLayerInfo layer = params.getLayer();
        final Filter filter = params.getFilter();
        final Style style = params.getStyle();
        // ok, internally rendered layer then, we check the style to see what's active
        final List<Rule> rules = getActiveRules(style, params.getScaleDenominator());
        if (rules.size() == 0) {
            return null;
        }

        // compute the request radius
        double radius = getSearchRadius(params, layer, rules);

        // compute the bbox for the request
        ReferencedEnvelope queryEnvelope = getEnvelopeFilter(params, radius);
        CoordinateReferenceSystem requestedCRS = params.getRequestedCRS();
        CoordinateReferenceSystem dataCRS = layer.getCoordinateReferenceSystem();
        if ((requestedCRS != null) && !CRS.equalsIgnoreMetadata(dataCRS, requestedCRS)) {
            if (dataCRS.getCoordinateSystem().getDimension() == 3
                    && requestedCRS.getCoordinateSystem().getDimension() == 2) {
                queryEnvelope = JTS.transformTo3D(queryEnvelope, dataCRS, true, 10);
            } else {
                queryEnvelope = queryEnvelope.transform(dataCRS, true);
            }
        }

        final FeatureSource<? extends FeatureType, ? extends Feature> featureSource;
        featureSource = layer.getFeatureSource(false);
        FeatureType schema = featureSource.getSchema();

        Filter getFInfoFilter = null;
        FilterFactory2 ff = params.getFilterFactory();
        try {
            GeometryDescriptor geometryDescriptor = schema.getGeometryDescriptor();
            String localName = geometryDescriptor.getLocalName();
            Polygon queryPolygon = JTS.toGeometry(queryEnvelope);
            getFInfoFilter = ff.intersects(ff.property(localName), ff.literal(queryPolygon));
        } catch (IllegalFilterException e) {
            e.printStackTrace();
            throw new ServiceException("Internal error : " + e.getMessage(), e);
        }

        // include the eventual layer definition filter
        if (filter != null) {
            getFInfoFilter = ff.and(getFInfoFilter, filter);
        }

        // see if we can include the rule filters as well, if too many we'll do them in
        // memory
        Filter postFilter = Filter.INCLUDE;
        Filter rulesFilters = buildRulesFilter(ff, rules);
        if (!(featureSource.getSchema() instanceof SimpleFeatureType)
                || !(rulesFilters instanceof Or)
                || (rulesFilters instanceof Or && ((Or) rulesFilters).getChildren().size() <= 20)) {
            getFInfoFilter = ff.and(getFInfoFilter, rulesFilters);
        } else {
            postFilter = rulesFilters;
        }

        // handle time/elevation
        Filter timeElevationFilter = wms.getTimeElevationToFilter(params.getTimes(),
                params.getElevations(), layer.getFeature());
        getFInfoFilter = Filters.and(ff, getFInfoFilter, timeElevationFilter);

        // simplify the filter
        SimplifyingFilterVisitor simplifier = new SimplifyingFilterVisitor();
        getFInfoFilter = (Filter) getFInfoFilter.accept(simplifier, null);
View Full Code Here

TOP

Related Classes of org.geoserver.wms.MapLayerInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.