Search in sources :

Example 1 with LineString

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

the class LineStringTest method itShouldSerializeMultiPoint.

@Test
public void itShouldSerializeMultiPoint() throws Exception {
    MultiPoint lineString = new LineString(new LngLatAlt(100, 0), new LngLatAlt(101, 1));
    assertEquals("{\"type\":\"LineString\",\"coordinates\":[[100.0,0.0],[101.0,1.0]]}", mapper.writeValueAsString(lineString));
}
Also used : MultiPoint(org.geojson.MultiPoint) LineString(org.geojson.LineString) LngLatAlt(org.geojson.LngLatAlt) Test(org.junit.Test)

Example 2 with LineString

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

the class LineStringTest method itShouldDeserializeLineString.

@Test
public void itShouldDeserializeLineString() throws Exception {
    LineString lineString = mapper.readValue("{\"type\":\"LineString\",\"coordinates\":[[100.0,0.0],[101.0,1.0]]}", LineString.class);
    assertNotNull(lineString);
    List<LngLatAlt> coordinates = lineString.getCoordinates();
    PointTest.assertLngLatAlt(100, 0, Double.NaN, coordinates.get(0));
    PointTest.assertLngLatAlt(101, 1, Double.NaN, coordinates.get(1));
}
Also used : LineString(org.geojson.LineString) LngLatAlt(org.geojson.LngLatAlt) Test(org.junit.Test)

Aggregations

LineString (org.geojson.LineString)2 LngLatAlt (org.geojson.LngLatAlt)2 Test (org.junit.Test)2 MultiPoint (org.geojson.MultiPoint)1