Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove debug code, move locateBetween and locateAlong to public inter…
…face
  • Loading branch information
mhugent committed Feb 1, 2012
1 parent 24b7c4e commit 7702b08
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 67 deletions.
7 changes: 4 additions & 3 deletions python/analysis/qgsgeometryanalyzer.sip
Expand Up @@ -57,9 +57,10 @@ class QgsGeometryAnalyzer
bool eventLayer( QgsVectorLayer* lineLayer, QgsVectorLayer* eventLayer, int lineField, int eventField, const QString& outputLayer,
const QString& outputFormat, int locationField1, int locationField2 = -1, QgsVectorDataProvider* memoryProvider = 0, QProgressDialog* p = 0 );

//locate without the need to give wkb. Only for debugging
QgsGeometry* testLocateBetweenMeasures( double fromMeasure, double toMeasure, QgsGeometry* lineGeom, QList<double>& zValues );
QgsGeometry* testLocateAlongMeasures( double measure, QgsGeometry* lineGeom, QList<double>& zValues );
/**Returns multilinestring*/
QgsGeometry* locateBetweenMeasures( double fromMeasure, double toMeasure, QgsGeometry* lineGeom );
/**Returns multipoint*/
QgsGeometry* locateAlongMeasure( double measure, QgsGeometry* lineGeom );

private:

Expand Down
57 changes: 0 additions & 57 deletions src/analysis/vector/qgsgeometryanalyzer.cpp
Expand Up @@ -947,7 +947,6 @@ bool QgsGeometryAnalyzer::eventLayer( QgsVectorLayer* lineLayer, QgsVectorLayer*
eventLayer->select( eventLayer->pendingAllAttributesList(), QgsRectangle(), true, false );
QgsGeometry* lrsGeom = 0;
QgsFeature lineFeature;
QgsGeometry* lineGeom = 0;
double measure1, measure2;

while ( eventLayer->nextFeature( fet ) )
Expand Down Expand Up @@ -1002,7 +1001,6 @@ QgsGeometry* QgsGeometryAnalyzer::locateBetweenMeasures( double fromMeasure, dou

//need to go with WKB and z coordinate until QgsGeometry supports M values
unsigned char* lineWkb = lineGeom->asWkb();
int wkbSize = lineGeom->wkbSize();

unsigned char* ptr = lineWkb + 1;
QGis::WkbType wkbType;
Expand Down Expand Up @@ -1319,58 +1317,3 @@ void QgsGeometryAnalyzer::locateAlongSegment( double x1, double y1, double m1, d
pt1.setY( y1 + dist * ( y2 - y1 ) );
pt1Ok = true;
}

QgsGeometry* QgsGeometryAnalyzer::testLocateBetweenMeasures( double fromMeasure, double toMeasure, QgsGeometry* lineGeom, QList<double>& zValues )
{
//assume single line
QgsPolyline line = lineGeom->asPolyline();

QgsMultiPolyline output;
QgsPolyline currentLine;

double x, y, z, prevx, prevy, prevz;

QgsPoint pt1, pt2;
bool measureInSegment; //true if measure is contained in the segment
bool secondPointClipped; //true if second point is != segment endpoint

for ( int i = 0; i < line.size(); ++i )
{
x = line.at( i ).x();
y = line.at( i ).y();
z = zValues.at( i );

if ( i > 0 )
{
measureInSegment = clipSegmentByRange( prevx, prevy, prevz, x, y, z, fromMeasure, toMeasure, pt1, pt2, secondPointClipped );
if ( measureInSegment )
{
if ( currentLine.size() < 1 ) //no points collected yet, so the first point needs to be added to the line
{
currentLine.append( pt1 );
}

if ( pt1 != pt2 ) //avoid duplicated entry if measure value equals m-value of vertex
{
currentLine.append( pt2 );
}

if ( secondPointClipped || i == line.size() - 1 ) //close current segment
{
if ( currentLine.size() > 1 )
{
output.append( currentLine );
}
currentLine.clear();
}
}
}
prevx = x; prevy = y; prevz = z;
}
return QgsGeometry::fromMultiPolyline( output );
}

QgsGeometry* QgsGeometryAnalyzer::testLocateAlongMeasures( double measure, QgsGeometry* lineGeom, QList<double>& zValues )
{
return 0;
}
11 changes: 4 additions & 7 deletions src/analysis/vector/qgsgeometryanalyzer.h
Expand Up @@ -111,9 +111,10 @@ class ANALYSIS_EXPORT QgsGeometryAnalyzer
bool eventLayer( QgsVectorLayer* lineLayer, QgsVectorLayer* eventLayer, int lineField, int eventField, const QString& outputLayer,
const QString& outputFormat, int locationField1, int locationField2 = -1, QgsVectorDataProvider* memoryProvider = 0, QProgressDialog* p = 0 );

//locate without the need to give wkb. Only for debugging
QgsGeometry* testLocateBetweenMeasures( double fromMeasure, double toMeasure, QgsGeometry* lineGeom, QList<double>& zValues );
QgsGeometry* testLocateAlongMeasures( double measure, QgsGeometry* lineGeom, QList<double>& zValues );
/**Returns multilinestring*/
QgsGeometry* locateBetweenMeasures( double fromMeasure, double toMeasure, QgsGeometry* lineGeom );
/**Returns multipoint*/
QgsGeometry* locateAlongMeasure( double measure, QgsGeometry* lineGeom );

private:

Expand All @@ -133,10 +134,6 @@ class ANALYSIS_EXPORT QgsGeometryAnalyzer

//helper functions for event layer

/**Returns multilinestring*/
QgsGeometry* locateBetweenMeasures( double fromMeasure, double toMeasure, QgsGeometry* lineGeom );
/**Returns multipoint*/
QgsGeometry* locateAlongMeasure( double measure, QgsGeometry* lineGeom );
unsigned char* locateBetweenWkbString( unsigned char* ptr, QgsMultiPolyline& result, double fromMeasure, double toMeasure );
unsigned char* locateAlongWkbString( unsigned char* ptr, QgsMultiPoint& result, double measure );
static bool clipSegmentByRange( double x1, double y1, double m1, double x2, double y2, double m2, double range1, double range2, QgsPoint& pt1, QgsPoint& pt2, bool& secondPointClipped );
Expand Down

0 comments on commit 7702b08

Please sign in to comment.