Skip to content

Commit 5014975

Browse files
committed
additional proj constants
1 parent 104f198 commit 5014975

3 files changed

Lines changed: 43 additions & 41 deletions

File tree

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,12 @@ public class ProjConstants {
258258
*/
259259
public static final String AXIS_DOWN = "d";
260260

261+
/**
262+
* Axis West South Up
263+
*/
264+
public static final String AXIS_WEST_SOUTH_UP = AXIS_WEST + AXIS_SOUTH
265+
+ AXIS_UP;
266+
261267
/**
262268
* metre units
263269
*/
@@ -273,4 +279,29 @@ public class ProjConstants {
273279
*/
274280
public static final String UNITS_FOOT = "ft";
275281

282+
/**
283+
* degree units
284+
*/
285+
public static final String UNITS_DEGREE = "deg";
286+
287+
/**
288+
* Pseudo Mercator name identifier
289+
*/
290+
public static final String PSEUDO_MERCATOR = "pseudo";
291+
292+
/**
293+
* Swiss Oblique Mercator name
294+
*/
295+
public static final String SWISS_OBLIQUE_MERCATOR = "swiss oblique mercator";
296+
297+
/**
298+
* Swiis Oblique Mercator backward compatible name
299+
*/
300+
public static final String SWISS_OBLIQUE_MERCATOR_COMPAT = "hotine_oblique_mercator_azimuth_center";
301+
302+
/**
303+
* UTM Zone name
304+
*/
305+
public static final String UTM_ZONE = "utm zone";
306+
276307
}

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@
88
*/
99
public class ProjParams {
1010

11-
/**
12-
* Axis West South Up
13-
*/
14-
private static final String axisWestSouthUp = ProjConstants.AXIS_WEST
15-
+ ProjConstants.AXIS_SOUTH + ProjConstants.AXIS_UP;
16-
1711
/**
1812
* proj param
1913
*/
@@ -1140,7 +1134,7 @@ public String toString() {
11401134
value.append("=");
11411135
value.append(y_0);
11421136
}
1143-
if (axis != null && axis.equals(axisWestSouthUp)) {
1137+
if (axis != null && axis.equals(ProjConstants.AXIS_WEST_SOUTH_UP)) {
11441138
// Only known PROJ axis specification is wsu
11451139
value.append(" +");
11461140
value.append(ProjConstants.PARAM_AXIS);

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

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -37,31 +37,6 @@
3737
*/
3838
public class ProjParser {
3939

40-
/**
41-
* Pseudo Mercator name check
42-
*/
43-
private static final String pseudoMercatorNameCheck = "pseudo";
44-
45-
/**
46-
* Degree Unit name check
47-
*/
48-
private static final String degreeUnitNameCheck = "deg";
49-
50-
/**
51-
* Swiss Oblique Mercator name
52-
*/
53-
private static final String swissObliqueMercatorName = "swiss oblique mercator";
54-
55-
/**
56-
* Swiis Oblique Mercator backward compatible name
57-
*/
58-
private static final String swissObliqueMercatorCompatName = "hotine_oblique_mercator_azimuth_center";
59-
60-
/**
61-
* UTM Zone name
62-
*/
63-
private static final String utmZoneName = "utm zone";
64-
6540
/**
6641
* Parse crs well-known text into PROJ params
6742
*
@@ -321,7 +296,7 @@ private static void updateDatum(ProjParams params, GeoDatum geoDatum,
321296
if (commonGeoDatum == GeoDatums.WGS84 && method.hasMethod() && method
322297
.getMethod() == OperationMethods.POPULAR_VISUALISATION_PSEUDO_MERCATOR
323298
&& mapProjection.getName().toLowerCase()
324-
.contains(pseudoMercatorNameCheck)) {
299+
.contains(ProjConstants.PSEUDO_MERCATOR)) {
325300
updateSphericalEllipsoid(params,
326301
geoDatum.getEllipsoid().getSemiMajorAxisText());
327302
} else {
@@ -524,8 +499,9 @@ private static void updateProj(ProjParams params,
524499
Unit unit = coordinateSystem.getAxisUnit();
525500

526501
if (unit != null && (unit.getType() == UnitType.ANGLEUNIT
527-
|| (unit.getType() == UnitType.UNIT && unit.getName()
528-
.toLowerCase().startsWith(degreeUnitNameCheck)))) {
502+
|| (unit.getType() == UnitType.UNIT
503+
&& unit.getName().toLowerCase()
504+
.startsWith(ProjConstants.UNITS_DEGREE)))) {
529505
params.setProj(ProjConstants.NAME_LONGLAT);
530506
} else {
531507
params.setProj(ProjConstants.NAME_MERC);
@@ -574,9 +550,9 @@ private static void updateProj(ProjParams params,
574550

575551
case HOTINE_OBLIQUE_MERCATOR_B:
576552
if (mapProjection.getName().toLowerCase()
577-
.contains(swissObliqueMercatorName)
578-
|| method.getName().toLowerCase()
579-
.contains(swissObliqueMercatorCompatName)) {
553+
.contains(ProjConstants.SWISS_OBLIQUE_MERCATOR)
554+
|| method.getName().toLowerCase().contains(
555+
ProjConstants.SWISS_OBLIQUE_MERCATOR_COMPAT)) {
580556
params.setProj(ProjConstants.NAME_SOMERC);
581557
} else {
582558
params.setProj(ProjConstants.NAME_OMERC);
@@ -626,7 +602,7 @@ private static void updateProj(ProjParams params,
626602
case TRANSVERSE_MERCATOR:
627603
case TRANSVERSE_MERCATOR_SOUTH_ORIENTATED:
628604
if (mapProjection.getName().toLowerCase()
629-
.contains(utmZoneName)) {
605+
.contains(ProjConstants.UTM_ZONE)) {
630606
params.setProj(ProjConstants.NAME_UTM);
631607
} else {
632608
params.setProj(ProjConstants.NAME_TMERC);
@@ -729,9 +705,10 @@ private static void updateParams(ProjParams params,
729705
MapProjection mapProjection, Unit unit) {
730706

731707
String name = mapProjection.getName();
732-
int index = name.toLowerCase().indexOf(utmZoneName);
708+
int index = name.toLowerCase().indexOf(ProjConstants.UTM_ZONE);
733709
if (index > -1) {
734-
String utm = name.substring(index + utmZoneName.length()).trim();
710+
String utm = name.substring(index + ProjConstants.UTM_ZONE.length())
711+
.trim();
735712
String[] parts = utm.split("\\s+");
736713
boolean south = false;
737714
if (parts.length > 0) {

0 commit comments

Comments
 (0)