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

Fix way-section identifier bug for closed loops #187

Merged
merged 2 commits into from
Aug 6, 2018

Conversation

MikeGost
Copy link
Contributor

@MikeGost MikeGost commented Aug 3, 2018

Description:

The original issue was reported by @jklamer - lots of benign MultiAtlasBorderFixer logs failing to fix conflicts (see below for sample output) when stitching together raw atlas shards. I dug into this and found a corner case in identifier assignment for way-sectioned edges that had a loop as part of the underlying PolyLine. Specifically, we would assign 000 as one of the identifiers for the Edge, even though the underlying way was being way-sectioned. This would trigger the MultiAtlasBorderFixer to attempt an edge fix, specifically triggering the hasInconsistentIdentifier() method to return inconsistencies and begin the fix process.

Sample Error in Logs:
2018-07-25 13:47:13 WARN [Executor task launch worker-0] MultiAtlasBorderFixer:288 - OSM way 201288149 fix for [[TemporaryRoad: subAtlas = CUB_7-35-55.atlas, osm = 201288149000, members = [Edge: id=201288149000000, startNode=2112447504000000, endNode=2112447504000000, polyLine=LINESTRING (-81.4222758 22.9527279, -81.4223432 22.952432, -81.4223722 22.9522485, -81.4223175 22.9521124, -81.4222147 22.951926, -81.4222147 22.9517869, -81.422385 22.9517248, -81.4225521 22.9517366, -81.4226999 22.9518402, -81.4229859 22.9519378, -81.4231434 22.9518964, -81.4231466 22.9517603, -81.4231016 22.951568, -81.4230116 22.9513608, -81.4230181 22.9512306, -81.423108 22.9511892, -81.4232526 22.9512158, -81.4233715 22.9513076, -81.4234615 22.951562, -81.4234936 22.951852, -81.4235451 22.9521686, -81.4235129 22.9523196, -81.4232334 22.9524616, -81.4230598 22.9525089, -81.4229217 22.9525888, -81.4229666 22.9528019, -81.4230759 22.9529972, -81.4231241 22.9531777, -81.4230116 22.9532664, -81.4228895 22.9532428, -81.4227578 22.953154, -81.422581 22.9530149, -81.4224075 22.9528463, -81.4222758 22.9527279), [Tags: [last_edit_user_name => Bilbo-denmark], [last_edit_changeset => 14662455], [last_edit_time => 1358265285000], [last_edit_user_id => 295005], [iso_country_code => CUB], [highway => service], [last_edit_version => 1]]] [Edge: id=201288149000001, startNode=2112447568000000, endNode=2112447504000000, polyLine=LINESTRING (-81.4215302 22.9537931, -81.4215302 22.9535564, -81.4216973 22.9534292, -81.421903 22.9534706, -81.4221183 22.9535623, -81.4222468 22.953586, -81.4223047 22.9534943, -81.4222276 22.9532339, -81.422144 22.9530475, -81.4222758 22.9527279), [Tags: [last_edit_user_name => Bilbo-denmark], [last_edit_changeset => 14662455], [last_edit_time => 1358265285000], [last_edit_user_id => 295005], [iso_country_code => CUB], [highway => service], [last_edit_version => 1]]] ]] is failed. org.openstreetmap.atlas.exception.CoreException: Found end first! POINT (-81.4215302 22.9537931)(occurrence 0) and POINT (-81.4222758 22.9527279)(occurrence 0) are not in order with respect to LINESTRING (-81.4222758 22.9527279, -81.4223432 22.952432, -81.4223722 22.9522485, -81.4223175 22.9521124, -81.4222147 22.951926, -81.4222147 22.9517869, -81.422385 22.9517248, -81.4225521 22.9517366, -81.4226999 22.9518402, -81.4229859 22.9519378, -81.4231434 22.9518964, -81.4231466 22.9517603, -81.4231016 22.951568, -81.4230116 22.9513608, -81.4230181 22.9512306, -81.423108 22.9511892, -81.4232526 22.9512158, -81.4233715 22.9513076, -81.4234615 22.951562, -81.4234936 22.951852, -81.4235451 22.9521686, -81.4235129 22.9523196, -81.4232334 22.9524616, -81.4230598 22.9525089, -81.4229217 22.9525888, -81.4229666 22.9528019, -81.4230759 22.9529972, -81.4231241 22.9531777, -81.4230116 22.9532664, -81.4228895 22.9532428, -81.4227578 22.953154, -81.422581 22.9530149, -81.4224075 22.9528463, -81.4222758 22.9527279, -81.4215302 22.9535564, -81.4216973 22.9534292, -81.421903 22.9534706, -81.4221183 22.9535623, -81.4222468 22.953586, -81.4223047 22.9534943, -81.4222276 22.9532339, -81.422144 22.9530475, -81.4222758 22.9527279) at org.openstreetmap.atlas.geography.PolyLine.between(PolyLine.java:302) at org.openstreetmap.atlas.geography.atlas.multi.MultiAtlasBorderFixer.fixBorderIssues(MultiAtlasBorderFixer.java:212) at org.openstreetmap.atlas.geography.atlas.multi.MultiAtlas.<init>(MultiAtlas.java:418) at org.openstreetmap.atlas.geography.atlas.multi.MultiAtlas.<init>(MultiAtlas.java:267) at org.openstreetmap.atlas.geography.atlas.multi.MultiAtlas.loadFromPackedAtlas(MultiAtlas.java:165) at org.openstreetmap.atlas.geography.atlas.multi.MultiAtlas.loadFromPackedAtlas(MultiAtlas.java:138) at org.openstreetmap.atlas.geography.atlas.AtlasResourceLoader.load(AtlasResourceLoader.java:90) at ...

Potential Impact:

This was a benign error, as no actual fixes took place or were necessary (because of the consistent identifiers). However, the resulting output clogged up the logs and potentially increased runtime, as an attempt to fix the underlying PolyLines was made for multiple Edges within an Atlas.

Unit Test Approach:

I've updated the existing unit tests that handle loop scenarios to explicitly check identifier correctness. Without the fix, these would fail.

Test Results:

I verified the fix in several ways:

  1. Programmatically:

I set a conditional break-point in the MultiAtlasBorderFixer to trigger when attempting to see if a fix was required for the first Edge in the output logs. Before the fix, the two edges for this OSM Identifier were:

{201288149000000=[[Edge: id=201288149000000, startNode=2112447504000000, endNode=2112447504000000, polyLine=LINESTRING (-81.4222758 22.9527279, -81.4223432 22.952432, -81.4223722 22.9522485, -81.4223175 22.9521124, -81.4222147 22.951926, -81.4222147 22.9517869, -81.422385 22.9517248, -81.4225521 22.9517366, -81.4226999 22.9518402, -81.4229859 22.9519378, -81.4231434 22.9518964, -81.4231466 22.9517603, -81.4231016 22.951568, -81.4230116 22.9513608, -81.4230181 22.9512306, -81.423108 22.9511892, -81.4232526 22.9512158, -81.4233715 22.9513076, -81.4234615 22.951562, -81.4234936 22.951852, -81.4235451 22.9521686, -81.4235129 22.9523196, -81.4232334 22.9524616, -81.4230598 22.9525089, -81.4229217 22.9525888, -81.4229666 22.9528019, -81.4230759 22.9529972, -81.4231241 22.9531777, -81.4230116 22.9532664, -81.4228895 22.9532428, -81.4227578 22.953154, -81.422581 22.9530149, -81.4224075 22.9528463, -81.4222758 22.9527279), [Tags: [last_edit_user_name => Bilbo-denmark], [last_edit_changeset => 14662455], [last_edit_time => 1358265285000], [last_edit_user_id => 295005], [iso_country_code => CUB], [highway => service], [last_edit_version => 1]]]], 

201288149000001=[[Edge: id=201288149000001, startNode=2112447568000000, endNode=2112447504000000, polyLine=LINESTRING (-81.4215302 22.9537931, -81.4215302 22.9535564, -81.4216973 22.9534292, -81.421903 22.9534706, -81.4221183 22.9535623, -81.4222468 22.953586, -81.4223047 22.9534943, -81.4222276 22.9532339, -81.422144 22.9530475, -81.4222758 22.9527279), [Tags: [last_edit_user_name => Bilbo-denmark], [last_edit_changeset => 14662455], [last_edit_time => 1358265285000], [last_edit_user_id => 295005], [iso_country_code => CUB], [highway => service], [last_edit_version => 1]]]]}

This caused an attempted fix, since an identifier ending with 000 implies no way-sectioning took place, but the presence of multiple edges for a single OSM Identifier implies way-sectioning did take place, prompting an attempted fix. Here is the output after the fix - which correctly resulted in no necessary fix:

{201288149000001=[[Edge: id=201288149000001, startNode=2112447568000000, endNode=2112447504000000, polyLine=LINESTRING (-81.4215302 22.9537931, -81.4215302 22.9535564, -81.4216973 22.9534292, -81.421903 22.9534706, -81.4221183 22.9535623, -81.4222468 22.953586, -81.4223047 22.9534943, -81.4222276 22.9532339, -81.422144 22.9530475, -81.4222758 22.9527279), [Tags: [last_edit_user_name => Bilbo-denmark], [last_edit_changeset => 14662455], [last_edit_time => 1358265285000], [last_edit_user_id => 295005], [iso_country_code => CUB], [highway => service], [last_edit_version => 1]]]], 

201288149000002=[[Edge: id=201288149000002, startNode=2112447504000000, endNode=2112447504000000, polyLine=LINESTRING (-81.4222758 22.9527279, -81.4223432 22.952432, -81.4223722 22.9522485, -81.4223175 22.9521124, -81.4222147 22.951926, -81.4222147 22.9517869, -81.422385 22.9517248, -81.4225521 22.9517366, -81.4226999 22.9518402, -81.4229859 22.9519378, -81.4231434 22.9518964, -81.4231466 22.9517603, -81.4231016 22.951568, -81.4230116 22.9513608, -81.4230181 22.9512306, -81.423108 22.9511892, -81.4232526 22.9512158, -81.4233715 22.9513076, -81.4234615 22.951562, -81.4234936 22.951852, -81.4235451 22.9521686, -81.4235129 22.9523196, -81.4232334 22.9524616, -81.4230598 22.9525089, -81.4229217 22.9525888, -81.4229666 22.9528019, -81.4230759 22.9529972, -81.4231241 22.9531777, -81.4230116 22.9532664, -81.4228895 22.9532428, -81.4227578 22.953154, -81.422581 22.9530149, -81.4224075 22.9528463, -81.4222758 22.9527279), [Tags: [last_edit_user_name => Bilbo-denmark], [last_edit_changeset => 14662455], [last_edit_time => 1358265285000], [last_edit_user_id => 295005], [iso_country_code => CUB], [highway => service], [last_edit_version => 1]]]]}

  1. Visually:

Below are the two edges created in the pre-fix atlas and the same two-edge in the post-fix atlas. You'll notice that the geometry and tags are identical, but the identifier is now correct. Because of way-sectioning, the identifiers changes from 000 and 001 to 001 and 002.

Original Atlas - first Edge:
prefixstart

Original Atlas - second Edge:
prefixend

New Atlas - first Edge:
postfixstart

New Atlas - second Edge:
postfixend

  1. Building new atlases and forming a MultiAtlas - I constructed two Cuba shards with the fix and combined them into a MultiAtlas, the MultiAtlasBorderFixer output was no longer present, but the data was identical across the MultiAtlases. I leveraged AtlasDelta to compare old and new multi-atlas and the only difference was the removal of the 000 edges.

In doubt: Contributing Guidelines

Copy link
Collaborator

@matthieun matthieun left a comment

Choose a reason for hiding this comment

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

Simple change, great fix! Thanks @MikeGost

@matthieun matthieun merged commit 3fa8864 into osmlab:dev Aug 6, 2018
@matthieun matthieun added this to the 5.1.6 milestone Aug 6, 2018
@MikeGost MikeGost deleted the identifier branch August 31, 2018 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants