Skip to content

Commit

Permalink
Long crossing continued (#1992)
Browse files Browse the repository at this point in the history
* Initial commit of long crossing check

* Follow-up improvements

Primarily:
- Use table highways
- Add fix message; show length
- Also detect too long crossings with: path=crossing; ford=*
- Change item to 2090 ('highway crossing')

---------

Co-authored-by: emerson <[email protected]>
  • Loading branch information
Famlam and emersonveenstra authored Aug 23, 2023
1 parent 0e78782 commit 7ea4276
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
80 changes: 80 additions & 0 deletions analysers/analyser_osmosis_highway_long_crossing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-

###########################################################################
## ##
## 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 ##
## the Free Software Foundation, either version 3 of the License, or ##
## (at your option) any later version. ##
## ##
## This program is distributed in the hope that it will be useful, ##
## but WITHOUT ANY WARRANTY; without even the implied warranty of ##
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ##
## GNU General Public License for more details. ##
## ##
## You should have received a copy of the GNU General Public License ##
## along with this program. If not, see <http://www.gnu.org/licenses/>. ##
## ##
###########################################################################

from modules.OsmoseTranslation import T_
from .Analyser_Osmosis import Analyser_Osmosis

sql10 = """
SELECT
id,
ST_AsText(way_locate(linestring)),
ST_Length(linestring_proj)
FROM
{0}highways
WHERE
(
(tags?'footway' AND tags->'footway' = 'crossing') OR
(tags?'cycleway' AND tags->'cycleway' = 'crossing') OR
(tags?'path' AND tags->'path' = 'crossing')
) AND
ST_Length(linestring_proj) > 200
UNION ALL
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)
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 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": 10, "data": [self.way_full, self.positionAsText],
"text": T_("Highway or waterway crossing of {0}m", round(res[2]))
}

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

def analyser_osmosis_diff(self):
self.run(sql10.format("touched_"), self.callback10)
1 change: 1 addition & 0 deletions osmose_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ def __init__(self, country, polygon_id=None, analyser_options=None, download_url
self.analyser["osmosis_polygon_small"] = "xxx"
self.analyser["osmosis_polygon_intersects"] = "xxx"
self.analyser["osmosis_way_angle"] = "xxx"
self.analyser["osmosis_highway_long_crossing"] = "xxx"

class default_country_simple(default_simple):
def __init__(self, part, country, polygon_id=None, analyser_options=None,
Expand Down

0 comments on commit 7ea4276

Please sign in to comment.