Changeset 5548 in josm for trunk/src/org/openstreetmap/josm/data/projection/Projections.java
- Timestamp:
- 2012-11-01T16:52:19+01:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/projection/Projections.java
r5237 r5548 25 25 import org.openstreetmap.josm.data.projection.proj.TransverseMercator; 26 26 import org.openstreetmap.josm.io.MirroredInputStream; 27 import org.openstreetmap.josm.tools.Pair; 27 28 28 29 /** … … 47 48 * should be compatible to PROJ.4 48 49 */ 49 public static Map<String, ProjFactory> projs = new HashMap<String, ProjFactory>();50 public static Map<String, Ellipsoid> ellipsoids = new HashMap<String, Ellipsoid>();51 public static Map<String, Datum> datums = new HashMap<String, Datum>();52 public static Map<String, NTV2GridShiftFileWrapper> nadgrids = new HashMap<String, NTV2GridShiftFileWrapper>();53 public static Map<String, String> inits = new HashMap<String, String>();50 final public static Map<String, ProjFactory> projs = new HashMap<String, ProjFactory>(); 51 final public static Map<String, Ellipsoid> ellipsoids = new HashMap<String, Ellipsoid>(); 52 final public static Map<String, Datum> datums = new HashMap<String, Datum>(); 53 final public static Map<String, NTV2GridShiftFileWrapper> nadgrids = new HashMap<String, NTV2GridShiftFileWrapper>(); 54 final public static Map<String, Pair<String, String>> inits = new HashMap<String, Pair<String, String>>(); 54 55 55 56 static { … … 109 110 110 111 public static String getInit(String id) { 111 return inits.get(id );112 return inits.get(id.toLowerCase()).b; 112 113 } 113 114 … … 116 117 */ 117 118 private static void loadInits() { 118 Pattern epsgPattern = Pattern.compile(" \\A<(\\d+)>(.*)<>\\Z");119 Pattern epsgPattern = Pattern.compile("<(\\d+)>(.*)<>"); 119 120 try { 120 121 InputStream in = new MirroredInputStream("resource://data/epsg"); 121 122 BufferedReader r = new BufferedReader(new InputStreamReader(in)); 122 String line ;123 String line, lastline = ""; 123 124 while ((line = r.readLine()) != null) { 124 125 line = line.trim(); 125 126 if (!line.startsWith("#") && !line.isEmpty()) { 127 if (!lastline.startsWith("#")) throw new AssertionError(); 128 String name = lastline.substring(1).trim(); 126 129 Matcher m = epsgPattern.matcher(line); 127 130 if (m.matches()) { 128 inits.put("epsg:" + m.group(1), m.group(2).trim());131 inits.put("epsg:" + m.group(1), Pair.create(name, m.group(2).trim())); 129 132 } else { 130 133 System.err.println("Warning: failed to parse line from the epsg projection definition: "+line); 131 134 } 132 135 } 136 lastline = line; 133 137 } 134 138 } catch (IOException ex) {
Note:
See TracChangeset
for help on using the changeset viewer.