Changeset 5237 in josm


Ignore:
Timestamp:
May 13, 2012 11:29:01 AM (13 months ago)
Author:
bastiK
Message:

projection: minor improvements

Location:
trunk/src/org/openstreetmap/josm/data/projection
Files:
1 added
6 edited

Legend:

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

    r5073 r5237  
    22package org.openstreetmap.josm.data.projection; 
    33 
     4import org.openstreetmap.josm.data.coor.EastNorth; 
     5import org.openstreetmap.josm.data.coor.LatLon; 
    46import org.openstreetmap.josm.data.projection.datum.Datum; 
    57import org.openstreetmap.josm.data.projection.proj.Proj; 
    6 import org.openstreetmap.josm.data.coor.EastNorth; 
    7 import org.openstreetmap.josm.data.coor.LatLon; 
    88 
    99/** 
  • trunk/src/org/openstreetmap/josm/data/projection/CustomProjection.java

    r5235 r5237  
    2121import org.openstreetmap.josm.data.projection.datum.NTV2Datum; 
    2222import org.openstreetmap.josm.data.projection.datum.NTV2GridShiftFileWrapper; 
     23import org.openstreetmap.josm.data.projection.datum.NullDatum; 
    2324import org.openstreetmap.josm.data.projection.datum.SevenParameterDatum; 
    2425import org.openstreetmap.josm.data.projection.datum.ThreeParameterDatum; 
     
    246247        String nadgridsId = parameters.get(Param.nadgrids.key); 
    247248        if (nadgridsId != null) { 
     249            if (nadgridsId.startsWith("@")) { 
     250                nadgridsId = nadgridsId.substring(1); 
     251            } 
     252            if (nadgridsId.equals("null")) 
     253                return new NullDatum(null, ellps); 
    248254            NTV2GridShiftFileWrapper nadgrids = Projections.getNTV2Grid(nadgridsId); 
    249255            if (nadgrids == null) 
     
    280286            } 
    281287        } 
     288        boolean isCentric = true; 
     289        for (int i = 0; i<towgs84Param.size(); i++) { 
     290            if (towgs84Param.get(i) != 0.0) { 
     291                isCentric = false; 
     292                break; 
     293            } 
     294        } 
     295        if (isCentric) 
     296            return new CentricDatum(null, null, ellps); 
    282297        boolean is3Param = true; 
    283298        for (int i = 3; i<towgs84Param.size(); i++) { 
     
    287302            } 
    288303        } 
    289         Datum datum = null; 
    290         if (is3Param) { 
    291             datum = new ThreeParameterDatum(null, null, ellps, 
     304        if (is3Param) 
     305            return new ThreeParameterDatum(null, null, ellps, 
    292306                    towgs84Param.get(0), 
    293307                    towgs84Param.get(1), 
    294                     towgs84Param.get(2) 
    295             ); 
    296         } else { 
    297             datum = new SevenParameterDatum(null, null, ellps, 
     308                    towgs84Param.get(2)); 
     309        else 
     310            return new SevenParameterDatum(null, null, ellps, 
    298311                    towgs84Param.get(0), 
    299312                    towgs84Param.get(1), 
     
    302315                    towgs84Param.get(4), 
    303316                    towgs84Param.get(5), 
    304                     towgs84Param.get(6) 
    305             ); 
    306         } 
    307         return datum; 
     317                    towgs84Param.get(6)); 
    308318    } 
    309319 
  • trunk/src/org/openstreetmap/josm/data/projection/Projections.java

    r5234 r5237  
    123123            while ((line = r.readLine()) != null) { 
    124124                line = line.trim(); 
    125                 if (!line.startsWith("#")) { 
     125                if (!line.startsWith("#") && !line.isEmpty()) { 
    126126                    Matcher m = epsgPattern.matcher(line); 
    127127                    if (m.matches()) { 
  • trunk/src/org/openstreetmap/josm/data/projection/datum/GRS80Datum.java

    r4869 r5237  
    1111 * is necessary to get from or to the WGS84 datum. 
    1212 */ 
    13 public class GRS80Datum extends AbstractDatum { 
     13public class GRS80Datum extends NullDatum { 
    1414 
    1515    public final static GRS80Datum INSTANCE = new GRS80Datum(); 
    1616 
    1717    private GRS80Datum() { 
    18         super(tr("GRS80"), null, Ellipsoid.GRS80); 
    19     } 
    20  
    21     @Override 
    22     public LatLon fromWGS84(LatLon ll) { 
    23         return ll; 
    24     } 
    25  
    26     @Override 
    27     public LatLon toWGS84(LatLon ll) { 
    28         return ll; 
     18        super(tr("GRS80"), Ellipsoid.GRS80); 
    2919    } 
    3020} 
  • trunk/src/org/openstreetmap/josm/data/projection/datum/WGS84Datum.java

    r4869 r5237  
    1010 * WGS84 datum. Transformation from and to WGS84 datum is a no-op. 
    1111 */ 
    12 public class WGS84Datum extends AbstractDatum { 
     12public class WGS84Datum extends NullDatum { 
    1313 
    1414    public static final WGS84Datum INSTANCE = new WGS84Datum(); 
    1515 
    1616    private WGS84Datum() { 
    17         super(tr("WGS84"), "WGS84", Ellipsoid.WGS84); 
    18     } 
    19  
    20     @Override 
    21     public LatLon fromWGS84(LatLon ll) { 
    22         return ll; 
    23     } 
    24  
    25     @Override 
    26     public LatLon toWGS84(LatLon ll) { 
    27         return ll; 
     17        super(tr("WGS84"), Ellipsoid.WGS84); 
    2818    } 
    2919} 
  • trunk/src/org/openstreetmap/josm/data/projection/proj/Mercator.java

    r5228 r5237  
    2020    @Override 
    2121    public String getProj4Id() { 
    22         return null; // "merc" is ellipsoidal Mercator projection in PROJ.4 
     22        return "josm:smerc"; // "merc" is ellipsoidal Mercator projection in PROJ.4 
    2323    } 
    2424 
Note: See TracChangeset for help on using the changeset viewer.