Skip to content

Commit 0263bd1

Browse files
committed
Drop PHP8.1
1 parent a577aab commit 0263bd1

9 files changed

Lines changed: 98 additions & 41307 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ jobs:
1919
- "8.4"
2020
- "8.3"
2121
- "8.2"
22-
- "8.1"
2322

2423
dependencies:
2524
- "highest"
@@ -122,10 +121,8 @@ jobs:
122121
123122
- name: PHPUnit (Unit)
124123
run: |
125-
if [ "${{ matrix.php-version }}" = "8.2" ] && [ "${{ matrix.dependencies }}" = "highest" ]; then
124+
if [ "${{ matrix.php-version }}" = "8.5" ] && [ "${{ matrix.dependencies }}" = "highest" ]; then
126125
php -dmemory_limit=-1 vendor/phpunit/phpunit/phpunit --exclude-group=integration --exclude-group=gigs;
127-
elif [ "${{ matrix.php-version }}" = "8.1" ] || [ "${{ matrix.dependencies }}" = "lowest" ]; then
128-
php -dmemory_limit=-1 vendor/phpunit/phpunit/phpunit --exclude-group=integration,gigs --no-coverage;
129126
else
130127
php -dmemory_limit=-1 vendor/phpunit/phpunit/phpunit --exclude-group=integration --exclude-group=gigs --no-coverage;
131128
fi;

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
],
1313
"license": "(MIT and proprietary)",
1414
"require": {
15-
"php": "^8.1",
15+
"php": "^8.2",
1616
"ext-zip": "*",
1717
"composer-runtime-api": "^2.1",
1818
"composer/pcre": "^3.3.2",
@@ -21,8 +21,8 @@
2121
"require-dev": {
2222
"ext-json": "*",
2323
"ext-sqlite3": "*",
24-
"friendsofphp/php-cs-fixer": "^3.90",
25-
"nikic/php-parser": "^5.6.2",
24+
"friendsofphp/php-cs-fixer": "^3.93",
25+
"nikic/php-parser": "^5.7",
2626
"php-coord/datapack-africa": "dev-master",
2727
"php-coord/datapack-antarctic": "dev-master",
2828
"php-coord/datapack-arctic": "dev-master",
@@ -32,7 +32,7 @@
3232
"php-coord/datapack-oceania": "dev-master",
3333
"php-coord/datapack-southamerica": "dev-master",
3434
"phpstan/phpstan": "^1.12",
35-
"phpunit/phpunit": "^10.5.58||^11.5.44"
35+
"phpunit/phpunit": "^11.5.44"
3636
},
3737
"suggest": {
3838
"php-coord/datapack-africa": "High-accuracy addon datapack for Africa",

src/CoordinateOperation/OSTNOSGM15Grid.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ private function getRecord(int $eastIndex, int $northIndex): GridValues
9292

9393
$this->gridFile->seek($record);
9494
/** @var array<int, string> $rawData */
95-
$rawData = $this->gridFile->fgetcsv();
95+
$rawData = $this->gridFile->fgetcsv(escape: '');
9696

9797
return new GridValues((float) $rawData[1], (float) $rawData[2], [(float) $rawData[3], (float) $rawData[4], (float) $rawData[5]]);
9898
}

src/CoordinateReferenceSystem/Projected.php

Lines changed: 91 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,101 @@
99

1010
namespace PHPCoord\CoordinateReferenceSystem;
1111

12-
use function version_compare;
12+
use PHPCoord\CoordinateSystem\Cartesian;
13+
use PHPCoord\CoordinateSystem\CoordinateSystem;
14+
use PHPCoord\Datum\Datum;
15+
use PHPCoord\Exception\UnknownCoordinateReferenceSystemException;
16+
use PHPCoord\Geometry\BoundingArea;
1317

14-
use const PHP_VERSION;
18+
use function assert;
19+
use function count;
20+
use function array_map;
1521

16-
if (version_compare(PHP_VERSION, '8.2.0', '>=')) {
17-
class Projected extends Projected82
22+
class Projected extends CoordinateReferenceSystem
23+
{
24+
use ProjectedConstantsChunk1;
25+
use ProjectedConstantsChunk2;
26+
use ProjectedConstantsChunk3;
27+
use ProjectedConstantsChunk4;
28+
use ProjectedSRIDData;
29+
30+
protected Geographic2D|Geographic3D $baseCRS;
31+
32+
protected ?string $derivingConversion;
33+
34+
/**
35+
* @var array<string, Projected>
36+
*/
37+
private static array $cachedObjects = [
38+
];
39+
40+
public function __construct(string $srid, CoordinateSystem $coordinateSystem, Datum $datum, BoundingArea $boundingArea, string $name = '', Geographic2D|Geographic3D|null $baseCRS = null, ?string $derivingConversion = null)
1841
{
42+
$this->srid = $srid;
43+
$this->coordinateSystem = $coordinateSystem;
44+
$this->datum = $datum;
45+
$this->boundingArea = $boundingArea;
46+
$this->name = $name;
47+
$this->baseCRS = $baseCRS ?? Geographic2D::fromSRID(Geographic2D::EPSG_WGS_84);
48+
$this->derivingConversion = $derivingConversion;
49+
assert(count($coordinateSystem->getAxes()) === 2 || count($coordinateSystem->getAxes()) === 3);
1950
}
20-
} else {
21-
class Projected extends Projected81
51+
52+
public function getBaseCRS(): Geographic2D|Geographic3D
53+
{
54+
return $this->baseCRS;
55+
}
56+
57+
public function getDerivingConversion(): string
58+
{
59+
return $this->derivingConversion;
60+
}
61+
62+
public static function fromSRID(string $srid): self
63+
{
64+
if (!isset(static::$sridData[$srid])) {
65+
throw new UnknownCoordinateReferenceSystemException($srid);
66+
}
67+
if (!isset(self::$cachedObjects[$srid])) {
68+
$data = static::$sridData[$srid];
69+
$baseCRS = Geographic::fromSRID($data['base_crs']);
70+
$extent = $data['extent'] instanceof BoundingArea ? $data['extent'] : BoundingArea::createFromExtentCodes($data['extent']);
71+
self::$cachedObjects[$srid] = new self($srid, Cartesian::fromSRID($data['coordinate_system']), $baseCRS->getDatum(), $extent, $data['name'], $baseCRS, $data['deriving_conversion']);
72+
}
73+
74+
return self::$cachedObjects[$srid];
75+
}
76+
77+
/**
78+
* @return array<string, string>
79+
*/
80+
public static function getSupportedSRIDs(): array
81+
{
82+
return array_map(static fn (array $data) => $data['name'], static::$sridData);
83+
}
84+
85+
/**
86+
* @return array<string, array{name: string, extent_description: string, help: string}>
87+
*/
88+
public static function getSupportedSRIDsWithHelp(): array
89+
{
90+
return array_map(static fn (array $data) => [
91+
'name' => $data['name'],
92+
'extent_description' => $data['name'],
93+
'help' => $data['help'],
94+
], static::$sridData);
95+
}
96+
97+
public static function registerCustomCRS(string $srid, string $name, string $baseCRSSrid, string $derivingConversionSrid, string $coordinateSystemSrid, BoundingArea $extent, string $help = ''): void
2298
{
99+
self::$sridData[$srid] = [
100+
'name' => $name,
101+
'coordinate_system' => $coordinateSystemSrid,
102+
'base_crs' => $baseCRSSrid,
103+
'deriving_conversion' => $derivingConversionSrid,
104+
'extent' => $extent,
105+
'extent_description' => '',
106+
'help' => $help,
107+
];
23108
}
24109
}

0 commit comments

Comments
 (0)