roadgraph_fix_OTF_and_sqrDist_01.diff
src/plugins/roadgraph/graphbuilder.cpp | ||
---|---|---|
18 | 18 | |
19 | 19 |
// Qgis includes |
20 | 20 | |
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 )
|
|
23 | 23 |
{ |
24 | 24 | |
25 | 25 |
} |
... | ... | |
38 | 38 |
{ |
39 | 39 |
return mTopologyToleraceFactor; |
40 | 40 |
} |
41 | ||
42 |
bool RgGraphBuilder::coordinateTransformEnabled() const |
|
43 |
{ |
|
44 |
return mCoordinateTransformEnabled; |
|
45 |
} |
src/plugins/roadgraph/graphbuilder.h | ||
---|---|---|
33 | 33 |
{ |
34 | 34 |
public: |
35 | 35 |
//! Constructor |
36 |
RgGraphBuilder( const QgsCoordinateReferenceSystem& crs, double topologyTolerance = 0.0 ); |
|
36 |
RgGraphBuilder( const QgsCoordinateReferenceSystem& crs, bool coordinateTransform, double topologyTolerance = 0.0 );
|
|
37 | 37 | |
38 | 38 |
//! Destructor |
39 | 39 |
virtual ~RgGraphBuilder(); |
... | ... | |
49 | 49 |
double topologyTolerance(); |
50 | 50 | |
51 | 51 |
/** |
52 |
* coordinate transform Enabled |
|
53 |
*/ |
|
54 |
bool coordinateTransformEnabled() const; |
|
55 | ||
56 |
/** |
|
52 | 57 |
* add vertex |
53 | 58 |
*/ |
54 | 59 |
virtual QgsPoint addVertex( const QgsPoint& pt ) = 0; |
... | ... | |
62 | 67 |
QgsCoordinateReferenceSystem mCrs; |
63 | 68 | |
64 | 69 |
double mTopologyToleraceFactor; |
70 | ||
71 |
bool mCoordinateTransformEnabled; |
|
65 | 72 |
}; |
66 | 73 |
#endif //GRAPHBUILDER |
src/plugins/roadgraph/linevectorlayerdirector.cpp | ||
---|---|---|
72 | 72 |
int featureCount = ( int ) vl->featureCount() * 2; |
73 | 73 |
int step = 0; |
74 | 74 | |
75 |
QgsCoordinateTransform ct( vl->crs(), builder->destinationCrs() ); |
|
76 | ||
75 |
QgsCoordinateTransform ct; |
|
77 | 76 |
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 |
} |
|
80 | 92 | |
81 | 93 |
tiedPoint = QVector< QgsPoint >( additionalPoints.size(), QgsPoint( 0.0, 0.0 ) ); |
82 | 94 |
TiePointInfo tmpInfo; |
... | ... | |
104 | 116 |
for ( i = 0; i != additionalPoints.size(); ++i ) |
105 | 117 |
{ |
106 | 118 |
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 |
}else |
|
124 |
{ |
|
125 |
info.mLength = additionalPoints[ i ].sqrDistToSegment( pt1.x(), pt1.y(), pt2.x(), pt2.y(), info.mTiedPoint ); |
|
126 |
} |
|
109 | 127 |
if ( pointLengthMap[ i ].mLength > info.mLength ) |
110 | 128 |
{ |
111 | 129 |
info.mTiedPoint = builder->addVertex( info.mTiedPoint ); |
src/plugins/roadgraph/roadgraphplugin.cpp | ||
---|---|---|
305 | 305 |
if ( graphDirector == NULL ) |
306 | 306 |
return; |
307 | 307 | |
308 |
RgSimpleGraphBuilder builder( mQGisIface->mapCanvas()->mapRenderer()->destinationCrs() ); |
|
308 |
RgSimpleGraphBuilder builder( mQGisIface->mapCanvas()->mapRenderer()->destinationCrs(), |
|
309 |
mQGisIface->mapCanvas()->mapRenderer()->hasCrsTransformEnabled() ); |
|
309 | 310 |
QVector< QgsPoint > null; |
310 | 311 |
graphDirector->makeGraph( &builder , null, null ); |
311 | 312 |
AdjacencyMatrix m = builder.adjacencyMatrix(); |
src/plugins/roadgraph/shortestpathwidget.cpp | ||
---|---|---|
236 | 236 |
return false; |
237 | 237 |
} |
238 | 238 | |
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 | ||
241 | 244 |
{ |
242 | 245 |
const RgGraphDirector *director = mPlugin->director(); |
243 | 246 |
if ( director == NULL ) |
src/plugins/roadgraph/simplegraphbuilder.cpp | ||
---|---|---|
21 | 21 |
#include <qgsfeature.h> |
22 | 22 |
#include <qgsgeometry.h> |
23 | 23 | |
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 )
|
|
26 | 26 |
{ |
27 | 27 |
} |
28 | 28 |
src/plugins/roadgraph/simplegraphbuilder.h | ||
---|---|---|
38 | 38 |
/** |
39 | 39 |
* default constructor |
40 | 40 |
*/ |
41 |
RgSimpleGraphBuilder( const QgsCoordinateReferenceSystem& crs, double topologyTolerance = 0.0 ); |
|
41 |
RgSimpleGraphBuilder( const QgsCoordinateReferenceSystem& crs, bool ctfEnabled, double topologyTolerance = 0.0 );
|
|
42 | 42 | |
43 | 43 |
/** |
44 | 44 |
* MANDATORY BUILDER PROPERTY DECLARATION |