Package org.geotools.feature

Examples of org.geotools.feature.FeatureCollection


        SimpleFeatureSource source = featureSource.getFeatureSource("lrssimple");
        LRSGeocodeProcess process = new LRSGeocodeProcess();
        SimpleFeatureCollection origional = source.getFeatures();

        try {
            FeatureCollection result = process.execute(origional, "from_lrs", null, 1.0);
            Assert.fail("Expected error from bad to_lrs name");
        } catch (ProcessException e) {
            // Successful
        }
    }
View Full Code Here


        SimpleFeatureSource source = featureSource.getFeatureSource("lrssimple");
        LRSGeocodeProcess process = new LRSGeocodeProcess();
        SimpleFeatureCollection origional = source.getFeatures();

        try {
            FeatureCollection result = process.execute(origional, "from_lrs", "to_lrs_bad", null);
            Assert.fail("Expected error from bad measure value");
        } catch (ProcessException e) {
            // Successful
        }
    }
View Full Code Here

    }

    @Test
    public void testNoFeaturesGiven() throws Exception {
        LRSGeocodeProcess process = new LRSGeocodeProcess();
        FeatureCollection origional = FeatureCollections.newCollection();

        FeatureCollection result = process.execute(origional, "from_lrs", "to_lrs", 1.0);
        Assert.assertEquals(0, result.size());
    }
View Full Code Here

    public void testGoodGeocode() throws Exception {
        SimpleFeatureSource source = featureSource.getFeatureSource("lrssimple");
        LRSGeocodeProcess process = new LRSGeocodeProcess();
        SimpleFeatureCollection origional = source.getFeatures();

        FeatureCollection result = process.execute(origional, "from_lrs", "to_lrs", 1.0);
        Assert.assertEquals(1, result.size());
        Feature feature = result.features().next();
        Point point = (Point) feature.getDefaultGeometryProperty().getValue();
        Assert.assertEquals(1.0, point.getX(), 0.0);
        Assert.assertEquals(0.0, point.getY(), 0.0);
    }
View Full Code Here

        }

        // load shapefile end (docs marker)

        final SpatialIndex index = new STRtree();
        FeatureCollection features = source.getFeatures();
        System.out.println("Slurping in features ...");
        features.accepts(new FeatureVisitor() {

            @Override
            public void visit(Feature feature) {
                SimpleFeature simpleFeature = (SimpleFeature) feature;
                Geometry geom = (MultiLineString) simpleFeature.getDefaultGeometry();
                // Just in case: check for  null or empty geometry
                if (geom != null) {
                    Envelope env = geom.getEnvelopeInternal();
                    if (!env.isNull()) {
                        index.insert(env, new LocationIndexedLine(geom));
                    }
                }
            }
        }, new NullProgressListener());

        // cache features end (docs marker)

        /*
         * For test data, we generate a large number of points placed randomly
         * within the bounding rectangle of the features.
         */
        final int NUM_POINTS = 10000;
        ReferencedEnvelope bounds = features.getBounds();
        Coordinate[] points = new Coordinate[NUM_POINTS];
        Random rand = new Random(file.hashCode());
        for (int i = 0; i < NUM_POINTS; i++) {
            points[i] = new Coordinate(
                    bounds.getMinX() + rand.nextDouble() * bounds.getWidth(),
 
View Full Code Here

        InputStream in = GMLParsing.class.getResourceAsStream( "states.xml");
        GMLConfiguration gml = new GMLConfiguration();
        Parser parser = new Parser(gml);
        parser.setStrict(false);
       
        FeatureCollection features = (FeatureCollection) parser.parse(in);
        FeatureIterator i = features.features();
       
        int nfeatures = 0;
        while( i.hasNext() ) {
            SimpleFeature f = (SimpleFeature) i.next();
            System.out.println(f.getID());
View Full Code Here

       
        GMLConfiguration gml = new GMLConfiguration();
        Parser parser = new Parser(gml);
        parser.setStrict(false);
       
        FeatureCollection features = (FeatureCollection) parser.parse(in);
        FeatureIterator i = features.features();
       
        int nfeatures = 0;
        while( i.hasNext() ) {
            SimpleFeature f = (SimpleFeature) i.next();
            System.out.println(f.getID());
View Full Code Here

        assertEquals("Value of land area is wrong", ((Double) firstFeature(features).getAttribute(
                "LAND_KM")).doubleValue(), 143986.61, 0.001);
    }

    public void testLoadAndCheckParentTypeIsPolygon() throws Exception {
        FeatureCollection features = loadFeatures(STATE_POP, Query.ALL);
        SimpleFeatureType schema = firstFeature(features).getFeatureType();
        assertEquals(schema.getSuper(), BasicFeatureTypes.POLYGON);
    }
View Full Code Here

        assertFalse(reader.hasNext());
        reader.close();
    }

    public void testAttributesWritingShapefile() throws Exception {
        FeatureCollection features = createFeatureCollection();
        File tmpFile = getTempFile("test-shp", ".shp");
        tmpFile.delete();
       
        // FIXME OGRDataStore s = new OGRDataStore(tmpFile.getAbsolutePath(), "ESRI shapefile", null);
        final String file = "/home/mauro/devel-box/projects/org.geotools/trunk/spike/mauro/ogr/target/test-shp.shp"; // FIXME Remove this HACK
View Full Code Here

       
        writeFeatures(s, features);
    }

    public void testAttributesWritingMapInfofile() throws Exception {
        FeatureCollection features = createFeatureCollectionForMapInfoDriver();
        File tmpFile = getTempFile("test-mapInfo-tab", ".tab");
        tmpFile.delete();
       
        // FIXME OGRDataStore s = new OGRDataStore(tmpFile.getAbsolutePath(), "MapInfo File", null);
        final String file = "/home/mauro/devel-box/projects/org.geotools/trunk/spike/mauro/ogr/target/test-tab.tab"; // FIXME Remove this HACK
View Full Code Here

TOP

Related Classes of org.geotools.feature.FeatureCollection

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.