public static List<Point> createPoints(OsmEntityProvider data, OsmWay way) { List<Point> points = new ArrayList<>(); try { for (int i = 0; i < way.getNumberOfNodes(); i++) { points.add(NODE_BUILDER.build(data.getNode(way.getNodeId(i)))); } } catch (EntityNotFoundException e) { Terrarium.LOGGER.warn("Unable to find node", e); } return points; } }
@Override public void handle(OsmWay way) throws IOException { Geometry osmGeometry = null; try { osmGeometry = builder.build(way, dataSet); if (osmGeometry instanceof LinearRing) { osmGeometry = new Polygon((LinearRing) osmGeometry, null, GEOMETRY_FACTORY); } } catch (IllegalArgumentException e) { log.warn("Could not build way (illegal argument): {}", e.getMessage()); } catch (EntityNotFoundException e) { // Nothing to do, continue... log.warn("Could not build way (entity not found): {}", e.getMessage()); } ways.put(way.getId(), way); handleEntity(way, osmGeometry); }
private boolean isWayInBounds(OsmWay way, double minLatitude, double minLongitude, double maxLatitude, double maxLongitude) { double wayMinLatitude = Double.MAX_VALUE; double wayMinLongitude = Double.MAX_VALUE; double wayMaxLatitude = -Double.MAX_VALUE; double wayMaxLongitude = -Double.MAX_VALUE; for (int i = 0; i < way.getNumberOfNodes(); i++) { try { OsmNode node = this.getNode(way.getNodeId(i)); double latitude = node.getLatitude(); if (latitude < wayMinLatitude) { wayMinLatitude = latitude; } if (latitude > wayMaxLatitude) { wayMaxLatitude = latitude; } double longitude = node.getLongitude(); if (longitude < wayMinLongitude) { wayMinLongitude = longitude; } if (longitude > wayMaxLongitude) { wayMaxLongitude = longitude; } } catch (EntityNotFoundException e) { } } return minLatitude < wayMaxLatitude && maxLatitude > wayMinLatitude && minLongitude < wayMaxLongitude && maxLongitude > wayMinLongitude; } }
nds.lengths[row] = way.getNumberOfNodes(); nds.childCount += nds.lengths[row]; ndsStruct.ensureSize(nds.childCount, nds.offsets[row] != 0); for (int j = 0; j < way.getNumberOfNodes(); j++) { ((LongColumnVector) ndsStruct.fields[0]).vector[(int) nds.offsets[row] + j] = way.getNodeId(j);