riverside/php-nominatim
Composer 安装命令:
composer require riverside/php-nominatim
包简介
PHP client for Nominatim, a search engine for OpenStreetMap data.
README 文档
README
A PHP client for Nominatim, the search engine for OpenStreetMap data.
| Build | Stable | License |
|---|---|---|
Installation
- If Composer is already installed
composer require riverside/php-nominatim
- If Composer is not installed on your system yet, you may go ahead and install it using this command line:
$ curl -sS https://getcomposer.org/installer | php
Next, add the following require entry to the composer.json file in the root of your project.
{
"require" : {
"riverside/php-nominatim" : "^2.0.1"
}
}
Finally, use Composer to install php-nominatim and its dependencies:
$ php composer.phar install
Loading
require __DIR__ . '/vendor/autoload.php';
Search (geocoding)
Look up a location from a textual description or address.
$client = new \Riverside\Nominatim\Client(); try { $response = $client->search('Madison Square Garden, NY'); if ($response->isOK()) { echo $response->getLat(0) . ", " . $response->getLng(0); } else { echo 'Location not found.'; } } catch (InvalidArgumentException $e) { echo $e->getMessage(); } catch (Exception $e) { echo $e->getMessage(); }
Reverse geocoding
Generates an address from a latitude and longitude.
$client = new \Riverside\Nominatim\Client(); try { $response = $client->reverse(48.8539373, 2.2825966); if ($response->isOK()) { echo $response->getAddress(0); } else { echo 'Address not found'; } } catch (InvalidArgumentException $e) { echo $e->getMessage(); } catch (Exception $e) { echo $e->getMessage(); }
Address lookup
Query the address and other details of one or multiple OSM objects like node, way or relation.
$client = new \Riverside\Nominatim\Client(); try { $client->setAddressDetails(1); $response = $client->lookup('R146656,W104393803,N240109189'); if ($response->isOK()) { echo '<pre>'; print_r($response->toArray()); } else { echo 'Address not found'; } } catch (InvalidArgumentException $e) { echo $e->getMessage(); } catch (Exception $e) { echo $e->getMessage(); }
Place details
Show all details about a single place saved in the database.
$client = new \Riverside\Nominatim\Client(); try { $client->setAddressDetails(1); $response = $client->details(199375150); if ($response->isOK()) { echo '<pre>'; print_r($response->toArray()); } else { echo 'Place not found'; } } catch (InvalidArgumentException $e) { echo $e->getMessage(); } catch (Exception $e) { echo $e->getMessage(); }
Status
Check if the service and database is running, and when the database was last updated.
$client = new \Riverside\Nominatim\Client(); try { $response = $client->status(); if ($response->isOK()) { echo '<pre>'; print_r($response->toArray()); } else { echo 'Status not found'; } } catch (InvalidArgumentException $e) { echo $e->getMessage(); } catch (Exception $e) { echo $e->getMessage(); }
Deletable
List objects that have been deleted in OSM but are held back in Nominatim in case the deletion was accidental.
$client = new \Riverside\Nominatim\Client(); try { $response = $client->deletable(); if ($response->isOK()) { echo '<pre>'; print_r($response->toArray()); } else { echo 'Deletable objects not found'; } } catch (InvalidArgumentException $e) { echo $e->getMessage(); } catch (Exception $e) { echo $e->getMessage(); }
Polygons
List of broken polygons detected by Nominatim.
$client = new \Riverside\Nominatim\Client(); try { $response = $client->polygons(); if ($response->isOK()) { echo '<pre>'; print_r($response->toArray()); } else { echo 'Polygons not found'; } } catch (InvalidArgumentException $e) { echo $e->getMessage(); } catch (Exception $e) { echo $e->getMessage(); }
Links
riverside/php-nominatim 适用场景与选型建议
riverside/php-nominatim 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 27.68k 次下载、GitHub Stars 达 12, 最近一次更新时间为 2020 年 01 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「geocoding」 「nominatim」 「osm」 「OpenStreetMap」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 riverside/php-nominatim 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 riverside/php-nominatim 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 riverside/php-nominatim 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Maps in minutes. Powered by the Google Maps API.
Yii2 map input widget. Allows you to select geographcal coordinates via a human-friendly inteface.
GISCO Geocoding Provider for Geocoder PHP.
Integrates an OpenStreetMap tile proxy in TYPO3 for GDPR-compliant integration.
Nominatim Geocoding API Client
Laravel integration for Nominatim Geocoding API Client
统计信息
- 总下载量: 27.68k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 14
- 点击次数: 26
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-01-06