Skip to content
Permalink
Browse files
QgsGeometry::length() returns perimeter for polygon geometries
  • Loading branch information
nyalldawson committed Nov 2, 2021
1 parent e10a48b commit 515fa62a8665c36ec6e5fbcc48b657eee5030797
Showing with 16 additions and 1 deletion.
  1. +16 −1 src/core/geometry/qgsgeometry.cpp
@@ -1913,7 +1913,22 @@ double QgsGeometry::length() const
return -1.0;
}

return d->geometry->length();
switch ( QgsWkbTypes::geometryType( d->geometry->wkbType() ) )
{
case QgsWkbTypes::PointGeometry:
return 0.0;

case QgsWkbTypes::LineGeometry:
return d->geometry->length();

case QgsWkbTypes::PolygonGeometry:
return d->geometry->perimeter();

case QgsWkbTypes::UnknownGeometry:
case QgsWkbTypes::NullGeometry:
return d->geometry->length();
}
return -1;
}

double QgsGeometry::distance( const QgsGeometry &geom ) const

0 comments on commit 515fa62

Please sign in to comment.