Package org.geotools.data.wfs

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(4629462.0, x, 0);
        assertEquals(819841.0, 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(4629462.0, x, 0);
View Full Code Here


public class MapServerTest {

    private WFSDataStore getWFSDataStore(HTTPClient httpClient) throws IOException, ServiceException {
        URL capabilitiesUrl = new URL("http://127.0.0.1:8888/mapserver?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

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

            @Override
            public HTTPResponse post(URL url, InputStream postContent, String postContentType) throws IOException {
                String request = new String(IOUtils.toByteArray(postContent), "UTF-8");    
                if (request.contains("<wfs:DescribeFeatureType"))
                {
                    return new TestHttpResponse(TestData.getResource(this, "MapServer/DescribeFeatureType_GovernmentalUnitCE.xsd"), "text/xml");
                } else {
                    return new TestHttpResponse(TestData.getResource(this, "MapServer/GetFeature_GovernmentalUnitCE.xml"), "text/xml");
                }
            }
        });
       
        SimpleFeatureSource source = wfs.getFeatureSource(new NameImpl("http://mapserver.gis.umn.edu/mapserver", "ms_GovernmentalUnitCE"));
        SimpleFeatureCollection features = source.getFeatures();
        SimpleFeatureIterator reader = features.features();
        SimpleFeature sf = null;       
        try {
            if (reader.hasNext()) {
View Full Code Here

                "hyd_HydroElementWBHI", "hyd_HydroElementWBMD", "trans_RoadSeg"};
        List<String> expectedTypeNames = Arrays.asList(expected);

        createTestProtocol(CUBEWERX_GOVUNITCE.CAPABILITIES);

        WFSDataStore ds = new WFSDataStore(wfs);

        String[] typeNames = ds.getTypeNames();
        assertNotNull(typeNames);
        List<String> names = Arrays.asList(typeNames);
        assertEquals(expectedTypeNames.size(), names.size());
        assertEquals(new HashSet<String>(expectedTypeNames), new HashSet<String>(names));
    }
View Full Code Here

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

        WFSDataStore ds = new WFSDataStore(wfs);

        try {
            ds.getSchema("nonExistentTypeName");
            fail("Expected SchemaNotFoundException");
        } catch (IOException e) {
            assertTrue(true);
        }

        SimpleFeatureType schema = ds.getSchema(CUBEWERX_GOVUNITCE.FEATURETYPENAME);
        assertNotNull(schema);
    }
View Full Code Here

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

        WFSDataStore ds = new WFSDataStore(wfs);
       
        wfs.setOutputformatOverride("text/xml; subtype=gml/2.1.2");

        Query query = new Query(CUBEWERX_GOVUNITCE.FEATURETYPENAME);
       
        FeatureReader<SimpleFeatureType, SimpleFeature> featureReader;
        featureReader = ds.getFeatureReader(query, Transaction.AUTO_COMMIT);
        while(featureReader.hasNext()) {
            SimpleFeature feature = featureReader.next();
            System.out.println(feature.getDefaultGeometry());
        }
        GetFeatureRequest request = wfs.getRequest();
View Full Code Here

   
        // override the describe feature type url so it loads from the test resource
        URL describeUrl = TestData.getResource(this, CUBEWERX_GOVUNITCE.SCHEMA);
        wfs.setDescribeFeatureTypeURLOverride(describeUrl);
   
        WFSDataStore ds = new WFSDataStore(wfs);
        Query query = new Query(CUBEWERX_GOVUNITCE.FEATURETYPENAME);
   
        // use the OtherSRS
        CoordinateReferenceSystem otherCrs = CRS
                .decode(CUBEWERX_GOVUNITCE.ALTERNATIVECRS);
        query.setCoordinateSystem(otherCrs);
        FeatureReader<SimpleFeatureType, SimpleFeature> featureReader;
        featureReader = ds.getFeatureReader(query, Transaction.AUTO_COMMIT);
        assertNotNull(featureReader);
        assertTrue(featureReader instanceof ForceCoordinateSystemFeatureReader);
        assertEquals(otherCrs, featureReader.getFeatureType()
                .getCoordinateReferenceSystem());
        GetFeatureRequest request = wfs.getRequest();
        assertEquals(CUBEWERX_GOVUNITCE.ALTERNATIVECRS, request.getSrsName());
   
        // use an SRS not supported by server
        CoordinateReferenceSystem unknownCrs = CRS.decode("EPSG:3003");
        query.setCoordinateSystem(unknownCrs);
   
        featureReader = ds.getFeatureReader(query, Transaction.AUTO_COMMIT);
        assertNotNull(featureReader);
        assertTrue(featureReader instanceof ReprojectFeatureReader);
        assertEquals(unknownCrs, featureReader.getFeatureType()
                .getCoordinateReferenceSystem());
        request = wfs.getRequest();
View Full Code Here

   
        // override the describe feature type url so it loads from the test resource
        URL describeUrl = TestData.getResource(this, CUBEWERX_GOVUNITCE.SCHEMA);
        wfs.setDescribeFeatureTypeURLOverride(describeUrl);
   
        WFSDataStore ds = new WFSDataStore(wfs);
        wfs.setUseDefaultSrs(true);
        Query query = new Query(CUBEWERX_GOVUNITCE.FEATURETYPENAME);
   
        // use the OtherSRS
        CoordinateReferenceSystem otherCrs = CRS
                .decode(CUBEWERX_GOVUNITCE.ALTERNATIVECRS);
        query.setCoordinateSystem(otherCrs);
        FeatureReader<SimpleFeatureType, SimpleFeature> featureReader;
        featureReader = ds.getFeatureReader(query, Transaction.AUTO_COMMIT);
        assertNotNull(featureReader);
        assertTrue(featureReader instanceof ReprojectFeatureReader);
        assertEquals(otherCrs, featureReader.getFeatureType()
                .getCoordinateReferenceSystem());
        GetFeatureRequest request = wfs.getRequest();
        assertNull(request.getSrsName());
   
        // use an SRS not supported by server
        CoordinateReferenceSystem unknownCrs = CRS.decode("EPSG:3003");
        query.setCoordinateSystem(unknownCrs);
   
        featureReader = ds.getFeatureReader(query, Transaction.AUTO_COMMIT);
        assertNotNull(featureReader);
        assertTrue(featureReader instanceof ReprojectFeatureReader);
        assertEquals(unknownCrs, featureReader.getFeatureType()
                .getCoordinateReferenceSystem());
        request = wfs.getRequest();
View Full Code Here

   
        // override the describe feature type url so it loads from the test resource
        URL describeUrl = TestData.getResource(this, CUBEWERX_GOVUNITCE.SCHEMA);
        wfs.setDescribeFeatureTypeURLOverride(describeUrl);
   
        WFSDataStore ds = new WFSDataStore(wfs);
        Query query = new Query(CUBEWERX_GOVUNITCE.FEATURETYPENAME);
   
        // use the OtherSRS
        CoordinateReferenceSystem otherCrs = CRS.decode(CUBEWERX_GOVUNITCE.URNCRS);
        query.setCoordinateSystem(otherCrs);
        FeatureReader<SimpleFeatureType, SimpleFeature> featureReader;
        featureReader = ds.getFeatureReader(query, Transaction.AUTO_COMMIT);
        assertNotNull(featureReader);
        assertTrue(featureReader instanceof ForceCoordinateSystemFeatureReader);
   
        assertEquals(GML2EncodingUtils.epsgCode(otherCrs),
                GML2EncodingUtils.epsgCode(featureReader.getFeatureType()
View Full Code Here

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

        WFSDataStore ds = new WFSDataStore(wfs);
        Query query = new Query(CUBEWERX_GOVUNITCE.FEATURETYPENAME);
        FeatureReader<SimpleFeatureType, SimpleFeature> featureReader;
        featureReader = ds.getFeatureReader(query, Transaction.AUTO_COMMIT);
        assertNotNull(featureReader);
        // test data file contains three features...
        assertTrue(featureReader.hasNext());
        assertNotNull(featureReader.next());
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.