use of org.bboxdb.tools.converter.osm.util.SerializableNode in project bboxdb by jnidzwetzki.
the class OSMJDBCNodeStore method getNodeForId.
/**
* Get the id for the node
* @param nodeId
* @return
* @throws SQLException
*/
public SerializableNode getNodeForId(final long nodeId) throws SQLException {
final int connectionNumber = getDatabaseForNode(nodeId);
final PreparedStatement selectNode = selectNodeStatements.get(connectionNumber);
selectNode.setLong(1, nodeId);
final ResultSet result = selectNode.executeQuery();
if (!result.next()) {
throw new RuntimeException("Unable to find node for way: " + nodeId);
}
final byte[] nodeBytes = result.getBytes(1);
result.close();
final SerializableNode node = SerializableNode.fromByteArray(nodeBytes);
return node;
}
use of org.bboxdb.tools.converter.osm.util.SerializableNode 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