Search in sources :

Example 66 with SimpleFeature

use of org.opengis.feature.simple.SimpleFeature in project dhis2-core by dhis2.

the class MapUtils method createFeatureLayerFromMapObject.

/**
     * Creates a feature layer based on a map object.
     */
public static Layer createFeatureLayerFromMapObject(InternalMapObject mapObject) {
    Style style = mapObject.getStyle();
    SimpleFeatureType featureType = mapObject.getFeatureType();
    SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(featureType);
    DefaultFeatureCollection featureCollection = new DefaultFeatureCollection();
    featureBuilder.add(mapObject.getGeometry());
    SimpleFeature feature = featureBuilder.buildFeature(null);
    featureCollection.add(feature);
    return new FeatureLayer(featureCollection, style);
}
Also used : FeatureLayer(org.geotools.map.FeatureLayer) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) Style(org.geotools.styling.Style) DefaultFeatureCollection(org.geotools.feature.DefaultFeatureCollection) SimpleFeature(org.opengis.feature.simple.SimpleFeature) SimpleFeatureBuilder(org.geotools.feature.simple.SimpleFeatureBuilder)

Aggregations

SimpleFeature (org.opengis.feature.simple.SimpleFeature)66 SimpleFeatureType (org.opengis.feature.simple.SimpleFeatureType)32 Test (org.junit.Test)27 SimpleFeatureBuilder (org.geotools.feature.simple.SimpleFeatureBuilder)21 RevFeature (org.locationtech.geogig.api.RevFeature)17 RevFeatureType (org.locationtech.geogig.api.RevFeatureType)16 Optional (com.google.common.base.Optional)15 Coordinate (com.vividsolutions.jts.geom.Coordinate)15 NodeRef (org.locationtech.geogig.api.NodeRef)13 ObjectId (org.locationtech.geogig.api.ObjectId)13 GeometryFactory (com.vividsolutions.jts.geom.GeometryFactory)12 File (java.io.File)10 ArrayList (java.util.ArrayList)10 DefaultTransaction (org.geotools.data.DefaultTransaction)10 WorkingTree (org.locationtech.geogig.repository.WorkingTree)10 IOException (java.io.IOException)9 List (java.util.List)9 Feature (org.opengis.feature.Feature)9 Function (com.google.common.base.Function)8 Transaction (org.geotools.data.Transaction)8