Skip to content

Commit c51cbae

Browse files
committed
parser ellipsoid set update
1 parent c64b01f commit c51cbae

2 files changed

Lines changed: 99 additions & 16 deletions

File tree

src/main/java/mil/nga/proj/CRSParser.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import mil.nga.crs.geo.TriaxialEllipsoid;
2525
import mil.nga.crs.projected.MapProjection;
2626
import mil.nga.crs.projected.MapProjectionMethod;
27-
import mil.nga.crs.projected.MapProjectionMethods;
2827
import mil.nga.crs.projected.MapProjectionParameter;
2928
import mil.nga.crs.projected.ProjectedCoordinateReferenceSystem;
3029
import mil.nga.crs.wkt.CRSReader;
@@ -143,8 +142,11 @@ public static CoordinateReferenceSystem convert(
143142
DatumParameters datumParameters = new DatumParameters();
144143

145144
MapProjectionMethod method = mapProjection.getMethod();
146-
if (method != null && method
147-
.getMethod() == MapProjectionMethods.POPULAR_VISUALISATION_PSEUDO_MERCATOR) {
145+
if (projected.hasIdentifiers()
146+
&& projected.getIdentifier(0).getNameAndUniqueIdentifier()
147+
.equalsIgnoreCase(ProjectionConstants.AUTHORITY_EPSG
148+
+ ":"
149+
+ ProjectionConstants.EPSG_WEB_MERCATOR)) {
148150
datumParameters.setA(ellipsoid.getA());
149151
datumParameters.setES(0);
150152
} else {

src/test/java/mil/nga/proj/ProjectionFactoryEpsgTest.java

Lines changed: 94 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ public void clear() {
4040
@Test
4141
public void test3035() {
4242

43+
final long code = 3035;
44+
4345
String definition = "PROJCRS[\"ETRS89-extended / LAEA Europe\",BASEGEOGCRS[\"ETRS89\","
4446
+ "ENSEMBLE[\"European Terrestrial Reference System 1989 ensemble\","
4547
+ "MEMBER[\"European Terrestrial Reference Frame 1989\",ID[\"EPSG\",1178]],"
@@ -64,7 +66,7 @@ public void test3035() {
6466
+ "AXIS[\"Northing (Y)\",north],AXIS[\"Easting (X)\",east],"
6567
+ "LENGTHUNIT[\"metre\",1,ID[\"EPSG\",9001]],ID[\"EPSG\",3035]]";
6668

67-
projectionTestDerived(3035, definition);
69+
projectionTestDerived(code, definition);
6870

6971
definition = "PROJCS[\"ETRS89 / ETRS-LAEA\",GEOGCS[\"ETRS89\","
7072
+ "DATUM[\"European_Terrestrial_Reference_System_1989\","
@@ -84,7 +86,7 @@ public void test3035() {
8486
+ "AUTHORITY[\"EPSG\",\"3035\"],"
8587
+ "AXIS[\"X\",EAST],AXIS[\"Y\",NORTH]]";
8688

87-
projectionTestDerived(3035, definition);
89+
projectionTestDerived(code, definition);
8890

8991
definition = "PROJCS[\"ETRS89 / LAEA Europe\",GEOGCRS[\"ETRS89\","
9092
+ "DATUM[\"European_Terrestrial_Reference_System_1989\","
@@ -103,7 +105,80 @@ public void test3035() {
103105
+ "UNIT[\"metre\",1,ID[\"EPSG\",\"9001\"]],"
104106
+ "ID[\"EPSG\",\"3035\"]]";
105107

106-
projectionTestDerived(3035, definition);
108+
projectionTestDerived(code, definition);
109+
110+
}
111+
112+
/**
113+
* Test EPSG 3395
114+
*/
115+
@Test
116+
public void test3395() {
117+
118+
final long code = 3395;
119+
120+
String definition = "PROJCRS[\"WGS 84 / World Mercator\",BASEGEOGCRS[\"WGS 84\","
121+
+ "ENSEMBLE[\"World Geodetic System 1984 ensemble\","
122+
+ "MEMBER[\"World Geodetic System 1984 (Transit)\",ID[\"EPSG\",1166]],"
123+
+ "MEMBER[\"World Geodetic System 1984 (G730)\",ID[\"EPSG\",1152]],"
124+
+ "MEMBER[\"World Geodetic System 1984 (G873)\",ID[\"EPSG\",1153]],"
125+
+ "MEMBER[\"World Geodetic System 1984 (G1150)\",ID[\"EPSG\",1154]],"
126+
+ "MEMBER[\"World Geodetic System 1984 (G1674)\",ID[\"EPSG\",1155]],"
127+
+ "MEMBER[\"World Geodetic System 1984 (G1762)\",ID[\"EPSG\",1156]],"
128+
+ "ELLIPSOID[\"WGS 84\",6378137,298.257223563,ID[\"EPSG\",7030]],"
129+
+ "ENSEMBLEACCURACY[2],ID[\"EPSG\",6326]],ID[\"EPSG\",4326]],"
130+
+ "CONVERSION[\"World Mercator\",METHOD[\"Mercator (variant A)\",ID[\"EPSG\",9804]],"
131+
+ "PARAMETER[\"Latitude of natural origin\",0,ANGLEUNIT[\"degree\",0.0174532925199433,ID[\"EPSG\",9102]]],"
132+
+ "PARAMETER[\"Longitude of natural origin\",0,ANGLEUNIT[\"degree\",0.0174532925199433,ID[\"EPSG\",9102]]],"
133+
+ "PARAMETER[\"Scale factor at natural origin\",1,SCALEUNIT[\"unity\",1,ID[\"EPSG\",9201]]],"
134+
+ "PARAMETER[\"False easting\",0,LENGTHUNIT[\"metre\",1,ID[\"EPSG\",9001]]],"
135+
+ "PARAMETER[\"False northing\",0,LENGTHUNIT[\"metre\",1,ID[\"EPSG\",9001]]],"
136+
+ "ID[\"EPSG\",19883]],CS[Cartesian,2,ID[\"EPSG\",4400]],"
137+
+ "AXIS[\"Easting (E)\",east],AXIS[\"Northing (N)\",north],"
138+
+ "LENGTHUNIT[\"metre\",1,ID[\"EPSG\",9001]],ID[\"EPSG\",3395]]";
139+
140+
projectionTestDerived(code, definition);
141+
142+
definition = "PROJCS[\"WGS 84 / World Mercator\",GEOGCS[\"WGS 84\","
143+
+ "DATUM[\"WGS_1984\","
144+
+ "SPHEROID[\"WGS 84\",6378137,298.257223563,"
145+
+ "AUTHORITY[\"EPSG\",\"7030\"]],"
146+
+ "AUTHORITY[\"EPSG\",\"6326\"]],"
147+
+ "PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],"
148+
+ "UNIT[\"degree\",0.01745329251994328,"
149+
+ "AUTHORITY[\"EPSG\",\"9122\"]],"
150+
+ "AUTHORITY[\"EPSG\",\"4326\"]],"
151+
+ "UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],"
152+
+ "PROJECTION[\"Mercator_1SP\"],"
153+
+ "PARAMETER[\"central_meridian\",0],"
154+
+ "PARAMETER[\"scale_factor\",1],"
155+
+ "PARAMETER[\"false_easting\",0],"
156+
+ "PARAMETER[\"false_northing\",0],"
157+
+ "AUTHORITY[\"EPSG\",\"3395\"],"
158+
+ "AXIS[\"Easting\",EAST],AXIS[\"Northing\",NORTH]]";
159+
160+
projectionTestDerived(code, definition);
161+
162+
definition = "PROJCRS[\"WGS 84 / World Mercator\","
163+
+ "BASEGEODCRS[\"WGS 84\","
164+
+ "DATUM[\"World Geodetic System 1984\","
165+
+ "ELLIPSOID[\"WGS 84\",6378137,298.257223563]]],"
166+
+ "CONVERSION[\"Mercator\","
167+
+ "METHOD[\"Mercator (variant A)\",ID[\"EPSG\",\"9804\"]],"
168+
+ "PARAMETER[\"Latitude of natural origin\",0,"
169+
+ "ANGLEUNIT[\"degree\",0.0174532925199433]],"
170+
+ "PARAMETER[\"Longitude of natural origin\",0,"
171+
+ "ANGLEUNIT[\"degree\",0.0174532925199433]],"
172+
+ "PARAMETER[\"Scale factor at natural origin\",1,"
173+
+ "SCALEUNIT[\"unity\",1.0]],"
174+
+ "PARAMETER[\"False easting\",0,LENGTHUNIT[\"metre\",1.0]],"
175+
+ "PARAMETER[\"False northing\",0,LENGTHUNIT[\"metre\",1.0]],"
176+
+ "ID[\"EPSG\",\"19833\"]],CS[Cartesian,2],"
177+
+ "AXIS[\"Easting (E)\",east,ORDER[1]],"
178+
+ "AXIS[\"Northing (N)\",north,ORDER[2]],"
179+
+ "LENGTHUNIT[\"metre\",1.0],ID[\"EPSG\",\"3395\"]]";
180+
181+
projectionTestDerived(code, definition);
107182

108183
}
109184

@@ -113,6 +188,8 @@ public void test3035() {
113188
@Test
114189
public void test3857() {
115190

191+
final long code = 3857;
192+
116193
String definition = "PROJCRS[\"WGS 84 / Pseudo-Mercator\",BASEGEOGCRS[\"WGS 84\","
117194
+ "ENSEMBLE[\"World Geodetic System 1984 ensemble\","
118195
+ "MEMBER[\"World Geodetic System 1984 (Transit)\",ID[\"EPSG\",1166]],"
@@ -133,7 +210,7 @@ public void test3857() {
133210
+ "AXIS[\"Easting (X)\",east],AXIS[\"Northing (Y)\",north],"
134211
+ "LENGTHUNIT[\"metre\",1,ID[\"EPSG\",9001]],ID[\"EPSG\",3857]]";
135212

136-
projectionTestDerived(3857, definition);
213+
projectionTestDerived(code, definition);
137214

138215
definition = "PROJCS[\"WGS 84 / Pseudo-Mercator\",GEOGCS[\"WGS 84\","
139216
+ "DATUM[\"WGS_1984\","
@@ -154,7 +231,7 @@ public void test3857() {
154231
+ "EXTENSION[\"PROJ4\",\"+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs\"],"
155232
+ "AUTHORITY[\"EPSG\",\"3857\"]]";
156233

157-
projectionTestDerived(3857, definition);
234+
projectionTestDerived(code, definition);
158235

159236
definition = "PROJCS[\"WGS 84 / Pseudo-Mercator\","
160237
+ "GEOGCRS[\"WGS 84\",DATUM[\"WGS_1984\","
@@ -172,7 +249,7 @@ public void test3857() {
172249
+ ",AXIS[\"X\",EAST],AXIS[\"Y\",NORTH]"
173250
+ ",ID[\"EPSG\",\"3857\"]]";
174251

175-
projectionTestDerived(3857, definition);
252+
projectionTestDerived(code, definition);
176253

177254
}
178255

@@ -182,6 +259,8 @@ public void test3857() {
182259
@Test
183260
public void test4326() {
184261

262+
final long code = 4326;
263+
185264
String definition = "GEOGCRS[\"WGS 84\",ENSEMBLE[\"World Geodetic System 1984 ensemble\","
186265
+ "MEMBER[\"World Geodetic System 1984 (Transit)\",ID[\"EPSG\",1166]],"
187266
+ "MEMBER[\"World Geodetic System 1984 (G730)\",ID[\"EPSG\",1152]],"
@@ -196,7 +275,7 @@ public void test4326() {
196275
+ "ANGLEUNIT[\"degree\",0.0174532925199433,ID[\"EPSG\",9102]],"
197276
+ "ID[\"EPSG\",4326]]";
198277

199-
projectionTestDerived(4326, definition);
278+
projectionTestDerived(code, definition);
200279

201280
definition = "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\","
202281
+ "SPHEROID[\"WGS 84\",6378137,298.257223563,"
@@ -207,14 +286,14 @@ public void test4326() {
207286
+ "AUTHORITY[\"EPSG\",\"9122\"]],"
208287
+ "AUTHORITY[\"EPSG\",\"4326\"]]";
209288

210-
projectionTestDerived(4326, definition);
289+
projectionTestDerived(code, definition);
211290

212291
definition = "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\","
213292
+ "SPHEROID[\"WGS84\",6378137,298.257223563]],"
214293
+ "PRIMEM[\"Greenwich\",0],"
215294
+ "UNIT[\"degree\",0.0174532925199433]]";
216295

217-
projectionTestSpecified(4326, definition);
296+
projectionTestSpecified(code, definition);
218297

219298
}
220299

@@ -224,6 +303,8 @@ public void test4326() {
224303
@Test
225304
public void test4979() {
226305

306+
final long code = 4979;
307+
227308
String definition = "GEOGCRS[\"WGS 84\",ENSEMBLE[\"World Geodetic System 1984 ensemble\","
228309
+ "MEMBER[\"World Geodetic System 1984 (Transit)\",ID[\"EPSG\",1166]],"
229310
+ "MEMBER[\"World Geodetic System 1984 (G730)\",ID[\"EPSG\",1152]],"
@@ -238,7 +319,7 @@ public void test4979() {
238319
+ "AXIS[\"Geodetic longitude (Lon)\",east,ANGLEUNIT[\"degree\",0.0174532925199433,ID[\"EPSG\",9102]]],"
239320
+ "AXIS[\"Ellipsoidal height (h)\",up,LENGTHUNIT[\"metre\",1,ID[\"EPSG\",9001]]],ID[\"EPSG\",4979]]";
240321

241-
projectionTestDerived(4979, definition);
322+
projectionTestDerived(code, definition);
242323

243324
definition = "GEOGCS[\"WGS 84\","
244325
+ "DATUM[\"World Geodetic System 1984\","
@@ -252,7 +333,7 @@ public void test4979() {
252333
+ "AXIS[\"Ellipsoidal height\",UP],"
253334
+ "AUTHORITY[\"EPSG\",\"4979\"]]";
254335

255-
projectionTestDerived(4979, definition);
336+
projectionTestDerived(code, definition);
256337

257338
definition = "GEODCRS[\"WGS 84\",DATUM[\"World Geodetic System 1984\","
258339
+ "ELLIPSOID[\"WGS 84\",6378137,298.257223563,"
@@ -264,7 +345,7 @@ public void test4979() {
264345
+ "AXIS[\"Ellipsoidal height (h)\",up,"
265346
+ "LENGTHUNIT[\"metre\",1.0]],ID[\"EPSG\",4979]]";
266347

267-
projectionTestDerived(4979, definition);
348+
projectionTestDerived(code, definition);
268349

269350
}
270351

@@ -501,7 +582,7 @@ private void compare(Projection projection, Projection projection2) {
501582

502583
assertEquals(proj.getAlpha(), proj2.getAlpha(), 0);
503584
assertEquals(proj.getAxisOrder(), proj2.getAxisOrder());
504-
//assertEquals(proj.getEPSGCode(), proj2.getEPSGCode(), 0);
585+
// assertEquals(proj.getEPSGCode(), proj2.getEPSGCode(), 0);
505586
assertEquals(proj.getEquatorRadius(), proj2.getEquatorRadius(), 0);
506587
assertEquals(proj.getFalseEasting(), proj2.getFalseEasting(), 0);
507588
assertEquals(proj.getFalseNorthing(), proj2.getFalseNorthing(), 0);

0 commit comments

Comments
 (0)