Skip to content

Commit 414f895

Browse files
committed
ETRS89, ellipsoid names and reciprocal flattening, prime meridian names
1 parent 2567d52 commit 414f895

5 files changed

Lines changed: 55 additions & 48 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ Adheres to [Semantic Versioning](http://semver.org/).
77
## 1.1.1 (TBD)
88

99
* Java 11
10+
* ETRS89 GeoDatums enumeration
11+
* Additional included names in Ellipsoids
12+
* Ellipsoids saved reciprocal flattening value
13+
* Prime Meridians name capitalizations
1014

1115
## [1.1.0](https://github.com/ngageoint/coordinate-reference-systems-java/releases/tag/1.1.0) (10-14-2021)
1216

src/main/java/mil/nga/crs/geo/Ellipsoids.java

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package mil.nga.crs.geo;
22

3-
import java.util.Arrays;
3+
import java.util.ArrayList;
44
import java.util.HashMap;
55
import java.util.List;
66
import java.util.Map;
@@ -259,14 +259,8 @@ public enum Ellipsoids {
259259
nameTypes.put(type.getShortName().toLowerCase(), type);
260260
for (String name : type.getNames()) {
261261
String lowercaseName = name.toLowerCase();
262-
nameTypes.put(lowercaseName, type);
263-
int index = lowercaseName.indexOf("(");
264-
if (index > -1) {
265-
String namePrefix = lowercaseName.substring(0, index)
266-
.trim();
267-
if (!nameTypes.containsKey(namePrefix)) {
268-
nameTypes.put(namePrefix, type);
269-
}
262+
if (!nameTypes.containsKey(lowercaseName)) {
263+
nameTypes.put(lowercaseName, type);
270264
}
271265
}
272266
}
@@ -275,7 +269,7 @@ public enum Ellipsoids {
275269
/**
276270
* Names
277271
*/
278-
private final List<String> names;
272+
private final List<String> names = new ArrayList<>();
279273

280274
/**
281275
* Short name
@@ -292,6 +286,11 @@ public enum Ellipsoids {
292286
*/
293287
private final double poleRadius;
294288

289+
/**
290+
* Reciprocal flattening
291+
*/
292+
private final double reciprocalFlattening;
293+
295294
/**
296295
* Eccentricity
297296
*/
@@ -319,8 +318,16 @@ public enum Ellipsoids {
319318
private Ellipsoids(String shortName, double equatorRadius,
320319
double poleRadius, double reciprocalFlattening, String... names) {
321320
this.shortName = shortName;
322-
this.names = Arrays.asList(names);
323321
this.equatorRadius = equatorRadius;
322+
this.reciprocalFlattening = reciprocalFlattening;
323+
324+
for (String name : names) {
325+
int index = name.indexOf("(");
326+
if (index > -1) {
327+
this.names.add(name.substring(0, index).trim());
328+
}
329+
this.names.add(name);
330+
}
324331

325332
if (poleRadius == 0.0 && reciprocalFlattening == 0.0) {
326333
throw new CRSException(
@@ -340,28 +347,6 @@ private Ellipsoids(String shortName, double equatorRadius,
340347
this.eccentricity = Math.sqrt(this.eccentricity2);
341348
}
342349

343-
/**
344-
* Constructor
345-
*
346-
* @param shortName
347-
* short name
348-
* @param equatorRadius
349-
* equator radius
350-
* @param eccentricity2
351-
* eccentricity squared
352-
* @param names
353-
* names
354-
*/
355-
private Ellipsoids(String shortName, double equatorRadius,
356-
double eccentricity2, String... names) {
357-
this.shortName = shortName;
358-
this.names = Arrays.asList(names);
359-
this.equatorRadius = equatorRadius;
360-
this.eccentricity2 = eccentricity2;
361-
this.poleRadius = equatorRadius * Math.sqrt(1.0 - eccentricity2);
362-
this.eccentricity = Math.sqrt(eccentricity2);
363-
}
364-
365350
/**
366351
* Get the name
367352
*
@@ -398,6 +383,16 @@ public double getEquatorRadius() {
398383
return equatorRadius;
399384
}
400385

386+
/**
387+
* Get the reciprocal flattening
388+
*
389+
* @return reciprocal flattening
390+
* @since 1.1.1
391+
*/
392+
public double getReciprocalFlattening() {
393+
return reciprocalFlattening;
394+
}
395+
401396
/**
402397
* Get the a
403398
*

src/main/java/mil/nga/crs/geo/GeoDatums.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ public enum GeoDatums {
3131
*/
3232
NAD83("NAD83", 0, 0, 0, Ellipsoids.GRS80, "North American Datum 1983"),
3333

34+
/**
35+
* European Terrestrial Reference System 1989 ensemble
36+
*/
37+
ETRS89("ETRS89", 0, 0, 0, Ellipsoids.GRS80,
38+
"European Terrestrial Reference System 1989",
39+
"European Terrestrial Reference System 1989 ensemble"),
40+
3441
/**
3542
* North American Datum 1927
3643
*/

src/main/java/mil/nga/crs/geo/PrimeMeridians.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,67 +14,67 @@ public enum PrimeMeridians {
1414
/**
1515
* Greenwich
1616
*/
17-
GREENWICH("greenwich", 0),
17+
GREENWICH("Greenwich", 0),
1818

1919
/**
2020
* Lisbon
2121
*/
22-
LISBON("lisbon", true, 9, 7, 54.862),
22+
LISBON("Lisbon", true, 9, 7, 54.862),
2323

2424
/**
2525
* Paris
2626
*/
27-
PARIS("paris", false, 2, 20, 14.025),
27+
PARIS("Paris", false, 2, 20, 14.025),
2828

2929
/**
3030
* Bogota
3131
*/
32-
BOGOTA("bogota", true, 74, 04, 51.3),
32+
BOGOTA("Bogota", true, 74, 04, 51.3),
3333

3434
/**
3535
* Madrid
3636
*/
37-
MADRID("madrid", true, 3, 41, 16.58),
37+
MADRID("Madrid", true, 3, 41, 16.58),
3838

3939
/**
4040
* Rome
4141
*/
42-
ROME("rome", false, 12, 27, 8.4),
42+
ROME("Rome", false, 12, 27, 8.4),
4343

4444
/**
4545
* Bern
4646
*/
47-
BERN("bern", false, 7, 26, 22.5),
47+
BERN("Bern", false, 7, 26, 22.5),
4848

4949
/**
5050
* Jakarta
5151
*/
52-
JAKARTA("jakarta", false, 106, 48, 27.79),
52+
JAKARTA("Jakarta", false, 106, 48, 27.79),
5353

5454
/**
5555
* Ferro
5656
*/
57-
FERRO("ferro", true, 17, 40, 0),
57+
FERRO("Ferro", true, 17, 40, 0),
5858

5959
/**
6060
* Brussels
6161
*/
62-
BRUSSELS("brussels", false, 4, 22, 4.71),
62+
BRUSSELS("Brussels", false, 4, 22, 4.71),
6363

6464
/**
6565
* Stockholm
6666
*/
67-
STOCKHOLM("stockholm", false, 18, 3, 29.8),
67+
STOCKHOLM("Stockholm", false, 18, 3, 29.8),
6868

6969
/**
7070
* Athens
7171
*/
72-
ATHENS("athens", false, 23, 42, 58.815),
72+
ATHENS("Athens", false, 23, 42, 58.815),
7373

7474
/**
7575
* Oslo
7676
*/
77-
OSLO("oslo", false, 10, 43, 22.5);
77+
OSLO("Oslo", false, 10, 43, 22.5);
7878

7979
/**
8080
* Name to prime meridians type mapping

src/main/java/mil/nga/crs/util/proj/ProjParser.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,8 @@ private static void updateDatum(ProjParams params, GeoDatum geoDatum,
269269

270270
GeoDatums commonGeoDatum = GeoDatums.fromName(geoDatum.getName());
271271

272-
if (commonGeoDatum != null) {
272+
// Check for special cases like EPSG 3035 which specify the ellipsoid
273+
if (commonGeoDatum != null && commonGeoDatum != GeoDatums.ETRS89) {
273274
updateDatum(params, geoDatum, commonGeoDatum, mapProjection);
274275
} else {
275276
updateEllipsoid(params, geoDatum.getEllipsoid());
@@ -478,7 +479,7 @@ private static void updatePrimeMeridian(ProjParams params,
478479
.fromName(primeMeridian.getName());
479480
if (commonPrimeMeridian != null) {
480481
if (commonPrimeMeridian != PrimeMeridians.GREENWICH) {
481-
params.setPm(commonPrimeMeridian.getName());
482+
params.setPm(commonPrimeMeridian.getName().toLowerCase());
482483
}
483484
} else {
484485
params.setPm(convert(primeMeridian.getLongitude(),

0 commit comments

Comments
 (0)