locationtech / proj4j

Java port of the Proj.4 library for coordinate reprojection
Other
181 stars 71 forks source link

reprojection from epsg:31370 to epsg:3857 is inaccurate #82

Closed kervel closed 2 years ago

kervel commented 2 years ago

Hello,

Reprojecting from epsg:31370 to epsg:3857 gives me a substantial error. In the past i have worked around it by first converting to lat/lon and then from lat/lon to epsg:3857.

reference:

from pyproj import Proj, transform
outProj = Proj("+init=EPSG:3857")
inProj = Proj("+init=EPSG:31370")
x,y = (153005.702,  175718.465)
transform(inProj, outProj, x,y)

gives (491082.88112307055, 6602178.34577499)

i then added this test to the proj4j tests (CoordinateTransformTest):

checkTransform("EPSG:31370", 153005.702,  175718.465, "EPSG:3857", 491082.88112307055, 6602178.34577499, 0.01);

which gives

EPSG:31370(Lambert Conformal Conic/User) => EPSG:3857(Mercator/User)
[153005.702, 175718.465] -> [491082.9125899461, 6602178.287684356, 42.83499916549772] (expected: [491082.88112307055, 6602178.34577499] tol: 0.01 diff: 0.05809063371270895 )
FAIL
Src CRS: +proj=lcc +lat_1=51.16666723333333 +lat_2=49.8333339 +lat_0=90 +lon_0=4.367486666666666 +x_0=150000.013 +y_0=5400088.438 +ellps=intl +towgs84=-106.8686,52.2978,-103.7239,0.3366,-0.457,1.8422,-1.2747 +units=m +no_defs 
Tgt CRS: +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs 

First i tought this is identical to https://github.com/locationtech/proj4j/issues/32 but the issue remains with latest master branch.

Thanks! Frank

kervel commented 2 years ago

the error in the above logs is only 5cm, which is not enough to explain what i'm seeing. so i'm closing this issue and i'll open a new one once i find what's going on.