use of org.geojson.Polygon in project geojson-jackson by opendatalab-de.
the class PolygonTest method itShouldSetExteriorRing.
@Test
public void itShouldSetExteriorRing() throws Exception {
Polygon polygon = new Polygon();
polygon.setExteriorRing(MockData.EXTERNAL);
assertEquals(MockData.EXTERNAL, polygon.getExteriorRing());
}
use of org.geojson.Polygon in project geojson-jackson by opendatalab-de.
the class PolygonTest method itShouldSerialize.
@Test
public void itShouldSerialize() throws Exception {
Polygon polygon = new Polygon(MockData.EXTERNAL);
assertEquals("{\"type\":\"Polygon\",\"coordinates\":" + "[[[100.0,0.0],[101.0,0.0],[101.0,1.0],[100.0,1.0],[100.0,0.0]]]}", mapper.writeValueAsString(polygon));
}
use of org.geojson.Polygon in project geojson-jackson by opendatalab-de.
the class PolygonTest method itShouldDeserialize.
@Test
public void itShouldDeserialize() throws Exception {
Polygon polygon = mapper.readValue("{\"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]]]}", Polygon.class);
assertListEquals(MockData.EXTERNAL, polygon.getExteriorRing());
assertListEquals(MockData.INTERNAL, polygon.getInteriorRing(0));
assertListEquals(MockData.INTERNAL, polygon.getInteriorRings().get(0));
}
use of org.geojson.Polygon in project onebusaway-gtfs-modules by OneBusAway.
the class LocationsGeoJSONReaderTest method read.
@Test
public void read() throws IOException {
Collection<Location> locations = new LocationsGeoJSONReader(new InputStreamReader(new FileInputStream(GtfsTestData.getLocationsGeojson())), "").read();
assertEquals(locations.size(), 1);
Location location = locations.iterator().next();
assertEquals("si_Wendenschlossstrasse", location.getId().getId());
assertEquals("Wendenschlossstrasse", location.getName());
assertEquals("A nice description", location.getDescription());
assertTrue(location.getGeometry() instanceof Polygon);
assertEquals(new Polygon(new LngLatAlt(13.576526641845703, 52.44413508398945), new LngLatAlt(13.575839996337889, 52.429169943434495), new LngLatAlt(13.590774536132812, 52.4105872618342), new LngLatAlt(13.60879898071289, 52.43225757383383), new LngLatAlt(13.576526641845703, 52.44413508398945)), location.getGeometry());
assertEquals("fare-zone-A", location.getZoneId());
assertEquals("http://example.com", location.getUrl());
}
use of org.geojson.Polygon in project dhis2-core by dhis2.
the class MetadataImportExportControllerTest method testPostValidGeoJsonAttribute.
@Test
void testPostValidGeoJsonAttribute() throws IOException {
POST("/metadata", "{\"organisationUnits\": [ {\"id\":\"rXnqqH2Pu6N\",\"name\": \"My Unit 2\",\"shortName\": \"OU2\",\"openingDate\": \"2020-01-01\"," + "\"attributeValues\": [{\"value\": \"{\\\"type\\\": \\\"Polygon\\\"," + "\\\"coordinates\\\": [[[100,0],[101,0],[101,1],[100,1],[100,0]]] }\"," + "\"attribute\": {\"id\": \"RRH9IFiZZYN\"}}]}]," + "\"attributes\":[{\"id\":\"RRH9IFiZZYN\",\"valueType\":\"GEOJSON\",\"organisationUnitAttribute\":true,\"name\":\"testgeojson\"}]}").content(HttpStatus.OK);
JsonIdentifiableObject organisationUnit = GET("/organisationUnits/{id}", "rXnqqH2Pu6N").content().asObject(JsonIdentifiableObject.class);
assertEquals(1, organisationUnit.getAttributeValues().size());
JsonAttributeValue attributeValue = organisationUnit.getAttributeValues().get(0);
GeoJsonObject geoJSON = new ObjectMapper().readValue(attributeValue.getValue(), GeoJsonObject.class);
assertTrue(geoJSON instanceof Polygon);
Polygon polygon = (Polygon) geoJSON;
assertEquals(100, polygon.getCoordinates().get(0).get(0).getLongitude());
}
Aggregations