- Timestamp:
- 2015-12-15T15:45:37+01:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/projection/Projections.java
r9127 r9133 63 63 } 64 64 65 private Projections() { 66 // Hide default constructor for utils classes 67 } 68 69 public static EastNorth project(LatLon ll) { 70 if (ll == null) return null; 71 return Main.getProjection().latlon2eastNorth(ll); 72 } 73 74 public static LatLon inverseProject(EastNorth en) { 75 if (en == null) return null; 76 return Main.getProjection().eastNorth2latlon(en); 77 } 65 private static final Set<String> allCodes = new HashSet<>(); 66 private static final Map<String, ProjectionChoice> allProjectionChoicesByCode = new HashMap<>(); 67 private static final Map<String, Projection> projectionsByCode_cache = new HashMap<>(); 78 68 79 69 /********************************* … … 144 134 List<ProjectionDefinition> pds; 145 135 try { 146 pds = loadProjectionDefinitions("resource://data/projection/ epsg");136 pds = loadProjectionDefinitions("resource://data/projection/custom-epsg"); 147 137 } catch (IOException ex) { 148 138 throw new RuntimeException(ex); … … 152 142 inits.put(pd.code, pd); 153 143 } 144 145 for (ProjectionChoice pc : ProjectionPreference.getProjectionChoices()) { 146 for (String code : pc.allCodes()) { 147 allProjectionChoicesByCode.put(code, pc); 148 } 149 } 150 allCodes.addAll(inits.keySet()); 151 allCodes.addAll(allProjectionChoicesByCode.keySet()); 152 } 153 154 private Projections() { 155 // Hide default constructor for utils classes 156 } 157 158 public static EastNorth project(LatLon ll) { 159 if (ll == null) return null; 160 return Main.getProjection().latlon2eastNorth(ll); 161 } 162 163 public static LatLon inverseProject(EastNorth en) { 164 if (en == null) return null; 165 return Main.getProjection().eastNorth2latlon(en); 154 166 } 155 167 … … 203 215 /** 204 216 * Load projection definitions from file. 205 * 217 * 206 218 * @param path the path 207 219 * @return projection definitions … … 214 226 ) { 215 227 return loadProjectionDefinitions(r); 216 } catch (IOException ex) {217 throw new RuntimeException(ex);218 228 } 219 229 } … … 221 231 /** 222 232 * Load projection definitions from file. 223 * 233 * 224 234 * @param r the reader 225 235 * @return projection definitions … … 249 259 } 250 260 251 private static final Set<String> allCodes = new HashSet<>();252 private static final Map<String, ProjectionChoice> allProjectionChoicesByCode = new HashMap<>();253 private static final Map<String, Projection> projectionsByCode_cache = new HashMap<>();254 255 static {256 for (ProjectionChoice pc : ProjectionPreference.getProjectionChoices()) {257 for (String code : pc.allCodes()) {258 allProjectionChoicesByCode.put(code, pc);259 }260 }261 allCodes.addAll(inits.keySet());262 allCodes.addAll(allProjectionChoicesByCode.keySet());263 }264 265 261 public static Projection getProjectionByCode(String code) { 266 262 Projection proj = projectionsByCode_cache.get(code);
Note:
See TracChangeset
for help on using the changeset viewer.