Package org.geotools.data.wfs

Examples of org.geotools.data.wfs.WFSDataStore


    private Name typeName = new NameImpl("http://www.tinyows.org/", "comuni_comuni11");
       
    private WFSDataStore getWFSDataStore(HTTPClient httpClient) throws IOException, ServiceException {
        URL capabilitiesUrl = new URL("http://127.0.0.1:8888/cgi-bin/tinyows?service=WFS&version=1.1.0&REQUEST=GetCapabilities");       
               
        WFSDataStore wfs = new WFSDataStore( new WFSClient(capabilitiesUrl, httpClient, WFSConfig.fromParams(Collections.EMPTY_MAP) ));
        return wfs;
    }
View Full Code Here


        return wfs;
    }

    @Test
    public void testGetCapabilities() throws Exception {
        WFSDataStore wfs = getWFSDataStore(new TinyOwsMockHttpClient());
        String types[] = wfs.getTypeNames();
        assertEquals(1, types.length);
        assertEquals(typeName.getLocalPart(), types[0]);
    }
View Full Code Here

   
    @Test
    public void testGetFirstFeatures() throws Exception {       
        final String queryXml = "<wfs:Query srsName=\"urn:ogc:def:crs:EPSG::3857\" typeName=\"comuni:comuni11\"/>";
        //final String queryXml = "<wfs:Query srsName=\"urn:ogc:def:crs:EPSG::3857\" typeName=\"comuni_comuni11\"/>";
        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 (stringContains(request,
                        "<wfs:GetFeature",
                        "maxFeatures=\"20\"",
                        "resultType=\"hits\"",
                        queryXml))
                {
                    assertXMLEqual("tinyows/CountFirstFeaturesRequest.xml", request);
                    return new TestHttpResponse(TestData.getResource(this, "tinyows/CountFirstFeatures.xml"), "text/xml");
                }
                else if (stringContains(request,
                        "<wfs:GetFeature",
                        "maxFeatures=\"20\"",
                        "resultType=\"results\"",
                        queryXml))
                {
                    assertXMLEqual("tinyows/GetFirstFeaturesRequest.xml", request);                   
                    return new TestHttpResponse(TestData.getResource(this, "tinyows/GetFirstFeatures.xml"), "text/xml");
                } else {
                    return super.post(url, new ByteArrayInputStream(request.getBytes("UTF-8")), postContentType);
                }
            }       
        });
       
        SimpleFeatureSource source = wfs.getFeatureSource(typeName);
       
        Query query = new Query(typeName.getLocalPart(), Filter.INCLUDE, 20, Query.ALL_NAMES, "my query");
        iterate(source.getFeatures(query), 20, true);       
    }
View Full Code Here

        iterate(source.getFeatures(query), 20, true);       
    }
   
    @Test
    public void testGetFeatureByIncludeAndOperatorAndInclude() throws Exception {
        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,
                        "<wfs:GetFeature",
                        "maxFeatures=\"20\"",
                        "resultType=\"results\"",
                        "<ogc:PropertyIsGreaterThan")) {
                    assertXMLEqual("tinyows/GetFeatureIncludeAndPropertyGreaterThanAndIncludeRequest.xml", request);
                    return new TestHttpResponse(TestData.getResource(this, "tinyows/GetFirstFeatures.xml"), "text/xml");
                } else {
                    postContent.reset();
                    return super.post(url, postContent, postContentType);
                }
            }
        });
       
        SimpleFeatureSource source = wfs.getFeatureSource(typeName);

        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
        Filter and = ff.and(
                Arrays.asList(Filter.INCLUDE,
                ff.greater(ff.property("gid"), ff.literal(0)),
View Full Code Here

        iterate(source.getFeatures(query), 20, false);       
    }
   
    @Test
    public void testGetFeatureById() throws Exception {       
        WFSDataStore wfs = getWFSDataStore(new TinyOwsMockHttpClient());
       
        SimpleFeatureSource source = wfs.getFeatureSource(typeName);

        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
        Set<FeatureId> fids = new HashSet<FeatureId>();
        fids.add(new FeatureIdImpl("comuni11.2671"));
        Query query = new Query(typeName.getLocalPart(), ff.id(fids));
View Full Code Here

        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 (isHitsRequest(request, queryTokens)) {
                    assertXMLEqual("tinyows/CountFeaturesByBBoxRequest.xml", request)
                    return new TestHttpResponse(TestData.getResource(this, "tinyows/CountFeaturesByBBox.xml"), "text/xml");
                } else if (isResultsRequest(request, queryTokens)) {
                    assertXMLEqual("tinyows/GetFeaturesByBBoxRequest.xml", request)
                    return new TestHttpResponse(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);
       
        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
        PropertyName bboxProperty = ff.property(sf.getDefaultGeometryProperty().getName());
        Query query = new Query(typeName.getLocalPart(), ff.bbox(bboxProperty, sf.getBounds()));
View Full Code Here

        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 TestHttpResponse(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

        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 TestHttpResponse(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

        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 TestHttpResponse(TestData.getResource(this, "tinyows/CountFeatureById.xml"), "text/xml");
                } else if (isResultsRequest(request, idQueryTokens)) {
                    return new TestHttpResponse(TestData.getResource(this, "tinyows/GetFeatureById.xml"), "text/xml");
                } else if (isResultsRequest(request, bboxQueryTokens)) {
                    return new TestHttpResponse(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

TOP

Related Classes of org.geotools.data.wfs.WFSDataStore

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.