Skip to content

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

@emxsys

Description

@emxsys

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)
            ];
        };

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions