Skip to content

Commit

Permalink
#61 Services findInText: added support for W3W service
Browse files Browse the repository at this point in the history
  • Loading branch information
DJTommek committed Oct 4, 2021
1 parent 9bcc817 commit 1849fbe
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/libs/BetterLocation/Service/WhatThreeWordService.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\BetterLocation\Service;

use App\BetterLocation\BetterLocation;
use App\BetterLocation\BetterLocationCollection;
use App\BetterLocation\Service\Exceptions\NotSupportedException;
use App\WhatThreeWord;
use Nette\Utils\Arrays;
Expand Down Expand Up @@ -76,4 +77,15 @@ public static function getShareText(float $lat, float $lon): string
$data = WhatThreeWord\Helper::coordsToWords($lat, $lon);
return '///' . $data->words;
}

public static function findInText(string $text): BetterLocationCollection
{
$collection = new BetterLocationCollection();
$wordsAddresses = WhatThreeWord\Helper::findInText($text);
foreach ($wordsAddresses as $wordsAddress) {
// It is ok to use processStatic since words should be already valid
$collection->add(self::processStatic($wordsAddress)->getCollection());
}
return $collection;
}
}

0 comments on commit 1849fbe

Please sign in to comment.