| 254 | /** |
| 255 | * Tests for bus stop ("public_transport"="stop_position"/"bus"="yes") Nodes a long a way that are missing a related nearby Node with "highway=bus_stop" |
| 256 | * @param n Node being visited |
| 257 | */ |
| 258 | public void testMissingBusStopNode(Node n) { |
| 259 | if (n.hasTag(BUS, "yes") && n.hasTag(PUBLIC_TRANSPORT, "stop_position")) { |
| 260 | int countOfNodesWithProperTags = 0; |
| 261 | //Approximately 15 meters depending on Lat/Lon |
| 262 | List<Node> nearbyNodesWithinTwentyFiveMeters = getNearbyNodesWithinShortDistance(n, 0.00015); |
| 263 | for (Node nearbyNodeWithinTwentyFiveMeters : nearbyNodesWithinTwentyFiveMeters) { |
| 264 | if (nearbyNodeWithinTwentyFiveMeters.hasTag(HIGHWAY, "bus_stop") && nearbyNodeWithinTwentyFiveMeters.hasTag(BUS, "yes")) { |
| 265 | countOfNodesWithProperTags += 1; |
| 266 | } |
| 267 | } |
| 268 | if (countOfNodesWithProperTags == 0) { |
| 269 | errors.add(TestError.builder(this, Severity.WARNING, SOURCE_BUS_STOP_NEEDED) |
| 270 | .message(tr("Node {2} needs a nearby related node with tags: {0} and {1}.", |
| 271 | "highway=bus_stop", "bus=yes", n.getOsmId())) |
| 272 | .primitives(n) |
| 273 | .build()); |
| 274 | } |
| 275 | } |
| 276 | return; |
| 277 | } |
| 278 | |
| 279 | /** |
| 280 | * Gathers list of Nodes within specified approximate distance (takes double but unit is LatLon degrees) of Node n. |
| 281 | * @param n Node being visited |
| 282 | * @param expanseDistance Distance to expand Node bounds. Units are in LatLon degrees. |
| 283 | * @return List of Nodes |
| 284 | */ |
| 285 | public List<Node> getNearbyNodesWithinShortDistance(Node n, double expanseDistance) { |
| 286 | |
| 287 | DataSet nodeDataSet = n.getDataSet(); |
| 288 | |
| 289 | BBox nodeBBox= n.getBBox(); |
| 290 | nodeBBox.addLatLon(nodeBBox.getCenter(), expanseDistance); |
| 291 | |
| 292 | return nodeDataSet.searchNodes(nodeBBox); |
| 293 | } |
| 294 | |