Skip to content

Commit 92d69e0

Browse files
stopa85milkjef-n
authored andcommittedMay 27, 2011
apply #3849
1 parent fa14705 commit 92d69e0

File tree

7 files changed

+50
-15
lines changed

7 files changed

+50
-15
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: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,23 @@ 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+
//
84+
//da.setSourceCrs( builder->destinationCrs().srsid() );
85+
//
86+
}
87+
else
88+
{
89+
ct.setDestCRS( vl->crs() );
90+
da.setProjectionsEnabled( false );
91+
}
8092

8193
tiedPoint = QVector< QgsPoint >( additionalPoints.size(), QgsPoint( 0.0, 0.0 ) );
8294
TiePointInfo tmpInfo;
@@ -104,8 +116,15 @@ void RgLineVectorLayerDirector::makeGraph( RgGraphBuilder *builder, const QVecto
104116
for ( i = 0; i != additionalPoints.size(); ++i )
105117
{
106118
TiePointInfo info;
107-
info.mLength = additionalPoints[ i ].sqrDistToSegment( pt1.x(), pt1.y(), pt2.x(), pt2.y(), info.mTiedPoint );
108-
119+
if ( pt1 == pt2 )
120+
{
121+
info.mLength = additionalPoints[ i ].sqrDist( pt1 );
122+
info.mTiedPoint = pt1;
123+
}
124+
else
125+
{
126+
info.mLength = additionalPoints[ i ].sqrDistToSegment( pt1.x(), pt1.y(), pt2.x(), pt2.y(), info.mTiedPoint );
127+
}
109128
if ( pointLengthMap[ i ].mLength > info.mLength )
110129
{
111130
info.mTiedPoint = builder->addVertex( info.mTiedPoint );

‎src/plugins/roadgraph/roadgraphplugin.cpp

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

307-
RgSimpleGraphBuilder builder( mQGisIface->mapCanvas()->mapRenderer()->destinationCrs() );
307+
RgSimpleGraphBuilder builder( mQGisIface->mapCanvas()->mapRenderer()->destinationCrs(),
308+
mQGisIface->mapCanvas()->mapRenderer()->hasCrsTransformEnabled() );
308309
QVector< QgsPoint > null;
309310
graphDirector->makeGraph( &builder , null, null );
310311
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.