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

Inaccurate 3857 to 4326 conversion causes poor WMTS tile registration #793

Open
emxsys opened this issue Nov 20, 2018 · 0 comments
Open
Labels

Comments

@emxsys
Copy link
Contributor

emxsys commented Nov 20, 2018

Description

The WWMath.epsg3857ToEpsg4326 doesn't use sufficient precision to convert coordinates correctly. The radius used in the function is 6.3781e6, it should be 6.378137e6 (note the addition of the "3" and "7" digits). The problem is manifest when displaying higher resolution tiles.

The following screen shot shows a blend of two USGS layers. The WMTS topographic layer uses the 3857 projection and you can see the streets are displaced to the west compared the WMS NAIP imagery layer.

screen shot 2018-11-20 at 6 14 27 am

Additional Information

Workaround

Applications can override and correct the epsg3857ToEpsg4326 function by running the following function after loading the WebWorldWind library.

        WorldWind.WWMath.epsg3857ToEpsg4326 = function (easting, northing) {
            var r = 6.378137e6,
                latRadians = (Math.PI / 2) - 2 * Math.atan(Math.exp(-northing / r)),
                lonRadians = easting / r;

            return [
                WorldWind.WWMath.clamp(latRadians * WorldWind.Angle.RADIANS_TO_DEGREES, -90, 90),
                WorldWind.WWMath.clamp(lonRadians * WorldWind.Angle.RADIANS_TO_DEGREES, -180, 180)
            ];
        };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant