Search in sources :

Example 6 with GeoJsonObject

use of org.geojson.GeoJsonObject in project geojson-jackson by opendatalab-de.

the class PointTest method itShouldDeserializeAPoint.

@Test
public void itShouldDeserializeAPoint() throws Exception {
    GeoJsonObject value = mapper.readValue("{\"type\":\"Point\",\"coordinates\":[100.0,5.0]}", GeoJsonObject.class);
    assertNotNull(value);
    assertTrue(value instanceof Point);
    Point point = (Point) value;
    assertLngLatAlt(100, 5, Double.NaN, point.getCoordinates());
}
Also used : Point(org.geojson.Point) GeoJsonObject(org.geojson.GeoJsonObject) Test(org.junit.Test)

Example 7 with GeoJsonObject

use of org.geojson.GeoJsonObject in project geojson-jackson by opendatalab-de.

the class CrsTest method itShouldParseCrsWithLink.

@Test
public void itShouldParseCrsWithLink() throws Exception {
    GeoJsonObject value = mapper.readValue("{\"crs\": { \"type\": \"link\", \"properties\": " + "{ \"href\": \"http://example.com/crs/42\", \"type\": \"proj4\" }}," + "\"type\":\"Point\",\"coordinates\":[100.0,5.0]}", GeoJsonObject.class);
    assertNotNull(value);
    assertEquals(CrsType.link, value.getCrs().getType());
}
Also used : GeoJsonObject(org.geojson.GeoJsonObject) Test(org.junit.Test)

Example 8 with GeoJsonObject

use of org.geojson.GeoJsonObject in project geojson-jackson by opendatalab-de.

the class PointTest method itShouldDeserializeAPointWithAdditionalAttributes.

@Test
public void itShouldDeserializeAPointWithAdditionalAttributes() throws IOException {
    GeoJsonObject value = mapper.readValue("{\"type\":\"Point\",\"coordinates\":[100.0,5.0,123,456,789.2]}", GeoJsonObject.class);
    Point point = (Point) value;
    assertLngLatAlt(100, 5, 123, new double[] { 456d, 789.2 }, point.getCoordinates());
}
Also used : Point(org.geojson.Point) GeoJsonObject(org.geojson.GeoJsonObject) Test(org.junit.Test)

Aggregations

GeoJsonObject (org.geojson.GeoJsonObject)8 Point (org.geojson.Point)5 Test (org.junit.Test)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 Feature (org.geojson.Feature)3 ArrayList (java.util.ArrayList)2 FeatureCollection (org.geojson.FeatureCollection)2 Polygon (org.geojson.Polygon)2 Test (org.junit.jupiter.api.Test)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 DeserializationFeature (com.fasterxml.jackson.databind.DeserializationFeature)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Lists (com.google.common.collect.Lists)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 URL (java.net.URL)1 URLConnection (java.net.URLConnection)1 Comparator (java.util.Comparator)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1