Skip to content

Commit 7702b08

Browse files
committed
Remove debug code, move locateBetween and locateAlong to public interface
1 parent 24b7c4e commit 7702b08

File tree

3 files changed

+8
-67
lines changed

3 files changed

+8
-67
lines changed

python/analysis/qgsgeometryanalyzer.sip

+4-3
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@ class QgsGeometryAnalyzer
5757
bool eventLayer( QgsVectorLayer* lineLayer, QgsVectorLayer* eventLayer, int lineField, int eventField, const QString& outputLayer,
5858
const QString& outputFormat, int locationField1, int locationField2 = -1, QgsVectorDataProvider* memoryProvider = 0, QProgressDialog* p = 0 );
5959

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

6465
private:
6566

src/analysis/vector/qgsgeometryanalyzer.cpp

-57
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,6 @@ bool QgsGeometryAnalyzer::eventLayer( QgsVectorLayer* lineLayer, QgsVectorLayer*
947947
eventLayer->select( eventLayer->pendingAllAttributesList(), QgsRectangle(), true, false );
948948
QgsGeometry* lrsGeom = 0;
949949
QgsFeature lineFeature;
950-
QgsGeometry* lineGeom = 0;
951950
double measure1, measure2;
952951

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

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

10071005
unsigned char* ptr = lineWkb + 1;
10081006
QGis::WkbType wkbType;
@@ -1319,58 +1317,3 @@ void QgsGeometryAnalyzer::locateAlongSegment( double x1, double y1, double m1, d
13191317
pt1.setY( y1 + dist * ( y2 - y1 ) );
13201318
pt1Ok = true;
13211319
}
1322-
1323-
QgsGeometry* QgsGeometryAnalyzer::testLocateBetweenMeasures( double fromMeasure, double toMeasure, QgsGeometry* lineGeom, QList<double>& zValues )
1324-
{
1325-
//assume single line
1326-
QgsPolyline line = lineGeom->asPolyline();
1327-
1328-
QgsMultiPolyline output;
1329-
QgsPolyline currentLine;
1330-
1331-
double x, y, z, prevx, prevy, prevz;
1332-
1333-
QgsPoint pt1, pt2;
1334-
bool measureInSegment; //true if measure is contained in the segment
1335-
bool secondPointClipped; //true if second point is != segment endpoint
1336-
1337-
for ( int i = 0; i < line.size(); ++i )
1338-
{
1339-
x = line.at( i ).x();
1340-
y = line.at( i ).y();
1341-
z = zValues.at( i );
1342-
1343-
if ( i > 0 )
1344-
{
1345-
measureInSegment = clipSegmentByRange( prevx, prevy, prevz, x, y, z, fromMeasure, toMeasure, pt1, pt2, secondPointClipped );
1346-
if ( measureInSegment )
1347-
{
1348-
if ( currentLine.size() < 1 ) //no points collected yet, so the first point needs to be added to the line
1349-
{
1350-
currentLine.append( pt1 );
1351-
}
1352-
1353-
if ( pt1 != pt2 ) //avoid duplicated entry if measure value equals m-value of vertex
1354-
{
1355-
currentLine.append( pt2 );
1356-
}
1357-
1358-
if ( secondPointClipped || i == line.size() - 1 ) //close current segment
1359-
{
1360-
if ( currentLine.size() > 1 )
1361-
{
1362-
output.append( currentLine );
1363-
}
1364-
currentLine.clear();
1365-
}
1366-
}
1367-
}
1368-
prevx = x; prevy = y; prevz = z;
1369-
}
1370-
return QgsGeometry::fromMultiPolyline( output );
1371-
}
1372-
1373-
QgsGeometry* QgsGeometryAnalyzer::testLocateAlongMeasures( double measure, QgsGeometry* lineGeom, QList<double>& zValues )
1374-
{
1375-
return 0;
1376-
}

src/analysis/vector/qgsgeometryanalyzer.h

+4-7
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,10 @@ class ANALYSIS_EXPORT QgsGeometryAnalyzer
111111
bool eventLayer( QgsVectorLayer* lineLayer, QgsVectorLayer* eventLayer, int lineField, int eventField, const QString& outputLayer,
112112
const QString& outputFormat, int locationField1, int locationField2 = -1, QgsVectorDataProvider* memoryProvider = 0, QProgressDialog* p = 0 );
113113

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

118119
private:
119120

@@ -133,10 +134,6 @@ class ANALYSIS_EXPORT QgsGeometryAnalyzer
133134

134135
//helper functions for event layer
135136

136-
/**Returns multilinestring*/
137-
QgsGeometry* locateBetweenMeasures( double fromMeasure, double toMeasure, QgsGeometry* lineGeom );
138-
/**Returns multipoint*/
139-
QgsGeometry* locateAlongMeasure( double measure, QgsGeometry* lineGeom );
140137
unsigned char* locateBetweenWkbString( unsigned char* ptr, QgsMultiPolyline& result, double fromMeasure, double toMeasure );
141138
unsigned char* locateAlongWkbString( unsigned char* ptr, QgsMultiPoint& result, double measure );
142139
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 );

0 commit comments

Comments
 (0)