Examples of FeatureSource


Examples of org.geotools.data.FeatureSource

        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

Examples of org.geotools.data.FeatureSource

    }

    @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

Examples of org.geotools.data.FeatureSource

        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

Examples of org.geotools.data.FeatureSource

        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

Examples of org.geotools.data.FeatureSource

          // 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

Examples of org.geotools.data.FeatureSource

        }

        // get feature results
        ShapefileDataStore store = new ShapefileDataStore(new File(shapefile).toURI().toURL());
        String name = store.getTypeNames()[0];
        FeatureSource source = store.getFeatureSource(name);
        collection = source.getFeatures();
    }
View Full Code Here

Examples of org.geotools.data.FeatureSource

        try {
            final Name typeName = Types.typeName(GSMLNS, "MappedFeature");
            FeatureType boreholeType = mappingDataStore.getSchema(typeName);
            assertNotNull(boreholeType);

            FeatureSource fSource = (FeatureSource) mappingDataStore.getFeatureSource(typeName);

            final int EXPECTED_RESULT_COUNT = 2;

            FeatureCollection features = (FeatureCollection) fSource.getFeatures();

            int resultCount = getCount(features);
            assertEquals(EXPECTED_RESULT_COUNT, resultCount);

            Feature feature;
View Full Code Here

Examples of org.geotools.data.FeatureSource

        Name typeName = Types.typeName("http://example.com", "FirstParentFeature");
        FeatureType featureType = dataAccess.getSchema(typeName);
        assertNotNull(featureType);

        FeatureSource fSource = (FeatureSource) dataAccess.getFeatureSource(typeName);
        FeatureCollection features = (FeatureCollection) fSource.getFeatures();

        assertEquals(5, size(features));

        FeatureIterator iterator = features.features();
        while (iterator.hasNext()) {
            Feature next = iterator.next();
            Collection<Property> children = next.getProperties("nestedFeature");
            if (next.getIdentifier().toString().equals("cc.1")) {
                // _=STRING:String,LINK_ONE:String,LINK_TWO:String
                // sc.1=string_one|cc.1|cc.2
                // sc.2=string_two|cc.1|cc.2
                // sc.3=string_three|NULL|cc.2
                assertEquals(2, children.size());
            } else {
                assertEquals(0, children.size());
            }
            for (Property nestedFeature : children) {
                Object value = nestedFeature.getValue();
                assertNotNull(value);
                value = ((Collection) value).iterator().next();
                assertTrue(value instanceof FeatureImpl);
                Feature feature = (Feature) value;
                assertNotNull(feature.getProperty("someAttribute").getValue());
            }
        }

        // <AttributeMapping>
        // <targetAttribute>FEATURE_LINK[2]</targetAttribute>
        // <sourceExpression>
        // <OCQL>LINK_TWO</OCQL>
        // </sourceExpression>
        // </AttributeMapping>
        dsParams = new HashMap();
        url = getClass().getResource(schemaBase + "SecondParentFeature.xml");
        assertNotNull(url);

        dsParams.put("dbtype", "app-schema");
        dsParams.put("url", url.toExternalForm());
        dataAccess = DataAccessFinder.getDataStore(dsParams);
        assertNotNull(dataAccess);
        typeName = Types.typeName("http://example.com", "SecondParentFeature");
        featureType = dataAccess.getSchema(typeName);
        assertNotNull(featureType);

        fSource = (FeatureSource) dataAccess.getFeatureSource(typeName);
        features = (FeatureCollection) fSource.getFeatures();

        assertEquals(5, size(features));

        iterator = features.features();
        while (iterator.hasNext()) {
View Full Code Here

Examples of org.geotools.data.FeatureSource

       
        query.setHints(hints);

        query.setProperties(selectedProperties);

        FeatureSource fSource = DataAccessRegistry.getFeatureSource((Name) featureTypeName);

        if (fSource == null) {
            throw new IOException("Internal error: Source could not be found");
        }

        FeatureCollection collection = fSource.getFeatures(query);

        if (!(collection instanceof MappingFeatureCollection)) {
            throw new IOException("Internal error: Mapping feature Collection expected but found "
                    + collection);
        }
View Full Code Here

Examples of org.geotools.data.FeatureSource

        //
        // Preparing feature information and styles
        //
        // /////////////////////////////////////////////////////////////////////
        final Style style = currLayer.getStyle();
        final FeatureSource featureSource = currLayer.getFeatureSource();

        final CoordinateReferenceSystem sourceCrs;
        final NumberRange scaleRange = NumberRange.create(scaleDenominator,scaleDenominator);
        final ArrayList<LiteFeatureTypeStyle> lfts ;

        if ( featureSource != null ) {
            FeatureCollection features = null;
            final FeatureType schema = featureSource.getSchema();

            final GeometryDescriptor geometryAttribute = schema.getGeometryDescriptor();
            if(geometryAttribute != null && geometryAttribute.getType() != null) {
                sourceCrs = geometryAttribute.getType().getCoordinateReferenceSystem();
            } else {
                sourceCrs = null;
            }
            if (LOGGER.isLoggable(Level.FINE)) {
                LOGGER.fine("Processing " + style.featureTypeStyles().size() +
                        " stylers for " + featureSource.getSchema().getName());
            }

            lfts = createLiteFeatureTypeStyles(style.featureTypeStyles(), schema, graphics);
            if(lfts.isEmpty())
                return;
           
            // make sure all spatial filters in the feature source native SRS
            reprojectSpatialFilters(lfts, featureSource);
           
            // apply the uom and dpi rescale
            applyUnitRescale(lfts);
           
            // classify by transformation
            List<List<LiteFeatureTypeStyle>> txClassified = classifyByTransformation(lfts);
           
            // render groups by uniform transformation
            for (List<LiteFeatureTypeStyle> uniform : txClassified) {
                Expression transform = uniform.get(0).transformation;
               
                // ... assume we have to do the generalization, the query layer process will
                // turn down the flag if we don't
                inMemoryGeneralization = true;
                boolean hasTransformation = transform != null;
                Query styleQuery = getStyleQuery(featureSource, schema,
                        uniform, mapArea, destinationCrs, sourceCrs, screenSize,
                        geometryAttribute, at, hasTransformation);
                Query definitionQuery = getDefinitionQuery(currLayer, featureSource, sourceCrs);
                if(hasTransformation) {
                    // prepare the stage for the raster transformations
                    GridGeometry2D gridGeometry = getRasterGridGeometry(destinationCrs, sourceCrs);
                    // vector transformation wise, we have to account for two separate queries,
                    // the one attached to the layer and then one coming from SLD.
                    // The first source attributes, the latter talks tx output attributes
                    // so they have to be applied before and after the transformation respectively
                   
                    RenderingTransformationHelper helper = new RenderingTransformationHelper() {
                       
                        @Override
                        protected GridCoverage2D readCoverage(GridCoverage2DReader reader, Object params, GridGeometry2D readGG) throws IOException {
                            GeneralParameterValue[] readParams = (GeneralParameterValue[]) params;
                            Interpolation interpolation = getRenderingInterpolation();
                            GridCoverageReaderHelper helper;
                            try {
                                helper = new GridCoverageReaderHelper(reader,
                                        readGG.getGridRange2D(),
                                        ReferencedEnvelope.reference(readGG.getEnvelope2D()),
                                        interpolation);
                                return helper.readCoverage(readParams);
                            } catch (InvalidGridGeometryException | FactoryException e) {
                                throw new IOException("Failure reading the coverage", e);
                            }

                        }
                    };
                   
                    Object result = helper.applyRenderingTransformation(transform, featureSource, definitionQuery,
                            styleQuery, gridGeometry, sourceCrs, java2dHints);
                    if(result == null) {
                        return;
                    } else if (result instanceof FeatureCollection) {
                        features = (FeatureCollection) result;
                    } else if (result instanceof GridCoverage2D) {
                        GridCoverage2D coverage = (GridCoverage2D) result;
                        // we only avoid disposing if the input was a in memory GridCovereage2D
                        if((schema instanceof SimpleFeatureType && !FeatureUtilities.isWrappedCoverage((SimpleFeatureType) schema))) {
                            coverage = new DisposableGridCoverage(coverage);
                        }
                        features = FeatureUtilities.wrapGridCoverage(coverage);
                    } else if (result instanceof GridCoverage2DReader) {
                        features = FeatureUtilities.wrapGridCoverageReader(
                                (GridCoverage2DReader) result, null);
                    } else {
                        throw new IllegalArgumentException(
                                "Don't know how to handle the results of the transformation, "
                                        + "the supported result types are FeatureCollection, GridCoverage2D "
                                        + "and GridCoverage2DReader, but we got: "
                                        + result.getClass());
                    }                   
                } else {
                    Query mixed = DataUtilities.mixQueries(definitionQuery, styleQuery, null);
                    checkAttributeExistence(featureSource.getSchema(), mixed);
                    features = featureSource.getFeatures(mixed);
                    features = RendererUtilities.fixFeatureCollectionReferencing(features, sourceCrs);
                }

                // HACK HACK HACK
                // For complex features, we need the targetCrs and version in scenario where we have
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.