<div dir="ltr">Thanks for the detailed write up and quick fix!<div><br></div><div>Just to clarify your last sentence, are you saying there are still potential cases where IsSame returns TRUE when it shouldn't? Or were you just emphasizing that this is a very tricky check to get right in all cases? I'm just wondering if I should ditch my optimization of checking the spatial reference and always do a reproject (via VRT) even if it results in a no-op in some cases. I assume the overhead of a no-op VRT is fairly small and I'm concerned with correctness more than anything else.</div><div><br></div><div>Thanks again.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 5, 2017 at 5:02 PM, Even Rouault <span dir="ltr"><<a href="mailto:even.rouault@spatialys.com" target="_blank">even.rouault@spatialys.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><u></u>
<div style="font-family:'monospace';font-size:9pt;font-weight:400;font-style:normal"><span class="">
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> I assume my understanding of IsSame is flawed so any clarification would be</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> a big help.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">></p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
</span><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">Matt,</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">Your understanding of IsSame() is correct. You just hit a bug. I've fixed it per <a href="https://trac.osgeo.org/gdal/ticket/7029" target="_blank">https://trac.osgeo.org/gdal/<wbr>ticket/7029</a>. You can see the changeset code as a workaround to add in your own code if you need.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">IsSame() is a "smart" comparison, ie it tries to abstract away unsignificant differences like the PROJCS text value that don't participate really to the SRS and can vary over formats, data producers, etc... The issue here is that web-mercator (EPSG:3857) and WGS84-mercator (EPSG:3395) are represented the same way at the GEOGCS and projection levels. The only difference is that GDAL creates a EXTENSION["PROJ4", ...] node in the web-mercator case to really use the spherical definition. And IsSame() before my fix neglected to compare that extension node. So you were a bit unlucky since that must be pretty much the only pair of EPSG entries in that situation.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">My initial tought was to compare the authority codes/nodes when they exist on both sides, but I was wondering if there are not cases where you'd have the same SRS registered in 2 different catalogs. Presumably within the same catalog, a different code should mean a different CRS, but I'm not even completely sure you couldn't find oddities. I was thinking to EPSG:3857 vs the deprecated EPSG:3785, but this isn't a good example, since they differ on the DATUM. So currently IsSame() returns FALSE on that pair, although I guess one might consider them as equivalent (the deprecated version is just a buggy expression on the current EPSG:3857). Or not...</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">You also have the situation where really different CRS (IsSame() == FALSE) ends up being translated the same way as proj.4 strings...</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">So it is actually not obvious to define the semantics of IsSame(). It should at least return FALSE for CRS that are clearly different (coordinate transformation results in differences).</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">Even</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">-- </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">Spatialys - Geospatial professional services</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><a href="http://www.spatialys.com" target="_blank">http://www.spatialys.com</a></p></div></blockquote></div><br></div>