Skip to content
Permalink
Browse files

Avoid some QgsGeometry pointer use in QgsGeometry API

  • Loading branch information
nyalldawson committed Nov 8, 2016
1 parent 1a4f8f5 commit f9bb230665c2efc9515496a4b6532d22011fa664
@@ -358,7 +358,7 @@ class QgsGeometry
@note available in python bindings as addPartGeometry (added in 2.2)
*/
// TODO QGIS 3.0 returns an enum instead of a magic constant
int addPart( const QgsGeometry *newPart /Transfer/ ) /PyName=addPartGeometry/;
int addPart( const QgsGeometry& newPart ) /PyName=addPartGeometry/;

/** Translate this geometry by dx, dy
@return 0 in case of success*/
@@ -388,7 +388,7 @@ class QgsGeometry
@return 0 in case of success, 1 if geometry has not been split, error else*/
// TODO QGIS 3.0 returns an enum instead of a magic constant
int splitGeometry( const QList<QgsPoint>& splitLine,
QList<QgsGeometry*>&newGeometries /Out/,
QList<QgsGeometry>& newGeometries /Out/,
bool topological,
QList<QgsPoint> &topologyTestPoints /Out/);

@@ -253,8 +253,7 @@ QgsGeometry QgsGeometry::collectGeometry( const QList< QgsGeometry >& geometries
}
else
{
QgsGeometry part = QgsGeometry( *git );
collected.addPart( &part );
collected.addPart( *git );
}
}
return collected;
@@ -731,14 +730,14 @@ int QgsGeometry::addPart( QgsAbstractGeometry* part, QgsWkbTypes::GeometryType g
return QgsGeometryEditUtils::addPart( d->geometry, part );
}

int QgsGeometry::addPart( const QgsGeometry *newPart )
int QgsGeometry::addPart( const QgsGeometry& newPart )
{
if ( !d->geometry || !newPart || !newPart->d || !newPart->d->geometry )
if ( !d->geometry || !newPart.d || !newPart.d->geometry )
{
return 1;
}

return addPart( newPart->d->geometry->clone() );
return addPart( newPart.d->geometry->clone() );
}

int QgsGeometry::addPart( GEOSGeometry *newPart )
@@ -786,7 +785,7 @@ int QgsGeometry::rotate( double rotation, const QgsPoint& center )
return 0;
}

int QgsGeometry::splitGeometry( const QList<QgsPoint>& splitLine, QList<QgsGeometry*>& newGeometries, bool topological, QList<QgsPoint> &topologyTestPoints )
int QgsGeometry::splitGeometry( const QList<QgsPoint>& splitLine, QList<QgsGeometry>& newGeometries, bool topological, QList<QgsPoint> &topologyTestPoints )
{
if ( !d->geometry )
{
@@ -811,7 +810,7 @@ int QgsGeometry::splitGeometry( const QList<QgsPoint>& splitLine, QList<QgsGeome
newGeometries.clear();
for ( int i = 1; i < newGeoms.size(); ++i )
{
newGeometries.push_back( new QgsGeometry( newGeoms.at( i ) ) );
newGeometries.push_back( QgsGeometry( newGeoms.at( i ) ) );
}
}

@@ -1401,7 +1400,7 @@ QgsGeometry QgsGeometry::offsetCurve( double distance, int segments, JoinStyle j
QgsGeometry first = results.takeAt( 0 );
Q_FOREACH ( const QgsGeometry& result, results )
{
first.addPart( & result );
first.addPart( result );
}
return first;
}
@@ -1440,7 +1439,7 @@ QgsGeometry QgsGeometry::singleSidedBuffer( double distance, int segments, Buffe
QgsGeometry first = results.takeAt( 0 );
Q_FOREACH ( const QgsGeometry& result, results )
{
first.addPart( & result );
first.addPart( result );
}
return first;
}
@@ -1480,7 +1479,7 @@ QgsGeometry QgsGeometry::extendLine( double startDistance, double endDistance )
QgsGeometry first = results.takeAt( 0 );
Q_FOREACH ( const QgsGeometry& result, results )
{
first.addPart( & result );
first.addPart( result );
}
return first;
}
@@ -402,7 +402,7 @@ class CORE_EXPORT QgsGeometry
@note available in python bindings as addPartGeometry (added in 2.2)
*/
// TODO QGIS 3.0 returns an enum instead of a magic constant
int addPart( const QgsGeometry *newPart );
int addPart( const QgsGeometry& newPart );

/** Translate this geometry by dx, dy
@return 0 in case of success*/
@@ -432,7 +432,7 @@ class CORE_EXPORT QgsGeometry
@return 0 in case of success, 1 if geometry has not been split, error else*/
// TODO QGIS 3.0 returns an enum instead of a magic constant
int splitGeometry( const QList<QgsPoint>& splitLine,
QList<QgsGeometry*>&newGeometries,
QList<QgsGeometry>& newGeometries,
bool topological,
QList<QgsPoint> &topologyTestPoints );

@@ -359,9 +359,8 @@ int QgsVectorLayerEditUtils::splitFeatures( const QList<QgsPoint>& splitLine, bo
{
continue;
}
QList<QgsGeometry*> newGeometries;
QList<QgsGeometry> newGeometries;
QList<QgsPoint> topologyTestPoints;
QgsGeometry* newGeometry = nullptr;
QgsGeometry featureGeom = feat.geometry();
splitFunctionReturn = featureGeom.splitGeometry( splitLine, newGeometries, topologicalEditing, topologyTestPoints );
if ( splitFunctionReturn == 0 )
@@ -372,9 +371,8 @@ int QgsVectorLayerEditUtils::splitFeatures( const QList<QgsPoint>& splitLine, bo
//insert new features
for ( int i = 0; i < newGeometries.size(); ++i )
{
newGeometry = newGeometries.at( i );
QgsFeature newFeature;
newFeature.setGeometry( *newGeometry );
newFeature.setGeometry( newGeometries.at( i ) );

//use default value where possible for primary key (e.g. autoincrement),
//and use the value from the original (split) feature if not primary key
@@ -492,7 +490,7 @@ int QgsVectorLayerEditUtils::splitParts( const QList<QgsPoint>& splitLine, bool
QgsFeature feat;
while ( fit.nextFeature( feat ) )
{
QList<QgsGeometry*> newGeometries;
QList<QgsGeometry> newGeometries;
QList<QgsPoint> topologyTestPoints;
QgsGeometry featureGeom = feat.geometry();
splitFunctionReturn = featureGeom.splitGeometry( splitLine, newGeometries, topologicalEditing, topologyTestPoints );
@@ -550,8 +548,6 @@ int QgsVectorLayerEditUtils::splitParts( const QList<QgsPoint>& splitLine, bool
{
returnCode = splitFunctionReturn;
}

qDeleteAll( newGeometries );
}

if ( numberOfSplittedParts == 0 && L->selectedFeatureCount() > 0 && returnCode == 0 )

0 comments on commit f9bb230

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