承接 riverside/php-nominatim 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

riverside/php-nominatim

最新稳定版本:2.0.0

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
CI Latest Stable Version 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"
    }
}

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

统计信息

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

GitHub 信息

  • Stars: 12
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-01-06