From 27a4c65e11ecaf631342312bc464550aebdce489 Mon Sep 17 00:00:00 2001 From: Arndt Date: Sat, 17 Oct 2015 18:23:54 +0200 Subject: [PATCH] fixed duplicate target problems --- .../main/java/btools/mapcreator/OsmNodeP.java | 47 +++++++++++++++++++ .../java/btools/mapcreator/WayLinker.java | 8 ++++ 2 files changed, 55 insertions(+) diff --git a/brouter-map-creator/src/main/java/btools/mapcreator/OsmNodeP.java b/brouter-map-creator/src/main/java/btools/mapcreator/OsmNodeP.java index 41dfeb3..b1582e2 100644 --- a/brouter-map-creator/src/main/java/btools/mapcreator/OsmNodeP.java +++ b/brouter-map-creator/src/main/java/btools/mapcreator/OsmNodeP.java @@ -7,6 +7,7 @@ package btools.mapcreator; import java.io.IOException; import java.util.ArrayList; +import java.util.HashMap; import btools.codec.MicroCache; import btools.codec.MicroCache1; @@ -263,6 +264,52 @@ public class OsmNodeP extends OsmLinkP } } + public void checkDuplicateTargets() + { + HashMap targets = new HashMap(); + + for ( OsmLinkP link0 = getFirstLink(); link0 != null; link0 = link0.getNext( this ) ) + { + OsmLinkP link = link0; + OsmNodeP origin = this; + OsmNodeP target = null; + + // first pass just to see if that link is consistent + while (link != null) + { + target = link.getTarget( origin ); + if ( !target.isTransferNode() ) + { + break; + } + // next link is the one (of two), does does'nt point back + for ( link = target.getFirstLink(); link != null; link = link.getNext( target ) ) + { + if ( link.getTarget( target ) != origin ) + break; + } + origin = target; + } + if ( link == null ) continue; + OsmLinkP oldLink = targets.put( target, link0 ); + if ( oldLink != null ) + { + unifyLink( oldLink ); + unifyLink( link0 ); + } + } + } + + private void unifyLink( OsmLinkP link ) + { + if ( link.isReverse( this ) ) return; + OsmNodeP target = link.getTarget( this ); + if ( target.isTransferNode() ) + { + target.incWayCount(); + } + } + public boolean writeNodeData2( MicroCache2 mc ) throws IOException { boolean hasLinks = false; diff --git a/brouter-map-creator/src/main/java/btools/mapcreator/WayLinker.java b/brouter-map-creator/src/main/java/btools/mapcreator/WayLinker.java index 1cedc61..019aa84 100644 --- a/brouter-map-creator/src/main/java/btools/mapcreator/WayLinker.java +++ b/brouter-map-creator/src/main/java/btools/mapcreator/WayLinker.java @@ -247,6 +247,14 @@ public class WayLinker extends MapCreatorBase int maxLon = minLon + 5000000; int maxLat = minLat + 5000000; + // cleanup duplicate targets + for ( OsmNodeP n : nodesList ) + { + if ( n == null || n.getFirstLink() == null || n.isTransferNode() ) + continue; + n.checkDuplicateTargets(); + } + // write segment data to individual files { int nLonSegs = ( maxLon - minLon ) / 1000000;