Skip to content

Commit

Permalink
Fix error when switching geom type in geometry collection
Browse files Browse the repository at this point in the history
Signed-off-by: Maximilian Krög <maxi_kroeg@web.de>
  • Loading branch information
MoonE committed Aug 26, 2023
1 parent 00d1774 commit a9d5c84
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 2 deletions.
2 changes: 1 addition & 1 deletion libraries/classes/Gis/GisMultiLineString.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public function prepareRowAsOl($spatial, int $srid, $label, $line_color, array $
*/
public function generateWkt(array $gis_data, $index, $empty = '')
{
$data_row = $gis_data[$index]['MULTILINESTRING'];
$data_row = $gis_data[$index]['MULTILINESTRING'] ?? null;

$no_of_lines = $data_row['no_of_lines'] ?? 1;
if ($no_of_lines < 1) {
Expand Down
2 changes: 1 addition & 1 deletion libraries/classes/Gis/GisMultiPolygon.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ private function drawPath($polygon, array $scale_data)
*/
public function generateWkt(array $gis_data, $index, $empty = '')
{
$data_row = $gis_data[$index]['MULTIPOLYGON'];
$data_row = $gis_data[$index]['MULTIPOLYGON'] ?? null;

$no_of_polygons = $data_row['no_of_polygons'] ?? 1;
if ($no_of_polygons < 1) {
Expand Down
90 changes: 90 additions & 0 deletions test/classes/Gis/GisGeometryCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,96 @@ public function providerForGenerateWkt(): array
];

return [
[
[
'gis_type' => 'GEOMETRYCOLLECTION',
'srid' => '0',
'GEOMETRYCOLLECTION' => [
'geom_count' => '1',
],
0 => [
'gis_type' => 'POINT',
],
],
0,
null,
'GEOMETRYCOLLECTION(POINT( ))',
],
[
[
'gis_type' => 'GEOMETRYCOLLECTION',
'srid' => '0',
'GEOMETRYCOLLECTION' => [
'geom_count' => '1',
],
0 => [
'gis_type' => 'LINESTRING',
],
],
0,
null,
'GEOMETRYCOLLECTION(LINESTRING( , ))',
],
[
[
'gis_type' => 'GEOMETRYCOLLECTION',
'srid' => '0',
'GEOMETRYCOLLECTION' => [
'geom_count' => '1',
],
0 => [
'gis_type' => 'POLYGON',
],
],
0,
null,
'GEOMETRYCOLLECTION(POLYGON(( , , , )))',
],
[
[
'gis_type' => 'GEOMETRYCOLLECTION',
'srid' => '0',
'GEOMETRYCOLLECTION' => [
'geom_count' => '1',
],
0 => [
'gis_type' => 'MULTIPOINT',
],
],
0,
null,
'GEOMETRYCOLLECTION(MULTIPOINT( ))',
],
[
[
'gis_type' => 'GEOMETRYCOLLECTION',
'srid' => '0',
'GEOMETRYCOLLECTION' => [
'geom_count' => '1',
],
0 => [
'gis_type' => 'MULTILINESTRING',
],
],
0,
null,
'GEOMETRYCOLLECTION(MULTILINESTRING(( , )))',
],
[
[
'gis_type' => 'GEOMETRYCOLLECTION',
'srid' => '0',
'GEOMETRYCOLLECTION' => [
'geom_count' => '1',
],
0 => [
'gis_type' => 'MULTIPOLYGON',
],
],
0,
null,
'GEOMETRYCOLLECTION(MULTIPOLYGON((( , , , ))))',
],
[
$temp1,
0,
Expand Down

0 comments on commit a9d5c84

Please sign in to comment.