Package org.geoserver.wms

Examples of org.geoserver.wms.MapLayerInfo


        // apply the override/security check for each layer in the request
        List<MapLayerInfo> layers = getMap.getLayers();
        for (int i = 0; i < layers.size(); i++)
        {
            MapLayerInfo layer = layers.get(i);
            ResourceInfo info = null;
            if(layer.getType() == MapLayerInfo.TYPE_VECTOR || layer.getType() == MapLayerInfo.TYPE_RASTER) {
              info = layer.getResource();
            } else if(!configurationManager.getConfiguration().isAllowRemoteAndInlineLayers()) {
                throw new ServiceException("Remote layers are not allowed");               
            }

            // get the rule, it contains default and allowed styles
View Full Code Here


            requestedLayerInfos.addAll(parseLayers(layerNames, remoteOwsUrl, remoteOwsType));

            List<MapLayerInfo> layers = new ArrayList<MapLayerInfo>();
            for (Object o : requestedLayerInfos) {
                if (o instanceof LayerInfo) {
                    layers.add(new MapLayerInfo((LayerInfo) o));
                } else if (o instanceof LayerGroupInfo) {
                    for (LayerInfo l : ((LayerGroupInfo) o).layers()) {
                        layers.add(new MapLayerInfo(l));
                    }
                } else if (o instanceof MapLayerInfo) {
                    // it was a remote OWS layer, add it directly
                    layers.add((MapLayerInfo) o);
                }
View Full Code Here

        }

        final List<MapLayerInfo> layers = new ArrayList<MapLayerInfo>();
        final List<Style> styles = new ArrayList<Style>();

        MapLayerInfo currLayer = null;
        String styleName = null;

        for (int i = 0; i < requestedLayers.size(); i++) {
            if (styleNames != null && styleNames.size() > 0) {
                styleName = styleNames.get(i);
            }
            Object o = requestedLayers.get(i);
            if (o instanceof LayerInfo) {
                currLayer = new MapLayerInfo((LayerInfo) o);

                if (styledLayers[i] instanceof NamedLayer) {
                    NamedLayer namedLayer = ((NamedLayer) styledLayers[i]);
                    currLayer.setLayerFeatureConstraints(namedLayer.getLayerFeatureConstraints());
                }

                layers.add(currLayer);
                Style style = findStyleOf(request, currLayer, styleName, styledLayers);
                styles.add(style);
            } else if (o instanceof LayerGroupInfo) {
                List<LayerInfo> subLayers = ((LayerGroupInfo) o).layers();
                for (LayerInfo layer : subLayers) {
                    currLayer = new MapLayerInfo(layer);
                    layers.add(currLayer);
                    Style style = findStyleOf(request, currLayer, styleName, styledLayers);
                    styles.add(style);
                }
            } else {
View Full Code Here

            throw new ServiceException("SLD document contains no layers");
        }

        final List<MapLayerInfo> layers = new ArrayList<MapLayerInfo>();
        final List<Style> styles = new ArrayList<Style>();
        MapLayerInfo currLayer = null;
        Style currStyle = null;

        String layerName;
        UserLayer ul;
        for (StyledLayer sl : styledLayers) {
            layerName = sl.getName();

            if (null == layerName) {
                throw new ServiceException("A UserLayer without layer name was passed");
            }

            if (sl instanceof UserLayer && ((((UserLayer) sl)).getRemoteOWS() != null)) {
                // this beast can define multiple feature sources and multiple styles, we'll
                // have to mix and match them (ugh)
                ul = ((UserLayer) sl);
                try {
                    addRemoteLayersFromUserLayer(request, ul, layers, styles);
                } catch (IOException e) {
                    throw new ServiceException("Error accessing remote layers", e,
                            "RemoteAccessFailed");
                }
            } else {
                // simpler case, one layer, eventually multiple styles
                currLayer = null;
                // handle the InLineFeature stuff
                if ((sl instanceof UserLayer)
                        && ((((UserLayer) sl)).getInlineFeatureDatastore() != null)) {
                    // SPECIAL CASE - we make the temporary version
                    ul = ((UserLayer) sl);

                    try {
                        currLayer = initializeInlineFeatureLayer(request, ul);
                    } catch (Exception e) {
                        throw new ServiceException(e);
                    }
                } else {
                    if (wms.getLayerGroupByName(layerName) != null) {
                        LayerGroupInfo group = wms.getLayerGroupByName(layerName);
                        List<LayerInfo> groupLayers = group.layers();
                        List<StyleInfo> groupStyles = group.styles();
                        for (int i = 0; i < groupLayers.size(); i++) {
                            LayerInfo layer = groupLayers.get(i);
                            layers.add(new MapLayerInfo(layer));
                            StyleInfo style = groupStyles.get(i);
                            if (style != null) {
                                styles.add(style.getStyle());
                            } else {
                                styles.add(layer.getDefaultStyle().getStyle());
                            }
                        }
                        // move to the next named layer
                        continue;
                    } else {
                        LayerInfo layerInfo = wms.getLayerByName(layerName);

                        if (layerInfo == null)
                            throw new ServiceException("Unknown layer: " + layerName);

                        currLayer = new MapLayerInfo(layerInfo);
                        if (sl instanceof NamedLayer) {
                            NamedLayer namedLayer = ((NamedLayer) sl);
                            currLayer.setLayerFeatureConstraints(namedLayer
                                    .getLayerFeatureConstraints());
                        }
                    }
                }

                if (currLayer.getType() == MapLayerInfo.TYPE_RASTER) {
                    try {
                        addStyles(wms, request, currLayer, sl, layers, styles);
                    } catch (ServiceException wm) {
                        // hmm, well, the style they specified in the wms
                        // request
View Full Code Here

            // this is messy, why the spec allows for multiple constraints and multiple
            // styles is beyond me... we'll style each remote layer with all possible
            // styles, feauture type style matching will do the rest during rendering
            for (int j = 0; j < layerStyles.length; j++) {
                Style style = layerStyles[i];
                MapLayerInfo info = new MapLayerInfo(fs);
                layers.add(info);
                styles.add(style);
                // treat it like an externally provided filter... ugly I know, but
                // the sane thing (adding a filter as a MapLayerInfo field) would
                // break havoc in GetFeatureInfo
View Full Code Here

        } else {
            DataStore inlineFeatureDatastore = ul.getInlineFeatureDatastore();
            String typeName = inlineFeatureDatastore.getTypeNames()[0];
            featureSource = inlineFeatureDatastore.getFeatureSource(typeName);
        }
        return new MapLayerInfo(featureSource);
    }
View Full Code Here

            // search into the remote WFS if there is any
            if (remoteTypeNames.contains(layerName)) {
                SimpleFeatureSource remoteSource;
                remoteSource = remoteWFS.getFeatureSource(layerName);
                if (remoteSource != null) {
                    layersOrGroups.add(new MapLayerInfo(remoteSource));
                    continue;
                }
            }

            // not a remote layer, lets look up for a registered one
View Full Code Here

         * <code>LayerDescription</code> element for each featuretype requested.
         *
         * @param req
         */
        private void handleLayers(DescribeLayerRequest req) {
            MapLayerInfo layer;

            final List layers = req.getLayers();

            AttributesImpl queryAtts = new AttributesImpl();
            queryAtts.addAttribute("", "typeName", "typeName", "", "");

            for (Iterator it = layers.iterator(); it.hasNext();) {
                layer = (MapLayerInfo) it.next();

                AttributesImpl layerAtts = new AttributesImpl();
                layerAtts.addAttribute("", "name", "name", "", "");
                String owsUrl;
                String owsType;
                if (MapLayerInfo.TYPE_VECTOR == layer.getType()) {
                    owsUrl = buildURL(baseURL, "wfs", null, URLType.SERVICE);
                    owsUrl = appendQueryString(owsUrl, "");
                    owsType = "WFS";
                    layerAtts.addAttribute("", "wfs", "wfs", "", owsUrl);
                } else if (MapLayerInfo.TYPE_RASTER == layer.getType()) {
                    owsUrl = buildURL(baseURL, "wcs", null, URLType.SERVICE);
                    owsUrl = appendQueryString(owsUrl, "");
                    owsType = "WCS";
                } else {
                    // non vector nor raster layer, LayerDescription will not contain these
                    // attributes
                    owsUrl = owsType = null;
                }

                if (owsType != null && owsUrl != null) {
                    // the layer is describable only if its vector or raster based
                    // in our case that meand directly associated to a resourceInfo (ie, no base
                    // map)
                    layerAtts.addAttribute("", "owsURL", "owsURL", "", owsUrl);
                    layerAtts.addAttribute("", "owsType", "owsType", "", owsType);
                }

                layerAtts.setAttribute(0, "", "name", "name", "", layer.getLayerInfo().prefixedName());
                start("LayerDescription", layerAtts);

                queryAtts.setAttribute(0, "", "typeName", "typeName", "", layer.getName());
                element("Query", null, queryAtts);

                end("LayerDescription");
            }
        }
View Full Code Here

        final List<String> layerNames = (List<String>) rawNamesParser.parse(paramValue);

        List<MapLayerInfo> layers = new ArrayList<MapLayerInfo>(layerNames.size());

        MapLayerInfo layer = null;

        for (String layerName : layerNames) {

            LayerInfo layerInfo = wms.getLayerByName(layerName);
            if (layerInfo == null) {
                LayerGroupInfo groupInfo = wms.getLayerGroupByName(layerName);
                if (groupInfo == null || LayerGroupInfo.Mode.CONTAINER.equals(groupInfo.getMode())) {
                    throw new ServiceException(layerName + ": no such layer on this server",
                            "LayerNotDefined", getClass().getSimpleName());
                } else {
                    for (LayerInfo li : groupInfo.layers()) {
                        layer = new MapLayerInfo(li);
                        layers.add(layer);
                    }
                }
            } else {
                layer = new MapLayerInfo(layerInfo);
                layers.add(layer);
            }
        }

        return layers;
View Full Code Here

        LayerInfo l = createMock(LayerInfo.class);
        expect(l.getResource()).andReturn(r);
        expect(l.getType()).andReturn(LayerInfo.Type.VECTOR);
        replay(l);
       
        return new MapLayerInfo(l);
    }
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.