use of org.geojson.Polygon 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));
}
use of org.geojson.Polygon in project geojson-jackson by opendatalab-de.
the class PolygonTest method itShouldFailOnAddInteriorRingWithoutExteriorRing.
@Test(expected = RuntimeException.class)
public void itShouldFailOnAddInteriorRingWithoutExteriorRing() throws Exception {
Polygon polygon = new Polygon();
polygon.addInteriorRing(MockData.EXTERNAL);
}
use of org.geojson.Polygon in project geojson-jackson by opendatalab-de.
the class PolygonTest method itShouldSerializeWithHole.
@Test
public void itShouldSerializeWithHole() throws Exception {
Polygon polygon = new Polygon(MockData.EXTERNAL);
polygon.addInteriorRing(MockData.INTERNAL);
assertEquals("{\"type\":\"Polygon\",\"coordinates\":" + "[[[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(polygon));
}
use of org.geojson.Polygon in project geojson-jackson by opendatalab-de.
the class PolygonTest method itShouldReplaceExteriorRing.
@Test
public void itShouldReplaceExteriorRing() throws Exception {
Polygon polygon = new Polygon(Arrays.asList(new LngLatAlt(0, 0), new LngLatAlt(1, 0), new LngLatAlt(1, 1), new LngLatAlt(0, 1), new LngLatAlt(0, 0)));
polygon.setExteriorRing(MockData.EXTERNAL);
assertEquals(MockData.EXTERNAL, polygon.getExteriorRing());
assertEquals(0, polygon.getInteriorRings().size());
}
use of org.geojson.Polygon in project dhis2-core by dhis2.
the class MetadataImportExportControllerTest method testPostInValidGeoJsonAttribute.
@Test
void testPostInValidGeoJsonAttribute() {
JsonWebMessage message = POST("/metadata", "{\"organisationUnits\": [ {\"id\":\"rXnqqH2Pu6N\",\"name\": \"My Unit 2\",\"shortName\": \"OU2\",\"openingDate\": \"2020-01-01\"," + "\"attributeValues\": [{\"value\": \"{\\\"type\\\": \\\"Polygon\\\"}\"," + "\"attribute\": {\"id\": \"RRH9IFiZZYN\"}}]}]," + "\"attributes\":[{\"id\":\"RRH9IFiZZYN\",\"valueType\":\"GEOJSON\",\"organisationUnitAttribute\":true,\"name\":\"testgeojson\"}]}").content(HttpStatus.CONFLICT).as(JsonWebMessage.class);
assertNotNull(message.find(JsonErrorReport.class, report -> report.getErrorCode() == ErrorCode.E6004));
}
Aggregations