Skip to content

Commit 3b9c2bb

Browse files
Merge pull request #64 from helsingborg-stad/fix/geo-faulty
fix: faulty geo (DONT MERGE HOTFIX)
2 parents 4e08928 + 5b0b106 commit 3b9c2bb

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

source/php/ApplyOpenStreetMapDataToPostObject.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,28 @@ public function __construct(private \Municipio\PostObject\PostObjectInterface $p
77
{}
88
public function apply():\Municipio\PostObject\PostObjectInterface|null {
99

10-
if (!($this->post->getSchemaProperty('geo') instanceof \Municipio\Schema\GeoCoordinates)) {
10+
/**
11+
* Hotfix: Manually get lat/lng.
12+
* Should be removed when https://github.com/helsingborg-stad/Municipio/pull/1403 is merged.
13+
*/
14+
15+
$geo = $this->post->getSchemaProperty('geo');
16+
17+
if (!$geo) {
18+
return $this->post;
19+
}
20+
21+
if (is_string($geo)) {
22+
$geo = unserialize($geo);
23+
}
24+
25+
if (isset($geo['lat'], $geo['lng'])) {
26+
$lat = $geo['lat'];
27+
$lng = $geo['lng'];
28+
} else {
1129
return $this->post;
1230
}
1331

14-
$lat = $this->post->getSchemaProperty('geo')['latitude'] ?? null;
15-
$lng = $this->post->getSchemaProperty('geo')['longitude'] ?? null;
1632
$googleMapsLink = $this->getGoogleMapsLink($lat, $lng);
1733

1834
$this->post->openStreetMapData = [

0 commit comments

Comments
 (0)