Skip to content

Commit

Permalink
Follow-up improvements
Browse files Browse the repository at this point in the history
- Use table highways
- Add fix message; show length
- Also detect too long crossings with: path=crossing; ford=*
- Change item to 2090 ('highway crossing')
  • Loading branch information
Famlam committed Aug 21, 2023
1 parent 5580b61 commit b5412b7
Showing 1 changed file with 34 additions and 10 deletions.
44 changes: 34 additions & 10 deletions analysers/analyser_osmosis_highway_long_crossing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

###########################################################################
## ##
## Copyright Osmose Contributors 2023 ##
## Copyright Osmose Contributors 2023 ##
## ##
## This program is free software: you can redistribute it and/or modify ##
## it under the terms of the GNU General Public License as published by ##
Expand All @@ -26,28 +26,52 @@
sql10 = """
SELECT
id,
ST_AsText(way_locate(linestring))
ST_AsText(way_locate(linestring)),
ST_Length(linestring_proj)
FROM
{0}ways
{0}highways
WHERE
tags != ''::hstore AND
(
(tags?'footway' AND tags->'footway' = 'crossing') OR
(tags?'cycleway' AND tags->'cycleway' = 'crossing')
(tags?'cycleway' AND tags->'cycleway' = 'crossing') OR
(tags?'path' AND tags->'path' = 'crossing')
) AND
ST_Length(linestring::geography) > 200
ST_Length(linestring_proj) > 200
UNION
SELECT
id,
ST_AsText(way_locate(linestring)),
ST_Length(linestring_proj)
FROM
{0}highways
WHERE
tags?'ford' AND tags->'ford' in ('yes', 'stepping_stones') AND
-- Some fords are pretty long, e.g. way 1077661529: 301m. Hence add quite a margin
ST_Length(linestring_proj) > 1000
"""

class Analyser_Osmosis_Highway_Long_Crossing(Analyser_Osmosis):

requires_tables_full = ['highways']
requires_tables_diff = ['touched_highways']

def __init__(self, config, logger = None):
Analyser_Osmosis.__init__(self, config, logger)
self.classs_change[1] = self.def_class(item = 7800, level = 2, tags = ['tag', 'highway', 'fix:survey'],
title = T_('Long Crossing'),
if not "proj" in self.config.options:
return
self.classs_change[10] = self.def_class(item = 2090, level = 2, tags = ['tag', 'highway', 'fix:survey'],
title = T_('Long crossing'),
detail = T_(
'''The crossing way is much longer than expected'''))
'''The crossing way is much longer than usual.'''),
fix = T_(
'''Split the way at the point were it no longer crosses a highway or waterway.
Remove crossing-related tags (such as `*=crossing`, `ford=*`) from the fragment that isn't a crossing.'''))

self.callback10 = lambda res: {"class":1, "data":[self.way_full, self.positionAsText] }
self.callback10 = lambda res: {
"class": 10, "data": [self.way_full, self.positionAsText],
"text": T_("Crossing of {0}m", round(res[2]))
}

def analyser_osmosis_full(self):
self.run(sql10.format(""), self.callback10)
Expand Down

0 comments on commit b5412b7

Please sign in to comment.