[postgis-tickets] [PostGIS] #2841: ST_MinimumBoundingCircle and ST_ConcaveHull not covering original

PostGIS trac at osgeo.org
Wed Sep 7 10:52:02 PDT 2016


#2841: ST_MinimumBoundingCircle and ST_ConcaveHull not covering original
----------------------+---------------------------
  Reporter:  robe     |      Owner:  robe
      Type:  defect   |     Status:  reopened
  Priority:  medium   |  Milestone:  PostGIS 2.2.3
 Component:  postgis  |    Version:  trunk
Resolution:           |   Keywords:
----------------------+---------------------------
Changes (by dbaston):

 * cc: mtoews (added)


Comment:

 Replying to [comment:11 komzpa]:
 > I'd say that I prefer Polygon as bounding circle.
 > Does it make the case in the ticket pass?

 My bad, I changed the function to produce a polygon.  Yes, it makes the
 case in the ticket pass.  With this function, as the number of segments
 increases, the polygon shrinks towards a true circle, rather than
 expanding towards a true circle (as with ST_Buffer).

 Wrapping this up into a single function:

 {{{
 CREATE OR REPLACE FUNCTION mbc_test (geom geometry, segments_per_quad int)
 RETURNS geometry AS $$
 DECLARE
 center geometry;
 radius float;
 points geometry[];
 theta float;
 segments int;
 r float;
 i int;
 BEGIN
     segments := segments_per_quad * 4;
     SELECT (c).center, (c).radius FROM (SELECT
 ST_MinimumBoundingRadius(geom) c) sq INTO center, radius;

     theta := 2 * pi() / segments;
     r := radius * sqrt(1 + tan(theta/2)^2); -- use excircle instead of
 incircle
     FOR i IN SELECT generate_series(0, segments) LOOP
         points[i] := ST_Translate(center, r*sin(i*theta), r*cos(i*theta));
     END LOOP;
     RETURN ST_MakePolygon(ST_MakeLine(points));
 END;
 $$ LANGUAGE PLPGSQL;
 }}}

 Any reasons not to use this logic instead of the current ST_Buffer on the
 center point?

--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/2841#comment:12>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-tickets mailing list