Recommend this page to a friend! |
Download .zip |
Info | Example | View files (18) | Download .zip | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2023-06-13 (3 months ago) | Not yet rated by the users | Total: 29 | All time: 10,894 This week: 111 |
Version | License | PHP version | Categories | |||
wmtstiledownloader 1.0 | MIT/X Consortium ... | 5 | PHP 5, Web services, Geography |
Description | Author | |
This package can download tiles of maps of a world region from WMTS. |
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
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.
Files |
File | Role | Description | ||
---|---|---|---|---|
src (1 file, 4 directories) | ||||
composer.json | Data | Auxiliary data | ||
composer.lock | Data | Auxiliary data | ||
phpstan.neon | Data | Auxiliary data | ||
readme.md | Doc. | Read me | ||
usage.php | Example | Example script |
Files | / | src |
File | Role | Description | ||
---|---|---|---|---|
Downloader (2 files) | ||||
Exceptions (4 files) | ||||
Helpers (2 files) | ||||
Types (4 files) | ||||
WMTSTileDownloader.php | Class | Class source |
Files | / | src | / | Downloader |
File | Role | Description |
---|---|---|
BasicDownloader.php | Class | Class source |
DownloaderInterface.php | Class | Class source |
Files | / | src | / | Exceptions |
File | Role | Description |
---|---|---|
InvalidLatitudeException.php | Class | Class source |
InvalidLongitudeException.php | Class | Class source |
InvalidTileXException.php | Class | Class source |
InvalidZoomLevelException.php | Class | Class source |
Files | / | src | / | Helpers |
File | Role | Description |
---|---|---|
Mercator.php | Class | Class source |
MercatorInterface.php | Class | Class source |
Files | / | src | / | Types |
File | Role | Description |
---|---|---|
LatLng.php | Class | Class source |
Point.php | Class | Class source |
Tile.php | Class | Class source |
ZoomLevel.php | Class | Class source |
wmtstiledownloader-2023-06-13.zip 16KB | |
wmtstiledownloader-2023-06-13.tar.gz 11KB | |
Install with Composer |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.