Changeset 8568 in josm for trunk/src/org/openstreetmap/josm/data/projection
- Timestamp:
- 2015-07-04T22:52:23+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/projection
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/projection/CustomProjection.java
r8533 r8568 8 8 import java.util.List; 9 9 import java.util.Map; 10 import java.util.concurrent.ConcurrentHashMap; 10 11 import java.util.regex.Matcher; 11 12 import java.util.regex.Pattern; … … 35 36 public class CustomProjection extends AbstractProjection { 36 37 38 private final static Map<String, Double> UNITS_TO_METERS = getUnitsToMeters(); 39 private final static double METER_PER_UNIT_DEGREE = 2 * Math.PI * 6370997 / 360; 40 37 41 /** 38 42 * pref String that defines the projection … … 45 49 protected String cacheDir; 46 50 protected Bounds bounds; 51 private double metersPerUnit = METER_PER_UNIT_DEGREE; // default to degrees 47 52 48 53 /** … … 89 94 wktext("wktext", false), // ignored 90 95 /** meters, US survey feet, etc. */ 91 units("units", true), // ignored96 units("units", true), 92 97 /** Don't use the /usr/share/proj/proj_def.dat defaults file */ 93 98 no_defs("no_defs", false), 94 99 init("init", true), 100 to_meter("to_meter", true), 95 101 // JOSM extensions, not present in PROJ.4 96 102 wmssrs("wmssrs", true), … … 103 109 104 110 /** Map of all parameters by key */ 105 static final Map<String, Param> paramsByKey = new HashMap<>();111 static final Map<String, Param> paramsByKey = new ConcurrentHashMap<>(); 106 112 static { 107 113 for (Param p : Param.values()) { … … 198 204 if (s != null) { 199 205 this.code = s; 206 } 207 s = parameters.get(Param.units.key); 208 if (s != null) { 209 this.metersPerUnit = UNITS_TO_METERS.get(s); 210 } 211 s = parameters.get(Param.to_meter.key); 212 if (s != null) { 213 this.metersPerUnit = parseDouble(s, Param.to_meter.key); 200 214 } 201 215 } … … 528 542 return name != null ? name : tr("Custom Projection"); 529 543 } 544 545 @Override 546 public double getMetersPerUnit() { 547 return metersPerUnit; 548 } 549 550 private static Map<String, Double> getUnitsToMeters() { 551 Map<String, Double> ret = new ConcurrentHashMap<>(); 552 ret.put("km", 1000d); 553 ret.put("m", 1d); 554 ret.put("dm", 1d/10); 555 ret.put("cm", 1d/100); 556 ret.put("mm", 1d/1000); 557 ret.put("kmi", 1852.0); 558 ret.put("in", 0.0254); 559 ret.put("ft", 0.3048); 560 ret.put("yd", 0.9144); 561 ret.put("mi", 1609.344); 562 ret.put("fathom", 1.8288); 563 ret.put("chain", 20.1168); 564 ret.put("link", 0.201168); 565 ret.put("us-in", 1d/39.37); 566 ret.put("us-ft", 0.304800609601219); 567 ret.put("us-yd", 0.914401828803658); 568 ret.put("us-ch", 20.11684023368047); 569 ret.put("us-mi", 1609.347218694437); 570 ret.put("ind-yd", 0.91439523); 571 ret.put("ind-ft", 0.30479841); 572 ret.put("ind-ch", 20.11669506); 573 ret.put("degree", METER_PER_UNIT_DEGREE); 574 return ret; 575 } 530 576 } -
trunk/src/org/openstreetmap/josm/data/projection/Projection.java
r6069 r8568 68 68 */ 69 69 Bounds getWorldBoundsLatLon(); 70 71 /** 72 * Get the number of meters per unit of this projection. This more 73 * defines the scale of the map, than real conversion of unit to meters 74 * as this value is more less correct only along great circles. 75 * 76 * Used by WMTS to properly scale tiles 77 * @return meters per unit of projection 78 * 79 */ 80 double getMetersPerUnit(); 70 81 } -
trunk/src/org/openstreetmap/josm/data/projection/proj/Proj.java
r7509 r8568 64 64 */ 65 65 double[] invproject(double east, double north); 66 67 66 }
Note:
See TracChangeset
for help on using the changeset viewer.