source: josm/trunk/src/org/openstreetmap/josm/data/projection/CustomProjection.java@ 9126

Last change on this file since 9126 was 9125, checked in by bastiK, 8 years ago

see #12186 - add projection parameter vunits (ignored)

  • Property svn:eol-style set to native
File size: 26.0 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.projection;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.util.ArrayList;
7import java.util.HashMap;
8import java.util.List;
9import java.util.Map;
10import java.util.concurrent.ConcurrentHashMap;
11import java.util.regex.Matcher;
12import java.util.regex.Pattern;
13
14import org.openstreetmap.josm.Main;
15import org.openstreetmap.josm.data.Bounds;
16import org.openstreetmap.josm.data.coor.LatLon;
17import org.openstreetmap.josm.data.projection.datum.CentricDatum;
18import org.openstreetmap.josm.data.projection.datum.Datum;
19import org.openstreetmap.josm.data.projection.datum.NTV2Datum;
20import org.openstreetmap.josm.data.projection.datum.NTV2GridShiftFileWrapper;
21import org.openstreetmap.josm.data.projection.datum.NullDatum;
22import org.openstreetmap.josm.data.projection.datum.SevenParameterDatum;
23import org.openstreetmap.josm.data.projection.datum.ThreeParameterDatum;
24import org.openstreetmap.josm.data.projection.datum.WGS84Datum;
25import org.openstreetmap.josm.data.projection.proj.Mercator;
26import org.openstreetmap.josm.data.projection.proj.Proj;
27import org.openstreetmap.josm.data.projection.proj.ProjParameters;
28import org.openstreetmap.josm.tools.Utils;
29
30/**
31 * Custom projection.
32 *
33 * Inspired by PROJ.4 and Proj4J.
34 * @since 5072
35 */
36public class CustomProjection extends AbstractProjection {
37
38 private static final double METER_PER_UNIT_DEGREE = 2 * Math.PI * 6370997 / 360;
39 private static final Map<String, Double> UNITS_TO_METERS = getUnitsToMeters();
40 private static final Map<String, Double> PRIME_MERIDANS = getPrimeMeridians();
41
42 /**
43 * pref String that defines the projection
44 *
45 * null means fall back mode (Mercator)
46 */
47 protected String pref;
48 protected String name;
49 protected String code;
50 protected String cacheDir;
51 protected Bounds bounds;
52 private double metersPerUnit = METER_PER_UNIT_DEGREE; // default to degrees
53 private String axis = "enu"; // default axis orientation is East, North, Up
54
55 /**
56 * Proj4-like projection parameters. See <a href="https://trac.osgeo.org/proj/wiki/GenParms">reference</a>.
57 * @since 7370 (public)
58 */
59 public enum Param {
60
61 /** False easting */
62 x_0("x_0", true),
63 /** False northing */
64 y_0("y_0", true),
65 /** Central meridian */
66 lon_0("lon_0", true),
67 /** Prime meridian */
68 pm("pm", true),
69 /** Scaling factor */
70 k_0("k_0", true),
71 /** Ellipsoid name (see {@code proj -le}) */
72 ellps("ellps", true),
73 /** Semimajor radius of the ellipsoid axis */
74 a("a", true),
75 /** Eccentricity of the ellipsoid squared */
76 es("es", true),
77 /** Reciprocal of the ellipsoid flattening term (e.g. 298) */
78 rf("rf", true),
79 /** Flattening of the ellipsoid = 1-sqrt(1-e^2) */
80 f("f", true),
81 /** Semiminor radius of the ellipsoid axis */
82 b("b", true),
83 /** Datum name (see {@code proj -ld}) */
84 datum("datum", true),
85 /** 3 or 7 term datum transform parameters */
86 towgs84("towgs84", true),
87 /** Filename of NTv2 grid file to use for datum transforms */
88 nadgrids("nadgrids", true),
89 /** Projection name (see {@code proj -l}) */
90 proj("proj", true),
91 /** Latitude of origin */
92 lat_0("lat_0", true),
93 /** Latitude of first standard parallel */
94 lat_1("lat_1", true),
95 /** Latitude of second standard parallel */
96 lat_2("lat_2", true),
97 /** the exact proj.4 string will be preserved in the WKT representation */
98 wktext("wktext", false), // ignored
99 /** meters, US survey feet, etc. */
100 units("units", true),
101 /** Don't use the /usr/share/proj/proj_def.dat defaults file */
102 no_defs("no_defs", false),
103 init("init", true),
104 /** crs units to meter multiplier */
105 to_meter("to_meter", true),
106 /** definition of axis for projection */
107 axis("axis", true),
108 /** UTM zone */
109 zone("zone", true),
110 /** indicate southern hemisphere for UTM */
111 south("south", false),
112 /** vertical units - ignore, as we don't use height information */
113 vunits("vunits", true),
114 // JOSM extensions, not present in PROJ.4
115 wmssrs("wmssrs", true),
116 bounds("bounds", true);
117
118 /** Parameter key */
119 public final String key;
120 /** {@code true} if the parameter has a value */
121 public final boolean hasValue;
122
123 /** Map of all parameters by key */
124 static final Map<String, Param> paramsByKey = new ConcurrentHashMap<>();
125 static {
126 for (Param p : Param.values()) {
127 paramsByKey.put(p.key, p);
128 }
129 }
130
131 Param(String key, boolean hasValue) {
132 this.key = key;
133 this.hasValue = hasValue;
134 }
135 }
136
137 /**
138 * Constructs a new empty {@code CustomProjection}.
139 */
140 public CustomProjection() {
141 // contents can be set later with update()
142 }
143
144 /**
145 * Constructs a new {@code CustomProjection} with given parameters.
146 * @param pref String containing projection parameters
147 * (ex: "+proj=tmerc +lon_0=-3 +k_0=0.9996 +x_0=500000 +ellps=WGS84 +datum=WGS84 +bounds=-8,-5,2,85")
148 */
149 public CustomProjection(String pref) {
150 this(null, null, pref, null);
151 }
152
153 /**
154 * Constructs a new {@code CustomProjection} with given name, code and parameters.
155 *
156 * @param name describe projection in one or two words
157 * @param code unique code for this projection - may be null
158 * @param pref the string that defines the custom projection
159 * @param cacheDir cache directory name
160 */
161 public CustomProjection(String name, String code, String pref, String cacheDir) {
162 this.name = name;
163 this.code = code;
164 this.pref = pref;
165 this.cacheDir = cacheDir;
166 try {
167 update(pref);
168 } catch (ProjectionConfigurationException ex) {
169 try {
170 update(null);
171 } catch (ProjectionConfigurationException ex1) {
172 throw new RuntimeException(ex1);
173 }
174 }
175 }
176
177 /**
178 * Updates this {@code CustomProjection} with given parameters.
179 * @param pref String containing projection parameters (ex: "+proj=lonlat +ellps=WGS84 +datum=WGS84 +bounds=-180,-90,180,90")
180 * @throws ProjectionConfigurationException if {@code pref} cannot be parsed properly
181 */
182 public final void update(String pref) throws ProjectionConfigurationException {
183 this.pref = pref;
184 if (pref == null) {
185 ellps = Ellipsoid.WGS84;
186 datum = WGS84Datum.INSTANCE;
187 proj = new Mercator();
188 bounds = new Bounds(
189 -85.05112877980659, -180.0,
190 85.05112877980659, 180.0, true);
191 } else {
192 Map<String, String> parameters = parseParameterList(pref);
193 ellps = parseEllipsoid(parameters);
194 datum = parseDatum(parameters, ellps);
195 if (ellps == null) {
196 ellps = datum.getEllipsoid();
197 }
198 proj = parseProjection(parameters, ellps);
199 // "utm" is a shortcut for a set of parameters
200 if ("utm".equals(parameters.get(Param.proj.key))) {
201 String zoneStr = parameters.get(Param.zone.key);
202 Integer zone;
203 if (zoneStr == null)
204 throw new ProjectionConfigurationException(tr("UTM projection (''+proj=utm'') requires ''+zone=...'' parameter."));
205 try {
206 zone = Integer.valueOf(zoneStr);
207 } catch (NumberFormatException e) {
208 zone = null;
209 }
210 if (zone == null || zone < 1 || zone > 60)
211 throw new ProjectionConfigurationException(tr("Expected integer value in range 1-60 for ''+zone=...'' parameter."));
212 this.lon0 = 6 * zone - 183;
213 this.k0 = 0.9996;
214 this.x0 = 500000;
215 this.y0 = parameters.containsKey(Param.south.key) ? 10000000 : 0;
216 }
217 String s = parameters.get(Param.x_0.key);
218 if (s != null) {
219 this.x0 = parseDouble(s, Param.x_0.key);
220 }
221 s = parameters.get(Param.y_0.key);
222 if (s != null) {
223 this.y0 = parseDouble(s, Param.y_0.key);
224 }
225 s = parameters.get(Param.lon_0.key);
226 if (s != null) {
227 this.lon0 = parseAngle(s, Param.lon_0.key);
228 }
229 s = parameters.get(Param.pm.key);
230 if (s != null) {
231 if (PRIME_MERIDANS.containsKey(s)) {
232 this.pm = PRIME_MERIDANS.get(s);
233 } else {
234 this.pm = parseAngle(s, Param.pm.key);
235 }
236 }
237 s = parameters.get(Param.k_0.key);
238 if (s != null) {
239 this.k0 = parseDouble(s, Param.k_0.key);
240 }
241 s = parameters.get(Param.bounds.key);
242 if (s != null) {
243 this.bounds = parseBounds(s);
244 }
245 s = parameters.get(Param.wmssrs.key);
246 if (s != null) {
247 this.code = s;
248 }
249 s = parameters.get(Param.units.key);
250 if (s != null) {
251 s = Utils.strip(s, "\"");
252 if (UNITS_TO_METERS.containsKey(s)) {
253 this.metersPerUnit = UNITS_TO_METERS.get(s);
254 } else {
255 Main.warn("No metersPerUnit found for: " + s);
256 }
257 }
258 s = parameters.get(Param.to_meter.key);
259 if (s != null) {
260 this.metersPerUnit = parseDouble(s, Param.to_meter.key);
261 }
262 s = parameters.get(Param.axis.key);
263 if (s != null) {
264 this.axis = s;
265 }
266 }
267 }
268
269 private Map<String, String> parseParameterList(String pref) throws ProjectionConfigurationException {
270 Map<String, String> parameters = new HashMap<>();
271 String[] parts = Utils.WHITE_SPACES_PATTERN.split(pref.trim());
272 if (pref.trim().isEmpty()) {
273 parts = new String[0];
274 }
275 for (String part : parts) {
276 if (part.isEmpty() || part.charAt(0) != '+')
277 throw new ProjectionConfigurationException(tr("Parameter must begin with a ''+'' character (found ''{0}'')", part));
278 Matcher m = Pattern.compile("\\+([a-zA-Z0-9_]+)(=(.*))?").matcher(part);
279 if (m.matches()) {
280 String key = m.group(1);
281 // alias
282 if ("k".equals(key)) {
283 key = Param.k_0.key;
284 }
285 String value = null;
286 if (m.groupCount() >= 3) {
287 value = m.group(3);
288 // some aliases
289 if (key.equals(Param.proj.key)) {
290 if ("longlat".equals(value) || "latlon".equals(value) || "latlong".equals(value)) {
291 value = "lonlat";
292 }
293 }
294 }
295 if (!Param.paramsByKey.containsKey(key))
296 throw new ProjectionConfigurationException(tr("Unknown parameter: ''{0}''.", key));
297 if (Param.paramsByKey.get(key).hasValue && value == null)
298 throw new ProjectionConfigurationException(tr("Value expected for parameter ''{0}''.", key));
299 if (!Param.paramsByKey.get(key).hasValue && value != null)
300 throw new ProjectionConfigurationException(tr("No value expected for parameter ''{0}''.", key));
301 parameters.put(key, value);
302 } else
303 throw new ProjectionConfigurationException(tr("Unexpected parameter format (''{0}'')", part));
304 }
305 // recursive resolution of +init includes
306 String initKey = parameters.get(Param.init.key);
307 if (initKey != null) {
308 String init = Projections.getInit(initKey);
309 if (init == null)
310 throw new ProjectionConfigurationException(tr("Value ''{0}'' for option +init not supported.", initKey));
311 Map<String, String> initp = null;
312 try {
313 initp = parseParameterList(init);
314 } catch (ProjectionConfigurationException ex) {
315 throw new ProjectionConfigurationException(tr(initKey+": "+ex.getMessage()), ex);
316 }
317 for (Map.Entry<String, String> e : parameters.entrySet()) {
318 initp.put(e.getKey(), e.getValue());
319 }
320 return initp;
321 }
322 return parameters;
323 }
324
325 public Ellipsoid parseEllipsoid(Map<String, String> parameters) throws ProjectionConfigurationException {
326 String code = parameters.get(Param.ellps.key);
327 if (code != null) {
328 Ellipsoid ellipsoid = Projections.getEllipsoid(code);
329 if (ellipsoid == null) {
330 throw new ProjectionConfigurationException(tr("Ellipsoid ''{0}'' not supported.", code));
331 } else {
332 return ellipsoid;
333 }
334 }
335 String s = parameters.get(Param.a.key);
336 if (s != null) {
337 double a = parseDouble(s, Param.a.key);
338 if (parameters.get(Param.es.key) != null) {
339 double es = parseDouble(parameters, Param.es.key);
340 return Ellipsoid.create_a_es(a, es);
341 }
342 if (parameters.get(Param.rf.key) != null) {
343 double rf = parseDouble(parameters, Param.rf.key);
344 return Ellipsoid.create_a_rf(a, rf);
345 }
346 if (parameters.get(Param.f.key) != null) {
347 double f = parseDouble(parameters, Param.f.key);
348 return Ellipsoid.create_a_f(a, f);
349 }
350 if (parameters.get(Param.b.key) != null) {
351 double b = parseDouble(parameters, Param.b.key);
352 return Ellipsoid.create_a_b(a, b);
353 }
354 }
355 if (parameters.containsKey(Param.a.key) ||
356 parameters.containsKey(Param.es.key) ||
357 parameters.containsKey(Param.rf.key) ||
358 parameters.containsKey(Param.f.key) ||
359 parameters.containsKey(Param.b.key))
360 throw new ProjectionConfigurationException(tr("Combination of ellipsoid parameters is not supported."));
361 return null;
362 }
363
364 public Datum parseDatum(Map<String, String> parameters, Ellipsoid ellps) throws ProjectionConfigurationException {
365 String datumId = parameters.get(Param.datum.key);
366 if (datumId != null) {
367 Datum datum = Projections.getDatum(datumId);
368 if (datum == null) throw new ProjectionConfigurationException(tr("Unknown datum identifier: ''{0}''", datumId));
369 return datum;
370 }
371 if (ellps == null) {
372 if (parameters.containsKey(Param.no_defs.key))
373 throw new ProjectionConfigurationException(tr("Ellipsoid required (+ellps=* or +a=*, +b=*)"));
374 // nothing specified, use WGS84 as default
375 ellps = Ellipsoid.WGS84;
376 }
377
378 String nadgridsId = parameters.get(Param.nadgrids.key);
379 if (nadgridsId != null) {
380 if (nadgridsId.startsWith("@")) {
381 nadgridsId = nadgridsId.substring(1);
382 }
383 if ("null".equals(nadgridsId))
384 return new NullDatum(null, ellps);
385 NTV2GridShiftFileWrapper nadgrids = Projections.getNTV2Grid(nadgridsId);
386 if (nadgrids == null)
387 throw new ProjectionConfigurationException(tr("Grid shift file ''{0}'' for option +nadgrids not supported.", nadgridsId));
388 return new NTV2Datum(nadgridsId, null, ellps, nadgrids);
389 }
390
391 String towgs84 = parameters.get(Param.towgs84.key);
392 if (towgs84 != null)
393 return parseToWGS84(towgs84, ellps);
394
395 return new NullDatum(null, ellps);
396 }
397
398 public Datum parseToWGS84(String paramList, Ellipsoid ellps) throws ProjectionConfigurationException {
399 String[] numStr = paramList.split(",");
400
401 if (numStr.length != 3 && numStr.length != 7)
402 throw new ProjectionConfigurationException(tr("Unexpected number of arguments for parameter ''towgs84'' (must be 3 or 7)"));
403 List<Double> towgs84Param = new ArrayList<>();
404 for (String str : numStr) {
405 try {
406 towgs84Param.add(Double.valueOf(str));
407 } catch (NumberFormatException e) {
408 throw new ProjectionConfigurationException(tr("Unable to parse value of parameter ''towgs84'' (''{0}'')", str), e);
409 }
410 }
411 boolean isCentric = true;
412 for (Double param : towgs84Param) {
413 if (param != 0) {
414 isCentric = false;
415 break;
416 }
417 }
418 if (isCentric)
419 return new CentricDatum(null, null, ellps);
420 boolean is3Param = true;
421 for (int i = 3; i < towgs84Param.size(); i++) {
422 if (towgs84Param.get(i) != 0) {
423 is3Param = false;
424 break;
425 }
426 }
427 if (is3Param)
428 return new ThreeParameterDatum(null, null, ellps,
429 towgs84Param.get(0),
430 towgs84Param.get(1),
431 towgs84Param.get(2));
432 else
433 return new SevenParameterDatum(null, null, ellps,
434 towgs84Param.get(0),
435 towgs84Param.get(1),
436 towgs84Param.get(2),
437 towgs84Param.get(3),
438 towgs84Param.get(4),
439 towgs84Param.get(5),
440 towgs84Param.get(6));
441 }
442
443 public Proj parseProjection(Map<String, String> parameters, Ellipsoid ellps) throws ProjectionConfigurationException {
444 String id = parameters.get(Param.proj.key);
445 if (id == null) throw new ProjectionConfigurationException(tr("Projection required (+proj=*)"));
446
447 // "utm" is not a real projection, but a shortcut for a set of parameters
448 if ("utm".equals(id)) {
449 id = "tmerc";
450 }
451 Proj proj = Projections.getBaseProjection(id);
452 if (proj == null) throw new ProjectionConfigurationException(tr("Unknown projection identifier: ''{0}''", id));
453
454 ProjParameters projParams = new ProjParameters();
455
456 projParams.ellps = ellps;
457
458 String s;
459 s = parameters.get(Param.lat_0.key);
460 if (s != null) {
461 projParams.lat0 = parseAngle(s, Param.lat_0.key);
462 }
463 s = parameters.get(Param.lat_1.key);
464 if (s != null) {
465 projParams.lat1 = parseAngle(s, Param.lat_1.key);
466 }
467 s = parameters.get(Param.lat_2.key);
468 if (s != null) {
469 projParams.lat2 = parseAngle(s, Param.lat_2.key);
470 }
471 proj.initialize(projParams);
472 return proj;
473 }
474
475 public static Bounds parseBounds(String boundsStr) throws ProjectionConfigurationException {
476 String[] numStr = boundsStr.split(",");
477 if (numStr.length != 4)
478 throw new ProjectionConfigurationException(tr("Unexpected number of arguments for parameter ''+bounds'' (must be 4)"));
479 return new Bounds(parseAngle(numStr[1], "minlat (+bounds)"),
480 parseAngle(numStr[0], "minlon (+bounds)"),
481 parseAngle(numStr[3], "maxlat (+bounds)"),
482 parseAngle(numStr[2], "maxlon (+bounds)"), false);
483 }
484
485 public static double parseDouble(Map<String, String> parameters, String parameterName) throws ProjectionConfigurationException {
486 if (!parameters.containsKey(parameterName))
487 throw new ProjectionConfigurationException(tr("Unknown parameter ''{0}''", parameterName));
488 String doubleStr = parameters.get(parameterName);
489 if (doubleStr == null)
490 throw new ProjectionConfigurationException(
491 tr("Expected number argument for parameter ''{0}''", parameterName));
492 return parseDouble(doubleStr, parameterName);
493 }
494
495 public static double parseDouble(String doubleStr, String parameterName) throws ProjectionConfigurationException {
496 try {
497 return Double.parseDouble(doubleStr);
498 } catch (NumberFormatException e) {
499 throw new ProjectionConfigurationException(
500 tr("Unable to parse value ''{1}'' of parameter ''{0}'' as number.", parameterName, doubleStr), e);
501 }
502 }
503
504 public static double parseAngle(String angleStr, String parameterName) throws ProjectionConfigurationException {
505 String s = angleStr;
506 double value = 0;
507 boolean neg = false;
508 Matcher m = Pattern.compile("^-").matcher(s);
509 if (m.find()) {
510 neg = true;
511 s = s.substring(m.end());
512 }
513 final String FLOAT = "(\\d+(\\.\\d*)?)";
514 boolean dms = false;
515 double deg = 0.0, min = 0.0, sec = 0.0;
516 // degrees
517 m = Pattern.compile("^"+FLOAT+"d").matcher(s);
518 if (m.find()) {
519 s = s.substring(m.end());
520 deg = Double.parseDouble(m.group(1));
521 dms = true;
522 }
523 // minutes
524 m = Pattern.compile("^"+FLOAT+"'").matcher(s);
525 if (m.find()) {
526 s = s.substring(m.end());
527 min = Double.parseDouble(m.group(1));
528 dms = true;
529 }
530 // seconds
531 m = Pattern.compile("^"+FLOAT+"\"").matcher(s);
532 if (m.find()) {
533 s = s.substring(m.end());
534 sec = Double.parseDouble(m.group(1));
535 dms = true;
536 }
537 // plain number (in degrees)
538 if (dms) {
539 value = deg + (min/60.0) + (sec/3600.0);
540 } else {
541 m = Pattern.compile("^"+FLOAT).matcher(s);
542 if (m.find()) {
543 s = s.substring(m.end());
544 value += Double.parseDouble(m.group(1));
545 }
546 }
547 m = Pattern.compile("^(N|E)", Pattern.CASE_INSENSITIVE).matcher(s);
548 if (m.find()) {
549 s = s.substring(m.end());
550 } else {
551 m = Pattern.compile("^(S|W)", Pattern.CASE_INSENSITIVE).matcher(s);
552 if (m.find()) {
553 s = s.substring(m.end());
554 neg = !neg;
555 }
556 }
557 if (neg) {
558 value = -value;
559 }
560 if (!s.isEmpty()) {
561 throw new ProjectionConfigurationException(
562 tr("Unable to parse value ''{1}'' of parameter ''{0}'' as coordinate value.", parameterName, angleStr));
563 }
564 return value;
565 }
566
567 @Override
568 public Integer getEpsgCode() {
569 if (code != null && code.startsWith("EPSG:")) {
570 try {
571 return Integer.valueOf(code.substring(5));
572 } catch (NumberFormatException e) {
573 Main.warn(e);
574 }
575 }
576 return null;
577 }
578
579 @Override
580 public String toCode() {
581 return code != null ? code : "proj:" + (pref == null ? "ERROR" : pref);
582 }
583
584 @Override
585 public String getCacheDirectoryName() {
586 return cacheDir != null ? cacheDir : "proj-"+Utils.md5Hex(pref == null ? "" : pref).substring(0, 4);
587 }
588
589 @Override
590 public Bounds getWorldBoundsLatLon() {
591 if (bounds != null) return bounds;
592 Bounds ab = proj.getAlgorithmBounds();
593 if (ab != null) {
594 double minlon = Math.max(ab.getMinLon() + lon0 + pm, -180);
595 double maxlon = Math.min(ab.getMaxLon() + lon0 + pm, 180);
596 return new Bounds(ab.getMinLat(), minlon, ab.getMaxLat(), maxlon, false);
597 } else {
598 return new Bounds(
599 new LatLon(-90.0, -180.0),
600 new LatLon(90.0, 180.0));
601 }
602 }
603
604 @Override
605 public String toString() {
606 return name != null ? name : tr("Custom Projection");
607 }
608
609 @Override
610 public double getMetersPerUnit() {
611 return metersPerUnit;
612 }
613
614 @Override
615 public boolean switchXY() {
616 // TODO: support for other axis orientation such as West South, and Up Down
617 return this.axis.startsWith("ne");
618 }
619
620 private static Map<String, Double> getUnitsToMeters() {
621 Map<String, Double> ret = new ConcurrentHashMap<>();
622 ret.put("km", 1000d);
623 ret.put("m", 1d);
624 ret.put("dm", 1d/10);
625 ret.put("cm", 1d/100);
626 ret.put("mm", 1d/1000);
627 ret.put("kmi", 1852.0);
628 ret.put("in", 0.0254);
629 ret.put("ft", 0.3048);
630 ret.put("yd", 0.9144);
631 ret.put("mi", 1609.344);
632 ret.put("fathom", 1.8288);
633 ret.put("chain", 20.1168);
634 ret.put("link", 0.201168);
635 ret.put("us-in", 1d/39.37);
636 ret.put("us-ft", 0.304800609601219);
637 ret.put("us-yd", 0.914401828803658);
638 ret.put("us-ch", 20.11684023368047);
639 ret.put("us-mi", 1609.347218694437);
640 ret.put("ind-yd", 0.91439523);
641 ret.put("ind-ft", 0.30479841);
642 ret.put("ind-ch", 20.11669506);
643 ret.put("degree", METER_PER_UNIT_DEGREE);
644 return ret;
645 }
646
647 private static Map<String, Double> getPrimeMeridians() {
648 Map<String, Double> ret = new ConcurrentHashMap<>();
649 try {
650 ret.put("greenwich", 0.0);
651 ret.put("lisbon", parseAngle("9d07'54.862\"W", null));
652 ret.put("paris", parseAngle("2d20'14.025\"E", null));
653 ret.put("bogota", parseAngle("74d04'51.3\"W", null));
654 ret.put("madrid", parseAngle("3d41'16.58\"W", null));
655 ret.put("rome", parseAngle("12d27'8.4\"E", null));
656 ret.put("bern", parseAngle("7d26'22.5\"E", null));
657 ret.put("jakarta", parseAngle("106d48'27.79\"E", null));
658 ret.put("ferro", parseAngle("17d40'W", null));
659 ret.put("brussels", parseAngle("4d22'4.71\"E", null));
660 ret.put("stockholm", parseAngle("18d3'29.8\"E", null));
661 ret.put("athens", parseAngle("23d42'58.815\"E", null));
662 ret.put("oslo", parseAngle("10d43'22.5\"E", null));
663 } catch (ProjectionConfigurationException ex) {
664 throw new RuntimeException();
665 }
666 return ret;
667 }
668}
Note: See TracBrowser for help on using the repository browser.