Skip to content
Permalink
Browse files

fix excess graph build if topology tolerance > 0

  • Loading branch information
Sergey Yakushevs
Sergey Yakushevs committed May 27, 2011
1 parent 68490ab commit ca3cf83168870c5521d4ff8264b9998f07898e7b
Showing with 17 additions and 16 deletions.
  1. +4 −4 src/analysis/network/qgsgraphbuilder.cpp
  2. +13 −12 src/analysis/network/qgslinevectorlayerdirector.cpp
@@ -42,8 +42,8 @@ QgsPoint QgsGraphBuilder::addVertex( const QgsPoint& pt )
QgsPoint newPoint = pt;
if ( topologyTolerance() > 0 )
{
newPoint = QgsPoint( ceil( pt.x() / topologyTolerance() ) * topologyTolerance(),
ceil( pt.y() / topologyTolerance() ) * topologyTolerance() );
newPoint = QgsPoint( ceil( pt.x() / topologyTolerance() ),
ceil( pt.y() / topologyTolerance() ) );
}
int newId = mGraph->addVertex( pt );

@@ -81,8 +81,8 @@ int QgsGraphBuilder::pointId( const QgsPoint& pt )
QgsPoint findPoint = pt;
if ( topologyTolerance() > 0.0 )
{
findPoint = QgsPoint( ceil( pt.x() / topologyTolerance() ) * topologyTolerance() ,
ceil( pt.y() / topologyTolerance() ) * topologyTolerance() ) ;
findPoint = QgsPoint( ceil( pt.x() / topologyTolerance() ),
ceil( pt.y() / topologyTolerance() ) ) ;
}

std::map< QgsPoint, int, QgsPointCompare >::iterator it = mPointMap.find( findPoint );
@@ -141,6 +141,7 @@ void QgsLineVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, c
if ( tiedPoint[ i ] != QgsPoint( 0.0, 0.0 ) )
{
tiedPoint[ i ] = builder->addVertex( tiedPoint[ i ] );
pointLengthMap[ i ].mTiedPoint = tiedPoint[ i ];
}
}

@@ -216,22 +217,22 @@ void QgsLineVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, c
for ( pointIt = pl.begin(); pointIt != pl.end(); ++pointIt )
{
pt2 = builder->addVertex( ct.transform( *pointIt ) );

std::map< double, QgsPoint > pointsOnArc;
pointsOnArc[ 0.0 ] = pt1;
pointsOnArc[ pt1.sqrDist( pt2 )] = pt2;

for ( pointLengthIt = pointLengthMap.begin(); pointLengthIt != pointLengthMap.end(); ++pointLengthIt )
if ( !isFirstPoint )
{
if ( pointLengthIt->mFirstPoint == pt1 && pointLengthIt->mLastPoint == pt2 )

std::map< double, QgsPoint > pointsOnArc;
pointsOnArc[ 0.0 ] = pt1;
pointsOnArc[ pt1.sqrDist( pt2 )] = pt2;

for ( pointLengthIt = pointLengthMap.begin(); pointLengthIt != pointLengthMap.end(); ++pointLengthIt )
{
QgsPoint tiedPoint = pointLengthIt->mTiedPoint;
pointsOnArc[ pt1.sqrDist( tiedPoint )] = tiedPoint;
if ( pointLengthIt->mFirstPoint == pt1 && pointLengthIt->mLastPoint == pt2 )
{
QgsPoint tiedPoint = pointLengthIt->mTiedPoint;
pointsOnArc[ pt1.sqrDist( tiedPoint )] = tiedPoint;
}
}
}

if ( !isFirstPoint )
{
std::map< double, QgsPoint >::iterator pointsIt;
QgsPoint pt1;
QgsPoint pt2;

0 comments on commit ca3cf83

Please sign in to comment.
You can’t perform that action at this time.