Changeset 13395 in josm for trunk/scripts


Ignore:
Timestamp:
2018-02-09T21:34:58+01:00 (6 years ago)
Author:
Don-vip
Message:

fix #15880 - support ESRI projections and update to EPSG database v9.2 (from proj.4), see:

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/scripts/BuildProjectionDefinitions.java

    r11324 r13395  
    99import java.util.HashMap;
    1010import java.util.LinkedHashMap;
    11 import java.util.List;
    1211import java.util.Map;
    1312
     
    2625    private static final String JOSM_EPSG_FILE = "data_nodist/projection/josm-epsg";
    2726    private static final String PROJ4_EPSG_FILE = "data_nodist/projection/epsg";
     27    private static final String PROJ4_ESRI_FILE = "data_nodist/projection/esri";
    2828    private static final String OUTPUT_EPSG_FILE = "data/projection/custom-epsg";
    2929
    3030    private static final Map<String, ProjectionDefinition> epsgProj4 = new LinkedHashMap<>();
     31    private static final Map<String, ProjectionDefinition> esriProj4 = new LinkedHashMap<>();
    3132    private static final Map<String, ProjectionDefinition> epsgJosm = new LinkedHashMap<>();
    3233
     
    3536    // statistics:
    3637    private static int noInJosm = 0;
     38    private static int noInProj4 = 0;
    3739    private static int noDeprecated = 0;
    3840    private static int noGeocent = 0;
     
    4244    private static int noJosm = 0;
    4345    private static int noProj4 = 0;
     46    private static int noEsri = 0;
    4447    private static int noOmercNoBounds = 0;
    4548
     
    5356    }
    5457
     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
    5564    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);
    6468
    6569        try (FileOutputStream output = new FileOutputStream(baseDir + File.separator + OUTPUT_EPSG_FILE);
     
    6771            out.write("## This file is autogenerated, do not edit!\n");
    6872            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));
    7175            out.write("##\n");
    7276            out.write("## Entries checked and maintained by the JOSM team:\n");
     
    7781            out.write("## Other supported projections (source: proj.4):\n");
    7882            for (ProjectionDefinition pd : epsgProj4.values()) {
    79                 if (doInclude(pd, true)) {
     83                if (doInclude(pd, true, false)) {
    8084                    write(out, pd);
    8185                    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++;
    8293                }
    8394            }
     
    8798            System.out.println(String.format("loaded %d entries from %s", epsgJosm.size(), JOSM_EPSG_FILE));
    8899            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));
    89101            System.out.println();
    90102            System.out.println("some entries from proj.4 have not been included:");
    91103            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));
    92105            System.out.println(String.format(" * deprecated: %d entries", noDeprecated));
    93106            System.out.println(String.format(" * using +proj=geocent, which is 3D (X,Y,Z) and not useful in JOSM: %d entries", noGeocent));
     
    101114            System.out.println(String.format("written %d entries from %s", noJosm, JOSM_EPSG_FILE));
    102115            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));
    103117        }
    104 
    105118    }
    106119
     
    110123    }
    111124
    112     static boolean doInclude(ProjectionDefinition pd, boolean noIncludeJosm) {
     125    static boolean doInclude(ProjectionDefinition pd, boolean noIncludeJosm, boolean noIncludeProj4) {
    113126
    114127        boolean result = true;
     
    119132                result = false;
    120133                noInJosm++;
     134            }
     135        }
     136        if (noIncludeProj4) {
     137            // we already have this projection
     138            if (epsgProj4.containsKey(pd.code)) {
     139                result = false;
     140                noInProj4++;
    121141            }
    122142        }
Note: See TracChangeset for help on using the changeset viewer.