Examples of WFSDataStore


Examples of org.geotools.data.wfs.WFSDataStore

        final String[] queryTokens = { "<ogc:BBOX>",
                "<ogc:PropertyName>the_geom</ogc:PropertyName>",
                "<gml:Envelope srsDimension=\"2\" srsName=\"urn:x-ogc:def:crs:EPSG:3857\">",
                "<gml:lowerCorner>4623055.0 815134.0</gml:lowerCorner>",
                "<gml:upperCorner>4629904.0 820740.0</gml:upperCorner>" };
        WFSDataStore wfs = getWFSDataStore(new TinyOwsMockHttpClient() {
            @Override
            public HTTPResponse post(URL url, InputStream postContent, String postContentType) throws IOException {
                String request = new String(IOUtils.toByteArray(postContent), "UTF-8");
                if (isResultsRequest(request, queryTokens)) {
                    assertXMLEqual("tinyows/GetFeaturesByBBoxRequest.xml", request)
                    return new MockHttpResponse(TestData.getResource(this, "tinyows/GetFeaturesByBBox.xml"), "text/xml");
                } else {
                    return super.post(url, new ByteArrayInputStream(request.getBytes("UTF-8")), postContentType);
                }
            }           
        });
       
        SimpleFeatureSource source = wfs.getFeatureSource(typeName);
        SimpleFeature sf = getSampleSimpleFeature(source);
       
        Set<FeatureId> fids = new HashSet<FeatureId>();
        fids.add(new FeatureIdImpl("comuni11.2671"));
       
View Full Code Here

Examples of org.geotools.data.wfs.WFSDataStore

        final String[] queryTokens = { "<ogc:BBOX>",
                "<ogc:PropertyName>the_geom</ogc:PropertyName>",
                "<gml:Envelope srsDimension=\"2\" srsName=\"urn:x-ogc:def:crs:EPSG:3857\">",
                "<gml:lowerCorner>4623055.0 815134.0</gml:lowerCorner>",
                "<gml:upperCorner>4629904.0 820740.0</gml:upperCorner>" };
        WFSDataStore wfs = getWFSDataStore(new TinyOwsMockHttpClient() {
            @Override
            public HTTPResponse post(URL url, InputStream postContent, String postContentType) throws IOException {
                String request = new String(IOUtils.toByteArray(postContent), "UTF-8");
                if (isResultsRequest(request, queryTokens)) {
                    assertXMLEqual("tinyows/GetFeaturesByBBoxRequest.xml", request)
                    return new MockHttpResponse(TestData.getResource(this, "tinyows/GetFeaturesByBBox.xml"), "text/xml");
                } else {
                    return super.post(url, new ByteArrayInputStream(request.getBytes("UTF-8")), postContentType);
                }
            }           
        });
       
        SimpleFeatureSource source = wfs.getFeatureSource(typeName);
        SimpleFeature sf = getSampleSimpleFeature(source);
       
        Set<FeatureId> fids = new HashSet<FeatureId>();
        fids.add(new FeatureIdImpl("comuni11.2671"));
       
View Full Code Here

Examples of org.geotools.data.wfs.WFSDataStore

        final String[] bboxQueryTokens =  { "<ogc:BBOX>",
                "<ogc:PropertyName>the_geom</ogc:PropertyName>",
                "<gml:Envelope srsDimension=\"2\" srsName=\"urn:x-ogc:def:crs:EPSG:3857\">",
                "<gml:lowerCorner>4623055.0 815134.0</gml:lowerCorner>",
                "<gml:upperCorner>4629904.0 820740.0</gml:upperCorner>" };
        WFSDataStore wfs = getWFSDataStore(new TinyOwsMockHttpClient() {
            @Override
            public HTTPResponse post(URL url, InputStream postContent, String postContentType) throws IOException {
                String request = new String(IOUtils.toByteArray(postContent), "UTF-8");
                if (isHitsRequest(request, idQueryTokens)) {
                    return new MockHttpResponse(TestData.getResource(this, "tinyows/CountFeatureById.xml"), "text/xml");
                } else if (isResultsRequest(request, idQueryTokens)) {
                    return new MockHttpResponse(TestData.getResource(this, "tinyows/GetFeatureById.xml"), "text/xml");
                } else if (isResultsRequest(request, bboxQueryTokens)) {
                    return new MockHttpResponse(TestData.getResource(this, "tinyows/GetFeaturesByBBox.xml"), "text/xml");
                } else {
                    return super.post(url, new ByteArrayInputStream(request.getBytes("UTF-8")), postContentType);
                }
            }           
        });
       
        SimpleFeatureSource source = wfs.getFeatureSource(typeName);
        SimpleFeature sf = getSampleSimpleFeature(source);
       
        Set<FeatureId> fids = new HashSet<FeatureId>();
        fids.add(new FeatureIdImpl("comuni11.2671"));
       
View Full Code Here

Examples of org.geotools.data.wfs.WFSDataStore

    }

    @Test
    public void testGetFeatures() throws Exception {
       
        WFSDataStore wfs = getWFSDataStore(new MockHttpClient() {
           
           
            @Override
            public HTTPResponse get(URL url) throws IOException {
                if (url.getQuery().contains("REQUEST=GetCapabilities")) {
                    return new MockHttpResponse(TestData.getResource(this, "MapServer/GetCapabilities_1_1_0.xml"), "text/xml");
                } else {
                    return new MockHttpResponse(TestData.getResource(this, "MapServer/GetFeature_GovernmentalUnitCE.xml"), "text/xml");                   
                }
               
            }

            @Override
            public HTTPResponse post(URL url, InputStream postContent, String postContentType) throws IOException {
                return new MockHttpResponse(TestData.getResource(this, "MapServer/GetFeature_GovernmentalUnitCE.xml"), "text/xml");
            }           
        });
        ((WFS_1_1_0_DataStore)wfs).setMappedURIs(new MapServerStrategy().getNamespaceURIMappings());
       
        SimpleFeatureSource source = wfs.getFeatureSource(MAPSRV_GOVUNITCE.FEATURETYPENAME);
        SimpleFeatureCollection features = source.getFeatures();
        SimpleFeatureIterator reader = features.features();
        SimpleFeature sf = null;       
        try {
            if (reader.hasNext()) {
View Full Code Here

Examples of org.geotools.data.wfs.WFSDataStore

        wfs.setPreferPostOverGet(true);
        return wfs;
    }
   
    public SimpleFeatureCollection GetFeatures() throws Exception {
        WFSDataStore wfs = getWFSDataStore(new TinyArcGISServerMockHttpClient() {
            @Override
            public HTTPResponse post(URL url, InputStream postContent, String postContentType) throws IOException {
                String request = new String(IOUtils.toByteArray(postContent), "UTF-8");
                if (!postContentType.isEmpty())
                {
                  return new MockHttpResponse(TestData.getResource(this, "arcgisserver/GetFeaturesResult.xml"), "text/xml");
                }
                else
                  return super.post(url, new ByteArrayInputStream(request.getBytes("UTF-8")), postContentType);
            }           
        });
       
        SimpleFeatureSource source = wfs.getFeatureSource(typeName);
        SimpleFeatureCollection featureCollection = source.getFeatures();
       
        return featureCollection;
       
    }
View Full Code Here

Examples of org.geotools.data.wfs.WFSDataStore

       
        // override the describe feature type url so it loads from the test resource
        URL describeUrl = TestData.getResource(this, "axisorder/DescribeFeatureType.xsd");
        wfs.setDescribeFeatureTypeURLOverride(describeUrl);
               
        WFSDataStore ds = new WFSDataStore(wfs);
               
        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
        Set<FeatureId> fids = new HashSet<FeatureId>();
        fids.add(new FeatureIdImpl("comuni11.2671"));
        Query query = new Query(typeName, ff.id(fids));

        SimpleFeatureSource source = ds.getFeatureSource(typeName);
        SimpleFeature feature = iterate(source.getFeatures(query), 1, true);
        Geometry geometry = (Geometry) feature.getDefaultGeometry();
        double x = geometry.getCoordinate().x;
        double y = geometry.getCoordinate().y;
        assertEquals(7.344559874483752, x, 0);
        assertEquals(41.587164718505285, y, 0);
       
        // specify axis order: results should be the same
        wfs.setAxisOrderOverride(WFSDataStoreFactory.AXIS_ORDER_NORTH_EAST, WFSDataStoreFactory.AXIS_ORDER_COMPLIANT);

        source = ds.getFeatureSource(typeName);
        feature = iterate(source.getFeatures(query), 1, true);
        geometry = (Geometry) feature.getDefaultGeometry();
        x = geometry.getCoordinate().x;
        y = geometry.getCoordinate().y;
        assertEquals(7.344559874483752, x, 0);
View Full Code Here

Examples of org.geotools.data.wfs.WFSDataStore

        // override the describe feature type url so it loads from the test resource
        URL describeUrl = TestData.getResource(this, "axisorder/DescribeFeatureType.xsd");
        wfs.setDescribeFeatureTypeURLOverride(describeUrl);

        WFSDataStore ds = new WFSDataStore(wfs);
       
        // axis order used will be NORTH / EAST
        wfs.setAxisOrderOverride(WFSDataStoreFactory.AXIS_ORDER_COMPLIANT, WFSDataStoreFactory.AXIS_ORDER_NORTH_EAST);
       
        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
        Set<FeatureId> fids = new HashSet<FeatureId>();
        fids.add(new FeatureIdImpl("comuni11.2671"));
        Query query = new Query(typeName, ff.bbox("the_geom", 4623055.0, 815134.0, 4629904.0, 820740.0, "EPSG:3857"));
       
        SimpleFeatureSource source = ds.getFeatureSource(typeName);
        source.getFeatures(query).features();
        BBOX filter = (BBOX)wfs.getRequest().getFilter();
       
        // filter coordinates are inverted
        assertEquals(815134.0, filter.getMinX(), 0.0);
View Full Code Here

Examples of org.geotools.data.wfs.WFSDataStore

        // override the describe feature type url so it loads from the test resource
        URL describeUrl = TestData.getResource(this, "axisorder/DescribeFeatureType.xsd");
        wfs.setDescribeFeatureTypeURLOverride(describeUrl);

        WFSDataStore ds = new WFSDataStore(wfs);
       
        // axis order used will be NORTH / EAST
        wfs.setAxisOrderOverride(WFSDataStoreFactory.AXIS_ORDER_COMPLIANT, WFSDataStoreFactory.AXIS_ORDER_EAST_NORTH);
       
        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
        Set<FeatureId> fids = new HashSet<FeatureId>();
        fids.add(new FeatureIdImpl("comuni11.2671"));
        Query query = new Query(typeName, ff.bbox("the_geom", 4623055.0, 815134.0, 4629904.0, 820740.0, "EPSG:3857"));
       
        SimpleFeatureSource source = ds.getFeatureSource(typeName);
        source.getFeatures(query).features();
        BBOX filter = (BBOX)wfs.getRequest().getFilter();
       
        // filter coordinates are NOT inverted
        assertEquals(4623055.0, filter.getMinX(), 0.0);
View Full Code Here

Examples of org.geotools.data.wfs.WFSDataStore

        // override the describe feature type url so it loads from the test resource
        URL describeUrl = TestData.getResource(this, "axisorder/DescribeFeatureType.xsd");
        wfs.setDescribeFeatureTypeURLOverride(describeUrl);

        WFSDataStore ds = new WFSDataStore(wfs);
       
        // axis order used will be NORTH / EAST
        wfs.setAxisOrderOverride(WFSDataStoreFactory.AXIS_ORDER_COMPLIANT, WFSDataStoreFactory.AXIS_ORDER_COMPLIANT);
       
        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
        Set<FeatureId> fids = new HashSet<FeatureId>();
        fids.add(new FeatureIdImpl("comuni11.2671"));
        Query query = new Query(typeName, ff.bbox("the_geom", 4623055.0, 815134.0, 4629904.0, 820740.0, "EPSG:3857"));
       
        SimpleFeatureSource source = ds.getFeatureSource(typeName);
        source.getFeatures(query).features();
        BBOX filter = (BBOX)wfs.getRequest().getFilter();
       
        // filter coordinates are NOT inverted
        assertEquals(4623055.0, filter.getMinX(), 0.0);
View Full Code Here

Examples of org.geotools.data.wfs.WFSDataStore

        // override the describe feature type url so it loads from the test resource
        URL describeUrl = TestData.getResource(this, "axisorder/DescribeFeatureType.xsd");
        wfs.setDescribeFeatureTypeURLOverride(describeUrl);

        WFSDataStore ds = new WFSDataStore(wfs);
        // axis order used will be EAST / NORTH
        wfs.setAxisOrderOverride(WFSDataStoreFactory.AXIS_ORDER_COMPLIANT, WFSDataStoreFactory.AXIS_ORDER_COMPLIANT);
       
        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
        Set<FeatureId> fids = new HashSet<FeatureId>();
        fids.add(new FeatureIdImpl("comuni11.2671"));
        Query query = new Query(typeName, ff.id(fids));

        SimpleFeatureSource source = ds.getFeatureSource(typeName);
        SimpleFeature feature = iterate(source.getFeatures(query), 1, true);
        Geometry geometry = (Geometry) feature.getDefaultGeometry();
        double x = geometry.getCoordinate().x;
        double y = geometry.getCoordinate().y;
        assertEquals(7.344559874483752, x, 0);
        assertEquals(41.587164718505285, y, 0);
       
        // specify axis order: results should be inverted
        wfs.setAxisOrderOverride(WFSDataStoreFactory.AXIS_ORDER_EAST_NORTH, WFSDataStoreFactory.AXIS_ORDER_COMPLIANT);

        source = ds.getFeatureSource(typeName);
        feature = iterate(source.getFeatures(query), 1, true);
        geometry = (Geometry) feature.getDefaultGeometry();
        x = geometry.getCoordinate().x;
        y = geometry.getCoordinate().y;
        assertEquals(7.344559874483752, y, 0);
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.