boogdaan/open-location-code

php的开放位置代码

dev-master 2018-02-03 16:15 UTC

This package is auto-updated.

Last update: 2024-09-22 21:49:06 UTC


README

Build Status

php的开放位置代码

开放位置代码是一种将位置编码成比经纬度更易使用的形式的方法。

它们被设计用来替代街道地址,尤其是在建筑物没有编号或街道没有命名的地区。

开放位置代码表示一个区域,而不是一个点。随着代码中数字的增加,区域缩小,因此长代码比短代码更精确。

可以将位置转换为代码,也可以将代码完全离线转换回位置。

基于此存储库的javascript版本。

使用方法

通过composer安装

$ composer require bogdaan/open-location-code

示例

use OpenLocationCode\OpenLocationCode;

// encode
var_dump(OpenLocationCode::encode(48.41, 34.81));

// decode (return area array)
var_dump(OpenLocationCode::decode("44870000+"));

OpenLocationCode::decode方法返回包含以下键的数组

  • latitudeLo, longitudeLo - 正方形左下角的坐标
  • latitudeHi, longitudeHi - 正方形右上角的坐标
  • codeLength - 解码长度

链接