From 4e4882a01e71b37bdf27f9538488ac39b07fc1df Mon Sep 17 00:00:00 2001 From: Mathieu Date: Tue, 27 Aug 2024 20:15:18 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20handle=20coordinates=20with=20=C2=B7=20a?= =?UTF-8?q?s=20separator?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/unit/app/GeoKrety/Service/CoordinateConverterTest.php | 1 + website/app/GeoKrety/Service/CoordinatesConverter.php | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/unit/app/GeoKrety/Service/CoordinateConverterTest.php b/tests/unit/app/GeoKrety/Service/CoordinateConverterTest.php index 7f1b3b75b3..89eefa24e4 100644 --- a/tests/unit/app/GeoKrety/Service/CoordinateConverterTest.php +++ b/tests/unit/app/GeoKrety/Service/CoordinateConverterTest.php @@ -40,6 +40,7 @@ public function testCheckActualConverter() { ['test' => '46° 44′ 0″ N, 12° 11′ 0″ E', 'result' => ['lat' => 46.733333, 'lon' => 12.183333, 'format' => 'fromDegreeMinuteSecondHemisphere']], ['test' => '55° 3′ 23.96″ N, 9° 44′ 32.71″ E', 'result' => ['lat' => 55.056656, 'lon' => 9.742419, 'format' => 'fromDegreeMinuteSecondHemisphere']], ['test' => 'N55° 3′ 23.96″ E9° 44′ 32.71″', 'result' => ['lat' => 55.056656, 'lon' => 9.742419, 'format' => 'fromHemisphereDegreeMinuteSecond']], + ['test' => 'N 53° 28,704\' · E 014° 47,064\'', 'result' => ['lat' => 53.478400, 'lon' => 14.784400, 'format' => 'fromHemisphereDegreeMinute']], // Examples from the help page ['test' => '52.205205 21.190891', 'result' => ['lat' => 52.205205, 'lon' => 21.190891, 'format' => 'fromDecimalDegree']], diff --git a/website/app/GeoKrety/Service/CoordinatesConverter.php b/website/app/GeoKrety/Service/CoordinatesConverter.php index 5162d8c278..7d780d99a7 100644 --- a/website/app/GeoKrety/Service/CoordinatesConverter.php +++ b/website/app/GeoKrety/Service/CoordinatesConverter.php @@ -110,6 +110,7 @@ function ($m) { $input = str_replace(' ', '', $coords); $input = str_replace('O', 'W', $input); $input = str_replace('+', '', $input); + $input = str_replace('·', '', $input); $input = preg_replace('/[″"],/', '"', $input); $input = str_replace(',', '.', $input); $input = preg_replace('/([°º])[,\.]/', '${1}', $input);