Skip to content
Permalink
Browse files

QgsFeature cleanup, part 1

Deprecate some QgsFeature methods which take or return pointers,
update other classes as required
  • Loading branch information
nyalldawson committed Jul 31, 2016
1 parent 429fe2d commit aceddae65a8066c0c50d30c3356884594e663ba4
Showing with 869 additions and 840 deletions.
  1. +31 −0 doc/api_break.dox
  2. +0 −45 python/core/qgsfeature.sip
  3. +2 −2 python/core/qgsvectorlayer.sip
  4. +2 −2 python/core/qgsvectorlayereditbuffer.sip
  5. +1 −1 python/core/qgsvectorlayereditpassthrough.sip
  6. +1 −1 python/core/qgsvectorlayerundocommand.sip
  7. +2 −2 python/gui/qgsrubberband.sip
  8. +2 −1 src/analysis/interpolation/DualEdgeTriangulation.cc
  9. +27 −17 src/analysis/vector/qgsgeometryanalyzer.cpp
  10. +3 −3 src/analysis/vector/qgsgeometryanalyzer.h
  11. +2 −1 src/analysis/vector/qgsoverlayanalyzer.cpp
  12. +2 −1 src/analysis/vector/qgspointsample.cpp
  13. +19 −29 src/analysis/vector/qgstransectsample.cpp
  14. +3 −4 src/analysis/vector/qgstransectsample.h
  15. +9 −7 src/app/gps/qgsgpsinformationwidget.cpp
  16. +3 −3 src/app/nodetool/qgsmaptoolnodetool.cpp
  17. +2 −2 src/app/nodetool/qgsmaptoolnodetool.h
  18. +8 −8 src/app/nodetool/qgsselectedfeature.cpp
  19. +2 −2 src/app/nodetool/qgsselectedfeature.h
  20. +28 −33 src/app/qgisapp.cpp
  21. +2 −2 src/app/qgisapp.h
  22. +1 −1 src/app/qgsattributetabledialog.cpp
  23. +5 −2 src/app/qgsclipboard.cpp
  24. +1 −1 src/app/qgsfieldcalculator.cpp
  25. +11 −4 src/app/qgsmaptooladdfeature.cpp
  26. +3 −3 src/app/qgsmaptooldeletepart.cpp
  27. +5 −6 src/app/qgsmaptooldeletering.cpp
  28. +3 −1 src/app/qgsmaptoolfillring.cpp
  29. +2 −2 src/app/qgsmaptoollabel.cpp
  30. +2 −2 src/app/qgsmaptoolmovefeature.cpp
  31. +34 −43 src/app/qgsmaptooloffsetcurve.cpp
  32. +4 −4 src/app/qgsmaptooloffsetcurve.h
  33. +5 −5 src/app/qgsmaptoolreshape.cpp
  34. +2 −2 src/app/qgsmaptoolrotatefeature.cpp
  35. +2 −2 src/app/qgsmaptoolsimplify.cpp
  36. +1 −1 src/app/qgsmergeattributesdialog.cpp
  37. +12 −46 src/core/qgsfeature.cpp
  38. +2 −40 src/core/qgsfeature.h
  39. +2 −10 src/core/qgsfeature_p.h
  40. +9 −7 src/core/qgsgml.cpp
  41. +3 −1 src/core/qgsofflineediting.cpp
  42. +5 −5 src/core/qgsogrutils.cpp
  43. +3 −2 src/core/qgsogrutils.h
  44. +8 −4 src/core/qgspointlocator.cpp
  45. +1 −1 src/core/qgspointlocator.h
  46. +6 −4 src/core/qgstracer.cpp
  47. +1 −1 src/core/qgstracer.h
  48. +19 −15 src/core/qgsvectorfilewriter.cpp
  49. +1 −1 src/core/qgsvectorfilewriter.h
  50. +3 −3 src/core/qgsvectorlayer.cpp
  51. +2 −2 src/core/qgsvectorlayer.h
  52. +3 −3 src/core/qgsvectorlayercache.cpp
  53. +1 −1 src/core/qgsvectorlayercache.h
  54. +1 −1 src/core/qgsvectorlayereditbuffer.cpp
  55. +2 −2 src/core/qgsvectorlayereditbuffer.h
  56. +3 −3 src/core/qgsvectorlayereditpassthrough.cpp
  57. +1 −1 src/core/qgsvectorlayereditpassthrough.h
  58. +22 −18 src/core/qgsvectorlayereditutils.cpp
  59. +1 −1 src/core/qgsvectorlayerfeatureiterator.cpp
  60. +3 −1 src/core/qgsvectorlayerimport.cpp
  61. +17 −21 src/core/qgsvectorlayerundocommand.cpp
  62. +3 −3 src/core/qgsvectorlayerundocommand.h
  63. +8 −3 src/core/symbology-ng/qgsinvertedpolygonrenderer.cpp
  64. +3 −1 src/gui/qgshighlight.cpp
  65. +2 −2 src/gui/qgsmaptoolcapture.cpp
  66. +13 −13 src/gui/qgsrubberband.cpp
  67. +2 −2 src/gui/qgsrubberband.h
  68. +5 −2 src/plugins/geometry_checker/checks/qgsgeometryanglecheck.cpp
  69. +11 −6 src/plugins/geometry_checker/checks/qgsgeometryareacheck.cpp
  70. +13 −6 src/plugins/geometry_checker/checks/qgsgeometrycheck.cpp
  71. +8 −6 src/plugins/geometry_checker/checks/qgsgeometrycontainedcheck.cpp
  72. +4 −2 src/plugins/geometry_checker/checks/qgsgeometrydegeneratepolygoncheck.cpp
  73. +8 −6 src/plugins/geometry_checker/checks/qgsgeometryduplicatecheck.cpp
  74. +5 −2 src/plugins/geometry_checker/checks/qgsgeometryduplicatenodescheck.cpp
  75. +7 −4 src/plugins/geometry_checker/checks/qgsgeometrygapcheck.cpp
  76. +4 −2 src/plugins/geometry_checker/checks/qgsgeometryholecheck.cpp
  77. +5 −3 src/plugins/geometry_checker/checks/qgsgeometrymultipartcheck.cpp
  78. +13 −10 src/plugins/geometry_checker/checks/qgsgeometryoverlapcheck.cpp
  79. +5 −2 src/plugins/geometry_checker/checks/qgsgeometrysegmentlengthcheck.cpp
  80. +12 −7 src/plugins/geometry_checker/checks/qgsgeometryselfintersectioncheck.cpp
  81. +7 −5 src/plugins/geometry_checker/checks/qgsgeometrytypecheck.cpp
  82. +1 −1 src/plugins/geometry_checker/qgsgeometrychecker.cpp
  83. +2 −2 src/plugins/geometry_checker/ui/qgsgeometrycheckerresulttab.cpp
  84. +1 −1 src/plugins/geometry_checker/utils/qgsfeaturepool.cpp
  85. +8 −7 src/plugins/geometry_snapper/qgsgeometrysnapper.cpp
  86. +2 −2 src/plugins/globe/featuresource/qgsglobefeaturesource.cpp
  87. +1 −1 src/plugins/globe/featuresource/qgsglobefeaturesource.h
  88. +3 −1 src/plugins/roadgraph/shortestpathwidget.cpp
  89. +1 −1 src/plugins/spatialquery/qgsrubberselectid.cpp
  90. +9 −10 src/plugins/spatialquery/qgsspatialquery.cpp
  91. +3 −4 src/plugins/spatialquery/qgsspatialquery.h
  92. +4 −4 src/plugins/topology/checkDock.cpp
  93. +7 −4 src/plugins/topology/topolError.cpp
  94. +66 −66 src/plugins/topology/topolTest.cpp
  95. +3 −3 src/providers/arcgisrest/qgsafsprovider.cpp
  96. +1 −1 src/providers/arcgisrest/qgsamsprovider.cpp
  97. +4 −4 src/providers/db2/qgsdb2featureiterator.cpp
  98. +2 −1 src/providers/delimitedtext/qgsdelimitedtextfeatureiterator.cpp
  99. +4 −5 src/providers/delimitedtext/qgsdelimitedtextprovider.cpp
  100. +7 −3 src/providers/gpx/qgsgpxfeatureiterator.cpp
  101. +3 −1 src/providers/grass/qgis.v.in.cpp
  102. +2 −2 src/providers/grass/qgsgrassfeatureiterator.cpp
  103. +4 −2 src/providers/grass/qgsgrassimport.cpp
  104. +4 −4 src/providers/grass/qgsgrassprovider.cpp
  105. +1 −1 src/providers/grass/qgsgrassprovider.h
  106. +4 −4 src/providers/mssql/qgsmssqlfeatureiterator.cpp
  107. +2 −2 src/providers/ogr/qgsogrfeatureiterator.cpp
  108. +7 −7 src/providers/oracle/qgsoraclefeatureiterator.cpp
  109. +1 −1 src/providers/oracle/qgsoracleprovider.cpp
  110. +3 −3 src/providers/postgres/qgspostgresfeatureiterator.cpp
  111. +5 −5 src/providers/spatialite/qgsspatialitefeatureiterator.cpp
  112. +1 −1 src/providers/virtual/qgsvirtuallayerfeatureiterator.cpp
  113. +1 −1 src/providers/virtual/qgsvirtuallayerprovider.cpp
  114. +12 −10 src/providers/wfs/qgswfsfeatureiterator.cpp
  115. +7 −4 src/providers/wfs/qgswfsshareddata.cpp
  116. +8 −4 src/providers/wms/qgswmsprovider.cpp
  117. +13 −4 src/server/qgswfsserver.cpp
  118. +2 −1 src/server/qgswmsconfigparser.cpp
  119. +10 −10 src/server/qgswmsserver.cpp
  120. +3 −3 tests/src/app/testqgisappclipboard.cpp
  121. +6 −2 tests/src/app/testqgsattributetable.cpp
  122. +6 −2 tests/src/app/testqgsfieldcalculator.cpp
  123. +12 −6 tests/src/app/testqgsmaptoolidentifyaction.cpp
  124. +2 −2 tests/src/core/testqgsconnectionpool.cpp
  125. +34 −12 tests/src/core/testqgsexpression.cpp
  126. +8 −60 tests/src/core/testqgsfeature.cpp
  127. +18 −6 tests/src/core/testqgslegendrenderer.cpp
  128. +2 −1 tests/src/core/testqgsmaprendererjob.cpp
  129. +5 −5 tests/src/core/testqgsogrutils.cpp
  130. +7 −3 tests/src/core/testqgspointlocator.cpp
  131. +9 −3 tests/src/core/testqgssnappingutils.cpp
  132. +9 −3 tests/src/core/testqgsspatialindex.cpp
  133. +4 −2 tests/src/core/testqgstracer.cpp
  134. +12 −6 tests/src/core/testqgsvectorfilewriter.cpp
  135. +6 −6 tests/src/gui/testqgsrubberband.cpp
  136. +6 −4 tests/src/providers/grass/testqgsgrassprovider.cpp
@@ -212,6 +212,15 @@ attributeIndexes(), pkAttributeIndexes(), isSaveAndLoadStyleToDBSupported()</li>
</li>
</ul>

\subsection qgis_api_break_3_0_QgsFeature QgsFeature

<ul>
<li>geometryAndOwnership() has been removed. Use geometry() instead.</li>
<li>setGeometryAndOwnership() has been removed. Use setGeometry() instead.</li>
<li>The setGeometry( QgsGeometry* ) method has been removed, use setGeometry( const QgsGeometry& ) instead.</li>
<li>setFields( const QgsFields*, bool ) has been removed, use setFields( const QgsFields&, bool ) instead.</li>
</ul>

\subsection qgis_api_break_3_0_QgsGroupWMSDataDialog QgsGroupWMSDataDialog

<ul>
@@ -384,6 +393,12 @@ be returned instead of a null pointer if no transformation is required.</li>
<li>setCoordinateTransform() now takes a QgsCoordinateTransform reference, not a pointer. An invalid QgsCoordinateTransform should be used instead of a null pointer if no transformation is required.</li>
</ul>

\subsection qgis_api_break_3_0_QgsRubberBand QgsRubberBand

<ul>
<li>setToGeometry() and addGeometry() now take geometry references, not pointers.</li>
</ul>

\subsection qgis_api_break_3_0_QgsPalLayerSettings QgsPalLayerSettings

<ul>
@@ -418,6 +433,15 @@ plugins calling this method will need to be updated.</li>
setExcludeAttributesWms()</li>
<li>excludeAttributesWFS() and setExcludeAttributesWFS() have been renamed to excludeAttributesWfs() and
setExcludeAttributesWfs()</li>
<li>changeGeometry() now accepts a geometry reference, not a pointer.</li>
<li>The geometryChanged() signal now uses a const QgsGeometry reference.</li>
</ul>

\subsection qgis_api_break_3_0_QgsVectorLayerEditBuffer QgsVectorLayerEditBuffer

<ul>
<li>changeGeometry() now accepts a geometry reference, not a pointer.</li>
<li>The geometryChanged() signal now uses a const QgsGeometry reference.</li>
</ul>

\subsection qgis_api_break_3_0_QgsVectorLayerImport QgsVectorLayerImport
@@ -429,6 +453,13 @@ pointers makes for more robust, safer code. Use an invalid (default constructed)
in code which previously passed a null pointer to QgsVectorLayerImport.</li>
</ul>

\subsection qgis_api_break_3_0_QgsVectorLayerUndoCommand QgsVectorLayerUndoCommand

<ul>
<li>QgsVectorLayerUndoCommandChangeGeometry constructor now accepts a geometry reference, not a pointer.</li>
</ul>


\subsection qgis_api_break_3_0_QgsPointLocator QgsPointLocator

<ul>
@@ -333,7 +333,6 @@ class QgsFeature
*
* @returns pointer to feature's geometry
* @see constGeometry
* @see geometryAndOwnership
* @see setGeometry
*/
QgsGeometry* geometry();
@@ -351,58 +350,14 @@ class QgsFeature
*/
const QgsGeometry* constGeometry() const;

/** Get the geometry object associated with this feature, and transfer ownership of the
* geometry to the caller. The caller assumes responsibility for the QgsGeometry*'s destruction.
* @returns pointer to feature's geometry
* @see geometry
* @see setGeometry
* @deprecated use constGeometry() instead
*/
QgsGeometry *geometryAndOwnership() /Factory,Deprecated/;

/** Set this feature's geometry from another QgsGeometry object. This method performs a deep copy
* of the geometry.
* @param geom new feature geometry
* @see geometry
* @see constGeometry
* @see geometryAndOwnership
* @see setGeometryAndOwnership
*/
void setGeometry( const QgsGeometry& geom );

/** Set this feature's geometry from a QgsGeometry pointer. Ownership of the geometry is transferred
* to the feature.
* @param geom new feature geometry
* @note not available in python bindings
* @see geometry
* @see constGeometry
* @see geometryAndOwnership
* @see setGeometryAndOwnership
*/
// void setGeometry( QgsGeometry* geom /Transfer/ );

/** Set this feature's geometry from WKB. This feature assumes responsibility for destroying the
* created geometry.
* @param geom geometry as WKB
* @param length size of WKB
* @see setGeometry
* @see geometry
* @see constGeometry
* @see geometryAndOwnership
* @deprecated will be removed in QGIS 3.0
*/
void setGeometryAndOwnership( unsigned char * geom /Transfer/, int length ) /Deprecated/;

/** Assign a field map with the feature to allow attribute access by attribute name.
* @param fields The attribute fields which this feature holds
* @param initAttributes If true, attributes are initialized. Clears any data previously assigned.
* C++: Defaults to false
* Python: Defaults to true
* @deprecated use setFields( const QgsFields& fields, bool initAttributes = false ) instead
* @note not available in Python bindings
*/
//void setFields( const QgsFields* fields, bool initAttributes = true );

/** Assign a field map with the feature to allow attribute access by attribute name.
* @param fields The attribute fields which this feature holds
* @param initAttributes If true, attributes are initialized. Clears any data previously assigned.
@@ -911,7 +911,7 @@ class QgsVectorLayer : QgsMapLayer
bool setReadOnly( bool readonly = true );

/** Change feature's geometry */
bool changeGeometry( QgsFeatureId fid, QgsGeometry* geom );
bool changeGeometry( QgsFeatureId fid, const QgsGeometry& geom );

/**
* Changes an attribute value (but does not commit it)
@@ -1615,7 +1615,7 @@ class QgsVectorLayer : QgsMapLayer
* @param fid The id of the changed feature
* @param geometry The new geometry
*/
void geometryChanged( QgsFeatureId fid, QgsGeometry& geometry );
void geometryChanged( QgsFeatureId fid, const QgsGeometry& geometry );

/** This signal is emitted, when attributes are deleted from the provider */
void committedAttributesDeleted( const QString& layerId, const QgsAttributeList& deletedAttributes );
@@ -31,7 +31,7 @@ class QgsVectorLayerEditBuffer : QObject
virtual bool deleteFeatures( const QgsFeatureIds& fid );

/** Change feature's geometry */
virtual bool changeGeometry( QgsFeatureId fid, QgsGeometry* geom );
virtual bool changeGeometry( QgsFeatureId fid, QgsGeometry geom );

/** Changed an attribute value (but does not commit it) */
virtual bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant() );
@@ -145,7 +145,7 @@ class QgsVectorLayerEditBuffer : QObject

void featureAdded( QgsFeatureId fid );
void featureDeleted( QgsFeatureId fid );
void geometryChanged( QgsFeatureId fid, QgsGeometry &geom );
void geometryChanged( QgsFeatureId fid, const QgsGeometry &geom );
void attributeValueChanged( QgsFeatureId fid, int idx, const QVariant & );
void attributeAdded( int idx );
void attributeDeleted( int idx );
@@ -10,7 +10,7 @@ class QgsVectorLayerEditPassthrough : QgsVectorLayerEditBuffer
bool addFeatures( QgsFeatureList& features );
bool deleteFeature( QgsFeatureId fid );
bool deleteFeatures( const QgsFeatureIds& fids );
bool changeGeometry( QgsFeatureId fid, QgsGeometry* geom );
bool changeGeometry( QgsFeatureId fid, QgsGeometry geom );
bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant() );
bool addAttribute( const QgsField &field );
bool deleteAttribute( int attr );
@@ -87,7 +87,7 @@ class QgsVectorLayerUndoCommandChangeGeometry : QgsVectorLayerUndoCommand
* @param fid feature ID of feature to modify geometry of
* @param newGeom new geometry for feature
*/
QgsVectorLayerUndoCommandChangeGeometry( QgsVectorLayerEditBuffer* buffer /Transfer/, QgsFeatureId fid, QgsGeometry* newGeom /Transfer/ );
QgsVectorLayerUndoCommandChangeGeometry( QgsVectorLayerEditBuffer* buffer /Transfer/, QgsFeatureId fid, QgsGeometry newGeom );
~QgsVectorLayerUndoCommandChangeGeometry();

virtual void undo();
@@ -170,7 +170,7 @@ class QgsRubberBand: QgsMapCanvasItem
* @param layer the layer containing the feature, used for coord transformation to map
* crs. In case of 0 pointer, the coordinates are not going to be transformed.
*/
void setToGeometry( const QgsGeometry *geom, QgsVectorLayer* layer );
void setToGeometry( const QgsGeometry& geom, QgsVectorLayer* layer );

/**
* Sets this rubber band to a map canvas rectangle
@@ -189,7 +189,7 @@ class QgsRubberBand: QgsMapCanvasItem
* @param layer the layer containing the feature, used for coord transformation to map
* crs. In case of 0 pointer, the coordinates are not going to be transformed.
*/
void addGeometry( const QgsGeometry *geom, QgsVectorLayer* layer );
void addGeometry( const QgsGeometry& geom, QgsVectorLayer* layer );

/**
* Adds translation to original coordinates (all in map coordinates)
@@ -3139,7 +3139,8 @@ bool DualEdgeTriangulation::saveAsShapefile( const QString& fileName ) const
lineGeom.push_back( QgsPoint( p1->getX(), p1->getY() ) );
lineGeom.push_back( QgsPoint( p2->getX(), p2->getY() ) );
QgsGeometry* geom = QgsGeometry::fromPolyline( lineGeom );
edgeLineFeature.setGeometry( geom );
edgeLineFeature.setGeometry( *geom );
delete geom;
edgeLineFeature.initAttributes( 1 );

//attributes
@@ -138,7 +138,8 @@ void QgsGeometryAnalyzer::simplifyFeature( QgsFeature& f, QgsVectorFileWriter* v
tmpGeometry = featureGeometry->simplify( tolerance );

QgsFeature newFeature;
newFeature.setGeometry( tmpGeometry );
newFeature.setGeometry( *tmpGeometry );
delete tmpGeometry;
newFeature.setAttributes( f.attributes() );

//add it to vector file writer
@@ -254,7 +255,8 @@ void QgsGeometryAnalyzer::centroidFeature( QgsFeature& f, QgsVectorFileWriter* v
tmpGeometry = featureGeometry->centroid();

QgsFeature newFeature;
newFeature.setGeometry( tmpGeometry );
newFeature.setGeometry( *tmpGeometry );
delete tmpGeometry;
newFeature.setAttributes( f.attributes() );

//add it to vector file writer
@@ -331,7 +333,9 @@ bool QgsGeometryAnalyzer::extent( QgsVectorLayer* layer,
attrs[8] = QVariant( height );
attrs[9] = QVariant( width );
feat.setAttributes( attrs );
feat.setGeometry( QgsGeometry::fromRect( rect ) );
QgsGeometry* g = QgsGeometry::fromRect( rect );
feat.setGeometry( *g );
delete g;
vWriter.addFeature( feat );
return true;
}
@@ -493,7 +497,8 @@ bool QgsGeometryAnalyzer::convexHull( QgsVectorLayer* layer, const QString& shap
attributes[2] = values.at( 1 );
QgsFeature dissolveFeature;
dissolveFeature.setAttributes( attributes );
dissolveFeature.setGeometry( dissolveGeometry );
dissolveFeature.setGeometry( *dissolveGeometry );
delete dissolveGeometry;
vWriter.addFeature( dissolveFeature );
}
//take all features
@@ -540,7 +545,8 @@ bool QgsGeometryAnalyzer::convexHull( QgsVectorLayer* layer, const QString& shap
attributes[2] = QVariant( values[ 1 ] );
QgsFeature dissolveFeature;
dissolveFeature.setAttributes( attributes );
dissolveFeature.setGeometry( dissolveGeometry );
dissolveFeature.setGeometry( *dissolveGeometry );
delete dissolveGeometry;
vWriter.addFeature( dissolveFeature );
}
}
@@ -702,7 +708,8 @@ bool QgsGeometryAnalyzer::dissolve( QgsVectorLayer* layer, const QString& shapef
++jt;
}
}
outputFeature.setGeometry( dissolveGeometry );
outputFeature.setGeometry( *dissolveGeometry );
delete dissolveGeometry;
vWriter.addFeature( outputFeature );
}
return true;
@@ -831,7 +838,8 @@ bool QgsGeometryAnalyzer::buffer( QgsVectorLayer* layer, const QString& shapefil
QgsDebugMsg( "no dissolved geometry - should not happen" );
return false;
}
dissolveFeature.setGeometry( dissolveGeometry );
dissolveFeature.setGeometry( *dissolveGeometry );
delete dissolveGeometry;
vWriter.addFeature( dissolveFeature );
}
return true;
@@ -878,7 +886,8 @@ void QgsGeometryAnalyzer::bufferFeature( QgsFeature& f, int nProcessedFeatures,
else //dissolve
{
QgsFeature newFeature;
newFeature.setGeometry( bufferGeometry );
newFeature.setGeometry( *bufferGeometry );
delete bufferGeometry;
newFeature.setAttributes( f.attributes() );

//add it to vector file writer
@@ -990,7 +999,8 @@ bool QgsGeometryAnalyzer::eventLayer( QgsVectorLayer* lineLayer, QgsVectorLayer*
if ( lrsGeom )
{
++nOutputFeatures;
addEventLayerFeature( fet, lrsGeom, featureIdIt->geometry(), fileWriter, memoryProviderFeatures, offsetField, offsetScale, forceSingleGeometry );
addEventLayerFeature( fet, lrsGeom, featureIdIt->constGeometry() ? *featureIdIt->constGeometry() :
QgsGeometry(), fileWriter, memoryProviderFeatures, offsetField, offsetScale, forceSingleGeometry );
}
}
if ( nOutputFeatures < 1 )
@@ -1012,7 +1022,7 @@ bool QgsGeometryAnalyzer::eventLayer( QgsVectorLayer* lineLayer, QgsVectorLayer*
return true;
}

void QgsGeometryAnalyzer::addEventLayerFeature( QgsFeature& feature, QgsGeometry* geom, QgsGeometry* lineGeom, QgsVectorFileWriter* fileWriter, QgsFeatureList& memoryFeatures,
void QgsGeometryAnalyzer::addEventLayerFeature( QgsFeature& feature, QgsGeometry* geom, const QgsGeometry& lineGeom, QgsVectorFileWriter* fileWriter, QgsFeatureList& memoryFeatures,
int offsetField, double offsetScale, bool forceSingleType )
{
if ( !geom )
@@ -1045,7 +1055,7 @@ void QgsGeometryAnalyzer::addEventLayerFeature( QgsFeature& feature, QgsGeometry
}
}

feature.setGeometry( *geomIt );
feature.setGeometry( **geomIt );
if ( fileWriter )
{
fileWriter->addFeature( feature );
@@ -1062,9 +1072,9 @@ void QgsGeometryAnalyzer::addEventLayerFeature( QgsFeature& feature, QgsGeometry
}
}

bool QgsGeometryAnalyzer::createOffsetGeometry( QgsGeometry* geom, QgsGeometry* lineGeom, double offset )
bool QgsGeometryAnalyzer::createOffsetGeometry( QgsGeometry* geom, const QgsGeometry& lineGeom, double offset )
{
if ( !geom || !lineGeom )
if ( !geom || lineGeom.isEmpty() )
{
return false;
}
@@ -1147,16 +1157,16 @@ bool QgsGeometryAnalyzer::createOffsetGeometry( QgsGeometry* geom, QgsGeometry*
return true;
}

QgsPoint QgsGeometryAnalyzer::createPointOffset( double x, double y, double dist, QgsGeometry* lineGeom ) const
QgsPoint QgsGeometryAnalyzer::createPointOffset( double x, double y, double dist, const QgsGeometry& lineGeom ) const
{
QgsPoint p( x, y );
QgsPoint minDistPoint;
int afterVertexNr;
lineGeom->closestSegmentWithContext( p, minDistPoint, afterVertexNr );
lineGeom.closestSegmentWithContext( p, minDistPoint, afterVertexNr );

int beforeVertexNr = afterVertexNr - 1;
QgsPoint beforeVertex = lineGeom->vertexAt( beforeVertexNr );
QgsPoint afterVertex = lineGeom->vertexAt( afterVertexNr );
QgsPoint beforeVertex = lineGeom.vertexAt( beforeVertexNr );
QgsPoint afterVertex = lineGeom.vertexAt( afterVertexNr );

//get normal vector
double dx = afterVertex.x() - beforeVertex.x();
@@ -142,14 +142,14 @@ class ANALYSIS_EXPORT QgsGeometryAnalyzer
void dissolveFeature( QgsFeature& f, int nProcessedFeatures, QgsGeometry** dissolveGeometry );

//helper functions for event layer
void addEventLayerFeature( QgsFeature& feature, QgsGeometry* geom, QgsGeometry* lineGeom, QgsVectorFileWriter* fileWriter, QgsFeatureList& memoryFeatures, int offsetField = -1, double offsetScale = 1.0,
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 lineGeom the line geometry to which the feature is referenced
@param offset the offset value in layer unit. Negative values mean offset towards left, positive values offset to the right side*/
bool createOffsetGeometry( QgsGeometry* geom, QgsGeometry* lineGeom, double offset );
QgsPoint createPointOffset( double x, double y, double dist, QgsGeometry* lineGeom ) const;
bool createOffsetGeometry( QgsGeometry* geom, const QgsGeometry& lineGeom, double offset );
QgsPoint createPointOffset( double x, double y, double dist, const QgsGeometry& lineGeom ) const;
QgsConstWkbPtr locateBetweenWkbString( QgsConstWkbPtr ptr, QgsMultiPolyline& result, double fromMeasure, double toMeasure );
QgsConstWkbPtr locateAlongWkbString( QgsConstWkbPtr 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 );
@@ -169,7 +169,8 @@ void QgsOverlayAnalyzer::intersectFeature( QgsFeature& f, QgsVectorFileWriter* v
{
intersectGeometry = featureGeometry->intersection( overlayFeature.constGeometry() );

outFeature.setGeometry( intersectGeometry );
outFeature.setGeometry( *intersectGeometry );
delete intersectGeometry;
QgsAttributes attributesA = f.attributes();
QgsAttributes attributesB = overlayFeature.attributes();
combineAttributeMaps( attributesA, attributesB );
@@ -127,7 +127,8 @@ void QgsPointSample::addSamplePoints( QgsFeature& inputFeature, QgsVectorFileWri
f.setAttribute( "id", mNCreatedPoints + 1 );
f.setAttribute( "station_id", points + 1 );
f.setAttribute( "stratum_id", inputFeature.id() );
f.setGeometry( ptGeom );
f.setGeometry( *ptGeom );
delete ptGeom;
writer.addFeature( f );
sIndex.insertFeature( f );
pointMapForFeature.insert( mNCreatedPoints, randPoint );

0 comments on commit aceddae

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