Changeset 9532 in josm


Ignore:
Timestamp:
2016-01-18T22:48:40+01:00 (4 years ago)
Author:
bastiK
Message:

see #12186 - add Oblique Mercator projection
(imports pieces of code from the Geotools project)

Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/data_nodist/projection/josm-epsg

    r9133 r9532  
    363363# UTM zone 60S
    364364<32760> +proj=utm +zone=60 +south +datum=WGS84 +units=m +bounds=172,-85,182,5  <>
     365##
     366## Following entries use Oblique Mercator projection.
     367## There is no easy way to automatically generate reasonable bounds for this projection
     368## so bounds have been added by hand. (Otherwise unchanged copy from epsg file.)
     369##
     370# NAD83(NSRS2007) / Michigan Oblique Mercator
     371<3591> +proj=omerc +lat_0=45.30916666666666 +lonc=-86 +alpha=337.25556 +k=0.9996 +x_0=2546731.496 +y_0=-4354009.816 +no_uoff +gamma=337.25556 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +bounds=-91,41,-82,49 <>
     372# GDBD2009 / Brunei BRSO
     373<5247> +proj=omerc +lat_0=4 +lonc=115 +alpha=53.31580995 +k=0.99984 +x_0=0 +y_0=0 +no_uoff +gamma=53.13010236111111 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +bounds=112,4,116,7 <>
     374# NAD83(NSRS2007) / Alaska zone 1
     375<3468> +proj=omerc +lat_0=57 +lonc=-133.6666666666667 +alpha=323.1301023611111 +k=0.9999 +x_0=5000000 +y_0=-5000000 +no_uoff +gamma=323.1301023611111 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +bounds=-141,54,-129,61 <>
     376# NAD83(2011) / Michigan Oblique Mercator
     377<6497> +proj=omerc +lat_0=45.30916666666666 +lonc=-86 +alpha=337.25556 +k=0.9996 +x_0=2546731.496 +y_0=-4354009.816 +no_uoff +gamma=337.25556 +ellps=GRS80 +units=m +no_defs +bounds=-91,41,-82,49 <>
     378# Rassadiran / Nakhl e Taqi
     379<2057> +proj=omerc +lat_0=27.51882880555555 +lonc=52.60353916666667 +alpha=0.5716611944444444 +k=0.999895934 +x_0=658377.437 +y_0=3044969.194 +gamma=0.5716611944444444 +ellps=intl +towgs84=-133.63,-157.5,-158.62,0,0,0,0 +units=m +no_defs +bounds=52,27,53,28 <>
     380# GDM2000 / East Malaysia BRSO
     381<3376> +proj=omerc +lat_0=4 +lonc=115 +alpha=53.31580995 +k=0.99984 +x_0=0 +y_0=0 +no_uoff +gamma=53.13010236111111 +ellps=GRS80 +units=m +no_defs +bounds=109,0,120,8 <>
     382# GDM2000 / Peninsula RSO
     383<3375> +proj=omerc +lat_0=4 +lonc=102.25 +alpha=323.0257964666666 +k=0.99984 +x_0=804671 +y_0=0 +no_uoff +gamma=323.1301023611111 +ellps=GRS80 +units=m +no_defs +bounds=98,1,106,8 <>
     384# NAD83(2011) / Alaska zone 1
     385<6394> +proj=omerc +lat_0=57 +lonc=-133.6666666666667 +alpha=323.1301023611111 +k=0.9999 +x_0=5000000 +y_0=-5000000 +no_uoff +gamma=323.1301023611111 +ellps=GRS80 +units=m +no_defs +bounds=-141,54,-129,61 <>
     386# NAD83 / Alaska zone 1
     387<26931> +proj=omerc +lat_0=57 +lonc=-133.6666666666667 +alpha=323.1301023611111 +k=0.9999 +x_0=5000000 +y_0=-5000000 +no_uoff +gamma=323.1301023611111 +datum=NAD83 +units=m +no_defs +bounds=-141,54,-129,61 <>
     388# Kertau (RSO) / RSO Malaya (ch)
     389<3167> +proj=omerc +lat_0=4 +lonc=102.25 +alpha=323.0257905 +k=0.99984 +x_0=40000 +y_0=0 +no_uoff +gamma=323.1301023611111 +a=6377295.664 +b=6356094.667915204 +to_meter=20.116756 +no_defs +bounds=99,1,105,7 <>
     390# Kertau (RSO) / RSO Malaya (m)
     391<3168> +proj=omerc +lat_0=4 +lonc=102.25 +alpha=323.0257905 +k=0.99984 +x_0=804670.24 +y_0=0 +no_uoff +gamma=323.1301023611111 +a=6377295.664 +b=6356094.667915204 +units=m +no_defs +bounds=99,1,105,7 <>
     392# NAD83(HARN) / Michigan Oblique Mercator
     393<3079> +proj=omerc +lat_0=45.30916666666666 +lonc=-86 +alpha=337.25556 +k=0.9996 +x_0=2546731.496 +y_0=-4354009.816 +no_uoff +gamma=337.25556 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +bounds=-91,41,-82,49 <>
     394# NAD83 / Michigan Oblique Mercator
     395<3078> +proj=omerc +lat_0=45.30916666666666 +lonc=-86 +alpha=337.25556 +k=0.9996 +x_0=2546731.496 +y_0=-4354009.816 +no_uoff +gamma=337.25556 +datum=NAD83 +units=m +no_defs +bounds=-91,41,-82,49 <>
     396# Timbalai 1948 / RSO Borneo (m)
     397<29873> +proj=omerc +lat_0=4 +lonc=115 +alpha=53.31582047222222 +k=0.99984 +x_0=590476.87 +y_0=442857.65 +gamma=53.13010236111111 +ellps=evrstSS +towgs84=-679,669,-48,0,0,0,0 +units=m +no_defs +bounds=109,0,120,8 <>
     398# Timbalai 1948 / RSO Borneo (ch)
     399<29871> +proj=omerc +lat_0=4 +lonc=115 +alpha=53.31582047222222 +k=0.99984 +x_0=590476.8714630401 +y_0=442857.653094361 +gamma=53.13010236111111 +ellps=evrstSS +towgs84=-679,669,-48,0,0,0,0 +to_meter=20.11676512155263 +no_defs +bounds=109,0,120,8 <>
     400# Timbalai 1948 / RSO Borneo (ft)
     401<29872> +proj=omerc +lat_0=4 +lonc=115 +alpha=53.31582047222222 +k=0.99984 +x_0=590476.8727431979 +y_0=442857.6545573985 +gamma=53.13010236111111 +ellps=evrstSS +towgs84=-679,669,-48,0,0,0,0 +to_meter=0.3047994715386762 +no_defs +bounds=109,0,120,8 <>
     402# Tananarive (Paris) / Laborde Grid approximation
     403<29702> +proj=omerc +lat_0=-18.9 +lonc=44.10000000000001 +alpha=18.9 +k=0.9995000000000001 +x_0=400000 +y_0=800000 +gamma=18.9 +ellps=intl +towgs84=-189,-242,-91,0,0,0,0 +pm=paris +units=m +no_defs +bounds=43,-26,51,-11 <>
  • trunk/scripts/BuildProjectionDefinitions.java

    r9413 r9532  
    4242    private static int noJosm = 0;
    4343    private static int noProj4 = 0;
     44    private static int noOmercNoBounds = 0;
    4445
    4546    /**
     
    9394            System.out.println("   in particular: " + baseProjectionMap);
    9495            System.out.println(String.format(" * requires data file for datum conversion: %d entries", noDatumgrid));
     96            if (noOmercNoBounds > 0) {
     97                System.out.println(String.format(" * projection is Oblique Mercator (requires bounds), but no bounds specified: %d entries", noOmercNoBounds));
     98            }
    9599            System.out.println();
    96100            System.out.println(String.format("written %d entries from %s", noJosm, JOSM_EPSG_FILE));
     
    164168            noDatumgrid++;
    165169        }
     170       
     171        if (result && "omerc".equals(proj) && !parameters.containsKey(CustomProjection.Param.bounds.key)) {
     172            result = false;
     173            noOmercNoBounds++;
     174        }
    166175
    167176        return result;
  • trunk/src/org/openstreetmap/josm/data/projection/CustomProjection.java

    r9431 r9532  
    2525import org.openstreetmap.josm.data.projection.datum.ThreeParameterDatum;
    2626import org.openstreetmap.josm.data.projection.datum.WGS84Datum;
     27import org.openstreetmap.josm.data.projection.proj.ICentralMeridianProvider;
    2728import org.openstreetmap.josm.data.projection.proj.IPolar;
    2829import org.openstreetmap.josm.data.projection.proj.Mercator;
     
    9899        /** Latitude of second standard parallel */
    99100        lat_2("lat_2", true),
    100         /** Latitude of true scale */
     101        /** Latitude of true scale (Polar Stereographic) */
    101102        lat_ts("lat_ts", true),
     103        /** longitude of the center of the projection (Oblique Mercator) */
     104        lonc("lonc", true),
     105        /** azimuth (true) of the center line passing through the center of the
     106         * projection (Oblique Mercator) */
     107        alpha("alpha", true),
     108        /** rectified bearing of the center line (Oblique Mercator) */
     109        gamma("gamma", true),
     110        /** select "Hotine" variant of Oblique Mercator */
     111        no_off("no_off", false),
     112        /** legacy alias for no_off */
     113        no_uoff("no_uoff", false),
     114        /** longitude of first point (Oblique Mercator) */
     115        lon_1("lon_1", true),
     116        /** longitude of second point (Oblique Mercator) */
     117        lon_2("lon_2", true),
    102118        /** the exact proj.4 string will be preserved in the WKT representation */
    103119        wktext("wktext", false),  // ignored
     
    232248            if (s != null) {
    233249                this.lon0 = parseAngle(s, Param.lon_0.key);
     250            }
     251            if (proj instanceof ICentralMeridianProvider) {
     252                this.lon0 = ((ICentralMeridianProvider) proj).getCentralMeridian();
    234253            }
    235254            s = parameters.get(Param.pm.key);
     
    501520        if (s != null) {
    502521            projParams.lat_ts = parseAngle(s, Param.lat_ts.key);
     522        }
     523        s = parameters.get(Param.lonc.key);
     524        if (s != null) {
     525            projParams.lonc = parseAngle(s, Param.lonc.key);
     526        }
     527        s = parameters.get(Param.alpha.key);
     528        if (s != null) {
     529            projParams.alpha = parseAngle(s, Param.alpha.key);
     530        }
     531        s = parameters.get(Param.gamma.key);
     532        if (s != null) {
     533            projParams.gamma = parseAngle(s, Param.gamma.key);
     534        }
     535        s = parameters.get(Param.lon_1.key);
     536        if (s != null) {
     537            projParams.lon1 = parseAngle(s, Param.lon_1.key);
     538        }
     539        s = parameters.get(Param.lon_2.key);
     540        if (s != null) {
     541            projParams.lon2 = parseAngle(s, Param.lon_2.key);
     542        }
     543        if (parameters.containsKey(Param.no_off.key) || parameters.containsKey(Param.no_uoff.key)) {
     544            projParams.no_off = true;
    503545        }
    504546        proj.initialize(projParams);
  • trunk/src/org/openstreetmap/josm/data/projection/Projections.java

    r9419 r9532  
    3535import org.openstreetmap.josm.data.projection.proj.LonLat;
    3636import org.openstreetmap.josm.data.projection.proj.Mercator;
     37import org.openstreetmap.josm.data.projection.proj.ObliqueMercator;
    3738import org.openstreetmap.josm.data.projection.proj.PolarStereographic;
    3839import org.openstreetmap.josm.data.projection.proj.Proj;
     
    8889        registerBaseProjection("lcc", LambertConformalConic.class, "core");
    8990        registerBaseProjection("lonlat", LonLat.class, "core");
     91        registerBaseProjection("omerc", ObliqueMercator.class, "core");
    9092        registerBaseProjection("somerc", SwissObliqueMercator.class, "core");
    9193        registerBaseProjection("stere", PolarStereographic.class, "core");
  • trunk/src/org/openstreetmap/josm/data/projection/proj/AbstractProj.java

    r9432 r9532  
    2525
    2626    /**
     27     * Difference allowed in iterative computations.
     28     */
     29    private static final double ITERATION_TOLERANCE = 1E-10;
     30
     31    /**
    2732     * Relative iteration precision used in the <code>mlfn</code> method
    2833     */
     
    153158
    154159    /**
     160     * Iteratively solve equation (7-9) from Snyder.
     161     */
     162    final double cphi2(final double ts) {
     163        final double eccnth = 0.5 * e;
     164        double phi = (Math.PI/2) - 2.0 * Math.atan(ts);
     165        for (int i=0; i<MAXIMUM_ITERATIONS; i++) {
     166            final double con  = e * Math.sin(phi);
     167            final double dphi = (Math.PI/2) - 2.0*Math.atan(ts * Math.pow((1-con)/(1+con), eccnth)) - phi;
     168            phi += dphi;
     169            if (Math.abs(dphi) <= ITERATION_TOLERANCE) {
     170                return phi;
     171            }
     172        }
     173        throw new RuntimeException("no convergence");
     174    }
     175
     176    /**
    155177     * Computes function <code>f(s,c,e²) = c/sqrt(1 - s²&times;e²)</code> needed for the true scale
    156178     * latitude (Snyder 14-15), where <var>s</var> and <var>c</var> are the sine and cosine of
  • trunk/src/org/openstreetmap/josm/data/projection/proj/ProjParameters.java

    r9419 r9532  
    1414    public Double lat1;
    1515    public Double lat2;
     16
     17    // Polar Stereographic
    1618    public Double lat_ts;
     19
     20    // Oblique Mercator
     21    public Double lonc;
     22    public Double alpha;
     23    public Double gamma;
     24    public Boolean no_off;
     25    public Double lon1;
     26    public Double lon2;
    1727}
  • trunk/src/org/openstreetmap/josm/gui/MapView.java

    r9246 r9532  
    739739        GeneralPath path = new GeneralPath();
    740740
     741        double d = 1.0;
    741742        path.moveTo(p.x, p.y);
    742743        double max = b.getMax().lat();
    743         for (; lat <= max; lat += 1.0) {
     744        for (; lat <= max; lat += d) {
    744745            p = getPoint(new LatLon(lat >= max ? max : lat, lon));
    745746            path.lineTo(p.x, p.y);
    746747        }
    747748        lat = max; max = b.getMax().lon();
    748         for (; lon <= max; lon += 1.0) {
     749        for (; lon <= max; lon += d) {
    749750            p = getPoint(new LatLon(lat, lon >= max ? max : lon));
    750751            path.lineTo(p.x, p.y);
    751752        }
    752753        lon = max; max = b.getMinLat();
    753         for (; lat >= max; lat -= 1.0) {
     754        for (; lat >= max; lat -= d) {
    754755            p = getPoint(new LatLon(lat <= max ? max : lat, lon));
    755756            path.lineTo(p.x, p.y);
    756757        }
    757758        lat = max; max = b.getMinLon();
    758         for (; lon >= max; lon -= 1.0) {
     759        for (; lon >= max; lon -= d) {
    759760            p = getPoint(new LatLon(lat, lon <= max ? max : lon));
    760761            path.lineTo(p.x, p.y);
Note: See TracChangeset for help on using the changeset viewer.