saikiran/geohashライブラリをインストール
composer require saikiran/geohash
地理的な位置を文字と数字の短い文字列にエンコードします。
use Sk\Geohash\Geohash;
$g = new Geohash();
public function run(Faker $faker)
{
// 緯度,経度,文字数
'geohash' => $g->encode($faker->latitude(), $faker->longitude(), 12),
}
文字と数字の文字列を緯度と経度にデコードします。
use Sk\Geohash\Geohash;
$g = new Geohash();
public function run(Faker $faker)
{
'geohash' => $g-> decode('エンコードされた文字列', 12),
}
- テーブルに緯度・経度を文字列かしたレコードを保持しておけば色々使い回しが出来そう!