Changeset 9105 in josm for trunk/src/org


Ignore:
Timestamp:
2015-12-13T01:06:16+01:00 (9 years ago)
Author:
bastiK
Message:

add support for proj.4 parameter +pm=* - prime meridian (see #12186)

Location:
trunk/src/org/openstreetmap/josm/data/projection
Files:
2 edited

Legend:

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

    r8840 r9105  
    2929    protected double y0;       /* false northing (in meters) */
    3030    protected double lon0;     /* central meridian */
     31    protected double pm;       /* prime meridian */
    3132    protected double k0 = 1.0; /* general scale factor */
    3233
     
    6667    public EastNorth latlon2eastNorth(LatLon ll) {
    6768        ll = datum.fromWGS84(ll);
    68         double[] en = proj.project(Math.toRadians(ll.lat()), Math.toRadians(ll.lon() - lon0));
     69        double[] en = proj.project(Math.toRadians(ll.lat()), Math.toRadians(ll.lon() - lon0 - pm));
    6970        return new EastNorth(ellps.a * k0 * en[0] + x0, ellps.a * k0 * en[1] + y0);
    7071    }
     
    7374    public LatLon eastNorth2latlon(EastNorth en) {
    7475        double[] latlon_rad = proj.invproject((en.east() - x0) / ellps.a / k0, (en.north() - y0) / ellps.a / k0);
    75         LatLon ll = new LatLon(Math.toDegrees(latlon_rad[0]), Math.toDegrees(latlon_rad[1]) + lon0);
     76        LatLon ll = new LatLon(Math.toDegrees(latlon_rad[0]), Math.toDegrees(latlon_rad[1]) + lon0 + pm);
    7677        return datum.toWGS84(ll);
    7778    }
  • trunk/src/org/openstreetmap/josm/data/projection/CustomProjection.java

    r8846 r9105  
    3838    private static final double METER_PER_UNIT_DEGREE = 2 * Math.PI * 6370997 / 360;
    3939    private static final Map<String, Double> UNITS_TO_METERS = getUnitsToMeters();
     40    private static final Map<String, Double> PRIME_MERIDANS = getPrimeMeridians();
    4041
    4142    /**
     
    6465        /** Central meridian */
    6566        lon_0("lon_0", true),
     67        /** Prime meridian */
     68        pm("pm", true),
    6669        /** Scaling factor */
    6770        k_0("k_0", true),
     
    222225                this.lon0 = parseAngle(s, Param.lon_0.key);
    223226            }
     227            s = parameters.get(Param.pm.key);
     228            if (s != null) {
     229                if (PRIME_MERIDANS.containsKey(s)) {
     230                    this.pm = PRIME_MERIDANS.get(s);
     231                } else {
     232                    this.pm = parseAngle(s, Param.pm.key);
     233                }
     234            }
    224235            s = parameters.get(Param.k_0.key);
    225236            if (s != null) {
     
    626637        return ret;
    627638    }
     639
     640    private static Map<String, Double> getPrimeMeridians() {
     641        Map<String, Double> ret = new ConcurrentHashMap<>();
     642        try {
     643            ret.put("greenwich", 0.0);
     644            ret.put("lisbon", parseAngle("9d07'54.862\"W", null));
     645            ret.put("paris", parseAngle("2d20'14.025\"E", null));
     646            ret.put("bogota", parseAngle("74d04'51.3\"W", null));
     647            ret.put("madrid", parseAngle("3d41'16.58\"W", null));
     648            ret.put("rome", parseAngle("12d27'8.4\"E", null));
     649            ret.put("bern", parseAngle("7d26'22.5\"E", null));
     650            ret.put("jakarta", parseAngle("106d48'27.79\"E", null));
     651            ret.put("ferro", parseAngle("17d40'W", null));
     652            ret.put("brussels", parseAngle("4d22'4.71\"E", null));
     653            ret.put("stockholm", parseAngle("18d3'29.8\"E", null));
     654            ret.put("athens", parseAngle("23d42'58.815\"E", null));
     655            ret.put("oslo", parseAngle("10d43'22.5\"E", null));
     656        } catch (ProjectionConfigurationException ex) {
     657            throw new RuntimeException();
     658        }
     659        return ret;
     660    }
    628661}
Note: See TracChangeset for help on using the changeset viewer.