<div dir="ltr">Hi Even,<div>this difference catched my eye too. I think SQL MM (and consequently GDAL and PostGIS) interpration is more logical, and I would suggest QGIS should follow it too.</div><div><br></div><div>Giovanni</div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-06-23 15:32 GMT+02:00 Even Rouault <span dir="ltr"><<a href="mailto:even.rouault@spatialys.com" target="_blank">even.rouault@spatialys.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I just came into a difference how QGIS and GDAL interpret a CircularString made<br>
of a 3 points p0, p1, p2 where p0 == p2, which is a way of representing a full<br>
circle.<br>
<br>
GDAL interprets p1 as the symetrical point of p0 with respect to the center<br>
(<a href="https://github.com/osgeo/gdal/blob/trunk/gdal/ogr/ogrcircularstring.cpp#L640" rel="noreferrer" target="_blank">https://github.com/osgeo/gdal/blob/trunk/gdal/ogr/ogrcircularstring.cpp#L640</a>),<br>
that is p1 is on the perimeter of the circle, or said otherwise the center of<br>
the circle is the midpoint of [p0,p1].<br>
Whereas QGIS interprets p1 as the center of the circle (<br>
<a href="https://github.com/qgis/QGIS/blob/master/src/core/geometry/qgsgeometryutils.cpp#L359" rel="noreferrer" target="_blank">https://github.com/qgis/QGIS/blob/master/src/core/geometry/qgsgeometryutils.cpp#L359</a><br>
)<br>
<br>
I'd think GDAL interpretation is the right one, since according to<br>
<a href="http://jtc1sc32.org/doc/N1101-1150/32N1107-WD13249-3--spatial.pdf" rel="noreferrer" target="_blank">http://jtc1sc32.org/doc/N1101-1150/32N1107-WD13249-3--spatial.pdf</a> (ISO SQL MM<br>
Part 3), paragraph 4.1.6 :<br>
(let's call this sentence S1)<br>
""" In the case where the segment is a circle, then the center is located<br>
at the midpoint of the line connecting the start point with the intermediate<br>
point. """<br>
<br>
But if you look a bit above in the paragraph, there's a sentence (call it S2)<br>
: """In the special case where a segment is a complete circle, that is, the<br>
start and end points are coincident, then the intermediate point shall be the<br>
midpoint of the segment. """, which looks confusing at first. I think this<br>
sentence must be interpreted considering distances along the curve, in which<br>
case the "midpoint of the segment" when doing a full walk along the circle<br>
from p0 back to p0 is the symetrical point of p0 with respect to the center.<br>
<br>
I think this interpretation is also more logical since, even in that<br>
particular case, p0,p1,p2 are all on the arc, like in the general case.<br>
<br>
I can also see that PostGIS (in <a href="https://github.com/postgis/postgis/blob/svn-
trunk/liblwgeom/lwalgorithm.c#L252" rel="noreferrer" target="_blank">https://github.com/postgis/postgis/blob/svn-<br>
trunk/liblwgeom/lwalgorithm.c#L252</a> ) has the same interpretation as GDAL (*)<br>
<br>
I'd be happy to read opinions regarding this.<br>
<br>
Even<br>
<br>
(*) Can also be shown with :<br>
<br>
# SELECT<br>
ST_AsText(ST_Envelope(ST_CurveToLine(ST_GeomFromText('CIRCULARSTRING(-1 0,1<br>
0,-1 0)'))));<br>
              st_astext<br>
--------------------------------------<br>
 POLYGON((-1 -1,-1 1,1 1,1 -1,-1 -1))<br>
<br>
And <a href="http://postgis.net/docs/manual-2.2/using_postgis_dbmanagement.html" rel="noreferrer" target="_blank">http://postgis.net/docs/manual-2.2/using_postgis_dbmanagement.html</a> says<br>
"The exception to this is for a closed circle, where the start and end points<br>
are the same. In this case the second point MUST be the center of the arc, ie<br>
the opposite side of the circle.", which is another way to rephrase S2.<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
Spatialys - Geospatial professional services<br>
<a href="http://www.spatialys.com" rel="noreferrer" target="_blank">http://www.spatialys.com</a><br>
_______________________________________________<br>
Qgis-developer mailing list<br>
<a href="mailto:Qgis-developer@lists.osgeo.org">Qgis-developer@lists.osgeo.org</a><br>
List info: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
Unsubscribe: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a></font></span></blockquote></div><br></div>