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 b04ea44
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 6 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
15 changes: 11 additions & 4 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6969,10 +6969,9 @@
<code>$temp_point[1]</code>
<code>$wkt</code>
</MixedArgument>
<MixedArrayAccess occurrences="22">
<MixedArrayAccess occurrences="21">
<code>$data_row[$i]</code>
<code>$data_row['no_of_lines']</code>
<code>$gis_data[$index]['MULTILINESTRING']</code>
<code>$point['x']</code>
<code>$point['y']</code>
<code>$point[0]</code>
Expand Down Expand Up @@ -7030,6 +7029,10 @@
<code>$black</code>
<code>$color</code>
</PossiblyFalseArgument>
<PossiblyNullArrayAccess occurrences="2">
<code>$data_row[$i]</code>
<code>$data_row['no_of_lines']</code>
</PossiblyNullArrayAccess>
<RedundantPropertyInitializationCheck occurrences="1">
<code>isset(self::$instance)</code>
</RedundantPropertyInitializationCheck>
Expand Down Expand Up @@ -7120,11 +7123,10 @@
<code>$ring['points']</code>
<code>$wkt</code>
</MixedArgument>
<MixedArrayAccess occurrences="38">
<MixedArrayAccess occurrences="37">
<code>$data_row[$k]</code>
<code>$data_row[$k]</code>
<code>$data_row['no_of_polygons']</code>
<code>$gis_data[$index]['MULTIPOLYGON']</code>
<code>$innerPoint['x']</code>
<code>$innerPoint['y']</code>
<code>$label_point[0]</code>
Expand Down Expand Up @@ -7229,6 +7231,11 @@
<code>$black</code>
<code>$color</code>
</PossiblyFalseArgument>
<PossiblyNullArrayAccess occurrences="3">
<code>$data_row[$k]</code>
<code>$data_row[$k]</code>
<code>$data_row['no_of_polygons']</code>
</PossiblyNullArrayAccess>
<RedundantPropertyInitializationCheck occurrences="1">
<code>isset(self::$instance)</code>
</RedundantPropertyInitializationCheck>
Expand Down
66 changes: 66 additions & 0 deletions test/classes/Gis/GisGeometryCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,72 @@ 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 b04ea44

Please sign in to comment.