Skip to content

Commit

Permalink
Merge pull request #465 from earboxer/openlocationcodes
Browse files Browse the repository at this point in the history
Address Service: Convert Open Location Codes to lat/lon
  • Loading branch information
tacruc authored Apr 14, 2022
2 parents 3f3d2a4 + 880d40e commit ae6d347
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"require": {
"lsolesen/pel": "^0.9.11"
"lsolesen/pel": "^0.9.11",
"bogdaan/open-location-code": "dev-master"
},
"require-dev": {
"christophwurst/nextcloud_testing": "^0.9.1"
Expand Down
10 changes: 10 additions & 0 deletions lib/Service/AddressService.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use OCP\IMemcache;
use \Sabre\VObject\Reader;
use \OCP\Files\IAppData;
use OpenLocationCode\OpenLocationCode;

/**
* Class AddressService
Expand Down Expand Up @@ -136,6 +137,15 @@ public function lookupAddress($adr, $uri) {

private function lookupAddressInternal($adr) {
$res = [null, null, False];

if (OpenLocationCode::isFull($adr)) {
$decoded = OpenLocationCode::decode($adr);
$res[0] = $decoded['latitudeCenter'];
$res[1] = $decoded['longitudeCenter'];
$res[2] = True;
return $res;
}

$adr_norm = strtolower(preg_replace('/\s+/', '', $adr));

$this->qb->select('lat', 'lng')
Expand Down

0 comments on commit ae6d347

Please sign in to comment.