[PROJ] Transformation failure -- valid?

Even Rouault even.rouault at spatialys.com
Tue May 21 02:55:34 PDT 2019


On mardi 21 mai 2019 16:51:48 CEST Nyall Dawson wrote:
> Hi list,
> 
> Another one from me. Attempting to reproject from WGS84 to web mercator:
> 
> PJ* crs = proj_create_crs_to_crs( 0, "+proj=longlat +datum=WGS84
> +no_defs", "+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0
> +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs")
> PK* res = proj_normalize_for_visualization( 0, crs );
> 
> Throws an error -61 when trying to reproject the coordinate -68.2 /
> 70.8 using res.
> 
> What am I missing?

Works for me:

#include "proj.h"
#include <stdio.h>

int main()
{
    PJ* crs = proj_create_crs_to_crs( 0,
        "+proj=longlat +datum=WGS84 +no_defs",
        "+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 
+k=1 +units=m +nadgrids=@null +wktext +no_defs",
        0);
    PJ* res = proj_normalize_for_visualization( 0, crs );
    PJ_COORD c;
    c.xyz.x = -68.2;
    c.xyz.y = 70.8;
    c.xyz.z = 0;
    c =  proj_trans(res, PJ_FWD, c);
    printf("%f %f\n", c.xy.x, c.xy.y);
    printf("%d\n", proj_errno(res));
    return 0;
}


ouputs

-7591989.272101 11334231.572082
0

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the PROJ mailing list