<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hi,</p>
    <p>it is a bit tricky.</p>
    <p>wen you use proj_create() with a PROJ string without +type=crs,
      it goes (almost) directly through the "historic" code of PROJ,
      which interprets its as a coordinate transformation string, and I
      indeed discover by looking at it that it accepts +lon_0 as an
      alternative to +zone (but if you don't specify something that is
      an expected longitude of natural origin for UTM, then it will
      round to the closest without warning...). But
      <a class="moz-txt-link-freetext" href="https://proj.org/operations/projections/utm.html">https://proj.org/operations/projections/utm.html</a> only documents
      +utm as a required parameter, so that is a bit of a chance that it
      works.</p>
    <p>When you use proj_create_crs_to_crs(), PROJ strings are
      interpretated as CRS, which goes to a different code path, and
      that code path enforces that +zone is specified, now to a valid
      value.</p>
    <p>Regarding error messages, yeah, this is a bit tricky and linked
      to the interaction of the C and C++ parts of the code. Basically
      the "Invalid zone number" is emitted as a C++ exception without a
      specific C error code, then it is caught by proj_create() which
      emits it as a logged error (proj_create() is called by
      proj_create_crs_to_crs()), and the generic PROJ_ERR_OTHER=4096 is
      set because the code that catch the C++ exception has no better
      hint.</p>
    <p>Even<br>
    </p>
    <div class="moz-cite-prefix">Le 26/10/2021 à 16:27, José Luis García
      Pallero a écrit :<br>
    </div>
    <blockquote type="cite"
cite="mid:CAFemY3a-2hbrDnquyKR1GbP2Yw2Cysiox-p-iXFL1hE2ssNj6w@mail.gmail.com">
      <pre class="moz-quote-pre" wrap="">Hello:

I'm using PROJ 8.1.1 from the Debian Sid repositories, and I'm having
troubles with proj_create_crs_to_crs() using a code that worked
without problems with PROJ 7.2.1.

My example, attached as tproj.c projects a point from (lat,lon) onto
the UTM zone 30 plane. I use the proj_trans_generic() function, but in
a first case I define the projection using the proj_create() function
with parameters "+proj=utm +lon_0=3w +ellps=GRS80". In this case all
works fine, as the UTM zone 30 is defined but its central meridian
+lon_0=3w.

But in my second example I define a transformation between CRSs using
the function proj_create_crs_to_crs(), and the parameter strings
"+proj=latlong +ellps=GRS80" and "+proj=utm +lon_0=3w +ellps=GRS80",
and the problem comes with +lon_0=3w. I need to define the parameter
string as "+proj=utm +zone=30 +ellps=GRS80", case in which all works
well. But why proj_create_crs_to_crs() works with +zone=30 and fails
with +lon_0=3w if both definitions are equivalent for the UTM, and it
works using proj_create()?

Also the error string created with proj_errno_string() is confusing,
as it returns "Unknown error (code 4096)", but at the same the string
"proj_create: Invalid zone number" is printed on screen. I think this
last message will be returned by proj_errno_string(). Also, in this
string proj_create() is referred instead of proj_create_crs_to_crs().

Attached I send the code

Thanks

</pre>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
PROJ mailing list
<a class="moz-txt-link-abbreviated" href="mailto:PROJ@lists.osgeo.org">PROJ@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/proj">https://lists.osgeo.org/mailman/listinfo/proj</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>