Coder Social home page Coder Social logo

jackson-datatype-jts's Introduction

Jackson-datatype-jts

Jackson Module which provides custom serializers and deserializers for JTS Geometry objects using the GeoJSON format

Installation

Releases of jackson-datatype-jts are available on Maven Central.

Maven

To use the module in Maven-based projects, use following dependency:

<dependency>
  <groupId>com.graphhopper.external</groupId>
  <artifactId>jackson-datatype-jts</artifactId>
  <version>[latest]</version>
</dependency>    

GraphHopper updates compared to upstream:

  • 2.14 uses JTS 1.19.0, requires Java 8
  • 0.12-2.5-1 uses JTS 1.15.1
  • 0.10-2.5-2 new groupId com.graphhopper.external and introduced JTS 1.15.0
  • 0.12-2.5-0 with the original jackson-databind dependency 2.4.2 and JTS 1.15.1
  • 0.12-2.5-1 with jackson-databind 2.9.6
  • 1.0-2.7 with jackson-databind 2.9.9 and JTS 1.16.0

Usage

Registering module

To use JTS geometry datatypes with Jackson, you will first need to register the module first (same as with all Jackson datatype modules):

ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JtsModule());

Reading and Writing Geometry types

After registering JTS module, Jackson Databind will be able to write Geometry instances as GeoJSON and and read GeoJSON geometries as JTS Geometry objects.

To write a Point object as GeoJSON:

GeometryFactory gf = new GeometryFactory();
Point point = gf.createPoint(new Coordinate(1.2345678, 2.3456789));
String geojson = objectMapper.writeValueAsString(point);

You can also read GeoJSON in as JTS geometry objects:

InputStream in;
Point point = mapper.readValue(in, Point.class);

jackson-datatype-jts's People

Contributors

akbertram avatar bddbot avatar calebjonasson avatar christophkaser avatar karussell avatar miguelcobain avatar mprins avatar purplep avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.