Ignore:
Timestamp:
2012-05-13T23:04:35+02:00 (12 years ago)
Author:
bastiK
Message:

projections: minor stuff

File:
1 edited

Legend:

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

    r5237 r5239  
    1616import org.openstreetmap.josm.data.Bounds;
    1717import org.openstreetmap.josm.data.coor.LatLon;
    18 import org.openstreetmap.josm.data.projection.CustomProjection.Param;
    1918import org.openstreetmap.josm.data.projection.datum.CentricDatum;
    2019import org.openstreetmap.josm.data.projection.datum.Datum;
     
    4443    protected Bounds bounds;
    4544
    46     protected static class Param {
     45    protected static enum Param {
     46
     47        x_0("x_0", true),
     48        y_0("y_0", true),
     49        lon_0("lon_0", true),
     50        k_0("k_0", true),
     51        ellps("ellps", true),
     52        a("a", true),
     53        es("es", true),
     54        rf("rf", true),
     55        f("f", true),
     56        b("b", true),
     57        datum("datum", true),
     58        towgs84("towgs84", true),
     59        nadgrids("nadgrids", true),
     60        proj("proj", true),
     61        lat_0("lat_0", true),
     62        lat_1("lat_1", true),
     63        lat_2("lat_2", true),
     64        wktext("wktext", false),  // ignored
     65        units("units", true),     // ignored
     66        no_defs("no_defs", false),
     67        init("init", true),
     68        // JOSM extension, not present in PROJ.4
     69        bounds("bounds", true);
     70
    4771        public String key;
    4872        public boolean hasValue;
    4973
    50         public final static Param x_0 = new Param("x_0", true);
    51         public final static Param y_0 = new Param("y_0", true);
    52         public final static Param lon_0 = new Param("lon_0", true);
    53         public final static Param k_0 = new Param("k_0", true);
    54         public final static Param ellps = new Param("ellps", true);
    55         public final static Param a = new Param("a", true);
    56         public final static Param es = new Param("es", true);
    57         public final static Param rf = new Param("rf", true);
    58         public final static Param f = new Param("f", true);
    59         public final static Param b = new Param("b", true);
    60         public final static Param datum = new Param("datum", true);
    61         public final static Param towgs84 = new Param("towgs84", true);
    62         public final static Param nadgrids = new Param("nadgrids", true);
    63         public final static Param proj = new Param("proj", true);
    64         public final static Param lat_0 = new Param("lat_0", true);
    65         public final static Param lat_1 = new Param("lat_1", true);
    66         public final static Param lat_2 = new Param("lat_2", true);
    67         public final static Param wktext = new Param("wktext", false);  // ignored
    68         public final static Param units = new Param("units", true);     // ignored
    69         public final static Param no_defs = new Param("no_defs", false);
    70         public final static Param init = new Param("init", true);
    71         // JOSM extension, not present in PROJ.4
    72         public final static Param bounds = new Param("bounds", true);
    73 
    74         public final static Set<Param> params = new HashSet<Param>(Arrays.asList(
    75                 x_0, y_0, lon_0, k_0, ellps, a, es, rf, f, b, datum, towgs84,
    76                 nadgrids, proj, lat_0, lat_1, lat_2, wktext, units, no_defs,
    77                 init, bounds
    78         ));
    79 
    8074        public final static Map<String, Param> paramsByKey = new HashMap<String, Param>();
    8175        static {
    82             for (Param p : params) {
     76            for (Param p : Param.values()) {
    8377                paramsByKey.put(p.key, p);
    8478            }
    8579        }
    8680
    87         public Param(String key, boolean hasValue) {
     81        Param(String key, boolean hasValue) {
    8882            this.key = key;
    8983            this.hasValue = hasValue;
     
    116110            bounds = new Bounds(
    117111                    new LatLon(-85.05112877980659, -180.0),
    118                     new LatLon(85.05112877980659, 180.0));
     112                    new LatLon(85.05112877980659, 180.0), true);
    119113        } else {
    120114            Map<String, String> parameters = parseParameterList(pref);
     
    384378        final String FLOAT = "(\\d+(\\.\\d*)?)";
    385379        boolean dms = false;
     380        double deg = 0.0, min = 0.0, sec = 0.0;
    386381        // degrees
    387382        m = Pattern.compile("^"+FLOAT+"d").matcher(s);
    388383        if (m.find()) {
    389384            s = s.substring(m.end());
    390             value += Double.parseDouble(m.group(1));
     385            deg = Double.parseDouble(m.group(1));
    391386            dms = true;
    392387        }
     
    395390        if (m.find()) {
    396391            s = s.substring(m.end());
    397             value += Double.parseDouble(m.group(1)) / 60.0;
     392            min = Double.parseDouble(m.group(1));
    398393            dms = true;
    399394        }
     
    402397        if (m.find()) {
    403398            s = s.substring(m.end());
    404             value += Double.parseDouble(m.group(1)) / 3600.0;
     399            sec = Double.parseDouble(m.group(1));
    405400            dms = true;
    406401        }
    407402        // plain number (in degrees)
    408         if (!dms) {
     403        if (dms) {
     404            value = deg + (min/60.0) + (sec/3600.0);
     405        } else {
    409406            m = Pattern.compile("^"+FLOAT).matcher(s);
    410407            if (m.find()) {
     
    433430    }
    434431
    435     public void dump() {
    436         System.err.println("x_0="+x_0);
    437         System.err.println("y_0="+y_0);
    438         System.err.println("lon_0="+lon_0);
    439         System.err.println("k_0="+k_0);
    440         System.err.println("ellps="+ellps);
    441         System.err.println("proj="+proj);
    442         System.err.println("datum="+datum);
    443     }
    444 
    445432    @Override
    446433    public Integer getEpsgCode() {
Note: See TracChangeset for help on using the changeset viewer.