Skip to content

Commit

Permalink
Disable warning for ways in bridge contour
Browse files Browse the repository at this point in the history
Disable the warning for missing `bridge:structure=*` or more detailed `bridge=*` if the highway/railway is contained within a `man_made=bridge` object.

See #2447

Also adds a test case
  • Loading branch information
Famlam authored and frodrigo committed Feb 16, 2025
1 parent 63fa79c commit 0f4abed
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 15 deletions.
40 changes: 25 additions & 15 deletions analysers/analyser_osmosis_highway_tunnel_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,26 @@

sql10 = """
SELECT
id,
ST_AsText(way_locate(linestring))
ways.id,
ST_AsText(way_locate(ways.linestring))
FROM
{0}ways
ways
LEFT JOIN polygons AS contours ON
ST_Contains(contours.poly, ways.linestring) AND
contours.tags != ''::hstore AND
contours.tags?'man_made' AND
contours.tags->'man_made' = 'bridge'
WHERE
tags != ''::hstore AND
ways.tags != ''::hstore AND
(
tags?'railway' OR
(tags?'highway' AND tags->'highway' IN ('motorway', 'trunk', 'primary', 'secondary'))
ways.tags?'railway' OR
(ways.tags?'highway' AND ways.tags->'highway' IN ('motorway', 'trunk', 'primary', 'secondary'))
) AND
tags?'bridge' AND
tags->'bridge' = 'yes' AND
ST_Length(linestring::geography) > 500 AND
NOT tags?'bridge:structure'
ways.tags?'bridge' AND
ways.tags->'bridge' = 'yes' AND
ST_Length(ways.linestring::geography) > 500 AND
NOT ways.tags?'bridge:structure' AND
contours IS NULL
"""

sql20 = """
Expand Down Expand Up @@ -151,19 +157,22 @@

class Analyser_Osmosis_Highway_Tunnel_Bridge(Analyser_Osmosis):

requires_tables_common = ['polygons']
requires_tables_full = ['highways']
requires_tables_diff = ['highways', 'touched_highways', 'not_touched_highways']

def __init__(self, config, logger = None):
Analyser_Osmosis.__init__(self, config, logger)
self.classs_change[1] = self.def_class(item = 7012, level = 3, tags = ['tag', 'highway', 'fix:survey'],
self.classs[1] = self.def_class(item = 7012, level = 3, tags = ['tag', 'highway', 'fix:survey'],
title = T_('Bridge structure missing'),
detail = T_(
'''The length of the bridge makes it deserve a more detailed tag than
`bridge=yes`.'''),
fix = T_(
'''See the possible [types of
bridges](https://wiki.openstreetmap.org/wiki/Key:bridge).'''))
'''Add a more detailed [bridge type or structure](https://wiki.openstreetmap.org/wiki/Key:bridge).
Alternatively, draw the contour of the bridge using `man_made=bridge`
and add information about the bridge architecture to this contour.'''))
#self.classs_change[2] = self.def_class(item = 7130, level = 3, tags = ['tag', 'highway', 'maxheight', "fix:survey"],
# title = T_('Missing maxheight tag'))
#self.classs_change[3] = self.def_class(item = 7130, level = 3, tags = ['tag', 'highway', 'layer', "fix:imagery"],
Expand Down Expand Up @@ -196,15 +205,16 @@ def __init__(self, config, logger = None):
#self.callback30 = lambda res: {"class":3, "data":[self.way_full, self.positionAsText] }
self.callback40 = lambda res: {"class": (4 if res[4] == 'bridge' else 5) + (2 if res[5] else 0), "data": [self.node_full, self.way_full, self.way_full, self.positionAsText] }

def analyser_osmosis_common(self):
self.run(sql10, self.callback10)

def analyser_osmosis_full(self):
self.run(sql10.format(""), self.callback10)
#self.run(sql20.format("", ""))
#self.run(sql21, self.callback20)
#self.run(sql30.format("", ""), self.callback30)
self.run(sql40.format("", ""), self.callback40)

def analyser_osmosis_diff(self):
self.run(sql10.format("touched_"), self.callback10)
#self.run(sql20.format("touched_", ""))
#self.run(sql21, self.callback20)
#self.run(sql30, self.callback30)
Expand Down
24 changes: 24 additions & 0 deletions tests/osmosis_highway_tunnel_bridge.osm
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@
<tag k='note' v='Bad node class 4/5/6/7' />
</node>
<node id='43' timestamp='2014-03-31T22:00:00Z' version='1' lat='51.86639246091' lon='5.88412773086' />
<node id='44' timestamp='2014-03-31T22:00:00Z' version='1' lat='51.86573022422' lon='5.89006715474' />
<node id='45' timestamp='2014-03-31T22:00:00Z' version='1' lat='51.86043589699' lon='5.88997590311' />
<node id='46' timestamp='2014-03-31T22:00:00Z' version='1' lat='51.86573086285' lon='5.88991521447' />
<node id='47' timestamp='2014-03-31T22:00:00Z' version='1' lat='51.86572897914' lon='5.89036337656' />
<node id='48' timestamp='2014-03-31T22:00:00Z' version='1' lat='51.86043451349' lon='5.89030501965' />
<node id='49' timestamp='2014-03-31T22:00:00Z' version='1' lat='51.86043639742' lon='5.88985685756' />
<way id='1000' timestamp='2014-03-31T22:00:00Z' version='1'>
<nd ref='1' />
<nd ref='3' />
Expand Down Expand Up @@ -222,4 +228,22 @@
<nd ref='43' />
<tag k='highway' v='tertiary' />
</way>
<way id='1023' timestamp='2014-03-31T22:00:00Z' version='1'>
<nd ref='44' />
<nd ref='45' />
<tag k='bridge' v='yes' />
<tag k='highway' v='secondary' />
<tag k='note' v='Class 1 no match, bridge structure on man_made object' />
</way>
<way id='1024' timestamp='2014-03-31T22:00:00Z' version='1'>
<nd ref='46' />
<nd ref='44' />
<nd ref='47' />
<nd ref='48' />
<nd ref='45' />
<nd ref='49' />
<nd ref='46' />
<tag k='bridge:structure' v='arch' />
<tag k='man_made' v='bridge' />
</way>
</osm>

0 comments on commit 0f4abed

Please sign in to comment.