ministryofweb/php-osm-tiles
Composer 安装命令:
composer require ministryofweb/php-osm-tiles
包简介
A library to convert map tile numbers to coordinates and vice versa.
README 文档
README
This library helps to convert OpenStreetMap (OSM) map tile numbers to geographical coordinates and vice versa.
Installation
Using Composer, add it to your composer.json by running:
composer require ministryofweb/php-osm-tiles
Compatibility
The PHP OSM Tiles library requires PHP >= 8.1.
If support for older PHP versions is needed, the PHP OSM Tiles library can be installed at version 2.0 (PHP 7.3, PHP 7.4 and PHP 8.0), 1.0 (PHP 7.1 and PHP 7.2) or version 0.1.0 (PHP 7.0).
Usage/Examples
Convert from geographical coordinates to map tile numbers
<?php use MinistryOfWeb\OsmTiles\Converter; use MinistryOfWeb\OsmTiles\LatLng; $converter = new Converter(); $point = new LatLng(52.5, 13.4); $zoom = 13; $tile = $converter->toTile($point, $zoom); printf('/tiles/%d/%d/%d.png', $zoom, $tile->x, $tile->y);
The code above produces the output below:
/tiles/13/4400/2687.png
Convert from map tile numbers to geographical coordinates
<?php use MinistryOfWeb\OsmTiles\Converter; use MinistryOfWeb\OsmTiles\Tile; $converter = new Converter(); $tile = new Tile(4400, 2687, 13); $point = $converter->toLatLng($tile); printf('%.5f, %.5f', $point->lat, $point->lat);
The code above produces the output below:
52.50953, 13.35938
Get Bounds of a Tile
It's possible to get the coordinates for the Tiles north-western, north-eastern, south-eastern and south-western nodes:
<?php use MinistryOfWeb\OsmTiles\LatLng; use MinistryOfWeb\OsmTiles\Tile; use MinistryOfWeb\OsmTiles\TileBounds; $tile = Tile::fromLocation(new LatLng(52.5, 13.5)); echo 'South-eastern point for tile is located at: ' . TileBounds::getSouthEast($tile)->lat . ', ' . TileBounds::getSouthEast($tile)->lng . PHP_EOL;
The code above produces the output below:
South-eastern point for tile is located at: 52.496159531097, 13.51318359375
Run Tests
make test
or
./vendor/bin/phpunit
Run all CI tools
make ci
OpenStreetMap Map Tile Names Documentation
ministryofweb/php-osm-tiles 适用场景与选型建议
ministryofweb/php-osm-tiles 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.47k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2018 年 01 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「osm」 「location」 「coordinate」 「tile」 「OpenStreetMap」 「geographic」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ministryofweb/php-osm-tiles 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ministryofweb/php-osm-tiles 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ministryofweb/php-osm-tiles 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The official PHP library for apiip.net that allowing customers to automate IP address validation and geolocation lookup in websites, applications and back-office system. Visit our API docs at https://apiip.net/documentation
Integrates an OpenStreetMap tile proxy in TYPO3 for GDPR-compliant integration.
OSM - OpenStreetMap extension for TYPO3
Entry GPS Coordinates plugin for Craft CMS
A Symfony2 Bundle to handle geographic location of your entities
Works with Open Street Map .osm.pbf compressed files.
统计信息
- 总下载量: 4.47k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-01-30