From 50762894a8ab3a15a7172d46500f680b20173b23 Mon Sep 17 00:00:00 2001 From: Famlam Date: Wed, 1 Jan 2025 20:57:38 +0100 Subject: [PATCH] Prevent reports on the intersecting node in P-ways Also add test cases --- ...nalyser_osmosis_highway_almost_junction.py | 28 +++- tests/osmosis_highway_almost_junction.osm | 123 ++++++++++++++++++ 2 files changed, 150 insertions(+), 1 deletion(-) create mode 100644 tests/osmosis_highway_almost_junction.osm diff --git a/analysers/analyser_osmosis_highway_almost_junction.py b/analysers/analyser_osmosis_highway_almost_junction.py index 64335aae4..9ff26f547 100644 --- a/analysers/analyser_osmosis_highway_almost_junction.py +++ b/analysers/analyser_osmosis_highway_almost_junction.py @@ -65,7 +65,8 @@ (nodes.tags?'railway' AND nodes.tags->'railway' IN ('subway_entrance')) OR (nodes.tags?'public_transport' AND nodes.tags->'public_transport' IN ('platform')) OR nodes.tags?'amenity' OR - nodes.tags?'barrier' + nodes.tags?'barrier' OR + array_length(array_positions(t.nodes, nodes.id), 1) != 1 -- exclude the self-intersecting node in P-shaped ways ) """ @@ -104,3 +105,28 @@ def __init__(self, config, logger = None): def analyser_osmosis_common(self): self.run(sql12.format(self.config.options.get("proj"))) self.run(sql13, lambda res: {"class":1, "data":[self.way_full, self.node, self.positionAsText]}) + + +########################################################################### + +from .Analyser_Osmosis import TestAnalyserOsmosis + +class Test(TestAnalyserOsmosis): + @classmethod + def setup_class(cls): + from modules import config + TestAnalyserOsmosis.setup_class() + cls.analyser_conf = cls.load_osm("tests/osmosis_highway_almost_junction.osm", + config.dir_tmp + "/tests/osmosis_highway_almost_junction.test.xml", + {"proj": 23032}) # Random proj to satisfy highway table generation + + def test_classes(self): + with Analyser_Osmosis_Highway_Almost_Junction(self.analyser_conf, self.logger) as a: + a.analyser() + + self.root_err = self.load_errors() + self.check_err(cl="1", elems=[("node", "17"), ("way", "1008")]) + self.check_err(cl="1", elems=[("node", "18"), ("way", "1007")]) + self.check_err(cl="1", elems=[("node", "23"), ("way", "1010")]) + + self.check_num_err(3) diff --git a/tests/osmosis_highway_almost_junction.osm b/tests/osmosis_highway_almost_junction.osm new file mode 100644 index 000000000..f3c7b37af --- /dev/null +++ b/tests/osmosis_highway_almost_junction.osm @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +