From 60128b0402d02f9d6489ca93cb9f16409ca6a407 Mon Sep 17 00:00:00 2001 From: SilentSpike Date: Wed, 30 Jan 2019 20:11:52 +0000 Subject: [PATCH] Fix one-way error positioning and description The direction of travel in the description was misleading as the way segment wasn't necessary linear and so the direction could change as you travel along the way. This is more explicit as it specifies the detected start/end nodes (also useful to show that it's not the whole way that might be one-way). The position is now taken as the central node in the `feature.points` list (or the average of the central two when there are an even number of points). --- data/core.yaml | 2 +- dist/locales/en.json | 2 +- modules/services/improveOSM.js | 21 +++++++++++++++------ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/data/core.yaml b/data/core.yaml index 214913dbc..2bb4915b8 100644 --- a/data/core.yaml +++ b/data/core.yaml @@ -680,7 +680,7 @@ en: error_types: ow: title: Missing One-way - description: 'Along this section of {highway}, {percentage}% of {num_trips} recorded trips travel {travel_direction}. There may be missing a "oneway" tag.' + description: 'Along this section of {highway}, {percentage}% of {num_trips} recorded trips travel from {from_node} to {to_node}. There may be missing a "oneway" tag.' mr: title: Missing Geometry description: '{num_trips} recorded trips in this area suggest there may be unmapped {geometry_type} here.' diff --git a/dist/locales/en.json b/dist/locales/en.json index 8e2d529ed..f4ef0c186 100644 --- a/dist/locales/en.json +++ b/dist/locales/en.json @@ -824,7 +824,7 @@ "error_types": { "ow": { "title": "Missing One-way", - "description": "Along this section of {highway}, {percentage}% of {num_trips} recorded trips travel {travel_direction}. There may be missing a \"oneway\" tag." + "description": "Along this section of {highway}, {percentage}% of {num_trips} recorded trips travel from {from_node} to {to_node}. There may be missing a \"oneway\" tag." }, "mr": { "title": "Missing Geometry", diff --git a/modules/services/improveOSM.js b/modules/services/improveOSM.js index 7a347027e..84164de6b 100644 --- a/modules/services/improveOSM.js +++ b/modules/services/improveOSM.js @@ -178,14 +178,22 @@ export default { // Road segments at high zoom == oneways if (data.roadSegments) { data.roadSegments.forEach(function(feature) { - // Travel direction along way segment clarifies one-way direction - var p1 = feature.points[0]; - var p2 = feature.points[1]; + // Position error at the approximate middle of the segment + var points = feature.points; + var mid = points.length / 2; + var loc; - var dir_of_travel = cardinalDirection(relativeBearing(p1, p2)); + // Even number of points, find midpoint of the middle two + // Odd number of points, use position of very middle point + if (mid % 1 == 0) { + loc = pointAverage([points[mid - 1], points[mid]]); + } else { + mid = points[Math.floor(mid)]; + loc = [mid.lon, mid.lat]; + } var d = new iOsmError({ - loc: pointAverage(feature.points), // TODO: This isn't great for curved roads, would be better to find actual midpoint of segment + loc: loc, comments: null, error_subtype: '', error_type: k, @@ -205,7 +213,8 @@ export default { percentage: feature.percentOfTrips, num_trips: feature.numberOfTrips, highway: linkErrorObject(t('QA.keepRight.error_parts.highway')), - travel_direction: dir_of_travel + from_node: linkEntity('n' + feature.fromNodeId), + to_node: linkEntity('n' + feature.toNodeId) }; _erCache.data[d.id] = d;