[PROJ] Transformation failure -- valid?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[PROJ] Transformation failure -- valid?

Nyall Dawson
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?

Nyall
_______________________________________________
PROJ mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/proj
Reply | Threaded
Open this post in threaded view
|

Re: Transformation failure -- valid?

Even Rouault-2
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
_______________________________________________
PROJ mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/proj
Reply | Threaded
Open this post in threaded view
|

Re: Transformation failure -- valid?

Nyall Dawson
On Tue, 21 May 2019 at 19:55, Even Rouault <[hidden email]> wrote:

>
> 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:

This was a silly error on my part -- I had some extra test code in
between creation of the crs and the proj_trans call which was raising
an error, and I'd omitted a call to proj_errno_reset to clear the
error afterwards. So the -61 error was actually coming from the
earlier call, and not the proj_trans one.

Nyall
_______________________________________________
PROJ mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/proj