Package org.geotools.data

Examples of org.geotools.data.FeatureSource


    private NameImpl name;

    protected void setUp() throws Exception {
        super.setUp();

        FeatureSource fs = createNiceMock(FeatureSource.class);
        replay(fs);
        FeatureType schema = createNiceMock(FeatureType.class);
        replay(schema);
        da = createNiceMock(DataAccess.class);
        name = new NameImpl("blah");
View Full Code Here


public class CSVOutputFormatTest extends WFSTestSupport {

    public void testFullRequest() throws Exception {
        MockHttpServletResponse resp = getAsServletResponse("wfs?request=GetFeature&typeName=sf:PrimitiveGeoFeature&outputFormat=csv");
       
        FeatureSource fs = getFeatureSource(MockData.PRIMITIVEGEOFEATURE);
       
//        System.out.println(resp.getOutputStreamContent());
       
        // check the mime type
        assertEquals("text/csv", resp.getContentType());
       
        // check the content disposition
        assertEquals("attachment; filename=PrimitiveGeoFeature.csv", resp.getHeader("Content-Disposition"));
       
        // read the response back with a parser that can handle escaping, newlines and what not
        List<String[]> lines = readLines(resp.getOutputStreamContent());
       
        // we should have one header line and then all the features in that feature type
        assertEquals(fs.getCount(Query.ALL) + 1, lines.size());
       
        for (String[] line : lines) {
            // check each line has the expected number of elements (num of att + 1 for the id)
            assertEquals(fs.getSchema().getDescriptors().size() + 1, line.length);
        }
    }
View Full Code Here

          // in this case the features field is not null but it is filled externally
                    if (features==null) {
                       
              store = FileDataStoreFinder.getDataStore(file);
              if (store==null) throw new ActionException(this, "the layer "+file.getCanonicalPath()+" cannot be found. Skip execution.");
                        FeatureSource featureSource = store.getFeatureSource();
                        SimpleFeatureType schema = (SimpleFeatureType) featureSource.getSchema();
                        Query query = new Query( schema.getTypeName(), Filter.INCLUDE );
                        query.setCoordinateSystem(CRS.decode("EPSG:4326", true));
                        features = (SimpleFeatureCollection) featureSource.getFeatures( query );
                       
          //    features = (SimpleFeatureCollection) featureSource.getFeatures();
                    }
                   
          //CoordinateReferenceSystem crs = DefaultGeographicCRS.WGS84;
View Full Code Here

                Throwables.propagate(e);
            }

            DataAccess data = dataStore.getDataStore(null);

            FeatureSource source = data.getFeatureSource(resourceName);
            builder.setupBounds(ft, source);

            return builder.buildLayer(ft);
        }
        else if (store instanceof CoverageStoreInfo) {
View Full Code Here

                }
                progressListener.setDescription("Importing " + tableName + " (" + tableCount + "/"
                        + typeNames.length + ")... ");
            }

            FeatureSource featureSource = getFeatureSource(typeName);
            SimpleFeatureType featureType = (SimpleFeatureType) featureSource.getSchema();

            final String fidPrefix = featureType.getTypeName() + ".";

            String path;
            if (destPath == null) {
View Full Code Here

        progressListener.complete();
        return workTree.getTree();
    }

    private boolean hasPrimaryKey(String typeName) {
        FeatureSource featureSource;
        try {
            featureSource = dataStore.getFeatureSource(typeName);
        } catch (Exception e) {
            throw new GeoToolsOpException(StatusCode.UNABLE_TO_GET_FEATURES);
        }
View Full Code Here

    }

    @SuppressWarnings({ "rawtypes", "unchecked" })
    private FeatureSource getFeatureSource(String typeName) {

        FeatureSource featureSource;
        try {
            featureSource = dataStore.getFeatureSource(typeName);
        } catch (Exception e) {
            throw new GeoToolsOpException(StatusCode.UNABLE_TO_GET_FEATURES);
        }
View Full Code Here

        store.addFeatures(features);

        final QueryCapabilities caps = mock(QueryCapabilities.class);
        when(caps.isOffsetSupported()).thenReturn(true);

        @SuppressWarnings("rawtypes")
        FeatureSource source = store.getFeatureSource(pointsName);
        assertFalse(source.getQueryCapabilities().isOffsetSupported());

        String treePath = "target_typename";
        workTree.insert(treePath, source, Query.ALL, LISTENER);

        assertEquals(3, workTree.countUnstaged(treePath).featureCount());
View Full Code Here

        store.addFeatures(features);

        final QueryCapabilities caps = mock(QueryCapabilities.class);
        when(caps.isOffsetSupported()).thenReturn(true);

        FeatureSource source = new ForwardingFeatureSource(store.getFeatureSource(pointsName)) {
            @Override
            public QueryCapabilities getQueryCapabilities() {
                return caps;
            }

            @Override
            public FeatureCollection getFeatures(Query query) throws IOException {
                Integer startIndex = query.getStartIndex();
                if (startIndex == null) {
                    return super.getFeatures();
                }
                int toIndex = (int) Math.min((long) startIndex + query.getMaxFeatures(),
                        features.size());
                List<SimpleFeature> result = features.subList(startIndex, toIndex);
                return DataUtilities.collection(result);
            }
        };

        assertTrue(source.getQueryCapabilities().isOffsetSupported());

        String treePath = "target_typename";
        workTree.insert(treePath, source, Query.ALL, LISTENER);

        assertEquals(3, workTree.countUnstaged(treePath).featureCount());
View Full Code Here

          // in this case the features field is not null but it is filled externally
                    if (features==null) {
                       
              store = FileDataStoreFinder.getDataStore(file);
              if (store==null) throw new ActionException(this, "the layer "+file.getCanonicalPath()+" cannot be found. Skip execution.");
                        FeatureSource featureSource = store.getFeatureSource();
                        SimpleFeatureType schema = (SimpleFeatureType) featureSource.getSchema();
                        Query query = new Query( schema.getTypeName(), Filter.INCLUDE );
                        query.setCoordinateSystem(CRS.decode("EPSG:4326", true));
                        features = (SimpleFeatureCollection) featureSource.getFeatures( query );
                       
          //    features = (SimpleFeatureCollection) featureSource.getFeatures();
                    }
                   
          //CoordinateReferenceSystem crs = DefaultGeographicCRS.WGS84;
View Full Code Here

TOP

Related Classes of org.geotools.data.FeatureSource

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.