Search in sources :

Example 1 with MultiPolygon

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

the class MultiPoligonTest method itShouldDeserialize.

@Test
public void itShouldDeserialize() throws Exception {
    MultiPolygon multiPolygon = mapper.readValue("{\"type\":\"MultiPolygon\",\"coordinates\":[[[[102.0,2.0],[103.0,2.0],[103.0,3.0],[102.0,3.0],[102.0,2.0]]]," + "[[[100.0,0.0],[101.0,0.0],[101.0,1.0],[100.0,1.0],[100.0,0.0]]," + "[[100.2,0.2],[100.8,0.2],[100.8,0.8],[100.2,0.8],[100.2,0.2]]]]}", MultiPolygon.class);
    assertEquals(2, multiPolygon.getCoordinates().size());
}
Also used : MultiPolygon(org.geojson.MultiPolygon) Test(org.junit.Test)

Example 2 with MultiPolygon

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

the class MultiPoligonTest method itShouldSerialize.

@Test
public void itShouldSerialize() throws Exception {
    MultiPolygon multiPolygon = new MultiPolygon();
    multiPolygon.add(new Polygon(new LngLatAlt(102, 2), new LngLatAlt(103, 2), new LngLatAlt(103, 3), new LngLatAlt(102, 3), new LngLatAlt(102, 2)));
    Polygon polygon = new Polygon(MockData.EXTERNAL);
    polygon.addInteriorRing(MockData.INTERNAL);
    multiPolygon.add(polygon);
    assertEquals("{\"type\":\"MultiPolygon\",\"coordinates\":[[[[102.0,2.0],[103.0,2.0],[103.0,3.0],[102.0,3.0],[102.0,2.0]]]," + "[[[100.0,0.0],[101.0,0.0],[101.0,1.0],[100.0,1.0],[100.0,0.0]]," + "[[100.2,0.2],[100.8,0.2],[100.8,0.8],[100.2,0.8],[100.2,0.2]]]]}", mapper.writeValueAsString(multiPolygon));
}
Also used : MultiPolygon(org.geojson.MultiPolygon) MultiPolygon(org.geojson.MultiPolygon) Polygon(org.geojson.Polygon) LngLatAlt(org.geojson.LngLatAlt) Test(org.junit.Test)

Aggregations

MultiPolygon (org.geojson.MultiPolygon)2 Test (org.junit.Test)2 LngLatAlt (org.geojson.LngLatAlt)1 Polygon (org.geojson.Polygon)1