Examples of GetFeatureInfoRequest


Examples of org.geoserver.wms.GetFeatureInfoRequest

        assertEquals("acme:foo", data.getResources().get(0));
    }
   
    @Test
    public void testWMSGetFeatureInfo() throws Exception {
        GetFeatureInfoRequest gfi = new GetFeatureInfoRequest();
       
        GetMapRequest gm = new GetMapRequest();
        gm.setHeight(330);
        gm.setWidth(780);
        Envelope env = new ReferencedEnvelope(-126.81851,-115.818992,44.852958,49.5066,null);
        CoordinateReferenceSystem crs = CRS.decode("EPSG:4326",true);
        CoordinateReferenceSystem logCrs = CRS.decode("EPSG:4326",false);
        gm.setBbox(env);
        gm.setCrs(crs);
        gfi.setGetMapRequest(gm);
        gfi.setXPixel(260);
        gfi.setYPixel(63);
        gfi.setVersion("1.1.1");
       
        gfi.setQueryLayers(Arrays.asList(createMapLayer("foo", "acme"), createMapLayer("bar", "acme")));
        callback.operationDispatched(new Request(), op("GetFeatureInfo", "WMS", "1.1.1", gfi));
       
        assertEquals("acme:foo", data.getResources().get(0));
        assertEquals("acme:bar", data.getResources().get(1));
        BBoxAsserts.assertEqualsBbox(new ReferencedEnvelope(48.62,48.62,-123.15,-123.15,logCrs),data.getBbox(), 0.01);
View Full Code Here

Examples of org.geoserver.wms.GetFeatureInfoRequest

         */
        /*
         * -123.34927,48.44669,3960017.648,1933344.872
         */
       
        GetFeatureInfoRequest gfi = new GetFeatureInfoRequest();
       
        GetMapRequest gm = new GetMapRequest();
        gm.setHeight(423);
        gm.setWidth(512);
        Envelope env = new ReferencedEnvelope(3833170.221556,4083455.358596,1841755.690829,2048534.231783,null);
        CoordinateReferenceSystem crs = CRS.decode("EPSG:3348",true);
        CoordinateReferenceSystem logCrs = CRS.decode("EPSG:4326", false);
        gm.setBbox(env);
        gm.setCrs(crs);
        gfi.setGetMapRequest(gm);
        gfi.setXPixel(259);
        gfi.setYPixel(241);
        gfi.setVersion("1.1.1");
       
        gfi.setQueryLayers(Arrays.asList(createMapLayer("foo", "acme"), createMapLayer("bar", "acme")));
        callback.operationDispatched(new Request(), op("GetFeatureInfo", "WMS", "1.1.1", gfi));
       
        assertEquals("acme:foo", data.getResources().get(0));
        assertEquals("acme:bar", data.getResources().get(1));
        BBoxAsserts.assertEqualsBbox(new ReferencedEnvelope(48.4,48.4,-123.3,-123.3,logCrs),data.getBbox(), 0.1);
View Full Code Here

Examples of org.geotools.data.wms.request.GetFeatureInfoRequest

        else {
            // supply an empty String as per UDIG-1507
            getmap.setProperty(GetMapRequest.STYLES, "");
        }
       
        final GetFeatureInfoRequest request = wms.createGetFeatureInfoRequest( getmap );                      
        request.setInfoFormat( desiredFormat );
        request.setQueryPoint( centre.x, centre.y );               
        request.setQueryLayers( Collections.singleton( wmslayer ) );
               
        LayerPointInfo info = new LayerPointInfo( layer ){
                   
            private GetFeatureInfoResponse response;
            /** Lazy request */
                   
            protected GetFeatureInfoResponse getResponse() throws IOException {
                if (this.response == null) {
                    try {
                        System.out.println(request.getFinalURL());
                        this.response = wms.issueRequest( request );
                    } catch (SAXException e) {
                        throw new IOException(
                                "Unable to parse the returned response from the server. Reason unknown."); //$NON-NLS-1$
                    }
                }
                return this.response;
            }
            public URL getRequestURL() {
                return request.getFinalURL();
            }
            /** Only acquire the value if needed */
            public String getMimeType() {
                try {
                    return getResponse().getContentType();
View Full Code Here

Examples of org.geotools.data.wms.request.GetFeatureInfoRequest

        String format = format(operationType, "jpeg");
        getMap.setFormat(format);
        getMap.setDimensions(500, 500);
        URL url = getMap.getFinalURL();
       
        GetFeatureInfoRequest getFeatureInfo = wms.createGetFeatureInfoRequest( getMap );
        getFeatureInfo.setInfoFormat("text/html");
        getFeatureInfo.setQueryLayers( Collections.singleton(layer));
        getFeatureInfo.setQueryPoint( 75100 );
        URL url2 = getFeatureInfo.getFinalURL();
       
        GetFeatureInfoResponse response = wms.issueRequest(getFeatureInfo);
        assertEquals("text/html", response.getContentType() );
        InputStream stream = response.getInputStream();
        StringBuilderWriter writer = new StringBuilderWriter();
View Full Code Here

Examples of org.geotools.data.wms.request.GetFeatureInfoRequest

            getMapRequest.setFormat("image/png");
//        http://demo.cubewerx.com/cipi12/cubeserv/cubeserv.cgi?INFO_FORMAT=text/html&LAYERS=ETOPO2:Foundation&FORMAT=image/png&HEIGHT=400&J=200&REQUEST=GetFeatureInfo&I=200&BBOX=-34.12087,15.503481,1.8462441,35.6043956&WIDTH=400&STYLES=&SRS=EPSG:4326&QUERY_LAYERS=ETOPO2:Foundation&VERSION=1.3.0
            getMapRequest.setBBox("-34.12087,15.503481,1.8462441,35.6043956");
            URL url2 = getMapRequest.getFinalURL();
           
            GetFeatureInfoRequest request = wms.createGetFeatureInfoRequest(getMapRequest);
//        request.setQueryLayers(request.getQueryableLayers());
            request.setProperty(GetFeatureInfoRequest.QUERY_LAYERS, "ETOPO2:Foundation");
            request.setQueryPoint(200, 200);
            request.setInfoFormat("text/html");
           
            //System.out.println(request.getFinalURL());
           
//     TODO   Currently this server rtreturns code 400 !?
            GetFeatureInfoResponse response = (GetFeatureInfoResponse) wms.issueRequest(request);
View Full Code Here

Examples of org.geotools.data.wms.request.GetFeatureInfoRequest

     * @return
     * @throws IOException
     */
    public InputStream getFeatureInfo(DirectPosition2D pos, String infoFormat, int featureCount, GetMapRequest getmap)
            throws IOException {
        GetFeatureInfoRequest request = wms.createGetFeatureInfoRequest(getmap);
        request.setFeatureCount(1);
        request.setQueryLayers(new LinkedHashSet<Layer>(layers));
        request.setInfoFormat(infoFormat);
        request.setFeatureCount(featureCount);
        try {
            AffineTransform tx = RendererUtilities.worldToScreenTransform(requestedEnvelope,
                    new Rectangle(width, height));
            Point2D dest = new Point2D.Double();
            Point2D src = new Point2D.Double(pos.x, pos.y);
            tx.transform(src, dest);
            request.setQueryPoint((int) dest.getX(), (int) dest.getY());
        } catch (Exception e) {
            throw (IOException) new IOException("Failed to grab feature info").initCause(e);
        }

        try {
            if(LOGGER.isLoggable(Level.FINE)) {
                LOGGER.fine("Issuing request: " + request.getFinalURL());
            }
            GetFeatureInfoResponse response = wms.issueRequest(request);
            return response.getInputStream();
        } catch (IOException e) {
            throw e;
View Full Code Here

Examples of org.geotools.data.wms.request.GetFeatureInfoRequest

            throw new UnsupportedOperationException("This Web Map Server does not support GetFeatureInfo requests");
        }

        URL onlineResource = findURL(getCapabilities().getRequest().getGetFeatureInfo());
       
        GetFeatureInfoRequest request = getSpecification().createGetFeatureInfoRequest(onlineResource,
                getMapRequest);

        return request;
    }
View Full Code Here

Examples of org.vfny.geoserver.wms.requests.GetFeatureInfoRequest

     *
     * @see AbstractFeatureInfoResponse#writeTo(OutputStream)
     */
    @Override
    public void writeTo(final OutputStream out) throws ServiceException, IOException {
        final GetFeatureInfoRequest fInfoReq = getRequest();
        final WMS wmsConfig = fInfoReq.getWMS();

        //the 'response' object we'll pass to our OutputFormat
        FeatureCollectionType features = WfsFactory.eINSTANCE.createFeatureCollectionType();
       
        //the 'request' object we'll pass to our OutputFormat
        GetFeatureType gfreq = WfsFactory.eINSTANCE.createGetFeatureType();
        gfreq.setBaseUrl(fInfoReq.getBaseUrl());

        for (Iterator i = results.iterator(); i.hasNext();) {
            FeatureCollection<SimpleFeatureType, SimpleFeature> fc = (FeatureCollection)i.next();
            features.getFeature().add(fc);
           
View Full Code Here

Examples of org.vfny.geoserver.wms.requests.GetFeatureInfoRequest

     */
    @Override
    public void writeTo(OutputStream out)
        throws ServiceException, java.io.IOException {
        // setup the writer
        final GetFeatureInfoRequest request = getRequest();
        final WMS wmsConfig = request.getWMS();
        final Charset charSet = wmsConfig.getCharSet();
        final OutputStreamWriter osw = new OutputStreamWriter(out, charSet);
       
        // if there is only one feature type loaded, we allow for header/footer customization,
        // otherwise we stick with the generic ones
View Full Code Here

Examples of org.vfny.geoserver.wms.requests.GetFeatureInfoRequest

    @SuppressWarnings("deprecation")
  @Override
    //@SuppressWarnings("unchecked")
    protected void execute(MapLayerInfo[] requestedLayers, Style[] styles, Filter[] filters, int x, int y, int buffer)
        throws WmsException {
        GetFeatureInfoRequest request = getRequest();
        this.format = request.getInfoFormat();

        GetMapRequest getMapReq = request.getGetMapRequest();
        CoordinateReferenceSystem requestedCRS = getMapReq.getCrs(); // optional, may be null

        // basic information about the request
        int width = getMapReq.getWidth();
        int height = getMapReq.getHeight();
        ReferencedEnvelope bbox = new ReferencedEnvelope(getMapReq.getBbox(), getMapReq.getCrs());
        double scaleDenominator = RendererUtilities.calculateOGCScale(bbox, width, new HashMap());
        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(GeoTools.getDefaultHints());

        final int layerCount = requestedLayers.length;
        results = new ArrayList<FeatureCollection<? extends FeatureType,? extends Feature>>(layerCount);
        metas = new ArrayList<MapLayerInfo>(layerCount);
       
        try {
            for (int i = 0; i < layerCount; i++) {
                List<Rule> rules = getActiveRules(styles[i], scaleDenominator);
                if(rules.size() == 0)
                    continue;
                MapLayerInfo layerInfo = requestedLayers[i];
                if (layerInfo.getType() == MapLayerInfo.TYPE_VECTOR) {
                    CoordinateReferenceSystem dataCRS = layerInfo.getCoordinateReferenceSystem();

                    // compute the request radius
                    double radius;
                    if(buffer <= 0) {
                        // estimate the radius given the currently active rules
                        MetaBufferEstimator estimator = new MetaBufferEstimator();
                        for (Rule rule : rules) {
                            rule.accept(estimator);
                        }
                       
                        if(estimator.getBuffer() < 6.0 || !estimator.isEstimateAccurate()) {
                            radius = 3.0;
                        } else {
                            radius =  estimator.getBuffer() / 2.0;
                        }
                    } else {
                        radius = buffer;
                    }
                   
                    // make sure we don't go overboard, the admin might have set a maximum
                    int maxRadius = request.getWMS().getMaxBuffer();
                    if(maxRadius > 0 && radius > maxRadius)
                        radius = maxRadius;
                   
                    Polygon pixelRect = getEnvelopeFilter(x, y, width, height, bbox, radius);
                    if ((requestedCRS != null) && !CRS.equalsIgnoreMetadata(dataCRS, requestedCRS)) {
                        try {
                            MathTransform transform = CRS.findMathTransform(requestedCRS, dataCRS, true);
                            pixelRect = (Polygon) JTS.transform(pixelRect, transform); // reprojected
                        } catch (MismatchedDimensionException e) {
                            LOGGER.severe(e.getLocalizedMessage());
                        } catch (TransformException e) {
                            LOGGER.severe(e.getLocalizedMessage());
                        } catch (FactoryException e) {
                            LOGGER.severe(e.getLocalizedMessage());
                        }
                    }

                    final FeatureSource<? extends FeatureType, ? extends Feature> featureSource;
                    featureSource = layerInfo.getFeatureSource(false);
                    FeatureType schema = featureSource.getSchema();
                   
                    Filter getFInfoFilter = null;
                    try {
                        GeometryDescriptor geometryDescriptor = schema.getGeometryDescriptor();
                        String localName = geometryDescriptor.getLocalName();
                        getFInfoFilter = ff.intersects(ff.property(localName), ff.literal(pixelRect));
                    } catch (IllegalFilterException e) {
                        e.printStackTrace();
                        throw new WmsException(null, "Internal error : " + e.getMessage());
                    }

                    // include the eventual layer definition filter
                    if (filters[i] != null) {
                        getFInfoFilter = ff.and(getFInfoFilter, filters[i]);
                    }
                   
                    // 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(!(rulesFilters instanceof Or) ||
                        (rulesFilters instanceof Or && ((Or) rulesFilters).getChildren().size() <= 20)) {
                        getFInfoFilter = ff.and(getFInfoFilter, rulesFilters);
                    } else {
                        postFilter = rulesFilters;
                    }

                    String typeName = schema.getName().getLocalPart();
                    Query q = new DefaultQuery(typeName, null, getFInfoFilter, request.getFeatureCount(), Query.ALL_NAMES, null);
                   
                    FeatureCollection<? extends FeatureType, ? extends Feature> match;
                    match = featureSource.getFeatures(q);
                   
                    // if we could not include the rules filter into the query, post process in memory
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.