Search in sources :

Example 1 with OSMTagEntityFilter

use of org.bboxdb.tools.converter.osm.filter.OSMTagEntityFilter 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)

Example 2 with OSMTagEntityFilter

use of org.bboxdb.tools.converter.osm.filter.OSMTagEntityFilter 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)

Aggregations

IOException (java.io.IOException)2 ParseException (org.apache.commons.cli.ParseException)2 OSMTagEntityFilter (org.bboxdb.tools.converter.osm.filter.OSMTagEntityFilter)2 Polygon (org.bboxdb.tools.converter.osm.util.Polygon)2 Tag (org.openstreetmap.osmosis.core.domain.v0_6.Tag)2 SerializableNode (org.bboxdb.tools.converter.osm.util.SerializableNode)1 WayNode (org.openstreetmap.osmosis.core.domain.v0_6.WayNode)1