• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

src/23-Nov-2023-1,8411,455

.gitignoreD23-Nov-202350 86

Android.bpD23-Nov-20231.2 KiB4541

LICENSED23-Nov-202310 KiB192155

METADATAD23-Nov-2023478 1917

MODULE_LICENSE_APACHE2D23-Nov-20230

OWNERSD23-Nov-202376 43

README.mdD23-Nov-20231.4 KiB6042

pom.xmlD23-Nov-20233.6 KiB125114

README.md

1GeoJson POJOs for Jackson
2=========================
3
4A small package of all GeoJson POJOs (Plain Old Java Objects) for serializing and
5deserializing of objects via JSON Jackson Parser.
6
7Usage
8-----
9
10If you know what kind of object you expect from a GeoJson file you can directly read it like this:
11
12
13```java
14FeatureCollection featureCollection =
15	new ObjectMapper().readValue(inputStream, FeatureCollection.class);
16```
17
18If you want to read any GeoJson file read the value as GeoJsonObject and then test for the contents via instanceOf:
19
20```java
21GeoJsonObject object = new ObjectMapper().readValue(inputStream, GeoJsonObject.class);
22if (object instanceof Polygon) {
23	...
24} else if (object instanceof Feature) {
25	...
26}
27```
28and so on.
29
30Or you can use the GeoJsonObjectVisitor to visit the right method:
31
32```java
33GeoJsonObject object = new ObjectMapper().readValue(inputStream, GeoJsonObject.class);
34object.accept(visitor);
35```
36
37
38Writing Json is even easier. You just have to create the GeoJson objects and pass them to the Jackson ObjectMapper.
39
40```java
41FeatureCollection featureCollection = new FeatureCollection();
42featureCollection.add(new Feature());
43
44String json= new ObjectMapper().writeValueAsString(featureCollection);
45```
46
47Maven Central
48-------------
49
50You can find the library in the Maven Central Repository.
51
52```xml
53<dependency>
54 <groupId>de.grundid.opendatalab</groupId>
55 <artifactId>geojson-jackson</artifactId>
56 <version>1.8.1</version>
57</dependency>
58```
59
60