nikop/wmts-tile-downloader
最新稳定版本:1.0.3
Composer 安装命令:
composer require nikop/wmts-tile-downloader
包简介
README 文档
README
This library provides very basic functionality for downloading Tile layers from a WMTS server. Your goal is to implement the DownloaderInterface with you logic with your logic and pass it to the WMTSTileDownloader class constructor when creating an object from it.
Data about the tile will be passed to the download method, and then you decide what to do.
int $x, int $y, int $z, int $counter
Example
use WMTSTileDownloader\Downloader\BasicDownloader; use WMTSTileDownloader\Helpers\Mercator; use WMTSTileDownloader\Types\LatLng; use WMTSTileDownloader\Types\ZoomLevel; use WMTSTileDownloader\WMTSTileDownloader; require 'vendor/autoload.php'; $downloader = new WMTSTileDownloader(mercator: new Mercator(), downloader: new BasicDownloader(saveTo: '/path/to/directory/for/storing/files')); $nw = new LatLng(59.977005492196, -12.2607421875); $se = new LatLng(49.610709938074, 1.93359375); $downloader->generateFromLatLongs(northWest: $nw, southEast: $se, zoomLevel: new ZoomLevel(9));
The library comes with an example BasicDownloader
<?php declare(strict_types=1); namespace WMTSTileDownloader\Downloader; use GuzzleHttp\Client; use GuzzleHttp\Exception\GuzzleException; final readonly class BasicDownloader implements DownloaderInterface { public function __construct(private string $saveTo) { } /** * @throws GuzzleException */ public function download(int $x, int $y, int $z, int $counter): bool { $url = 'https://tile.openstreetmap.org/'.$z.'/'.$x.'/'.$y.'.png'; $this->downloadFile($url,$z.'_'.$x.'_'.$y,'.png'); return true; } /** * @throws GuzzleException */ public function downloadFile(string $url, string $name, string $extensions): void { $path = rtrim($this->saveTo,'/').'/' . $name . $extensions; $client = new Client(); $client->get($url, ['sink' => $path]); } }
class that implements the DownloaderInterface It is just for example purposes, but in many cases, it may be the only thing that you need: just download tiles in a folder.
统计信息
- 总下载量: 8
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-06-12