Make farm_map_combine_geoms() more resilient to empty geometries.
This commit is contained in:
parent
4b9df8fe63
commit
7e930dd210
|
@ -95,6 +95,11 @@ function farm_map_combine_geoms($geoms = array()) {
|
|||
$wkt_strings = array();
|
||||
foreach ($geoms as &$geom) {
|
||||
|
||||
// If the geometry is empty, skip it.
|
||||
if (empty($geom)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Convert to a GeoPHP geometry object.
|
||||
$geometry = geoPHP::load($geom, 'wkt');
|
||||
|
||||
|
@ -130,6 +135,11 @@ function farm_map_combine_geoms($geoms = array()) {
|
|||
// Combine all the WKT strings together into one.
|
||||
$wkt = implode(',', $wkt_strings);
|
||||
|
||||
// If the WKT is empty, bail.
|
||||
if (empty($wkt)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// If there is more than one geometry, wrap them all in a geometry collection.
|
||||
if ($geometrycollection) {
|
||||
$wkt = 'GEOMETRYCOLLECTION (' . $wkt . ')';
|
||||
|
|
Loading…
Reference in New Issue