Package org.geotools.data

Examples of org.geotools.data.Query


            SimpleFeatureSource featureSource = store.getFeatureSource();

            CoordinateReferenceSystem sourceCRS = featureSource.getInfo().getCRS();
            CoordinateReferenceSystem WGS84 = CRS.decode("EPSG:4326", true);

            Query query = new Query();
            query.setCoordinateSystem(sourceCRS);
            query.setCoordinateSystemReproject(WGS84);
            SimpleFeatureCollection featureCollection = featureSource.getFeatures(query);

            SimpleFeatureIterator it = featureCollection.features();
            int i = 0;
            while (it.hasNext()) {
View Full Code Here


        }
        final String defaultGeomAttName = geometryDescriptor.getLocalName();

        // we're calculating the bounds, so we'd better be sure and add the
        // spatial column to the query's propertynames
        final Query realQuery = new Query(query);
        realQuery.setPropertyNames(new String[] { defaultGeomAttName });

        final ArcSDEQuery boundsQuery;

        if (typeInfo.isInProcessView()) {
            final SeQueryInfo definitionQuery = typeInfo.getSdeDefinitionQuery();
View Full Code Here

        log("Testing feature source");
        final SimpleFeatureType schema = fs.getSchema();
        final String typeName = schema.getTypeName();
        final String spatialColName = schema.getGeometryDescriptor().getLocalName();

        Query query = new Query(typeName, Filter.INCLUDE, new String[] { spatialColName });
        long runTime = 0;
        for (int run = 0; run < numRuns; run++) {
            runTime += iterate(fs, query);
        }
        double avg = runTime / numRuns;
View Full Code Here

        log("-----------------------------------------------------");
        log("Testing feature source without geometry");
        DataStore ds = testData.getDataStore();
        SimpleFeatureSource fs = ds.getFeatureSource(typeName);
        try {
            Query query = new Query(typeName, Filter.INCLUDE, new String[] { "TOWN_ID" });
            long runTime = 0;
            for (int run = 0; run < numRuns; run++) {
                runTime += iterate(fs, query);
            }
            double avg = runTime / numRuns;
View Full Code Here

        for (int i = 0; i < queryAtts.length; i++) {
            queryAtts[i] = schema.getDescriptor(i).getLocalName();
        }

        // build the query asking for a subset of attributes
        final Query query = new Query(typeName, Filter.INCLUDE, queryAtts);

        FeatureReader<SimpleFeatureType, SimpleFeature> reader;
        reader = ds.getFeatureReader(query, Transaction.AUTO_COMMIT);
        SimpleFeatureType resultSchema;
        try {
View Full Code Here

            --i;
            queryAtts[j] = schema.getDescriptor(i).getLocalName();
        }

        // build the query asking for a subset of attributes
        final Query query = new Query(typeName, Filter.INCLUDE, queryAtts);

        FeatureReader<SimpleFeatureType, SimpleFeature> reader;
        reader = ds.getFeatureReader(query, Transaction.AUTO_COMMIT);
        try {
View Full Code Here

        final String[] queryAtts = { "SHAPE" };
        final Filter filter = CQL.toFilter("INT32_COL = 1");

        // build the query asking for a subset of attributes
        final Query query = new Query(typeName, filter, queryAtts);

        SimpleFeatureCollection features = fs.getFeatures(query);
        SimpleFeatureType resultSchema = features.getSchema();

        assertEquals(1, resultSchema.getAttributeCount());
View Full Code Here

        return false;
    }

    private FeatureReader<SimpleFeatureType, SimpleFeature> getReader(String typeName)
            throws IOException {
        Query q = new Query(typeName, Filter.INCLUDE);
        FeatureReader<SimpleFeatureType, SimpleFeature> reader = store.getFeatureReader(q,
                Transaction.AUTO_COMMIT);
        SimpleFeatureType retType = reader.getFeatureType();
        assertNotNull(retType.getGeometryDescriptor());
        assertTrue(reader.hasNext());
View Full Code Here

    @Test
    public void testAttributeOnlyQuery() throws Exception {
        DataStore ds = testData.getDataStore();
        SimpleFeatureSource fSource = ds.getFeatureSource(testData.getTempTableName());
        SimpleFeatureType type = fSource.getSchema();
        Query attOnlyQuery = new Query(type.getTypeName());
        List<String> propNames = new ArrayList<String>(type.getAttributeCount() - 1);

        for (int i = 0; i < type.getAttributeCount(); i++) {
            if (type.getDescriptor(i) instanceof GeometryDescriptor) {
                continue;
            }

            propNames.add(type.getDescriptor(i).getLocalName());
        }

        attOnlyQuery.setPropertyNames(propNames);

        SimpleFeatureCollection results = fSource.getFeatures(attOnlyQuery);
        SimpleFeatureType resultSchema = results.getSchema();
        assertEquals(propNames.size(), resultSchema.getAttributeCount());
View Full Code Here

    public void testFidFilters() throws Exception {
        final DataStore ds = testData.getDataStore();
        final String typeName = testData.getTempTableName();

        // grab some fids
        FeatureReader<SimpleFeatureType, SimpleFeature> reader = ds.getFeatureReader(new Query(
                typeName), Transaction.AUTO_COMMIT);
        List<FeatureId> fids = new ArrayList<FeatureId>();

        while (reader.hasNext()) {
            fids.add(ff.featureId(reader.next().getID()));

            // skip one
            if (reader.hasNext()) {
                reader.next();
            }
        }

        reader.close();

        Id filter = ff.id(new HashSet<FeatureId>(fids));

        SimpleFeatureSource source = ds.getFeatureSource(typeName);
        Query query = new Query(typeName, filter);
        SimpleFeatureCollection results = source.getFeatures(query);

        assertEquals(fids.size(), results.size());
        SimpleFeatureIterator iterator = results.features();
        try {
View Full Code Here

TOP

Related Classes of org.geotools.data.Query

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.