定制 wimski/nominatim-geocoding-api-client 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

wimski/nominatim-geocoding-api-client

Composer 安装命令:

composer require wimski/nominatim-geocoding-api-client

包简介

Nominatim Geocoding API Client

README 文档

README

Latest Stable Version Coverage Status PHPUnit PHPStan

Nominatim Geocoding API Client

Changelog

View the changelog.

Usage

Install package

composer require wimski/nominatim-geocoding-api-client

Example

use Wimski\Nominatim\Client;
use Wimski\Nominatim\Config\NominatimConfig;
use Wimski\Nominatim\GeocoderServices\NominatimGeocoderService;
use Wimski\Nominatim\RequestParameters\ForwardGeocodingQueryRequestParameters;
use Wimski\Nominatim\Transformers\GeocodingResponseTransformer;

$config = new NominatimConfig(
    'my-custom-user-agent',
    'email@provider.net',
);

$service = new NominatimGeocoderService(
    new Client(),
    new GeocodingResponseTransformer(),
    $config,
);

$requestParameters = ForwardGeocodingQueryRequestParameters::make('some query')
    ->addCountryCode('nl')
    ->includeAddressDetails();

$response = $service->requestForwardGeocoding($requestParameters);

// Get data from the response
$latitude = $response->getItems()[0]->getCoordinate()->getLatitude();

PSR HTTP

The Client class uses Discovery by default to get instances of the following contracts:

  • Psr\Http\Client\ClientInterface
  • Psr\Http\Message\RequestFactoryInterface
  • Psr\Http\Message\UriFactoryInterface

This means that you need to include (a) PSR compatible package(s) in your project.

If you already have setup a specific HTTP client configuration in your project, which you would also like to use for Nominatim requests, you can pass that as a constructor argument to the Client:

$service = new NominatimGeocoderService(
    new Client($myCustomPsrHttpClient),
    new GeocodingResponseTransformer(),
    new NominatimConfig('user-agent', 'email@provider.net'),
);

Services

Services for the following providers are currently available:

Custom services can easily be created by extending the AbstractGeocoderService as long as the provider implements the Nominatim spec correctly.

PHPUnit

composer run phpunit

PHPStan

composer run phpstan

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 3.82k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-02-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固