Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial commit of long crossing check #1764

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions analysers/analyser_osmosis_highway_long_crossing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/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))
FROM
{0}ways
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is limited to highways, right? Then table {0}highways is probably more efficient?

Note you'll have to import highways and touched_highways, see for example:

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

WHERE
tags != ''::hstore AND
(
(tags?'footway' AND tags->'footway' = 'crossing') OR
(tags?'cycleway' AND tags->'cycleway' = 'crossing')
) AND
ST_Length(linestring::geography) > 200
"""

class Analyser_Osmosis_Highway_Long_Crossing(Analyser_Osmosis):

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'),
detail = T_(
'''The crossing way is much longer than expected'''))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also add a fix message, describing to split the way when the crossing is over?
Also, don't forget to add a '.' at the end of the detail message :)


self.callback10 = lambda res: {"class":1, "data":[self.way_full, self.positionAsText] }

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 @@ -194,6 +194,7 @@ def __init__(self, country, polygon_id=None, analyser_options=None, download_url
self.analyser["osmosis_camp_pitch_out_of_camp_site"] = "xxx"
self.analyser["osmosis_relation_open"] = "xxx"
self.analyser["osmosis_polygon_small"] = "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