Skip to content

Commit fb43d16

Browse files
committedMay 10, 2011
Road graph plugin not work or work incorrectly.
Show message "First point not tied" if: 1. 'on the fly' CRS transfomation disabled 2. Source layer CRS not equal project CRS
1 parent ee20b30 commit fb43d16

File tree

7 files changed

+39
-13
lines changed

7 files changed

+39
-13
lines changed
 

‎src/plugins/roadgraph/graphbuilder.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
// Qgis includes
2020

21-
RgGraphBuilder::RgGraphBuilder( const QgsCoordinateReferenceSystem& crs, double topologyTolerance ) :
22-
mCrs( crs ), mTopologyToleraceFactor( topologyTolerance )
21+
RgGraphBuilder::RgGraphBuilder( const QgsCoordinateReferenceSystem& crs, bool ctfEnabled, double topologyTolerance ) :
22+
mCrs( crs ), mTopologyToleraceFactor( topologyTolerance ), mCoordinateTransformEnabled( ctfEnabled )
2323
{
2424

2525
}
@@ -38,3 +38,8 @@ double RgGraphBuilder::topologyTolerance()
3838
{
3939
return mTopologyToleraceFactor;
4040
}
41+
42+
bool RgGraphBuilder::coordinateTransformEnabled() const
43+
{
44+
return mCoordinateTransformEnabled;
45+
}

‎src/plugins/roadgraph/graphbuilder.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class RgGraphBuilder
3333
{
3434
public:
3535
//! Constructor
36-
RgGraphBuilder( const QgsCoordinateReferenceSystem& crs, double topologyTolerance = 0.0 );
36+
RgGraphBuilder( const QgsCoordinateReferenceSystem& crs, bool coordinateTransform, double topologyTolerance = 0.0 );
3737

3838
//! Destructor
3939
virtual ~RgGraphBuilder();
@@ -48,6 +48,11 @@ class RgGraphBuilder
4848
*/
4949
double topologyTolerance();
5050

51+
/**
52+
* coordinate transform Enabled
53+
*/
54+
bool coordinateTransformEnabled() const;
55+
5156
/**
5257
* add vertex
5358
*/
@@ -62,5 +67,7 @@ class RgGraphBuilder
6267
QgsCoordinateReferenceSystem mCrs;
6368

6469
double mTopologyToleraceFactor;
70+
71+
bool mCoordinateTransformEnabled;
6572
};
6673
#endif //GRAPHBUILDER

‎src/plugins/roadgraph/linevectorlayerdirector.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,21 @@ void RgLineVectorLayerDirector::makeGraph( RgGraphBuilder *builder, const QVecto
7272
int featureCount = ( int ) vl->featureCount() * 2;
7373
int step = 0;
7474

75-
QgsCoordinateTransform ct( vl->crs(), builder->destinationCrs() );
76-
75+
QgsCoordinateTransform ct;
7776
QgsDistanceArea da;
78-
da.setSourceCrs( builder->destinationCrs().srsid() );
79-
da.setProjectionsEnabled( true );
77+
ct.setSourceCrs( vl->crs() );
78+
79+
if ( builder->coordinateTransformEnabled() )
80+
{
81+
ct.setDestCRS( builder->destinationCrs() );
82+
da.setProjectionsEnabled( true );
83+
da.setSourceCrs( builder->destinationCrs().srsid() );
84+
}
85+
else
86+
{
87+
ct.setDestCRS( vl->crs() );
88+
da.setProjectionsEnabled( false );
89+
}
8090

8191
tiedPoint = QVector< QgsPoint >( additionalPoints.size(), QgsPoint( 0.0, 0.0 ) );
8292
TiePointInfo tmpInfo;

‎src/plugins/roadgraph/roadgraphplugin.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,8 @@ void RoadGraphPlugin::render( QPainter *painter )
305305
if ( graphDirector == NULL )
306306
return;
307307

308-
RgSimpleGraphBuilder builder( mQGisIface->mapCanvas()->mapRenderer()->destinationCrs() );
308+
RgSimpleGraphBuilder builder( mQGisIface->mapCanvas()->mapRenderer()->destinationCrs(),
309+
mQGisIface->mapCanvas()->mapRenderer()->hasCrsTransformEnabled() );
309310
QVector< QgsPoint > null;
310311
graphDirector->makeGraph( &builder , null, null );
311312
AdjacencyMatrix m = builder.adjacencyMatrix();

‎src/plugins/roadgraph/shortestpathwidget.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,11 @@ bool RgShortestPathWidget::getPath( AdjacencyMatrix& matrix, QgsPoint& p1, QgsPo
236236
return false;
237237
}
238238

239-
RgSimpleGraphBuilder builder( mPlugin->iface()->mapCanvas()->mapRenderer()->destinationCrs(),
240-
mPlugin->topologyToleranceFactor() );
239+
RgSimpleGraphBuilder builder(
240+
mPlugin->iface()->mapCanvas()->mapRenderer()->destinationCrs(),
241+
mPlugin->iface()->mapCanvas()->mapRenderer()->hasCrsTransformEnabled(),
242+
mPlugin->topologyToleranceFactor() );
243+
241244
{
242245
const RgGraphDirector *director = mPlugin->director();
243246
if ( director == NULL )

‎src/plugins/roadgraph/simplegraphbuilder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
#include <qgsfeature.h>
2222
#include <qgsgeometry.h>
2323

24-
RgSimpleGraphBuilder::RgSimpleGraphBuilder( const QgsCoordinateReferenceSystem& crs, double topologyTolerance ) :
25-
RgGraphBuilder( crs, topologyTolerance )
24+
RgSimpleGraphBuilder::RgSimpleGraphBuilder( const QgsCoordinateReferenceSystem& crs, bool ctfEnabled, double topologyTolerance ) :
25+
RgGraphBuilder( crs, ctfEnabled, topologyTolerance )
2626
{
2727
}
2828

‎src/plugins/roadgraph/simplegraphbuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class RgSimpleGraphBuilder : public RgGraphBuilder
3838
/**
3939
* default constructor
4040
*/
41-
RgSimpleGraphBuilder( const QgsCoordinateReferenceSystem& crs, double topologyTolerance = 0.0 );
41+
RgSimpleGraphBuilder( const QgsCoordinateReferenceSystem& crs, bool ctfEnabled, double topologyTolerance = 0.0 );
4242

4343
/**
4444
* MANDATORY BUILDER PROPERTY DECLARATION

0 commit comments

Comments
 (0)
Please sign in to comment.