Skip to content

Commit

Permalink
apply #3849
Browse files Browse the repository at this point in the history
  • Loading branch information
stopa85milk authored and jef-n committed May 27, 2011
1 parent 77f2e06 commit d61e6d5
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 15 deletions.
9 changes: 7 additions & 2 deletions src/plugins/roadgraph/graphbuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

// Qgis includes

RgGraphBuilder::RgGraphBuilder( const QgsCoordinateReferenceSystem& crs, double topologyTolerance ) :
mCrs( crs ), mTopologyToleraceFactor( topologyTolerance )
RgGraphBuilder::RgGraphBuilder( const QgsCoordinateReferenceSystem& crs, bool ctfEnabled, double topologyTolerance ) :
mCrs( crs ), mTopologyToleraceFactor( topologyTolerance ), mCoordinateTransformEnabled( ctfEnabled )
{

}
Expand All @@ -38,3 +38,8 @@ double RgGraphBuilder::topologyTolerance()
{
return mTopologyToleraceFactor;
}

bool RgGraphBuilder::coordinateTransformEnabled() const
{
return mCoordinateTransformEnabled;
}
9 changes: 8 additions & 1 deletion src/plugins/roadgraph/graphbuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class RgGraphBuilder
{
public:
//! Constructor
RgGraphBuilder( const QgsCoordinateReferenceSystem& crs, double topologyTolerance = 0.0 );
RgGraphBuilder( const QgsCoordinateReferenceSystem& crs, bool coordinateTransform, double topologyTolerance = 0.0 );

//! Destructor
virtual ~RgGraphBuilder();
Expand All @@ -48,6 +48,11 @@ class RgGraphBuilder
*/
double topologyTolerance();

/**
* coordinate transform Enabled
*/
bool coordinateTransformEnabled() const;

/**
* add vertex
*/
Expand All @@ -62,5 +67,7 @@ class RgGraphBuilder
QgsCoordinateReferenceSystem mCrs;

double mTopologyToleraceFactor;

bool mCoordinateTransformEnabled;
};
#endif //GRAPHBUILDER
31 changes: 25 additions & 6 deletions src/plugins/roadgraph/linevectorlayerdirector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,23 @@ void RgLineVectorLayerDirector::makeGraph( RgGraphBuilder *builder, const QVecto
int featureCount = ( int ) vl->featureCount() * 2;
int step = 0;

QgsCoordinateTransform ct( vl->crs(), builder->destinationCrs() );

QgsCoordinateTransform ct;
QgsDistanceArea da;
da.setSourceCrs( builder->destinationCrs().srsid() );
da.setProjectionsEnabled( true );
ct.setSourceCrs( vl->crs() );

if ( builder->coordinateTransformEnabled() )
{
ct.setDestCRS( builder->destinationCrs() );
da.setProjectionsEnabled( true );
//
//da.setSourceCrs( builder->destinationCrs().srsid() );
//
}
else
{
ct.setDestCRS( vl->crs() );
da.setProjectionsEnabled( false );
}

tiedPoint = QVector< QgsPoint >( additionalPoints.size(), QgsPoint( 0.0, 0.0 ) );
TiePointInfo tmpInfo;
Expand Down Expand Up @@ -104,8 +116,15 @@ void RgLineVectorLayerDirector::makeGraph( RgGraphBuilder *builder, const QVecto
for ( i = 0; i != additionalPoints.size(); ++i )
{
TiePointInfo info;
info.mLength = additionalPoints[ i ].sqrDistToSegment( pt1.x(), pt1.y(), pt2.x(), pt2.y(), info.mTiedPoint );

if ( pt1 == pt2 )
{
info.mLength = additionalPoints[ i ].sqrDist( pt1 );
info.mTiedPoint = pt1;
}
else
{
info.mLength = additionalPoints[ i ].sqrDistToSegment( pt1.x(), pt1.y(), pt2.x(), pt2.y(), info.mTiedPoint );
}
if ( pointLengthMap[ i ].mLength > info.mLength )
{
info.mTiedPoint = builder->addVertex( info.mTiedPoint );
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/roadgraph/roadgraphplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,8 @@ void RoadGraphPlugin::render( QPainter *painter )
if ( graphDirector == NULL )
return;

RgSimpleGraphBuilder builder( mQGisIface->mapCanvas()->mapRenderer()->destinationCrs() );
RgSimpleGraphBuilder builder( mQGisIface->mapCanvas()->mapRenderer()->destinationCrs(),
mQGisIface->mapCanvas()->mapRenderer()->hasCrsTransformEnabled() );
QVector< QgsPoint > null;
graphDirector->makeGraph( &builder , null, null );
AdjacencyMatrix m = builder.adjacencyMatrix();
Expand Down
7 changes: 5 additions & 2 deletions src/plugins/roadgraph/shortestpathwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,11 @@ bool RgShortestPathWidget::getPath( AdjacencyMatrix& matrix, QgsPoint& p1, QgsPo
return false;
}

RgSimpleGraphBuilder builder( mPlugin->iface()->mapCanvas()->mapRenderer()->destinationCrs(),
mPlugin->topologyToleranceFactor() );
RgSimpleGraphBuilder builder(
mPlugin->iface()->mapCanvas()->mapRenderer()->destinationCrs(),
mPlugin->iface()->mapCanvas()->mapRenderer()->hasCrsTransformEnabled(),
mPlugin->topologyToleranceFactor() );

{
const RgGraphDirector *director = mPlugin->director();
if ( director == NULL )
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/roadgraph/simplegraphbuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
#include <qgsfeature.h>
#include <qgsgeometry.h>

RgSimpleGraphBuilder::RgSimpleGraphBuilder( const QgsCoordinateReferenceSystem& crs, double topologyTolerance ) :
RgGraphBuilder( crs, topologyTolerance )
RgSimpleGraphBuilder::RgSimpleGraphBuilder( const QgsCoordinateReferenceSystem& crs, bool ctfEnabled, double topologyTolerance ) :
RgGraphBuilder( crs, ctfEnabled, topologyTolerance )
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/roadgraph/simplegraphbuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class RgSimpleGraphBuilder : public RgGraphBuilder
/**
* default constructor
*/
RgSimpleGraphBuilder( const QgsCoordinateReferenceSystem& crs, double topologyTolerance = 0.0 );
RgSimpleGraphBuilder( const QgsCoordinateReferenceSystem& crs, bool ctfEnabled, double topologyTolerance = 0.0 );

/**
* MANDATORY BUILDER PROPERTY DECLARATION
Expand Down

0 comments on commit d61e6d5

Please sign in to comment.