Skip to content
Permalink
Browse files
Add offset parameters to eventLayer functions
  • Loading branch information
mhugent committed Mar 23, 2012
1 parent 2d4a596 commit a0db1e396ad949088930fd55f28ac195e633f1f1
Showing with 29 additions and 7 deletions.
  1. +2 −2 python/analysis/qgsgeometryanalyzer.sip
  2. +18 −3 src/analysis/vector/qgsgeometryanalyzer.cpp
  3. +9 −2 src/analysis/vector/qgsgeometryanalyzer.h
@@ -60,8 +60,8 @@ class QgsGeometryAnalyzer
@param p progress dialog or 0 if no progress dialog should be shown
*/
bool eventLayer( QgsVectorLayer* lineLayer, QgsVectorLayer* eventLayer, int lineField, int eventField, QList<int>& unlocatedFeatureIds /Out/,
const QString& outputLayer, const QString& outputFormat, int locationField1, int locationField2 = -1, bool forceSingleGeometry = false,
QgsVectorDataProvider* memoryProvider = 0, QProgressDialog* p = 0 );
const QString& outputLayer, const QString& outputFormat, int locationField1, int locationField2 = -1, int offsetField = -1, double offsetScale = 1.0,
bool forceSingleGeometry = false, QgsVectorDataProvider* memoryProvider = 0, QProgressDialog* p = 0 );

/**Returns multilinestring*/
QgsGeometry* locateBetweenMeasures( double fromMeasure, double toMeasure, QgsGeometry* lineGeom );
@@ -910,7 +910,8 @@ void QgsGeometryAnalyzer::bufferFeature( QgsFeature& f, int nProcessedFeatures,
}

bool QgsGeometryAnalyzer::eventLayer( QgsVectorLayer* lineLayer, QgsVectorLayer* eventLayer, int lineField, int eventField, QList<int>& unlocatedFeatureIds, const QString& outputLayer,
const QString& outputFormat, int locationField1, int locationField2, bool forceSingleGeometry, QgsVectorDataProvider* memoryProvider, QProgressDialog* p )
const QString& outputFormat, int locationField1, int locationField2, int offsetField, double offsetScale,
bool forceSingleGeometry, QgsVectorDataProvider* memoryProvider, QProgressDialog* p )
{
if ( !lineLayer || !eventLayer || !lineLayer->isValid() || !eventLayer->isValid() )
{
@@ -1012,7 +1013,7 @@ bool QgsGeometryAnalyzer::eventLayer( QgsVectorLayer* lineLayer, QgsVectorLayer*
if ( lrsGeom )
{
++nOutputFeatures;
addEventLayerFeature( fet, lrsGeom, fileWriter, memoryProviderFeatures, forceSingleGeometry );
addEventLayerFeature( fet, lrsGeom, lineFeature.geometry(), fileWriter, memoryProviderFeatures, offsetField, offsetScale, forceSingleGeometry );
}
}
if ( nOutputFeatures < 1 )
@@ -1034,7 +1035,8 @@ bool QgsGeometryAnalyzer::eventLayer( QgsVectorLayer* lineLayer, QgsVectorLayer*
return true;
}

void QgsGeometryAnalyzer::addEventLayerFeature( QgsFeature& feature, QgsGeometry* geom, QgsVectorFileWriter* fileWriter, QgsFeatureList& memoryFeatures, bool forceSingleType )
void QgsGeometryAnalyzer::addEventLayerFeature( QgsFeature& feature, QgsGeometry* geom, const QgsGeometry* lineGeom, QgsVectorFileWriter* fileWriter, QgsFeatureList& memoryFeatures,
int offsetField, double offsetScale, bool forceSingleType )
{
if ( !geom )
{
@@ -1054,6 +1056,14 @@ void QgsGeometryAnalyzer::addEventLayerFeature( QgsFeature& feature, QgsGeometry
QList<QgsGeometry*>::iterator geomIt = geomList.begin();
for ( ; geomIt != geomList.end(); ++geomIt )
{
//consider offset
if ( offsetField >= 0 )
{
double offsetVal = feature.attributeMap()[offsetField].toDouble();
offsetVal *= offsetScale;
createOffsetGeometry( *geomIt, lineGeom, offsetVal );
}

feature.setGeometry( *geomIt );
if ( fileWriter )
{
@@ -1071,6 +1081,11 @@ void QgsGeometryAnalyzer::addEventLayerFeature( QgsFeature& feature, QgsGeometry
}
}

void QgsGeometryAnalyzer::createOffsetGeometry( QgsGeometry* geom, const QgsGeometry* lineGeom, double offset )
{
//todo...
}

QgsGeometry* QgsGeometryAnalyzer::locateBetweenMeasures( double fromMeasure, double toMeasure, QgsGeometry* lineGeom )
{
if ( !lineGeom )
@@ -116,7 +116,8 @@ class ANALYSIS_EXPORT QgsGeometryAnalyzer
@param p progress dialog or 0 if no progress dialog should be shown
*/
bool eventLayer( QgsVectorLayer* lineLayer, QgsVectorLayer* eventLayer, int lineField, int eventField, QList<int>& unlocatedFeatureIds, const QString& outputLayer,
const QString& outputFormat, int locationField1, int locationField2 = -1, bool forceSingleGeometry = false, QgsVectorDataProvider* memoryProvider = 0, QProgressDialog* p = 0 );
const QString& outputFormat, int locationField1, int locationField2 = -1, int offsetField = -1, double offsetScale = 1.0,
bool forceSingleGeometry = false, QgsVectorDataProvider* memoryProvider = 0, QProgressDialog* p = 0 );

/**Returns linear reference geometry as a multiline (or 0 if no match). Currently, the z-coordinates are considered to be the measures (no support for m-values in QGIS)*/
QgsGeometry* locateBetweenMeasures( double fromMeasure, double toMeasure, QgsGeometry* lineGeom );
@@ -141,7 +142,13 @@ class ANALYSIS_EXPORT QgsGeometryAnalyzer
void dissolveFeature( QgsFeature& f, int nProcessedFeatures, QgsGeometry** dissolveGeometry );

//helper functions for event layer
void addEventLayerFeature( QgsFeature& feature, QgsGeometry* geom, QgsVectorFileWriter* fileWriter, QgsFeatureList& memoryFeatures, bool forceSingleType = false );
void addEventLayerFeature( QgsFeature& feature, QgsGeometry* geom, const QgsGeometry* lineGeom, QgsVectorFileWriter* fileWriter, QgsFeatureList& memoryFeatures, int offsetField = -1, double offsetScale = 1.0,
bool forceSingleType = false );
/**Create geometry offset relative to line geometry.
@param geom the geometry to modify
@param the line geometry to wich the feature is referenced
@param offset the offset value in layer unit. Negativ value means offset towards left, positive value is offset to the right side*/
void createOffsetGeometry( QgsGeometry* geom, const QgsGeometry* lineGeom, double offset );
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 );

0 comments on commit a0db1e3

Please sign in to comment.