Skip to content

Commit

Permalink
fix excess graph build if topology tolerance > 0
Browse files Browse the repository at this point in the history
  • Loading branch information
stopa85milk committed May 27, 2011
1 parent 68490ab commit ca3cf83
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
8 changes: 4 additions & 4 deletions src/analysis/network/qgsgraphbuilder.cpp
Expand Up @@ -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 );

Expand Down Expand Up @@ -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 );
Expand Down
25 changes: 13 additions & 12 deletions src/analysis/network/qgslinevectorlayerdirector.cpp
Expand Up @@ -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 ];
}
}

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit ca3cf83

Please sign in to comment.