[Qgis-developer] Interpretation of a 3 point CircularString with p0 == p2 (circle)

Even Rouault even.rouault at spatialys.com
Thu Jun 23 06:32:20 PDT 2016


Hi,

I just came into a difference how QGIS and GDAL interpret a CircularString made 
of a 3 points p0, p1, p2 where p0 == p2, which is a way of representing a full 
circle.

GDAL interprets p1 as the symetrical point of p0 with respect to the center
(https://github.com/osgeo/gdal/blob/trunk/gdal/ogr/ogrcircularstring.cpp#L640), 
that is p1 is on the perimeter of the circle, or said otherwise the center of 
the circle is the midpoint of [p0,p1].
Whereas QGIS interprets p1 as the center of the circle ( 
https://github.com/qgis/QGIS/blob/master/src/core/geometry/qgsgeometryutils.cpp#L359 
)

I'd think GDAL interpretation is the right one, since according to 
http://jtc1sc32.org/doc/N1101-1150/32N1107-WD13249-3--spatial.pdf (ISO SQL MM 
Part 3), paragraph 4.1.6 :
(let's call this sentence S1)
""" In the case where the segment is a circle, then the center is located 
at the midpoint of the line connecting the start point with the intermediate 
point. """

But if you look a bit above in the paragraph, there's a sentence (call it S2) 
: """In the special case where a segment is a complete circle, that is, the 
start and end points are coincident, then the intermediate point shall be the 
midpoint of the segment. """, which looks confusing at first. I think this 
sentence must be interpreted considering distances along the curve, in which 
case the "midpoint of the segment" when doing a full walk along the circle 
from p0 back to p0 is the symetrical point of p0 with respect to the center.

I think this interpretation is also more logical since, even in that 
particular case, p0,p1,p2 are all on the arc, like in the general case.

I can also see that PostGIS (in https://github.com/postgis/postgis/blob/svn-
trunk/liblwgeom/lwalgorithm.c#L252 ) has the same interpretation as GDAL (*)

I'd be happy to read opinions regarding this.

Even

(*) Can also be shown with :

# SELECT 
ST_AsText(ST_Envelope(ST_CurveToLine(ST_GeomFromText('CIRCULARSTRING(-1 0,1 
0,-1 0)'))));
              st_astext               
--------------------------------------
 POLYGON((-1 -1,-1 1,1 1,1 -1,-1 -1))

And http://postgis.net/docs/manual-2.2/using_postgis_dbmanagement.html says 
"The exception to this is for a closed circle, where the start and end points 
are the same. In this case the second point MUST be the center of the arc, ie 
the opposite side of the circle.", which is another way to rephrase S2.


-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the Qgis-developer mailing list