Skip to content

Commit d81f4aa

Browse files
committed
Add Projection.getEpsg() method to get epsg/srid code as integer
1 parent 7e04c5f commit d81f4aa

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/main/groovy/geoscript/proj/Projection.groovy

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ class Projection {
7070
return CRS.lookupIdentifier(crs, true)
7171
}
7272

73+
/**
74+
* Get the EPSG code
75+
* @return The EPSG code
76+
*/
77+
int getEpsg() {
78+
CRS.lookupEpsgCode(crs, true)
79+
}
80+
7381
/**
7482
* Get the well known text
7583
* @return The well known texts

src/test/groovy/geoscript/proj/ProjectionTestCase.groovy

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ class ProjectionTestCase {
3232
assertEquals "EPSG:2927", p1.id
3333
}
3434

35+
@Test void getEpsg() {
36+
Projection p = new Projection("EPSG:2927")
37+
assertEquals 2927, p.epsg
38+
p = new Projection("EPSG:4326")
39+
assertEquals 4326, p.epsg
40+
p = new Projection("EPSG:3857")
41+
assertEquals 3857, p.epsg
42+
}
43+
3544
@Test void getWkt() {
3645
Projection p1 = new Projection("EPSG:4326")
3746

0 commit comments

Comments
 (0)