getSupportedSRIDsWithHelp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * PHPCoord.
5
 *
6
 * @author Doug Wright
7
 */
8
declare(strict_types=1);
9
10
namespace PHPCoord\CoordinateReferenceSystem;
11
12
use PHPCoord\CoordinateSystem\CoordinateSystem;
13
use PHPCoord\Datum\Datum;
14
use PHPCoord\Exception\UnknownCoordinateReferenceSystemException;
15
use PHPCoord\Geometry\BoundingArea;
16
17
use function array_merge;
18
19
abstract class CoordinateReferenceSystem
20
{
21
    public const CRS_TYPE_COMPOUND = 'compound';
22
23
    public const CRS_TYPE_DERIVED = 'derived';
24
25
    public const CRS_TYPE_DYNAMIC_GEOCENTRIC = 'dynamic geocentric';
26
27
    public const CRS_TYPE_DYNAMIC_GEOGRAPHIC_2D = 'dynamic geographic 2D';
28
29
    public const CRS_TYPE_DYNAMIC_GEOGRAPHIC_3D = 'dynamic geographic 3D';
30
31
    public const CRS_TYPE_DYNAMIC_VERTICAL = 'dynamic vertical';
32
33
    public const CRS_TYPE_ENGINEERING = 'engineering';
34
35
    public const CRS_TYPE_GEOCENTRIC = 'geocentric';
36
37
    public const CRS_TYPE_GEOGRAPHIC_2D = 'geographic 2D';
38
39
    public const CRS_TYPE_GEOGRAPHIC_3D = 'geographic 3D';
40
41
    public const CRS_TYPE_PROJECTED = 'projected';
42
43
    public const CRS_TYPE_VERTICAL = 'vertical';
44
45
    public const CRS_SRID_PREFIX_EPSG = 'urn:ogc:def:crs:EPSG::';
46
47
    protected string $srid;
48
49
    protected string $name;
50
51
    protected CoordinateSystem $coordinateSystem;
52
53
    protected Datum $datum;
54
55
    protected BoundingArea $boundingArea;
56
57
    /**
58
     * @var array<string, Compound|Geocentric|Geographic2D|Geographic3D|Projected|Vertical>
59
     */
60
    private static array $cachedObjects = [
61
    ];
62
63 1687
    public function getSRID(): string
64
    {
65 1687
        return $this->srid;
66
    }
67
68 72
    public function getName(): string
69
    {
70 72
        return $this->name;
71
    }
72
73 2369
    public function getCoordinateSystem(): CoordinateSystem
74
    {
75 2369
        return $this->coordinateSystem;
76
    }
77
78 1599
    public function getDatum(): Datum
79
    {
80 1599
        return $this->datum;
81
    }
82
83 274
    public function getBoundingArea(): BoundingArea
84
    {
85 274
        return $this->boundingArea;
86
    }
87
88 363
    public static function fromSRID(string $srid): Compound|Geocentric|Geographic2D|Geographic3D|Projected|Vertical
89
    {
90 363
        if (!isset(self::$cachedObjects[$srid])) {
91
            try {
92 254
                self::$cachedObjects[$srid] = Projected::fromSRID($srid);
93 200
            } catch (UnknownCoordinateReferenceSystemException) {
94
                try {
95 200
                    self::$cachedObjects[$srid] = Geographic2D::fromSRID($srid);
96 155
                } catch (UnknownCoordinateReferenceSystemException) {
97
                    try {
98 155
                        self::$cachedObjects[$srid] = Geographic3D::fromSRID($srid);
99 154
                    } catch (UnknownCoordinateReferenceSystemException) {
100
                        try {
101 154
                            self::$cachedObjects[$srid] = Geocentric::fromSRID($srid);
102 11
                        } catch (UnknownCoordinateReferenceSystemException) {
103
                            try {
104 11
                                self::$cachedObjects[$srid] = Vertical::fromSRID($srid);
105 1
                            } catch (UnknownCoordinateReferenceSystemException) {
106
                                try {
107 1
                                    self::$cachedObjects[$srid] = Compound::fromSRID($srid);
108
                                } catch (UnknownCoordinateReferenceSystemException) {
109
                                    throw new UnknownCoordinateReferenceSystemException($srid);
110
                                }
111
                            }
112
                        }
113
                    }
114
                }
115
            }
116
        }
117
118 363
        return self::$cachedObjects[$srid];
119
    }
120
121
    /**
122
     * @return array<string, string>
123
     */
124
    public static function getSupportedSRIDs(): array
125
    {
126
        return array_merge(Compound::getSupportedSRIDs(), Geocentric::getSupportedSRIDs(), Geographic2D::getSupportedSRIDs(), Geographic3D::getSupportedSRIDs(), Projected::getSupportedSRIDs(), Vertical::getSupportedSRIDs());
127
    }
128
129
    /**
130
     * @return array<string, array{name: string, extent_description: string, help: string}>
131
     */
132
    public static function getSupportedSRIDsWithHelp(): array
133
    {
134
        return array_merge(Compound::getSupportedSRIDsWithHelp(), Geocentric::getSupportedSRIDsWithHelp(), Geographic2D::getSupportedSRIDsWithHelp(), Geographic3D::getSupportedSRIDsWithHelp(), Projected::getSupportedSRIDsWithHelp(), Vertical::getSupportedSRIDsWithHelp());
135
    }
136
}
137