Package org.geoserver.wms

Examples of org.geoserver.wms.GetMapRequest$MandatoryParameters


    public void testRasterPlacemarkFalse() throws Exception {
        doTestRasterPlacemark(false);
    }

    protected void doTestRasterPlacemark(boolean doPlacemarks) throws Exception {
        GetMapRequest getMapRequest = createGetMapRequest(MockData.BASIC_POLYGONS);
        HashMap formatOptions = new HashMap();
        formatOptions.put("kmplacemark", new Boolean(doPlacemarks));
        formatOptions.put("kmscore", new Integer(0));
        getMapRequest.setFormatOptions(formatOptions);

        WMSMapContext mapContext = new WMSMapContext(getMapRequest);
        mapContext.addLayer(mapLayer);
        mapContext.setMapHeight(1024);
        mapContext.setMapWidth(1024);
View Full Code Here


     *
     * @see org.geoserver.ows.Response#canHandle(org.geoserver.platform.Operation)
     */
    @Override
    public boolean canHandle(final Operation operation) {
        GetMapRequest request;
        Object[] parameters = operation.getParameters();
        request = (GetMapRequest) OwsUtils.parameter(parameters, GetMapRequest.class);
        if (request == null) {
            return false;
        }
        Set<String> outputFormats = getOutputFormats();
        if (outputFormats.size() == 0) {
            //rely only on response binding
            return true;
        }
        String outputFormat = request.getFormat();
        boolean match = outputFormats.contains(outputFormat);
        return match;
    }
View Full Code Here

        // check the style to see what's active
        final List<Rule> rules = getActiveRules(style, params.getScaleDenominator());
        if (rules.size() == 0) {
            return null;
        }
        GetMapRequest getMap = params.getGetMapRequest();
        WMSMapContent mc = new WMSMapContent(getMap);
        try {
            // prepare the fake web map content
            mc.setTransparent(true);
            mc.setBuffer(params.getBuffer());
            mc.getViewport().setBounds(new ReferencedEnvelope(getMap.getBbox(), getMap.getCrs()));
            mc.setMapWidth(getMap.getWidth());
            mc.setMapHeight(getMap.getHeight());
            FeatureLayer layer = getLayer(params, style);
            mc.addLayer(layer);
            // setup the env variables just like in the original GetMap
            RenderingVariables.setupEnvironmentVariables(mc);
           
            // setup the transformation from screen to world space
            AffineTransform worldToScreen = RendererUtilities.worldToScreenTransform(
                    params.getRequestedBounds(), new Rectangle(params.getWidth(), params.getHeight()));
            AffineTransform screenToWorld = worldToScreen.createInverse();
           
            // apply uom rescale on the rules
            rescaleRules(rules, params);
           
            // setup the area we are actually going to paint
            int radius = getSearchRadius(params, rules, layer, getMap, screenToWorld);
            if(radius < buffer) {
                radius = buffer;
            }
            Envelope targetRasterSpace = new Envelope(params.getX() - radius, params.getX() + radius,
                    params.getY() - radius, params.getY() + radius);
            Envelope targetModelSpace = JTS.transform(targetRasterSpace, new AffineTransform2D(screenToWorld));
           
            // prepare the image we are going to check rendering against
            int paintAreaSize = radius * 2 + 1;
            final BufferedImage image = ImageTypeSpecifier.createFromBufferedImageType(
                    BufferedImage.TYPE_INT_ARGB).createBufferedImage(paintAreaSize,
                    paintAreaSize);
            image.setAccelerationPriority(0);
   
            // and now the listener that will check for painted pixels
            int mid = radius;
            int hitAreaSize = buffer * 2 + 1;
            Rectangle hitArea = new Rectangle(mid - buffer, mid - buffer, hitAreaSize, hitAreaSize);
            final FeatureInfoRenderListener featureInfoListener = new FeatureInfoRenderListener(
                    image, hitArea, maxFeatures, params.getPropertyNames());

            // update the map context
            mc.getViewport().setBounds(new ReferencedEnvelope(targetModelSpace, getMap.getCrs()));
            mc.setMapWidth(paintAreaSize);
            mc.setMapHeight(paintAreaSize);
           
            // and now run the rendering _almost_ like a GetMap
            RenderedImageMapOutputFormat rim = new RenderedImageMapOutputFormat(wms) {
View Full Code Here

            filter = layerFilter;
        } else {
            filter = FF.and(Arrays.asList(layerFilter, dimensionFilter));
        }

        GetMapRequest getMap = params.getGetMapRequest();
        FeatureSource<? extends FeatureType, ? extends Feature> featureSource = layer
                .getFeatureSource(true);
        final Query definitionQuery = new Query(featureSource.getSchema().getName().getLocalPart());
        definitionQuery.setVersion(getMap.getFeatureVersion());
        definitionQuery.setFilter(filter);
        Map<String, String> viewParams = params.getViewParams();
        if (viewParams != null) {
            definitionQuery.setHints(new Hints(Hints.VIRTUAL_TABLE_PARAMETERS, viewParams));
        }

        // check for startIndex + offset
        final Integer startIndex = getMap.getStartIndex();
        if (startIndex != null) {
            QueryCapabilities queryCapabilities = featureSource.getQueryCapabilities();
            if (queryCapabilities.isOffsetSupported()) {
                // fsource is required to support
                // SortBy.NATURAL_ORDER so we don't bother checking
                definitionQuery.setStartIndex(startIndex);
            } else {
                // source = new PagingFeatureSource(source,
                // request.getStartIndex(), limit);
                throw new ServiceException("startIndex is not supported for the " + layer.getName()
                        + " layer");
            }
        }

        int maxFeatures = getMap.getMaxFeatures() != null ? getMap.getMaxFeatures()
                : Integer.MAX_VALUE;
        definitionQuery.setMaxFeatures(maxFeatures);

        FeatureLayer result = new FeatureLayer(new FeatureInfoFeatureSource(featureSource,
                params.getPropertyNames()), style);
View Full Code Here

                }
            }

            String selfLinks = (String) mapContent.getRequest().getFormatOptions().get("selfLinks");
            if (selfLinks != null && selfLinks.equalsIgnoreCase("true")) {
                GetMapRequest request = mapContent.getRequest();
                String link = "";

                try {
                    link = getFeatureTypeURL();
                } catch (IOException ioe) {
View Full Code Here

            Catalog catalog = gs.getCatalog();
            String nsUri = mapLayer.getFeatureSource().getSchema().getName().getNamespaceURI();
            NamespaceInfo ns = catalog.getNamespaceByURI(nsUri);
            String featureTypeName = mapLayer.getFeatureSource().getSchema().getName()
                    .getLocalPart();
            GetMapRequest request = mapContent.getRequest();
            String baseURL = request.getBaseUrl();
            String prefix = ns.getPrefix();
            return buildURL(baseURL, appendPath("rest", prefix, featureTypeName), null,
                    URLType.SERVICE);
        }
View Full Code Here

    @Override
    public Object read(Object req, Map kvp, Map rawKvp) throws Exception {
        GetFeatureInfoRequest request = (GetFeatureInfoRequest) super.read(req, kvp, rawKvp);
        request.setRawKvp(rawKvp);

        GetMapRequest getMapPart = new GetMapRequest();
        try {
            getMapPart = getMapReader.read(getMapPart, kvp, rawKvp);
        } catch (ServiceException se) {
            throw se;
        } catch (Exception e) {
            throw new ServiceException(e);
        }

        request.setGetMapRequest(getMapPart);
       
        List<MapLayerInfo> getMapLayers = getMapPart.getLayers();
       
        if ((getMapPart.getSldBody() != null || getMapPart.getSld() != null)
                && (rawKvp.get("QUERY_LAYERS") == null || "".equals(rawKvp.get("QUERY_LAYERS")))) {
            // in this case we assume all layers in SLD body are to be queried (GS own extension)(
            request.setQueryLayers(getMapLayers);
        } else {
            request.setQueryLayers(new MapLayerInfoKvpParser("QUERY_LAYERS", wms).parse((String) rawKvp
                    .get("QUERY_LAYERS")));
        }
       
        if (request.getQueryLayers().isEmpty()) {
            throw new ServiceException("No QUERY_LAYERS has been requested, or no "
                    + "queriable layer in the request anyways");
        }
       
        if(kvp.containsKey("propertyName")) {
            List<List<String>> propertyNames = (List<List<String>>) kvp.get("propertyName");
            if(propertyNames.size() == 1 && request.getQueryLayers().size() > 1) {
                // assume we asked the same list for all layers
                while(propertyNames.size() < request.getQueryLayers().size()) {
                    propertyNames.add(propertyNames.get(0));
                }
            }
            if(propertyNames.size() != request.getQueryLayers().size()) {
                throw new ServiceException("Mismatch between the property name set count "
                        + propertyNames.size() + " and the query layers count " + request.getQueryLayers().size(),
                        "InvalidParameter", "propertyName");
            }
            request.setPropertyNames(propertyNames);
        }

        // make sure they are a subset of layers
        List<MapLayerInfo> queryLayers = new ArrayList<MapLayerInfo>(request.getQueryLayers());
        queryLayers.removeAll(getMapLayers);
        if (queryLayers.size() > 0) {
            // we've already expanded base layers so let's avoid list the names, they are not
            // the original ones anymore
            throw new ServiceException("QUERY_LAYERS contains layers not cited in LAYERS. "
                    + "It should be a proper subset of those instead");
        }

        for (MapLayerInfo l : request.getQueryLayers()) {
            LayerInfo layerInfo = l.getLayerInfo();
            if (!wms.isQueryable(layerInfo)) {
                throw new ServiceException("Layer " + l.getName() + " is not queryable",
                    WMSErrorCode.LAYER_NOT_QUERYABLE.get(request.getVersion()), "QUERY_LAYERS");
            }
        }

        String format = (String) (kvp.containsKey("INFO_FORMAT") ? kvp.get("INFO_FORMAT") : null);

        if (format == null) {
            format = "text/plain";
        } else {
            List<String> infoFormats = wms.getAvailableFeatureInfoFormats();
            if (!infoFormats.contains(format)) {
                throw new ServiceException("Invalid format '" + format
                        + "', supported formats are " + infoFormats, "InvalidFormat", "info_format");
            }
            if (wms.getAllowedFeatureInfoFormats().contains(format)==false)
                throw wms.unallowedGetFeatureInfoFormatException(format);
        }

        request.setInfoFormat(format);

        request.setFeatureCount(1); // DJB: according to the WMS spec (7.3.3.7 FEATURE_COUNT) this
                                    // should be 1. also tested for by cite
        try {
            int maxFeatures = Integer.parseInt(String.valueOf(kvp.get("FEATURE_COUNT")));
            request.setFeatureCount(maxFeatures);
        } catch (NumberFormatException ex) {
            // do nothing, FEATURE_COUNT is optional
        }

        Version version = wms.negotiateVersion(request.getVersion());
        request.setVersion(version.toString());
       
        //JD: most wms 1.3 client implementations still use x/y rather than i/j, so we support those
        // too when i/j not specified when not running in strict cite compliance mode
        String colPixel, rowPixel;
        if(version.compareTo(WMS.VERSION_1_3_0) >= 0) {
            colPixel = "I";
            rowPixel = "J";
           
            if (!kvp.containsKey(colPixel) && !kvp.containsKey(rowPixel)) {
                if (!wms.getServiceInfo().isCiteCompliant() && kvp.containsKey("X")
                    && kvp.containsKey("Y")) {
                    colPixel = "X";
                    rowPixel = "Y";
                }
            }
        }
        else {
            colPixel = "X";
            rowPixel = "Y";
        }
       
        try {
            String colParam = String.valueOf(kvp.get(colPixel));
            String rowParam = String.valueOf(kvp.get(rowPixel));
            int x = Integer.parseInt(colParam);
            int y = Integer.parseInt(rowParam);
           
            //ensure x/y in dimension of image
            if (x < 0 || x > getMapPart.getWidth() || y < 0 || y > getMapPart.getHeight()) {
                throw new ServiceException(
                    String.format("%d, %d not in dimensions of image: %d, %d", x, y,
                        getMapPart.getWidth(), getMapPart.getHeight()), "InvalidPoint");
            }
            request.setXPixel(x);
            request.setYPixel(y);
        } catch (NumberFormatException ex) {
            String msg = colPixel + " and " + rowPixel + " incorrectly specified";
View Full Code Here

        }

        public void encode(Object o) throws IllegalArgumentException {

            final WMSMapContent mapContent = (WMSMapContent) o;
            final GetMapRequest request = mapContent.getRequest();
            final List<Layer> layers = mapContent.layers();

            final KMLLookAt lookAtOpts = new KMLLookAt(request.getFormatOptions());
            // start("kml");
            start("kml",
                    KMLUtils.attributes(new String[] { "xmlns", "http://www.opengis.net/kml/2.2",
                            "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance",
                            "xsi:schemaLocation",
                            "http://www.opengis.net/kml/2.2 http://schemas.opengis.net/kml/2.2.0/ogckml22.xsd" }));

            // calculate scale denominator
            scaleDenominator = 1;
            try {
                scaleDenominator = RendererUtilities.calculateOGCScale(mapContent.getRenderingArea(),
                        mapContent.getMapWidth(), null);
            } catch (Exception e) {
                LOGGER.log(Level.WARNING, "Error calculating scale denominator", e);
            }
            LOGGER.log(Level.FINE, "scale denominator = " + scaleDenominator);

            // if we have more than one layer ( or a legend was requested ),
            // use the name "GeoServer" to group them
            boolean group;
            Boolean legend = (Boolean) request.getFormatOptions().get("legend");
            if (legend != null) {
                group = (layers.size() > 1) || legend.booleanValue();
            } else {
                group = (layers.size() > 1);
            }
View Full Code Here

        DefaultValueConfigurations config = getConfigurations(resource);
        if (config != null
                && request != null
                && ("GetMap".equalsIgnoreCase(request.getRequest()) || "GetFeatureInfo"
                        .equalsIgnoreCase(request.getRequest()))) {
            GetMapRequest getMap = getGetMap(request);
            try {
                Map<String, Object> defaults = getDefaultValues(resource, getMap, config);

                String key = dimensionName;
                if (dimensionName.startsWith(ResourceInfo.CUSTOM_DIMENSION_PREFIX)) {
View Full Code Here

    }

    private GetMapRequest getGetMap(Request request) {
        Operation op = request.getOperation();
        Object parsedRequest = op.getParameters()[0];
        GetMapRequest getMap;

        if (parsedRequest instanceof GetMapRequest) {
            getMap = (GetMapRequest) parsedRequest;
        } else if (parsedRequest instanceof GetFeatureInfoRequest) {
            getMap = ((GetFeatureInfoRequest) parsedRequest).getGetMapRequest();
View Full Code Here

TOP

Related Classes of org.geoserver.wms.GetMapRequest$MandatoryParameters

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.