Skip to content

Commit

Permalink
Fix displaying svg points with x or y zero
Browse files Browse the repository at this point in the history
Points where at least one coordinate is non-zero are
definitely valid. Only points with x and y zero may be invalid.

Signed-off-by: Maximilian Krög <maxi_kroeg@web.de>
  • Loading branch information
MoonE committed Nov 3, 2024
1 parent bdf9afc commit b3ba7c5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion libraries/classes/Gis/GisMultiPoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public function prepareRowAsSvg($spatial, $label, $point_color, array $scale_dat

$row = '';
foreach ($points_arr as $point) {
if (((float) $point[0]) === 0.0 || ((float) $point[1]) === 0.0) {
if (((float) $point[0]) === 0.0 && ((float) $point[1]) === 0.0) {
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/classes/Gis/GisPoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public function prepareRowAsSvg($spatial, $label, $point_color, array $scale_dat
$points_arr = $this->extractPoints($point, $scale_data);

$row = '';
if (((float) $points_arr[0][0]) !== 0.0 && ((float) $points_arr[0][1]) !== 0.0) {
if (((float) $points_arr[0][0]) !== 0.0 || ((float) $points_arr[0][1]) !== 0.0) {
$row .= '<circle cx="' . $points_arr[0][0]
. '" cy="' . $points_arr[0][1] . '" r="3"';
foreach ($point_options as $option => $val) {
Expand Down
11 changes: 4 additions & 7 deletions test/classes/Gis/GisPointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,8 @@ public function testPrepareRowAsSvg(
array $scaleData,
string $output
): void {
self::assertSame($output, $this->object->prepareRowAsSvg(
$spatial,
$label,
$pointColor,
$scaleData
));
$string = $this->object->prepareRowAsSvg($spatial, $label, $pointColor, $scaleData);
self::assertMatchesRegularExpressionCompat($output, $string);
}

/**
Expand All @@ -286,7 +282,8 @@ public static function providerForPrepareRowAsSvg(): array
'scale' => 2,
'height' => 150,
],
'',
'/^<circle cx="0" cy="218" r="3" name="svg" id="svg\d+" class="point vector"'
. ' fill="white" stroke="#B02EE0" stroke-width="2"\/>$/',
],
];
}
Expand Down

0 comments on commit b3ba7c5

Please sign in to comment.