use of org.bboxdb.tools.converter.osm.util.Polygon in project bboxdb by jnidzwetzki.
the class TestPolygon method testJSONEncoding2.
@Test
public void testJSONEncoding2() {
final Polygon polygon = new Polygon(47);
polygon.addPoint(4, 5);
final String json = polygon.toGeoJson();
final Polygon polygon2 = Polygon.fromGeoJson(json);
Assert.assertTrue(polygon.equals(polygon2));
Assert.assertEquals(47, polygon2.getId());
}
use of org.bboxdb.tools.converter.osm.util.Polygon in project bboxdb by jnidzwetzki.
the class TestPolygon method testJSONEncoding4.
@Test
public void testJSONEncoding4() {
final Polygon polygon = new Polygon(47);
polygon.addPoint(4, 5);
polygon.addPoint(67, 45);
polygon.addPoint(3, -4);
polygon.addPoint(0, 12);
polygon.addPoint(2, 4);
final String json = polygon.toGeoJson();
final Polygon polygon2 = Polygon.fromGeoJson(json);
Assert.assertTrue(polygon.equals(polygon2));
Assert.assertEquals(47, polygon2.getId());
}
use of org.bboxdb.tools.converter.osm.util.Polygon in project bboxdb by jnidzwetzki.
the class TestPolygon method testJSONEncoding6.
@Test
public void testJSONEncoding6() {
final Polygon polygon = new Polygon(47);
polygon.addPoint(4, 5);
polygon.addPoint(67, 45);
polygon.addPoint(3, -4);
polygon.addPoint(0, 12);
polygon.addPoint(2, 4);
polygon.addProperty("key1", "value1");
polygon.addProperty("key2", "value2");
polygon.addProperty("key3", "value3");
polygon.addProperty("key4", "value4");
polygon.addProperty("key5", "value5");
polygon.addProperty("key6", "value6");
final String json = polygon.toGeoJson();
final Polygon polygon2 = Polygon.fromGeoJson(json);
Assert.assertTrue(polygon.equals(polygon2));
Assert.assertEquals(47, polygon2.getId());
}
use of org.bboxdb.tools.converter.osm.util.Polygon in project bboxdb by jnidzwetzki.
the class TestPolygon method testJSONEncoding3.
@Test
public void testJSONEncoding3() {
final Polygon polygon = new Polygon(47);
polygon.addPoint(4, 5);
polygon.addPoint(67, 45);
final String json = polygon.toGeoJson();
final Polygon polygon2 = Polygon.fromGeoJson(json);
Assert.assertTrue(polygon.equals(polygon2));
Assert.assertEquals(47, polygon2.getId());
}
use of org.bboxdb.tools.converter.osm.util.Polygon in project bboxdb by jnidzwetzki.
the class OSMDataConverter method handleWay.
/**
* Handle a way
* @param entityContainer
*/
protected void handleWay(final Way way) {
try {
for (final OSMType osmType : filter.keySet()) {
final OSMTagEntityFilter entityFilter = filter.get(osmType);
if (entityFilter.match(way.getTags())) {
final Polygon geometricalStructure = new Polygon(way.getId());
for (final Tag tag : way.getTags()) {
geometricalStructure.addProperty(tag.getKey(), tag.getValue());
}
// Perform search async
for (final WayNode wayNode : way.getWayNodes()) {
final SerializableNode node = osmNodeStore.getNodeForId(wayNode.getNodeId());
geometricalStructure.addPoint(node.getLatitude(), node.getLongitude());
}
writePolygonToOutput(osmType, geometricalStructure);
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations