Skip to content

Commit 7e163d5

Browse files
authored
Add integer function to EPSG and ESRI types (#333)
1 parent 525c1be commit 7e163d5

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

src/codes.jl

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ See also [`EPSG`](@ref), [`ESRI`](@ref).
1111
"""
1212
abstract type CRSCode end
1313

14+
"""
15+
CoordRefSystems.integer(::Type{<:CRSCode})
16+
17+
Get the integer code associated with the `CRSCode` type.
18+
"""
19+
function integer end
20+
1421
"""
1522
EPSG{code}
1623
@@ -21,12 +28,7 @@ See [EPSG Geodetic Parameter Dataset](https://en.wikipedia.org/wiki/EPSG_Geodeti
2128
"""
2229
abstract type EPSG{Code} <: CRSCode end
2330

24-
"""
25-
ESRI{code}
26-
27-
ESRI dataset `code`. Codes can be searched at [epsg.io](https://epsg.io).
28-
"""
29-
abstract type ESRI{Code} <: CRSCode end
31+
integer(::Type{EPSG{Code}}) where {Code} = Code
3032

3133
function wkt2(::Type{EPSG{Code}}) where {Code}
3234
epsg = joinpath(pkgdir(@__MODULE__), "artifacts", "epsg-wkt2")
@@ -50,6 +52,15 @@ function wkt2(::Type{EPSG{Code}}) where {Code}
5052
str
5153
end
5254

55+
"""
56+
ESRI{code}
57+
58+
ESRI dataset `code`. Codes can be searched at [epsg.io](https://epsg.io).
59+
"""
60+
abstract type ESRI{Code} <: CRSCode end
61+
62+
integer(::Type{ESRI{Code}}) where {Code} = Code
63+
5364
function wkt2(::Type{ESRI{Code}}) where {Code}
5465
throw(ArgumentError("""
5566
OGC WKT-CRS version 2 does not support ESRI:$Code.

test/codes.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@testset "Codes" begin
2+
@test CoordRefSystems.integer(EPSG{4326}) == 4326
3+
@test CoordRefSystems.integer(ESRI{102100}) == 102100
4+
end

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ testfiles = [
7171
"crs/traits.jl",
7272

7373
# EPSG/ESRI codes
74+
"codes.jl",
7475
"get.jl",
7576

7677
# WKT strings

0 commit comments

Comments
 (0)