diff --git a/CHANGELOG.md b/CHANGELOG.md index 669021b81..1348f1b74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +## [5.8.0] - 2024-02-03 +### Added +- Support for compressed grid files to reduce distribution sizes + ## [5.7.0] - 2024-01-27 ### Changed - Updates to data for Canada, Denmark, France, Germany and USA @@ -317,8 +321,9 @@ Initial release of this fork (based off of v2.3 of original) - Eastings and northings are rounded to 1m, and lat/long to 5dp (approx 1m) to avoid any misconceptions that precision is the same thing as accuracy. - When calculating surface distances, a more accurate mean radius is now used rather than that derived from historical definitions of a nautical mile -[Unreleased]: https://github.com/dvdoug/PHPCoord/compare/v5.7.0..master +[Unreleased]: https://github.com/dvdoug/PHPCoord/compare/v5.8.0..master +[5.8.0]: https://github.com/dvdoug/PHPCoord/compare/v5.7.0..v5.8.0 [5.7.0]: https://github.com/dvdoug/PHPCoord/compare/v5.6.0..v5.7.0 [5.6.0]: https://github.com/dvdoug/PHPCoord/compare/v5.5.0..v5.6.0 [5.5.0]: https://github.com/dvdoug/PHPCoord/compare/v5.4.0..v5.5.0 diff --git a/composer.json b/composer.json index befb91449..5f2f5137c 100644 --- a/composer.json +++ b/composer.json @@ -13,6 +13,7 @@ "license": "(MIT and proprietary)", "require": { "php": "^8.0", + "ext-zip": "*", "composer-runtime-api": "^2.1", "composer/pcre": "^3.1", "opis/json-schema": "^2.3" diff --git a/src/CoordinateOperation/GridFile.php b/src/CoordinateOperation/GridFile.php index 6db963910..fa244b54f 100644 --- a/src/CoordinateOperation/GridFile.php +++ b/src/CoordinateOperation/GridFile.php @@ -9,14 +9,33 @@ namespace PHPCoord\CoordinateOperation; use SplFileObject; +use ZipArchive; use function assert; +use function file_exists; +use function sys_get_temp_dir; +use function str_ends_with; /** * @internal */ class GridFile extends SplFileObject { + public function __construct(string $filename) + { + if (str_ends_with($filename, '.zip')) { + $zip = new ZipArchive(); + $zip->open($filename); + $filename = sys_get_temp_dir() . '/' . $zip->getNameIndex(0); // only 1 file inside + + if (!file_exists($filename)) { + $zip->extractTo(sys_get_temp_dir()); + } + } + + parent::__construct($filename); + } + public function fgets(): string { $result = parent::fgets();