<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Joaquim,</p>
    <p>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).</p>
    <p>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.<br>
    </p>
    <p>So while the following patch to PROJ is probably technically
      correct, it wouldn't help in practice<br>
    </p>
    <p>diff --git a/src/projections/aitoff.cpp
      b/src/projections/aitoff.cpp<br>
      index 9d060999f..cce319157 100644<br>
      --- a/src/projections/aitoff.cpp<br>
      +++ b/src/projections/aitoff.cpp<br>
      @@ -59,6 +59,11 @@ static PJ_XY aitoff_s_forward(PJ_LP lp, PJ *P)
      { /* Spheroidal, forward */<br>
           struct pj_opaque *Q = static_cast<struct pj_opaque
      *>(P->opaque);<br>
           double c, d;<br>
       <br>
      +    if( fabs(lp.lam) > 2 * M_PI ) {<br>
      +        proj_errno_set(<br>
      +                    P,
      PROJ_ERR_COORD_TRANSFM_OUTSIDE_PROJECTION_DOMAIN);<br>
      +        return xy;<br>
      +    }<br>
           c = 0.5 * lp.lam;<br>
           d = acos(cos(lp.phi) * cos(c));<br>
           if (d != 0.0) { /* basic Aitoff */<br>
    </p>
    <p>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.</p>
    <p>Even<br>
    </p>
    <p><br>
    </p>
    <div class="moz-cite-prefix">Le 30/04/2023 à 03:11, Joaquim Manuel
      Freire Luís via gdal-dev a écrit :<br>
    </div>
    <blockquote type="cite"
cite="mid:GVXPR04MB9926EFB97370930CB11EF8DBA6699@GVXPR04MB9926.eurprd04.prod.outlook.com">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <meta name="Generator" content="Microsoft Word 15 (filtered
        medium)">
      <style>@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-ligatures:standardcontextual;}a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-ligatures:standardcontextual;}div.WordSection1
        {page:WordSection1;}</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
      <div class="WordSection1">
        <p class="MsoNormal">Even, this is a kind of continuation of the
          subject that I brought up in
          <a href="https://github.com/OSGeo/gdal/issues/7644"
            moz-do-not-send="true" class="moz-txt-link-freetext">https://github.com/OSGeo/gdal/issues/7644</a><o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">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<o:p></o:p></p>
        <p class="MsoNormal">(see <a
href="https://forum.generic-mapping-tools.org/t/best-projection-for-rectangular-world-map/3715/82?u=joaquim"
            moz-do-not-send="true" class="moz-txt-link-freetext">
https://forum.generic-mapping-tools.org/t/best-projection-for-rectangular-world-map/3715/82?u=joaquim</a>)<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">But when I try the same with +proj=wintry
          the gdalwarp op works well but the ogr2ogr doesn’t.<o:p></o:p></p>
        <p class="MsoNormal">(see <a
href="https://forum.generic-mapping-tools.org/t/best-projection-for-rectangular-world-map/3715/85?u=joaquim"
            moz-do-not-send="true" class="moz-txt-link-freetext">
https://forum.generic-mapping-tools.org/t/best-projection-for-rectangular-world-map/3715/85?u=joaquim</a>)<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">You can more less reproduce this case using
          this file<o:p></o:p></p>
        <p class="MsoNormal"><a
            href="http://fct-gmt.ualg.pt/tmp/cl540.gpkg"
            moz-do-not-send="true" class="moz-txt-link-freetext">http://fct-gmt.ualg.pt/tmp/cl540.gpkg</a><o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">ogr2ogr  -t_srs "+proj=wintri +over"
          cl540_wintri.gpkg cl540.gpkg<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">Why would that be in this case?<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">Joaquim<o:p></o:p></p>
      </div>
      <br>
      <fieldset class="moz-mime-attachment-header"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
gdal-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
<a class="moz-txt-link-freetext" href="http://www.spatialys.com">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
  </body>
</html>