Ignore:
Timestamp:
2015-12-15T15:45:37+01:00 (4 years ago)
Author:
bastiK
Message:

see #12186 - add more projections
The list of projections is now generated during the build process:
scripts/BuildEpsgList.java runs and creates data/projection/custom-epsg which is generated by combining data_nodist/projection/josm-epsg (a list maintained by the JOSM team) and data_nodist/projection/epsg (an upstream list from the proj.4 project, git: 3795cdf)
The ant task epsg cares for this.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/projection/Projections.java

    r9127 r9133  
    6363    }
    6464
    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<>();
    7868
    7969    /*********************************
     
    144134        List<ProjectionDefinition> pds;
    145135        try {
    146             pds = loadProjectionDefinitions("resource://data/projection/epsg");
     136            pds = loadProjectionDefinitions("resource://data/projection/custom-epsg");
    147137        } catch (IOException ex) {
    148138            throw new RuntimeException(ex);
     
    152142            inits.put(pd.code, pd);
    153143        }
     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);
    154166    }
    155167
     
    203215    /**
    204216     * Load projection definitions from file.
    205      * 
     217     *
    206218     * @param path the path
    207219     * @return projection definitions
     
    214226        ) {
    215227            return loadProjectionDefinitions(r);
    216         } catch (IOException ex) {
    217             throw new RuntimeException(ex);
    218228        }
    219229    }
     
    221231    /**
    222232     * Load projection definitions from file.
    223      * 
     233     *
    224234     * @param r the reader
    225235     * @return projection definitions
     
    249259    }
    250260
    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 
    265261    public static Projection getProjectionByCode(String code) {
    266262        Projection proj = projectionsByCode_cache.get(code);
Note: See TracChangeset for help on using the changeset viewer.