Search in sources :

Example 11 with Polygon

use of org.bboxdb.tools.converter.osm.util.Polygon in project bboxdb by jnidzwetzki.

the class OSMDataConverter method handleNode.

/**
 * Handle a node
 * @param entityContainer
 */
protected void handleNode(final Node node) {
    try {
        for (final OSMType osmType : filter.keySet()) {
            final OSMTagEntityFilter entityFilter = filter.get(osmType);
            if (entityFilter.match(node.getTags())) {
                final Polygon geometricalStructure = new Polygon(node.getId());
                geometricalStructure.addPoint(node.getLatitude(), node.getLongitude());
                for (final Tag tag : node.getTags()) {
                    geometricalStructure.addProperty(tag.getKey(), tag.getValue());
                }
                writePolygonToOutput(osmType, geometricalStructure);
            }
        }
        osmNodeStore.storeNode(node);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : OSMTagEntityFilter(org.bboxdb.tools.converter.osm.filter.OSMTagEntityFilter) 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)

Example 12 with Polygon

use of org.bboxdb.tools.converter.osm.util.Polygon in project bboxdb by jnidzwetzki.

the class BenchmarkFileInsertPerformance method handleLine.

/**
 * Handle a line from the input file
 * @param line
 * @throws BBoxDBException
 */
protected void handleLine(String line) {
    try {
        final Polygon polygon = Polygon.fromGeoJson(line);
        final byte[] tupleBytes = polygon.toGeoJson().getBytes();
        final Tuple tuple = new Tuple(Long.toString(polygon.getId()), polygon.getBoundingBox(), tupleBytes);
        final EmptyResultFuture insertFuture = bboxdbClient.insertTuple(table, tuple);
        // register pending future
        pendingFutures.put(insertFuture);
        insertedTuples.incrementAndGet();
    } catch (BBoxDBException e) {
        System.err.println("Got an exeption while reading file: " + e);
        System.exit(-1);
    }
}
Also used : Polygon(org.bboxdb.tools.converter.osm.util.Polygon) BBoxDBException(org.bboxdb.misc.BBoxDBException) Tuple(org.bboxdb.storage.entity.Tuple) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture)

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