3
0
Fork 0
mirror of https://github.com/farmOS/farmOS.git synced 2024-02-23 11:37:38 +01:00

Fix Error: Call to a member function geometryType() on boolean in farm_area_calculate_area()

This commit is contained in:
Michael Stenta 2020-01-09 13:47:38 -05:00
parent 1e398698e6
commit ff8871ed45

View file

@ -423,7 +423,17 @@ function farm_area_calculate_area($area_id, $format = FALSE) {
// Load the WKT into a GeoPHP Geometry object and reduce it.
geophp_load();
$polygon = geoPHP::load($geom, 'wkt');
// If the geometry is empty, bail.
if ($polygon->isEmpty()) {
return '';
}
// Reduce the geometry. If this returns FALSE, bail.
$polygon = geoPHP::geometryReduce($polygon);
if (empty($polygon)) {
return '';
}
// Ensure that it is a simple polygon.
if ($polygon->geometryType() != 'Polygon') {