daveross/offline-country-reverse-geocoder

确定一个经纬度点所在的地区

1.1.1 2015-06-01 13:02 UTC

This package is not auto-updated.

Last update: 2024-09-14 17:37:20 UTC


README

Latest Stable Version License Build Status

确定一个经纬度点所在的地区,返回一个ISO 3166-1两字母国家代码。所有处理都是在本地使用国家边界的数据集完成的,无需连接到API。

使用https://github.com/bencampion/reverse-country-code的数据文件

安装

使用Composer Total Downloads

composer require daveross/offline-country-reverse-geocoder:~1.0.0

或手动将依赖项添加到您的composer.json文件中

"require": {
	"php": ">=5.3",
	"daveross/offline-country-reverse-geocoder": "~1.0.0"
}

不使用Composer

将此库的文件复制到您应用程序中第三方库所在的目录。包括此库中的src/offline-country-reverse-geocoder.php,它将从同一目录加载polygons.properties

示例

echo 'Washington DC is in ' . \DaveRoss\OfflineCountryReverseGeocoder\get_country(-77.0164, 38.9047) . "\n";
echo 'Chicago is in ' . \DaveRoss\OfflineCountryReverseGeocoder\get_country(-87.6847, 41.8369) . "\n";
echo 'London is in ' . \DaveRoss\OfflineCountryReverseGeocoder\get_country( -0.12750, 51.50722 ) . "\n";
echo 'New Delhi is in ' . \DaveRoss\OfflineCountryReverseGeocoder\get_country( 77.12, 28.38 ) . "\n";
echo 'Sydney is in ' . \DaveRoss\OfflineCountryReverseGeocoder\get_country( 151.2073200, -33.8678500 ) . "\n";

##数据集

此库使用来自thematicmapping.org的世界边界数据集。数据存储在项目中的属性文件中,将国家代码映射到Well Known Text格式的多边形和多多边形。数据集由GIS Stack Exchange用户elrobis转换为Well Known Text格式。

##许可

所有代码均采用MIT许可证

请参阅我为何贡献开源软件

数据文件src/polygons.properties在Creative Commons Attribution-Share Alike License下可用,符合https://github.com/bencampion/reverse-country-code的许可协议