fixed duplicate target problems

This commit is contained in:
Arndt 2015-10-17 18:23:54 +02:00
parent 11871ee4d7
commit 27a4c65e11
2 changed files with 55 additions and 0 deletions

View file

@ -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<OsmNodeP,OsmLinkP> targets = new HashMap<OsmNodeP,OsmLinkP>();
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;

View file

@ -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;