Bug: 199275786

Clone this repo:
  1. 0a3f43d Update OWNERS am: 105049acaf am: 2bb76ad5c9 am: 8c66c7bc7d am: 301ac396ea am: 660889e8be by Neil Fuller · 12 months ago android13-dev android13-frc-adbd-release android13-frc-art-release android13-frc-cellbroadcast-release android13-frc-conscrypt-release master aml_uwb_330810010 t_frc_adb_330444000 t_frc_art_330443060 t_frc_ase_330444010 t_frc_cbr_330443000 t_frc_con_330443020
  2. 660889e Update OWNERS am: 105049acaf am: 2bb76ad5c9 am: 8c66c7bc7d am: 301ac396ea by Neil Fuller · 12 months ago
  3. 301ac39 Update OWNERS am: 105049acaf am: 2bb76ad5c9 am: 8c66c7bc7d by Neil Fuller · 12 months ago
  4. 8c66c7b Update OWNERS am: 105049acaf am: 2bb76ad5c9 by Neil Fuller · 12 months ago
  5. 2bb76ad Update OWNERS am: 105049acaf by Neil Fuller · 12 months ago

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:

FeatureCollection 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:

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

and so on.

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

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

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

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

String json= new ObjectMapper().writeValueAsString(featureCollection);

Maven Central

You can find the library in the Maven Central Repository.

<dependency>
 <groupId>de.grundid.opendatalab</groupId>
 <artifactId>geojson-jackson</artifactId>
 <version>1.8.1</version>
</dependency>