com.scaleset.geo.geojson.GeoJsonModule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scaleset-geo Show documentation
Show all versions of scaleset-geo Show documentation
Simple framework for dealing with GeoJson and similar data formats
The newest version!
package com.scaleset.geo.geojson;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.vividsolutions.jts.geom.*;
public class GeoJsonModule extends SimpleModule {
static GeometryDeserializer GEO_DE = new GeometryDeserializer();
public GeoJsonModule() {
this(null);
}
public GeoJsonModule(Integer precision) {
// deserializers - Jackson requires a deserializer for each subclass of geometry
GeometryDeserializer de = new GeometryDeserializer();
addDeserializer(Geometry.class, new GeometryDeserializer());
addDeserializer(GeometryCollection.class, new GeometryDeserializer());
addDeserializer(Point.class, new GeometryDeserializer());
addDeserializer(LinearRing.class, new GeometryDeserializer());
addDeserializer(LineString.class, new GeometryDeserializer());
addDeserializer(MultiLineString.class, new GeometryDeserializer());
addDeserializer(MultiPoint.class, new GeometryDeserializer());
addDeserializer(MultiPolygon.class, new GeometryDeserializer());
addDeserializer(Polygon.class, new GeometryDeserializer());
addDeserializer(Envelope.class, new EnvelopeDeserializer());
addDeserializer(Coordinate.class, new CoordinateDeserializer());
// serializers
addSerializer(Geometry.class, new GeometrySerializer(precision));
addSerializer(Envelope.class, new EnvelopeSerializer(precision));
addSerializer(Coordinate.class, new CoordinateSerializer(precision));
}
}