Skip to content
Permalink
Browse files

apply #3849

  • Loading branch information
Sergey Yakushevs authored and jef-n committed May 27, 2011
1 parent fa14705 commit 92d69e09e78f6c97da12c8bba381eecc28d67986
@@ -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 )
{

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

bool RgGraphBuilder::coordinateTransformEnabled() const
{
return mCoordinateTransformEnabled;
}
@@ -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();
@@ -48,6 +48,11 @@ class RgGraphBuilder
*/
double topologyTolerance();

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

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

double mTopologyToleraceFactor;

bool mCoordinateTransformEnabled;
};
#endif //GRAPHBUILDER
@@ -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;
@@ -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 );
@@ -304,7 +304,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();
@@ -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 )
@@ -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 )
{
}

@@ -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

0 comments on commit 92d69e0

Please sign in to comment.
You can’t perform that action at this time.