Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
  • Loading branch information
stopa85milk committed May 10, 2011
1 parent ee20b30 commit fb43d16
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 13 deletions.
9 changes: 7 additions & 2 deletions src/plugins/roadgraph/graphbuilder.cpp
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
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
18 changes: 14 additions & 4 deletions src/plugins/roadgraph/linevectorlayerdirector.cpp
Expand Up @@ -72,11 +72,21 @@ 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
3 changes: 2 additions & 1 deletion src/plugins/roadgraph/roadgraphplugin.cpp
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
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
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
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 fb43d16

Please sign in to comment.