All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.scaleset.geo.geojson.GeoJsonModule Maven / Gradle / Ivy

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));
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy