Package org.geotools.data

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


        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

        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

       
        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

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

        Set<FeatureTypeMapping> featureTypeMappings = new HashSet<FeatureTypeMapping>();

        for (Iterator it = mappingsConfigs.iterator(); it.hasNext();) {
            TypeMapping dto = (TypeMapping) it.next();           
            try {
                FeatureSource featureSource = getFeatureSource(dto, sourceDataStores);
                // get CRS from underlying feature source and pass it on
                CoordinateReferenceSystem crs;
                try {
                    crs = featureSource.getSchema().getCoordinateReferenceSystem();
                } catch (UnsupportedOperationException e) {
                    // web service back end doesn't support getSchema
                    crs = null;
                }
                AttributeDescriptor target = getTargetDescriptor(dto, crs);
View Full Code Here

        }

        AppSchemaDataAccessConfigurator.LOGGER.fine("asking datastore " + sourceDataStore
                + " for source type " + typeName);
        Name name = Types.degloseName(typeName, namespaces);
        FeatureSource fSource = sourceDataStore.getFeatureSource(name);
        if (fSource instanceof XmlFeatureSource) {
            ((XmlFeatureSource) fSource).setNamespaces(namespaces);
        }
        AppSchemaDataAccessConfigurator.LOGGER.fine("found feature source for " + typeName);
        return fSource;
View Full Code Here

        }       

        boolean isJoining = AppSchemaDataAccessConfigurator.isJoining();
        boolean removeQueryLimitIfDenormalised = false;

        FeatureSource mappedSource = mapping.getSource();           
       
        if (isJoining && !(mappedSource instanceof JDBCFeatureSource
                || mappedSource instanceof JDBCFeatureStore)) {
          // check if joining is explicitly set for non database backends
          if (AppSchemaDataAccessConfigurator.isJoiningSet()) {
View Full Code Here

                + "gss:formattedName = Unit Name1233811724109 UC1233811724109 description name ]]";
    }
   
    private FeatureCollection getFeatures(final int maxFeatures, Filter inputFilter)
            throws Exception {
        FeatureSource fSource = (FeatureSource) mappingDataStore.getFeatureSource(typeName);
        FeatureCollection features = (FeatureCollection) fSource.getFeatures(namedQuery(
                inputFilter, new Integer(maxFeatures)));
        return features;
    }
View Full Code Here

        if (!notFound) {
            fail("Expecting DataSourceException but didn't occur. Deregistering data access fails.");
        }
        notFound = false;
        try {
            FeatureSource source = AppSchemaDataAccessRegistry.getSimpleFeatureSource(typeName);
        } catch (DataSourceException e) {
            notFound = true;
            assertTrue(e.getMessage().startsWith("Feature type " + typeName + " not found"));
        }
        if (!notFound) {
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.