Package org.geotools.data

Examples of org.geotools.data.FeatureSource


    // WRAPPED METHODS TO ENFORCE SECURITY POLICY
    //--------------------------------------------------------------------------

    public FeatureSource getFeatureSource(ProgressListener listener, Hints hints)
            throws IOException {
        final FeatureSource fs = delegate.getFeatureSource(listener, hints);
       
        if(policy.level == AccessLevel.METADATA) {
            throw SecureCatalogImpl.unauthorizedAccess(this.getName());
        } else {
            return (FeatureSource) SecuredObjects.secure(fs, policy);
View Full Code Here


            // perform the query
            Query query = new Query(null, filter, new String[] { attribute });
            // .. just enough to judge if we went beyond the limit
            query.setMaxFeatures(maxResults + 1);
            FeatureSource fs = ft.getFeatureSource(null, null);
            fi = fs.getFeatures(query).features();
            List<Object> results = new ArrayList<Object>(maxResults);
            while (fi.hasNext()) {
                Feature f = fi.next();
                Object value = f.getProperty(attribute).getValue();
                if(value instanceof Geometry && crs != null) {
View Full Code Here

        Map params = ds.getConnectionParameters();
        params.put("dbtype", "h2");
        params.put("database", getTestData().getDataDirectoryRoot().getAbsolutePath());
        cat.add(ds);
       
        FeatureSource fs1 = getFeatureSource(SystemTestData.FIFTEEN);
        FeatureSource fs2 = getFeatureSource(SystemTestData.SEVEN);
       
        DataStore store = (DataStore) ds.getDataStore(null);
        SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder();
       
        tb.init((SimpleFeatureType) fs1.getSchema());
        tb.remove("boundedBy");
        store.createSchema(tb.buildFeatureType());
       
        tb.init((SimpleFeatureType) fs2.getSchema());
        tb.remove("boundedBy");
        store.createSchema(tb.buildFeatureType());
       
        CatalogBuilder cb = new CatalogBuilder(cat);
        cb.setStore(ds);
       
        FeatureStore fs = (FeatureStore) store.getFeatureSource("Fifteen");
        fs.addFeatures(fs1.getFeatures());
        FeatureTypeInfo ft = cb.buildFeatureType(fs);
        cat.add(ft);
       
        fs = (FeatureStore) store.getFeatureSource("Seven");
        fs.addFeatures(fs2.getFeatures());
        ft = cb.buildFeatureType(fs);
        cat.add(ft);
    }
View Full Code Here

    private void testExcelOutputFormat( Workbook wb ) throws IOException{
        Sheet sheet = wb.getSheet("PrimitiveGeoFeature");
        assertNotNull(sheet);

        FeatureSource fs = getFeatureSource(MockData.PRIMITIVEGEOFEATURE);

        // check the number of rows in the output
        final int feautureRows = fs.getCount(Query.ALL);
        assertEquals(feautureRows + 1, sheet.getPhysicalNumberOfRows());

        // check the header is what we expect
        final SimpleFeatureType schema = (SimpleFeatureType) fs.getSchema();
        final Row header = sheet.getRow(0);
        assertEquals("FID", header.getCell(0).getRichStringCellValue().toString());
        for (int i = 0; i < schema.getAttributeCount(); i++) {
            assertEquals(schema.getDescriptor(i).getLocalName(), header.getCell(i + 1)
                    .getRichStringCellValue().toString());
        }

        // check some selected values to see if the content and data type is the one
        // we expect
        FeatureIterator fi = fs.getFeatures().features();
        SimpleFeature sf = (SimpleFeature) fi.next();
        fi.close();

        // ... a string cell
        Cell cell = sheet.getRow(1).getCell(1);
View Full Code Here

        // check we have the expected sheets
      Sheet sheet = wb.getSheet("PrimitiveGeoFeature");
        assertNotNull(sheet);

        // check the number of rows in the output
        FeatureSource fs = getFeatureSource(MockData.PRIMITIVEGEOFEATURE);
        assertEquals(fs.getCount(Query.ALL) + 1, sheet.getPhysicalNumberOfRows());

        sheet = wb.getSheet("GenericEntity");
        assertNotNull(sheet);

        // check the number of rows in the output
        fs = getFeatureSource(MockData.GENERICENTITY);
        assertEquals(fs.getCount(Query.ALL) + 1, sheet.getPhysicalNumberOfRows());     
    }
View Full Code Here

        assertNotNull(layer.getDefaultStyle());
        assertNotNull(layer.getResource().getProjectionPolicy());
       
        if (layer.getType() == LayerInfo.Type.VECTOR) {
            FeatureTypeInfo featureType = (FeatureTypeInfo) layer.getResource();
            FeatureSource source = featureType.getFeatureSource(null, null);
            assertTrue(source.getCount(Query.ALL) > 0);
           
            //do a wfs request
            Document dom = getAsDOM("wfs?request=getFeature&typename=" + featureType.getPrefixedName());
            assertEquals("wfs:FeatureCollection", dom.getDocumentElement().getNodeName());
            assertEquals(
                source.getCount(Query.ALL), dom.getElementsByTagName(featureType.getPrefixedName()).getLength());
        }

        //do a wms request
        MockHttpServletResponse response =
            getAsServletResponse("wms/reflect?layers=" + layer.getResource().getPrefixedName());
View Full Code Here

        Catalog catalog = gs.getCatalog();
        Set<String> featuresInTile = Collections.emptySet();
        try {
            // grab information needed to reach the db and get a hold to a db
            // connection
            FeatureSource featureSource = layer.getFeatureSource();
            featureType = catalog.getFeatureTypeByName(featureSource.getName());
           
            String dataDir = catalog.getResourceLoader().getBaseDirectory().getCanonicalPath();
            tableName = getDatabaseName(context, layer);

            // grab the features per tile, use a default if user did not
View Full Code Here

        Set<String> parentFids = getUpwardFids(tile.getParent(), conn);
        Set<String> currFids = new HashSet<String>();
        FeatureIterator fi = null;
        try {
            // grab the features
            FeatureSource fs = featureType.getFeatureSource(null,null);
            GeometryDescriptor geom = fs.getSchema().getGeometryDescriptor();
            CoordinateReferenceSystem nativeCrs = geom
                    .getCoordinateReferenceSystem();

            ReferencedEnvelope nativeTileEnvelope = null;
View Full Code Here

            restrictedResource = new DecoratingFeatureTypeInfo(resource) {

                @Override
                public FeatureSource getFeatureSource(ProgressListener listener, Hints hints)
                        throws IOException {
                    FeatureSource fs = super.getFeatureSource(listener, hints);
                    if (!(fs instanceof SimpleFeatureSource)) {
                        throw new IllegalStateException(
                                "Cannot apply dynamic dimension restrictions to complex features");
                    }
                    SimpleFeatureSource simpleSource = (SimpleFeatureSource) fs;
View Full Code Here

                computeQueryBounds = true;
            }

            ReferencedEnvelope layerLatLongBbox = null;
            if (computeQueryBounds) {
                FeatureSource featureSource = layer.getFeatureSource();
                try {
                    CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:4326");
                    FeatureCollection features = featureSource.getFeatures(layerQuery);
                    layerLatLongBbox = features.getBounds();
                    layerLatLongBbox = layerLatLongBbox.transform(targetCRS, true);
                } catch (Exception e) {
                    LOGGER.info("Error computing bounds for " + featureSource.getName() + " with "
                            + layerQuery);
                }

            }
            if (layerLatLongBbox == null) {
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.