Changeset 5239 in josm


Ignore:
Timestamp:
May 13, 2012 11:04:35 PM (13 months ago)
Author:
bastiK
Message:

projections: minor stuff

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/data_nodist/projection-regression-test-data.csv

    r5236 r5239  
    495495EPSG:3812 
    496496  ll  50.76787953358437 3.4513353977071453 
    497   en  585284.6677650046 662323.5758590293 
    498   ll2 50.76787953358439 3.4513353977071453 
     497  en  585284.6677650047 662323.5758590293 
     498  ll2 50.76787953358439 3.451335397707146 
    499499EPSG:21781 
    500500  ll  46.582471410091934 8.159223152110604 
     
    523523EPSG:27561 
    524524  ll  48.687023294540744 9.13470536591202 
    525   en  1099861.4328694288 132165.3475888513 
     525  en  1099861.4328694288 132165.3475888506 
    526526  ll2 48.687023294540765 9.134705365912021 
    527527EPSG:27562 
     
    531531EPSG:27563 
    532532  ll  46.443136133672226 5.992820527372115 
    533   en  881070.7805340261 466693.7656533603 
    534   ll2 46.44313613367226 5.992820527372114 
     533  en  881070.7805340262 466693.7656533603 
     534  ll2 46.44313613367226 5.992820527372113 
    535535EPSG:27564 
    536536  ll  43.42400252536329 0.5163786716368639 
  • trunk/src/org/openstreetmap/josm/data/projection/AbstractProjection.java

    r5237 r5239  
    9898 
    9999    protected static final double convertDegreeMinuteSecond(double degree, double minute, double second) { 
    100         return degree + convertMinuteSecond(minute, second); 
     100        return degree + (minute/60.0) + (second/3600.0); 
    101101    } 
     102     
     103    public void dump() { 
     104        System.err.println("x_0="+x_0); 
     105        System.err.println("y_0="+y_0); 
     106        System.err.println("lon_0="+lon_0); 
     107        System.err.println("k_0="+k_0); 
     108        System.err.println("ellps="+ellps); 
     109        System.err.println("proj="+proj); 
     110        System.err.println("datum="+datum); 
     111    } 
     112 
    102113} 
  • 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.