Search in sources :

Example 16 with SimpleFeatureCollection

use of org.geotools.data.simple.SimpleFeatureCollection in project GeoGig by boundlessgeo.

the class GeoGigFeatureSourceTest method testGetFeatures.

@Test
public void testGetFeatures() throws Exception {
    SimpleFeatureCollection collection;
    Set<List<Object>> actual;
    Set<List<Object>> expected;
    collection = pointsSource.getFeatures();
    assertEquals(pointsType, collection.getSchema());
    actual = Sets.newHashSet();
    for (Feature f : toList(collection)) {
        SimpleFeature sf = (SimpleFeature) f;
        actual.add(sf.getAttributes());
    }
    expected = ImmutableSet.of(((SimpleFeature) points1).getAttributes(), ((SimpleFeature) points2).getAttributes(), ((SimpleFeature) points3).getAttributes());
    assertEquals(expected, actual);
    collection = linesSource.getFeatures();
    assertEquals(linesType, collection.getSchema());
    actual = Sets.newHashSet();
    for (Feature f : toList(collection)) {
        actual.add(((SimpleFeature) f).getAttributes());
    }
    expected = ImmutableSet.of(((SimpleFeature) lines1).getAttributes(), ((SimpleFeature) lines2).getAttributes(), ((SimpleFeature) lines3).getAttributes());
    assertEquals(expected, actual);
}
Also used : List(java.util.List) SimpleFeature(org.opengis.feature.simple.SimpleFeature) Feature(org.opengis.feature.Feature) SimpleFeature(org.opengis.feature.simple.SimpleFeature) SimpleFeatureCollection(org.geotools.data.simple.SimpleFeatureCollection) Test(org.junit.Test)

Aggregations

SimpleFeatureCollection (org.geotools.data.simple.SimpleFeatureCollection)16 SimpleFeature (org.opengis.feature.simple.SimpleFeature)14 Test (org.junit.Test)12 SimpleFeatureIterator (org.geotools.data.simple.SimpleFeatureIterator)11 SimpleFeatureStore (org.geotools.data.simple.SimpleFeatureStore)10 Feature (org.opengis.feature.Feature)10 MemoryDataStore (org.geotools.data.memory.MemoryDataStore)9 SimpleFeatureSource (org.geotools.data.simple.SimpleFeatureSource)9 SimpleFeatureType (org.opengis.feature.simple.SimpleFeatureType)5 IOException (java.io.IOException)3 ReferencedEnvelope (org.geotools.geometry.jts.ReferencedEnvelope)3 MapLayer (au.org.emii.portal.menu.MapLayer)2 GeometryFactory (com.vividsolutions.jts.geom.GeometryFactory)2 LineString (com.vividsolutions.jts.geom.LineString)2 ParseException (com.vividsolutions.jts.io.ParseException)2 File (java.io.File)2 HashMap (java.util.HashMap)2 List (java.util.List)2 SimpleFeatureBuilder (org.geotools.feature.simple.SimpleFeatureBuilder)2 SimpleFeatureTypeBuilder (org.geotools.feature.simple.SimpleFeatureTypeBuilder)2