Joaquim,

I've looked at that. Experimentally, it doesn't seem that the current maths for wintri in +over mode give reasonable results for longitudes > 360deg in absolute value (and I'm not sure if there would be a natural extension possible. Far beyond my knowledge of the underlying maths).

gdalwarp does a little better by default because it couples the forward and inverse transformer to check the domain of validity and experimentally must find this limitation and will thus give up for source pixels whose longitude > 360 deg. For ogr2ogr / vector this is more complicated as reprojection of a single geometry  (here cl540.gpkg is a single polygon with longitudes in [-540,540] range). is a "all points succeed to reproject => OK" / "one single point fails to reproject => KO" type of situation, at least in the logic followed by OGRGeometry::transform() logic.

So while the following patch to PROJ is probably technically correct, it wouldn't help in practice

diff --git a/src/projections/aitoff.cpp b/src/projections/aitoff.cpp
index 9d060999f..cce319157 100644
--- a/src/projections/aitoff.cpp
+++ b/src/projections/aitoff.cpp
@@ -59,6 +59,11 @@ static PJ_XY aitoff_s_forward(PJ_LP lp, PJ *P) { /* Spheroidal, forward */
     struct pj_opaque *Q = static_cast<struct pj_opaque *>(P->opaque);
     double c, d;

+    if( fabs(lp.lam) > 2 * M_PI ) {
+        proj_errno_set(
+                    P, PROJ_ERR_COORD_TRANSFM_OUTSIDE_PROJECTION_DOMAIN);
+        return xy;
+    }
     c = 0.5 * lp.lam;
     d = acos(cos(lp.phi) * cos(c));
     if (d != 0.0) { /* basic Aitoff */

The only solution I can offer is that you must explictly clip your source geometry to the validity range of wintri with -clipsrc -360 -90 360 90.

Even


Le 30/04/2023 à 03:11, Joaquim Manuel Freire Luís via gdal-dev a écrit :

Even, this is a kind of continuation of the subject that I brought up in https://github.com/OSGeo/gdal/issues/7644

The file size limitation of attachments doesn’t help to make this case easily reproducible, but the story is, I can make that rectangular map using gdalwarp and ogr2ogr that use the +over option and +proj=vandg

(see https://forum.generic-mapping-tools.org/t/best-projection-for-rectangular-world-map/3715/82?u=joaquim)

But when I try the same with +proj=wintry the gdalwarp op works well but the ogr2ogr doesn’t.

(see https://forum.generic-mapping-tools.org/t/best-projection-for-rectangular-world-map/3715/85?u=joaquim)

You can more less reproduce this case using this file

http://fct-gmt.ualg.pt/tmp/cl540.gpkg

ogr2ogr  -t_srs "+proj=wintri +over" cl540_wintri.gpkg cl540.gpkg

Why would that be in this case?

Joaquim


_______________________________________________
gdal-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/gdal-dev

--
http://www.spatialys.com
My software is free, but my time generally not.
_______________________________________________
gdal-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to