Changeset 13395 in josm for trunk/scripts
- Timestamp:
- 2018-02-09T21:34:58+01:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/scripts/BuildProjectionDefinitions.java
r11324 r13395 9 9 import java.util.HashMap; 10 10 import java.util.LinkedHashMap; 11 import java.util.List;12 11 import java.util.Map; 13 12 … … 26 25 private static final String JOSM_EPSG_FILE = "data_nodist/projection/josm-epsg"; 27 26 private static final String PROJ4_EPSG_FILE = "data_nodist/projection/epsg"; 27 private static final String PROJ4_ESRI_FILE = "data_nodist/projection/esri"; 28 28 private static final String OUTPUT_EPSG_FILE = "data/projection/custom-epsg"; 29 29 30 30 private static final Map<String, ProjectionDefinition> epsgProj4 = new LinkedHashMap<>(); 31 private static final Map<String, ProjectionDefinition> esriProj4 = new LinkedHashMap<>(); 31 32 private static final Map<String, ProjectionDefinition> epsgJosm = new LinkedHashMap<>(); 32 33 … … 35 36 // statistics: 36 37 private static int noInJosm = 0; 38 private static int noInProj4 = 0; 37 39 private static int noDeprecated = 0; 38 40 private static int noGeocent = 0; … … 42 44 private static int noJosm = 0; 43 45 private static int noProj4 = 0; 46 private static int noEsri = 0; 44 47 private static int noOmercNoBounds = 0; 45 48 … … 53 56 } 54 57 58 static void initMap(String baseDir, String file, Map<String, ProjectionDefinition> map) throws IOException { 59 for (ProjectionDefinition pd : Projections.loadProjectionDefinitions(baseDir + File.separator + file)) { 60 map.put(pd.code, pd); 61 } 62 } 63 55 64 static void buildList(String baseDir) throws IOException { 56 List<ProjectionDefinition> pdJosm = Projections.loadProjectionDefinitions(baseDir + File.separator + JOSM_EPSG_FILE); 57 for (ProjectionDefinition pd : pdJosm) { 58 epsgJosm.put(pd.code, pd); 59 } 60 List<ProjectionDefinition> pdProj4 = Projections.loadProjectionDefinitions(baseDir + File.separator + PROJ4_EPSG_FILE); 61 for (ProjectionDefinition pd : pdProj4) { 62 epsgProj4.put(pd.code, pd); 63 } 65 initMap(baseDir, JOSM_EPSG_FILE, epsgJosm); 66 initMap(baseDir, PROJ4_EPSG_FILE, epsgProj4); 67 initMap(baseDir, PROJ4_ESRI_FILE, esriProj4); 64 68 65 69 try (FileOutputStream output = new FileOutputStream(baseDir + File.separator + OUTPUT_EPSG_FILE); … … 67 71 out.write("## This file is autogenerated, do not edit!\n"); 68 72 out.write("## Run ant task \"epsg\" to rebuild.\n"); 69 out.write(String.format("## Source files are %s (can be changed) and %s (copied from the proj.4 project).%n",70 JOSM_EPSG_FILE, PROJ4_EPSG_FILE ));73 out.write(String.format("## Source files are %s (can be changed), %s and %s (copied from the proj.4 project).%n", 74 JOSM_EPSG_FILE, PROJ4_EPSG_FILE, PROJ4_ESRI_FILE)); 71 75 out.write("##\n"); 72 76 out.write("## Entries checked and maintained by the JOSM team:\n"); … … 77 81 out.write("## Other supported projections (source: proj.4):\n"); 78 82 for (ProjectionDefinition pd : epsgProj4.values()) { 79 if (doInclude(pd, true )) {83 if (doInclude(pd, true, false)) { 80 84 write(out, pd); 81 85 noProj4++; 86 } 87 } 88 out.write("## ESRI-specific projections (source: proj.4):\n"); 89 for (ProjectionDefinition pd : esriProj4.values()) { 90 if (doInclude(pd, true, true)) { 91 write(out, pd); 92 noEsri++; 82 93 } 83 94 } … … 87 98 System.out.println(String.format("loaded %d entries from %s", epsgJosm.size(), JOSM_EPSG_FILE)); 88 99 System.out.println(String.format("loaded %d entries from %s", epsgProj4.size(), PROJ4_EPSG_FILE)); 100 System.out.println(String.format("loaded %d entries from %s", esriProj4.size(), PROJ4_ESRI_FILE)); 89 101 System.out.println(); 90 102 System.out.println("some entries from proj.4 have not been included:"); 91 103 System.out.println(String.format(" * already in the maintained JOSM list: %d entries", noInJosm)); 104 System.out.println(String.format(" * ESRI already in the standard EPSG list: %d entries", noInProj4)); 92 105 System.out.println(String.format(" * deprecated: %d entries", noDeprecated)); 93 106 System.out.println(String.format(" * using +proj=geocent, which is 3D (X,Y,Z) and not useful in JOSM: %d entries", noGeocent)); … … 101 114 System.out.println(String.format("written %d entries from %s", noJosm, JOSM_EPSG_FILE)); 102 115 System.out.println(String.format("written %d entries from %s", noProj4, PROJ4_EPSG_FILE)); 116 System.out.println(String.format("written %d entries from %s", noEsri, PROJ4_ESRI_FILE)); 103 117 } 104 105 118 } 106 119 … … 110 123 } 111 124 112 static boolean doInclude(ProjectionDefinition pd, boolean noIncludeJosm ) {125 static boolean doInclude(ProjectionDefinition pd, boolean noIncludeJosm, boolean noIncludeProj4) { 113 126 114 127 boolean result = true; … … 119 132 result = false; 120 133 noInJosm++; 134 } 135 } 136 if (noIncludeProj4) { 137 // we already have this projection 138 if (epsgProj4.containsKey(pd.code)) { 139 result = false; 140 noInProj4++; 121 141 } 122 142 }
Note:
See TracChangeset
for help on using the changeset viewer.