<div dir="ltr">Seems like whether a PROJ warning is reported as an error or warning depends on whether it has "Default it to" in the text. This one does not, and is returned as an error. The logic here is unclear to me.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Mar 28, 2024 at 9:35 AM Simon Eves <<a href="mailto:simon.eves@heavy.ai">simon.eves@heavy.ai</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Thanks for this, chaps. That certainly explains the original of the issue.<div><br></div><div>My remaining question, if GDAL is going to declare the resulting SR as invalid, is whether that is grounds for rejecting the file completely, given that GDAL does not expose those warnings when converting it to another format. In other words, should we actually bother calling <b>Validate()</b> at all, or just keep our head in the sand and continue with the import anyway?</div><div><br></div><div>That said, I note that the PROJ code calls <b>emitRecoverableWarning()</b> in this case, and yet the resulting string ends up in <b>m_wktImportErrors</b> in GDAL and thus triggers the hard error. Surely if it's a warning, the string should end up in <b>m_wktImportWarnings</b>, which would be <b>CPLDebug</b>'d but NOT trigger the hard error.</div><div><br></div><div>Simon</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Mar 28, 2024 at 8:10 AM Even Rouault <<a href="mailto:even.rouault@spatialys.com" target="_blank">even.rouault@spatialys.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><u></u>
<div>
<p>Hi,</p>
<p>just a few complements to Javier's analysis:</p>
<p>- what you observe and what Javier mentioned applies if you
import directly the .prj WKT content, but the GDAL shapefile
driver actually replaces this not pretty WKT with a cleaned
version of EPSG:4326 (at least with GDAL+PROJ master), so if you
use the high level GDAL API, things should work smoothly</p>
<p>- the 9001 ID you observe when looking at the WKT2 output of the
result of the ingestion of the .prj is *not* a CRS ID. It is the
ID of the ellipsoid's lengthunit=metre. You can have several IDs
in a WKT definition: for the CRS, datum, ellipsoid, projection
method, projection parameter, units, etc. They only apply to the
node to which they are applied to. In some contexts, they are
advised to be omitted. The general rule is "if you know the id of
a top-level object, you can omit the IDs of its child elements,
except in several cases". All gory details at
<a href="https://www.ogc.org/standard/wkt-crs/" target="_blank">https://www.ogc.org/standard/wkt-crs/</a><br>
</p>
<p>So all in all, to me things are working as expected. It is mostly
you deal with a a slightly non-compliant .prj file</p>
<p>Even<br>
</p>
<div>Le 28/03/2024 à 03:06, Simon Eves via
PROJ a écrit :<br>
</div>
<blockquote type="cite">
<div dir="ltr">When trying to import this Shapefile bundle into
our system with GDAL...
<div><br clear="all">
<div><a href="https://drive.google.com/file/d/13Mwhnugcy8HrnGlc81gyroxnp9s15Skt/view?usp=sharing" target="_blank">https://drive.google.com/file/d/13Mwhnugcy8HrnGlc81gyroxnp9s15Skt/view?usp=sharing</a><br>
</div>
<div><br>
</div>
<div>...we get an <b>OGRERR_CORRUPT_DATA</b> from <b>OGRSpatialReference::Validate()</b>
on the SR obtained from the first feature.</div>
<div><br>
</div>
<div>Tracing through the GDAL and PROJ code, this appears to
be because the PROJ import of that CRS results in the
following WKT Import Error from PROJ...</div>
<div><br>
</div>
<div><i>Coordinate system of GeographicCRS in the WKT
definition is different from the one of the authority.
Unsetting the identifier to avoid confusion<br>
</i></div>
<div><br>
</div>
<div>...and any WKT Import Error makes GDAL report that error
code.</div>
<div><br>
</div>
The PROJ code throws this in <b>WKTParser::Private::buildGeodeticCRS</b>
(io.cpp:3229 in 9.3.0) which is old code (although the second
branch which can throw the same error was seemingly added
between 8.2 and 9.3 in <a href="https://github.com/OSGeo/PROJ/pull/3274" target="_blank">https://github.com/OSGeo/PROJ/pull/3274</a>
...but it's the first branch that's triggering in this case).</div>
<div><br>
</div>
<div><b>ogrinfo</b> on the Shapefile reports no errors or
warnings, although it does report a CRS ID of 9001 even though
it reports WGS84 elsewhere in the CRS block.</div>
<div><br>
</div>
<div>I was able to trivially <b>ogr2ogr</b> it to GeoJSON, also
with no errors or warnings, and that imports with no issue.</div>
<div><br>
</div>
<div><span class="gmail_signature_prefix">Is there an actual
problem (a bad file) here, or are we doing something wrong?</span></div>
<div><span class="gmail_signature_prefix"><br>
</span></div>
<div><span class="gmail_signature_prefix">Thanks, as ever, in
advance.</span></div>
<div><span class="gmail_signature_prefix"><br>
</span></div>
<div><span class="gmail_signature_prefix">-- </span><br>
<div dir="ltr" class="gmail_signature">
<div dir="ltr">Simon Eves
<div>Senior Rendering Engineer</div>
<div>+1 (415) 902-1996<br>
<a href="mailto:simon.eves@heavy.ai" target="_blank">simon.eves@heavy.ai</a></div>
<div><span>
<p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><a href="http://www.heavy.ai" target="_blank"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(17,85,204);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"><span style="border:none;display:inline-block;overflow:hidden;width:156px;height:29px"><img src="https://lh4.googleusercontent.com/mzi9GaXA9r6isEqIx5nIYx0oQnpZtzBnF19Pu83MUBPDvp_rpcQXv55z-IZcQrybunkhKf6mXNJjIQinIbkHTigssDxIks_tXAaV1aDQzVT8FpE1wOn3MW0W_iiTnDjVZzMUNgs" style="margin-left: 0px; margin-top: 0px;" width="156" height="29"></span></span></a></p>
</span></div>
</div>
</div>
</div>
</div>
<br>
<fieldset></fieldset>
<pre>_______________________________________________
PROJ mailing list
<a href="mailto:PROJ@lists.osgeo.org" target="_blank">PROJ@lists.osgeo.org</a>
<a href="https://lists.osgeo.org/mailman/listinfo/proj" target="_blank">https://lists.osgeo.org/mailman/listinfo/proj</a>
</pre>
</blockquote>
<pre cols="72">--
<a href="http://www.spatialys.com" target="_blank">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
</div>
</blockquote></div>
</blockquote></div>