Package org.geotools.data.wfs

Examples of org.geotools.data.wfs.WFSDataStore


    CoordinateReferenceSystem crs = null;
    private boolean writable = false;
   
    WFSGeoResourceInfo(WFSGeoResourceImpl wfsGeoResourceImpl) throws IOException {
        wfsResource = wfsGeoResourceImpl;
        WFSDataStore ds = wfsResource.parent.getDS(null);
       
        FeatureSource<SimpleFeatureType, SimpleFeature> featureSource = ds
                .getFeatureSource(wfsResource.typename);
       
        writable = featureSource instanceof FeatureStore;

        ResourceInfo resourceInfo = featureSource.getInfo();
        SimpleFeatureType ft = null;
        try {
            ft = ds.getSchema(wfsResource.typename);
        } catch (Exception crippled) {
            // unable to handle the describe feature type response for this
            // typeName
            if (WfsPlugin.getDefault().isDebugging()) {
                crippled.printStackTrace();
View Full Code Here


        }
        if (adaptee.isAssignableFrom(IGeoResourceInfo.class)){
            return adaptee.cast(createInfo(monitor));
        }
        if (adaptee.isAssignableFrom(SimpleFeatureSource.class)) {
            WFSDataStore wfs = parent.getDS(monitor);
            SimpleFeatureSource featureSource = wfs.getFeatureSource(typename);
            return adaptee.cast(featureSource);           
        }
        if (adaptee.isAssignableFrom(FeatureStore.class)) {
            WFSDataStore wfs = parent.getDS(monitor);
            SimpleFeatureSource featureSource = wfs.getFeatureSource(typename);
            if( featureSource instanceof FeatureStore){
                return adaptee.cast(featureSource);
            }
            else {
                return null; // write access not available
View Full Code Here

            }
        }
        return null;
    }
    private static void writeFeatureType( ILayer layer, BufferedWriter out ) throws IOException {
        WFSDataStore wfs = (WFSDataStore) layer.getResource( WFSDataStore.class, null );
        SimpleFeatureType type = layer.getSchema();
        String typeName = type.getName().getLocalPart();
       
        int hidden = layer.isVisible() ? 1 : 0;
        ServiceInfo serviceInfo = wfs.getInfo();
    String title = serviceInfo.getTitle();
        String version = "1.0.0"; // only known entry at this time //$NON-NLS-1$
        URI source = serviceInfo.getSource();
        String get = source == null? "" : source.toString();
       
        ResourceInfo resourceInfo = wfs.getFeatureSource(typeName).getInfo();
        append( 4, out, "<SimpleFeatureType hidden=\""+ hidden +"\">" ); //$NON-NLS-1$ //$NON-NLS-2$
        append( 6, out,   "<Server service=\"OGC:WFS\" title=\""+title+"\" version=\""+version+"\">" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        append( 8, out,     "<OnlineResource method=\"GET\" xlink:href=\""+get+"\" xlink:type=\"simple\"/>" ); //$NON-NLS-1$ //$NON-NLS-2$
        append( 6, out,   "</Server>" ); //$NON-NLS-1$
        append( 6, out,   "<Name>"+typeName+"</Name>"); //$NON-NLS-1$ //$NON-NLS-2$
View Full Code Here

    @Override
    public DataStore createDataStore() throws Exception {

        wfs = mockUpWfsClient();

        WFSDataStore wfsds = new WFSDataStore(wfs);
        return wfsds;
    }
View Full Code Here

        Map<String, Serializable> params = new HashMap<String, Serializable>();
        params.put(WFSDataStoreFactory.URL.key, SERVER_URL);
        params.put(WFSDataStoreFactory.PROTOCOL.key, usePost);
        params.put("USE_PULL_PARSER", Boolean.TRUE);
        WFSDataStoreFactory dataStoreFactory = new WFSDataStoreFactory();
        WFSDataStore wfs = dataStoreFactory.createDataStore(params);
       
        final WFS_1_1_0_Protocol originalHandler = (WFS_1_1_0_Protocol) ((WFS_1_1_0_DataStore) wfs).wfs;
        originalHandler.http = new HttpProtocolWrapper(originalHandler.http) {
           
            @Override
            public HTTPResponse get(URL url) throws IOException {
                // check the vendor params actually made it into the url (at this stage they are not url encoded)
                Map<String, String> kvp = HttpUtil.requestKvp(url);
                assertEquals("true", kvp.get("strict"));
                assertEquals("mysecret", kvp.get("authkey"));
                assertEquals("low:2000000;high:5000000", kvp.get("viewparams"));
               
                return super.get(url);
            }
           
            @Override
            public HTTPResponse post(URL url, InputStream postContent, String postContentType)
                    throws IOException {
                Map<String, String> kvp = HttpUtil.requestKvp(url);
               
                // check the vendor params actually made it into the url
                assertEquals("true", kvp.get("strict"));
                assertEquals("mysecret", kvp.get("authkey"));
                assertEquals("low%3A2000000%3Bhigh%3A5000000", kvp.get("viewparams"));
               
                return super.post(url, postContent, postContentType);
            }

        };   
       

        Map<String, String> vparams = new HashMap<String, String>();
        vparams.put("authkey", "mysecret");
        vparams.put("viewparams", "low:2000000;high:5000000");
        vparams.put("strict", "true");
        Hints hints = new Hints(WFSDataStore.WFS_VENDOR_PARAMETERS, vparams);
        Query q = new Query("topp:states");
        q.setHints(hints);
       
        // read some features, check
        FeatureReader fr = wfs.getFeatureReader(q, Transaction.AUTO_COMMIT);
        assertTrue(fr.hasNext());
        fr.close();
    }
View Full Code Here

        return wfs;
    }

    @Test
    public void testGetCapabilities() throws Exception {
        WFSDataStore wfs = getWFSDataStore(new TinyOwsMockHttpClient());      
        String types[] = wfs.getTypeNames();
        Assert.assertEquals(1, types.length);
        Assert.assertEquals("comuni:comuni11", 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\"/>";
        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 MockHttpResponse(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 MockHttpResponse(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, 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 MockHttpResponse(TestData.getResource(this, "tinyows/GetFirstFeatures.xml"), "text/xml");
                } else {
                    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, 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 MockHttpResponse(TestData.getResource(this, "tinyows/CountFeaturesByBBox.xml"), "text/xml");
                } else 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);
       
        FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
        PropertyName bboxProperty = ff.property(sf.getDefaultGeometryProperty().getName());
        Query query = new Query(typeName, ff.bbox(bboxProperty, sf.getBounds()));
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.