Search in sources :

Example 6 with Polygon

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());
}
Also used : Polygon(org.bboxdb.tools.converter.osm.util.Polygon) Test(org.junit.Test)

Example 7 with Polygon

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());
}
Also used : Polygon(org.bboxdb.tools.converter.osm.util.Polygon) Test(org.junit.Test)

Example 8 with Polygon

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());
}
Also used : Polygon(org.bboxdb.tools.converter.osm.util.Polygon) Test(org.junit.Test)

Example 9 with Polygon

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());
}
Also used : Polygon(org.bboxdb.tools.converter.osm.util.Polygon) Test(org.junit.Test)

Example 10 with Polygon

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);
    }
}
Also used : OSMTagEntityFilter(org.bboxdb.tools.converter.osm.filter.OSMTagEntityFilter) WayNode(org.openstreetmap.osmosis.core.domain.v0_6.WayNode) SerializableNode(org.bboxdb.tools.converter.osm.util.SerializableNode) Tag(org.openstreetmap.osmosis.core.domain.v0_6.Tag) Polygon(org.bboxdb.tools.converter.osm.util.Polygon) IOException(java.io.IOException) ParseException(org.apache.commons.cli.ParseException)

Aggregations

Polygon (org.bboxdb.tools.converter.osm.util.Polygon)12 Test (org.junit.Test)8 IOException (java.io.IOException)2 ParseException (org.apache.commons.cli.ParseException)2 Tuple (org.bboxdb.storage.entity.Tuple)2 OSMTagEntityFilter (org.bboxdb.tools.converter.osm.filter.OSMTagEntityFilter)2 Tag (org.openstreetmap.osmosis.core.domain.v0_6.Tag)2 BBoxDBException (org.bboxdb.misc.BBoxDBException)1 EmptyResultFuture (org.bboxdb.network.client.future.EmptyResultFuture)1 SerializableNode (org.bboxdb.tools.converter.osm.util.SerializableNode)1 WayNode (org.openstreetmap.osmosis.core.domain.v0_6.WayNode)1