Skip to content
Permalink
Browse files

pre topology tolerance changeset

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15232 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
stopa85
stopa85 committed Feb 21, 2011
1 parent 8f24123 commit f6a6da975de81d30c0125a06cd818461ad189b9f
@@ -18,8 +18,8 @@

// Qgis includes

RgGraphBuilder::RgGraphBuilder( const QgsCoordinateReferenceSystem& crs ) :
mCrs( crs )
RgGraphBuilder::RgGraphBuilder( const QgsCoordinateReferenceSystem& crs, double topologyTolerance ) :
mCrs( crs ), mTopologyToleraceFactor( topologyTolerance )
{

}
@@ -33,3 +33,8 @@ QgsCoordinateReferenceSystem& RgGraphBuilder::destinationCrs()
{
return mCrs;
}

double RgGraphBuilder::topologyTolerance()
{
return mTopologyToleraceFactor;
}
@@ -33,7 +33,7 @@ class RgGraphBuilder
{
public:
//! Constructor
RgGraphBuilder( const QgsCoordinateReferenceSystem& crs );
RgGraphBuilder( const QgsCoordinateReferenceSystem& crs, double topologyTolerance = 0.0 );

//! Destructor
virtual ~RgGraphBuilder();
@@ -43,10 +43,15 @@ class RgGraphBuilder
*/
QgsCoordinateReferenceSystem& destinationCrs();

/**
* get topology tolerance factor
*/
double topologyTolerance();

/**
* add vertex
*/
virtual void addVertex( const QgsPoint& pt ) = 0;
virtual QgsPoint addVertex( const QgsPoint& pt ) = 0;

/**
* add arc
@@ -55,5 +60,7 @@ class RgGraphBuilder

private:
QgsCoordinateReferenceSystem mCrs;

double mTopologyToleraceFactor;
};
#endif //GRAPHBUILDER
@@ -94,7 +94,7 @@ void RgLineVectorLayerDirector::makeGraph( RgGraphBuilder *builder, const QVecto
QgsPolyline::iterator pointIt;
for ( pointIt = pl.begin(); pointIt != pl.end(); ++pointIt )
{
pt2 = ct.transform( *pointIt );
pt2 = builder->addVertex( ct.transform( *pointIt ) );
if ( !isFirstPoint )
{
int i = 0;
@@ -105,6 +105,7 @@ void RgLineVectorLayerDirector::makeGraph( RgGraphBuilder *builder, const QVecto

if ( pointLengthMap[ i ].mLength > info.mLength )
{
info.mTiedPoint = builder->addVertex( info.mTiedPoint );
info.mFirstPoint = pt1;
info.mLastPoint = pt2;

@@ -181,7 +182,7 @@ void RgLineVectorLayerDirector::makeGraph( RgGraphBuilder *builder, const QVecto
QgsPolyline::iterator pointIt;
for ( pointIt = pl.begin(); pointIt != pl.end(); ++pointIt )
{
pt2 = ct.transform( *pointIt );
pt2 = builder->addVertex( ct.transform( *pointIt ) );

std::map< double, QgsPoint > pointsOnArc;
pointsOnArc[ 0.0 ] = pt1;
@@ -19,14 +19,30 @@

// Qgis includes

RgSimpleGraphBuilder::RgSimpleGraphBuilder( const QgsCoordinateReferenceSystem& crs ) :
RgGraphBuilder( crs )
RgSimpleGraphBuilder::RgSimpleGraphBuilder( const QgsCoordinateReferenceSystem& crs, double topologyTolerance ) :
RgGraphBuilder( crs, topologyTolerance )
{
}

void RgSimpleGraphBuilder::addVertex( const QgsPoint& pt )
QgsPoint RgSimpleGraphBuilder::addVertex( const QgsPoint& pt )
{
// I cann't use QgsSpatialIndex in this time.
// QgsSpatialIndex::nearestNeighbor() return only features id not geometry
//
// This code is very slow and need me for a tests.

double t = topologyTolerance();
if ( t > 0.0 )
{
AdjacencyMatrix::iterator it;
for ( it = mMatrix.begin(); it != mMatrix.end(); ++it )
{
if ( it->first.sqrDist( pt ) < t )
return it->first;
}
}
mMatrix[ pt ];
return pt;
}

void RgSimpleGraphBuilder::addArc( const QgsPoint& pt1, const QgsPoint& pt2, double cost, double speed )
@@ -37,12 +37,12 @@ class RgSimpleGraphBuilder : public RgGraphBuilder
/**
* default constructor
*/
RgSimpleGraphBuilder( const QgsCoordinateReferenceSystem& crs );
RgSimpleGraphBuilder( const QgsCoordinateReferenceSystem& crs, double topologyTolerance = 0.0 );

/**
* MANDATORY BUILDER PROPERTY DECLARATION
*/
void addVertex( const QgsPoint& pt );
QgsPoint addVertex( const QgsPoint& pt );
void addArc( const QgsPoint& pt1, const QgsPoint& pt2, double cost, double speed );

/**

0 comments on commit f6a6da9

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