opendatalab-de/geojson-jackson

Name: geojson-jackson

Owner: OpenDataLab

Description: GeoJson POJOs for Jackson - serialize and deserialize objects with ease

Created: 2013-07-16 11:00:54.0

Updated: 2018-02-16 16:08:22.0

Pushed: 2018-01-05 18:10:49.0

Homepage: http://blog.opendatalab.de

Size: 88

Language: Java

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

GeoJson POJOs for Jackson

A small package of all GeoJson POJOs (Plain Old Java Objects) for serializing and deserializing of objects via JSON Jackson Parser.

Usage

If you know what kind of object you expect from a GeoJson file you can directly read it like this:

ureCollection featureCollection = 
new ObjectMapper().readValue(inputStream, FeatureCollection.class);

If you want to read any GeoJson file read the value as GeoJsonObject and then test for the contents via instanceOf:

sonObject object = new ObjectMapper().readValue(inputStream, GeoJsonObject.class);
object instanceof Polygon) {
...
se if (object instanceof Feature) {
...

and so on.

Or you can use the GeoJsonObjectVisitor to visit the right method:

sonObject object = new ObjectMapper().readValue(inputStream, GeoJsonObject.class);
ct.accept(visitor);

Writing Json is even easier. You just have to create the GeoJson objects and pass them to the Jackson ObjectMapper.

ureCollection featureCollection = new FeatureCollection();
ureCollection.add(new Feature());

ng json= new ObjectMapper().writeValueAsString(featureCollection);
Maven Central

You can find the library in the Maven Central Repository.

endency>
oupId>de.grundid.opendatalab</groupId>
tifactId>geojson-jackson</artifactId>
rsion>1.8</version>
pendency>

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.