From 810bd391526c43622b756eb6d271608396b5bd41 Mon Sep 17 00:00:00 2001 From: Paul Bienkowski Date: Sun, 19 Dec 2021 21:21:45 +0100 Subject: [PATCH] Fix direction of road segments (fixes #142) BREAKING CHANGE: This changes the tile generation function, please update your database with `prepare_sql_tiles.py`. --- api/obs/api/routes/mapdetails.py | 2 +- tile-generator/layers/obs_roads/layer.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/obs/api/routes/mapdetails.py b/api/obs/api/routes/mapdetails.py index 2c9ce59..fc475d7 100644 --- a/api/obs/api/routes/mapdetails.py +++ b/api/obs/api/routes/mapdetails.py @@ -108,7 +108,7 @@ async def mapdetails_road(req): def partition(arr, cond): return arr[:, cond], arr[:, ~cond] - forwards, backwards = partition(data, mask) + forwards, backwards = partition(data, ~mask) print("for", forwards.dtype, "back", backwards.dtype) def array_stats(arr, rounder): diff --git a/tile-generator/layers/obs_roads/layer.sql b/tile-generator/layers/obs_roads/layer.sql index 181bf15..85f700a 100644 --- a/tile-generator/layers/obs_roads/layer.sql +++ b/tile-generator/layers/obs_roads/layer.sql @@ -24,7 +24,7 @@ RETURNS TABLE( r.dir as direction, case when road.directionality = 0 then r.dir else 0 end as offset_direction FROM road - LEFT JOIN (VALUES (1, TRUE), (-1, FALSE), (0, FALSE)) AS r(dir, rev) ON (abs(r.dir) != road.directionality) + LEFT JOIN (VALUES (-1, TRUE), (1, FALSE), (0, FALSE)) AS r(dir, rev) ON (abs(r.dir) != road.directionality) FULL OUTER JOIN overtaking_event ON (road.way_id = overtaking_event.way_id and (road.directionality != 0 or overtaking_event.direction_reversed = r.rev)) -- WHERE road.name = 'Merzhauser Straße' WHERE road.geometry && bbox