Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Web Mercator transforms with newest versions of proj4js #1526

Open
geographika opened this issue Mar 26, 2018 · 0 comments
Open

Incorrect Web Mercator transforms with newest versions of proj4js #1526

geographika opened this issue Mar 26, 2018 · 0 comments

Comments

@geographika
Copy link

geographika commented Mar 26, 2018

It looks like there was a change between proj4js 2.3.15 and 2.3.16 that has broken EPSG:4326 to EPSG:3857 transformations:

        var pt = new OpenLayers.Geometry.Point(-898447, 6907203);
        var epsg4326 = new OpenLayers.Projection("EPSG:4326");
        var epsg3857 = new OpenLayers.Projection("EPSG:3857");
        pt.transform(epsg3857, epsg4326);
        console.log(pt.x);
        console.log(pt.y);

        expect(Math.round(pt.x)).toEqual(-8);
        expect(Math.round(pt.y)).toEqual(53);

In 2.3.16 and later the results are:

        // proj4 - 2.3.16.js
        // -0.14086354683193542
        // 0.9178388206728668
        // console.log(JSON.stringify(proj4.defs["EPSG:4326"]))
        // { "title": "WGS 84 (long/lat)", "projName": "longlat", "ellps": "WGS84", "datumCode": "WGS84", "units": "degrees", "k0": 1, "axis": "enu" }
        // console.log(JSON.stringify(proj4.defs["EPSG:3857"]))
        // { "title": "WGS 84 / Pseudo-Mercator", "projName": "merc", "a": 6378137, "b": 6378137, "lat_ts": 0, "long0": 0, "x0": 0, "y0": 0, "k0": 1, "units": "m", "datumCode": "none", "no_defs": true, "axis": "enu" }

In 2.3.15 they are:

        // proj4-2.3.15
        // -8.070886720713318
        // 52.588290697820085
        // console.log(JSON.stringify(proj4.defs["EPSG:4326"]))
        // { "title": "WGS 84 (long/lat)", "projName": "longlat", "ellps": "WGS84", "datumCode": "WGS84", "units": "degrees", "a": 6378137, "rf": 298.257223563, "ellipseName": "WGS 84", "b": 6356752.314245179, "a2": 40680631590769, "b2": 40408299984661.445, "es": 0.006694379990141316, "e": 0.08181919084262149, "ep2": 0.006739496742276434, "k0": 1, "axis": "enu", "datum": { "datum_type": 4, "a": 6378137, "b": 6356752.314245179, "es": 0.006694379990141316, "ep2": 0.006739496742276434 } }
        // console.log(JSON.stringify(proj4.defs["EPSG:3857"]))
        // {"title":"WGS 84 / Pseudo-Mercator","projName":"merc","a":6378137,"b":6378137,"lat_ts":0,"long0":0,"x0":0,"y0":0,"k0":1,"units":"m","datumCode":"none","no_defs":true,"sphere":true,"a2":40680631590769,"b2":40680631590769,"es":0,"e":0,"ep2":0,"axis":"enu","datum":{"datum_type":5,"a":6378137,"b":6378137,"es":0,"ep2":0}}

However proj4js works fine independently of ol2:


        var toProj = proj4('EPSG:4326');
        var fromProj = proj4('EPSG:3857');
        var res = proj4(fromProj, toProj, [-898447, 6907203]);
        expect(Math.round(res[0])).toEqual(-8);
        expect(Math.round(res[1])).toEqual(53);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant