Skip to content

Commit 49aae6e

Browse files
committed
Rename QgsGeometry::isEmpty to isNull
Differentiates missing geometries from empty geometries (eg empty geometry collections)
1 parent 61d3147 commit 49aae6e

File tree

84 files changed

+257
-260
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+257
-260
lines changed

doc/api_break.dox

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1044,8 +1044,10 @@ QgsGeometry {#qgis_api_break_3_0_QgsGeometry}
10441044

10451045
- All QgsGeometry methods now accept geometry references instead of pointers, and return a QgsGeometry
10461046
value instead of a pointer. The biggest impact with this change is that PyQGIS code should not compare a geometry
1047-
result to None, but instead either use a boolean test (`if g.buffer(10):`) or explicitly use the isEmpty()
1047+
result to None, but instead either use a boolean test (`if g.buffer(10):`) or explicitly use the isNull()
10481048
method to determine if a geometry is valid.
1049+
- isEmpty() was renamed to isNull() to differentiate a missing geometry from a geometry which is empty (eg an
1050+
empty geometry collection)
10491051
- wkbSize() and asWkb() has been replaced by exportToWkb(). WKB representation is no longer cached within QgsGeometry
10501052
- asGeos() has been replaced by exportToGeos(). GEOS representation is no longer cached within QgsGeometry
10511053
- int addPart( const QList<QgsPoint> &points, QgsWkbTypes::GeometryType geomType ) has been renamed to addPoints

python/core/geometry/qgsgeometry.sip

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,7 @@ class QgsGeometry
5757
*/
5858
void setGeometry( QgsAbstractGeometry* geometry /Transfer/ );
5959

60-
/** Returns true if the geometry is empty (ie, contains no underlying geometry
61-
* accessible via @link geometry @endlink).
62-
* @see geometry
63-
* @note added in QGIS 2.10
64-
*/
65-
bool isEmpty() const;
60+
bool isNull() const;
6661

6762
/** Creates a new geometry from a WKT string */
6863
static QgsGeometry fromWkt( const QString& wkt );

python/plugins/processing/algs/qgis/CheckValidity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def doCheck(self, feedback):
137137
attrs = inFeat.attributes()
138138

139139
valid = True
140-
if not geom.isEmpty() and not geom.isGeosEmpty():
140+
if not geom.isNull() and not geom.isGeosEmpty():
141141
errors = list(geom.validateGeometry())
142142
if errors:
143143
# QGIS method return a summary at the end

python/plugins/processing/algs/qgis/Delaunay.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def processAlgorithm(self, feedback):
8282
total = 100.0 / len(features)
8383
for current, inFeat in enumerate(features):
8484
geom = QgsGeometry(inFeat.geometry())
85-
if geom.isEmpty():
85+
if geom.isNull():
8686
continue
8787
if geom.isMultipart():
8888
points = geom.asMultiPoint()

python/plugins/processing/algs/qgis/Dissolve.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def processAlgorithm(self, feedback):
9393
first = False
9494

9595
tmpInGeom = inFeat.geometry()
96-
if tmpInGeom.isEmpty() or tmpInGeom.isGeosEmpty():
96+
if tmpInGeom.isNull() or tmpInGeom.isGeosEmpty():
9797
continue
9898

9999
errors = tmpInGeom.validateGeometry()

python/plugins/processing/algs/qgis/PolygonCentroids.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def processAlgorithm(self, feedback):
8080
inGeom = feat.geometry()
8181
attrs = feat.attributes()
8282

83-
if inGeom.isEmpty():
83+
if inGeom.isNull():
8484
outGeom = QgsGeometry(None)
8585
else:
8686
outGeom = QgsGeometry(inGeom.centroid())

python/plugins/processing/algs/qgis/ReverseLineDirection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def processAlgorithm(self, feedback):
6565
attrs = inFeat.attributes()
6666

6767
outGeom = None
68-
if not inGeom.isEmpty():
68+
if not inGeom.isNull():
6969
reversedLine = inGeom.geometry().reversed()
7070
if not reversedLine:
7171
raise GeoAlgorithmExecutionException(

python/plugins/processing/algs/qgis/SplitWithLines.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def processAlgorithm(self, feedback):
127127
while len(inGeoms) > 0:
128128
inGeom = inGeoms.pop()
129129

130-
if inGeom.isEmpty(): # this has been encountered and created a run-time error
130+
if inGeom.isNull(): # this has been encountered and created a run-time error
131131
continue
132132

133133
if split_geom_engine.intersects(inGeom.geometry()):

src/analysis/interpolation/qgsinterpolator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ int QgsInterpolator::cacheBaseData()
105105

106106
int QgsInterpolator::addVerticesToCache( const QgsGeometry& geom, bool zCoord, double attributeValue )
107107
{
108-
if ( geom.isEmpty() )
108+
if ( geom.isNull() )
109109
return 1;
110110

111111
bool hasZValue = false;

src/analysis/interpolation/qgstininterpolator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ int QgsTINInterpolator::insertData( QgsFeature* f, bool zCoord, int attr, InputT
175175

176176
QgsGeometry g = f->geometry();
177177
{
178-
if ( g.isEmpty() )
178+
if ( g.isNull() )
179179
{
180180
return 2;
181181
}

0 commit comments

Comments
 (0)