Search in sources :

Example 1 with FeatureToGeoJsonJacksonMapper

use of eu.europa.ec.fisheries.uvms.commons.geometry.mapper.FeatureToGeoJsonJacksonMapper in project UVMS-ActivityModule-APP by UnionVMS.

the class FishingTripToGeoJsonMapper method toJson.

// Convert Geometry list into GEO JSON format
public static ObjectNode toJson(List<Geometry> geoList) {
    ObjectNode rootNode = null;
    DefaultFeatureCollection trips = new DefaultFeatureCollection(null, build());
    for (Geometry geo : geoList) {
        SimpleFeature feature = toFeature(geo);
        trips.add(feature);
    }
    try {
        rootNode = new FeatureToGeoJsonJacksonMapper().convert(trips);
    } catch (IOException e) {
        log.error("Error while trying to convert fishing trips to Geo JSON", e);
    }
    return rootNode;
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) FeatureToGeoJsonJacksonMapper(eu.europa.ec.fisheries.uvms.commons.geometry.mapper.FeatureToGeoJsonJacksonMapper) IOException(java.io.IOException) DefaultFeatureCollection(org.geotools.feature.DefaultFeatureCollection) SimpleFeature(org.opengis.feature.simple.SimpleFeature)

Aggregations

ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 Geometry (com.vividsolutions.jts.geom.Geometry)1 FeatureToGeoJsonJacksonMapper (eu.europa.ec.fisheries.uvms.commons.geometry.mapper.FeatureToGeoJsonJacksonMapper)1 IOException (java.io.IOException)1 DefaultFeatureCollection (org.geotools.feature.DefaultFeatureCollection)1 SimpleFeature (org.opengis.feature.simple.SimpleFeature)1