Package org.geotools.data

Examples of org.geotools.data.FeatureSource


        dsParams.put("dbtype", "app-schema");
        dsParams.put("url", url.toExternalForm());
        DataAccess mfDataAccess = DataAccessFinder.getDataStore(dsParams);
        assertNotNull(mfDataAccess);

        FeatureSource guSource = (FeatureSource) guDataStore
                .getFeatureSource(FeatureChainingTest.GEOLOGIC_UNIT);

        FeatureCollection guFeatures = (FeatureCollection) guSource.getFeatures();
        assertEquals(3, size(guFeatures));

        FeatureSource cpSource = DataAccessRegistry
                .getFeatureSource(FeatureChainingTest.COMPOSITION_PART);
        FeatureCollection cpFeatures = (FeatureCollection) cpSource.getFeatures();
        assertEquals(4, size(cpFeatures));

        FeatureSource cgiSource = DataAccessRegistry
                .getFeatureSource(FeatureChainingTest.CGI_TERM_VALUE);
        FeatureCollection cgiFeatures = (FeatureCollection) cgiSource.getFeatures();
        assertEquals(6, size(cgiFeatures));
    }
View Full Code Here


        if (file == null) {
            return;
        }

        FileDataStore store = FileDataStoreFinder.getDataStore(file);
        FeatureSource featureSource = store.getFeatureSource();

        // Create a map content and add our shapefile to it
        MapContent map = new MapContent();
        map.setTitle("StyleLab");
View Full Code Here

    }

    public int getCount(Query query) throws IOException {
        int count = 0;
        Query namedQuery = namedQuery(query);
        FeatureSource mappedSource = mapping.getSource();
        if (!(mappedSource instanceof JDBCFeatureSource || mappedSource instanceof JDBCFeatureStore)) {
            count = store.getCount(namedQuery);
        }
        if (count >= 0) {
            // normal case
View Full Code Here

    public void testFeatureSource() throws Exception {
        File file = copyShapefiles("shapes/archsites.shp");
        tempDir = file.getParentFile();
       
        DataStore dds = new DirectoryDataStore(tempDir, getFileStoreFactory());
        FeatureSource fs = dds.getFeatureSource("archsites");
        assertNotNull(fs);
        assertSame(dds, fs.getDataStore());
        dds.dispose();
    }
View Full Code Here

        Style style = RendererBaseTest.loadStyle(this, invert ? "attributeRename.sld"
                : "attributeRenameNoInvert.sld");
        // grab the data
        File property = new File(TestData.getResource(this, "point.properties").toURI());
        PropertyDataStore ds = new PropertyDataStore(property.getParentFile());
        FeatureSource fs = ds.getFeatureSource("point");

        // prepare a feature layer with a query and the rendering tx
        FeatureLayer layer = new FeatureLayer(fs, style);
        layer.setQuery(new Query(null, CQL.toFilter("id > 5")));
View Full Code Here

        // grab the style
        Style style = RendererBaseTest.loadStyle(this, "reproject-rt.sld");
        // grab the data
        File property = new File(TestData.getResource(this, "point.properties").toURI());
        PropertyDataStore ds = new PropertyDataStore(property.getParentFile());
        FeatureSource fs = ds.getFeatureSource("point");

        // prepare a feature layer with a query and the rendering tx
        FeatureLayer layer = new FeatureLayer(fs, style);
       
        // prepare a bbox in UTM-32N
View Full Code Here

     * @throws IOException
     *             if there are errors getting the count
     */
    protected int getCount(final Query targetQuery) throws IOException {
        final FeatureTypeMapping mapping = getMappingByElement(getName(targetQuery));
        FeatureSource mappedSource = mapping.getSource();
        // Wrap with JoiningJDBCFeatureSource like in DataAccessMappingFeatureIterator
        // this is so it'd use the splitFilter in JoiningJDBCFeatureSource
        // otherwise you'll get an error when it can't find complex attributes in the
        // simple feature source
        if (mappedSource instanceof JDBCFeatureSource) {
            mappedSource = new JoiningJDBCFeatureSource((JDBCFeatureSource) mappedSource);
        } else if (mappedSource instanceof JDBCFeatureStore) {
            mappedSource = new JoiningJDBCFeatureSource((JDBCFeatureStore) mappedSource);
        }
        Query unmappedQuery = unrollQuery(targetQuery, mapping);
        return mappedSource.getCount(unmappedQuery);
    }
View Full Code Here

     * @return
     */
    @SuppressWarnings("unchecked")
    public Query unrollQuery(Query query, FeatureTypeMapping mapping) {
        Query unrolledQuery = Query.ALL;
        FeatureSource source = mapping.getSource();

        if (!Query.ALL.equals(query)) {
            Filter complexFilter = query.getFilter();
            Filter unrolledFilter = AppSchemaDataAccess.unrollFilter(complexFilter, mapping);

            Object includeProps = query.getHints().get(Query.INCLUDE_MANDATORY_PROPS);
            List<PropertyName> propNames = getSurrogatePropertyNames(query.getProperties(),
                    mapping,
                    includeProps instanceof Boolean && ((Boolean) includeProps).booleanValue());

            Query newQuery = new Query();
            String name = source.getName().getLocalPart();
            newQuery.setTypeName(name);
            newQuery.setFilter(unrolledFilter);
            newQuery.setProperties(propNames);
            newQuery.setCoordinateSystem(query.getCoordinateSystem());
            newQuery.setCoordinateSystemReproject(query.getCoordinateSystemReproject());
View Full Code Here

    private static MapContext loadShapefile( final URL shape, final Style style )
            throws IOException
    {
        final ShapefileDataStore shapefileDataStore = new ShapefileDataStore( shape );

        final FeatureSource featureSource = shapefileDataStore.getFeatureSource();

        CoordinateReferenceSystem crs = featureSource.getSchema().getDefaultGeometry().getCoordinateSystem();
        if ( crs == null )
        {
            crs = DefaultGeographicCRS.WGS84;
        }
View Full Code Here

    public MapContext load( URL shape, URL sld ) throws Exception
    {
        ShapefileDataStore ds = new ShapefileDataStore( shape );

        FeatureSource fs = ds.getFeatureSource();
        com.vividsolutions.jts.geom.Envelope env = fs.getBounds();
        myMapPane.setMapArea( env );
        StyleFactory factory = CommonFactoryFinder.getStyleFactory( null );

        SLDParser stylereader = new SLDParser( factory, sld );
        org.geotools.styling.Style[] style = stylereader.readXML();

        CoordinateReferenceSystem crs = fs.getSchema().getDefaultGeometry().getCoordinateSystem();
        if ( crs == null )
        {
            crs = DefaultGeographicCRS.WGS84;
        }
        MapContext context = new DefaultMapContext( crs );
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.