-- Contributed by Bruce Rindahl\r
-- Availability: 1.4.0\r
-----------------------------------------------------------------------\r
-CREATE OR REPLACE FUNCTION ST_MinimumBoundingCircle(inputgeom geometry, segs_per_quarter integer)\r
+CREATE OR REPLACE FUNCTION ST_MinimumBoundingCircle(inputgeom geometry, segs_per_quarter integer DEFAULT 48)\r
RETURNS geometry AS\r
$BODY$\r
DECLARE\r
-- Compute the midpoint\r
p1 = ST_line_interpolate_point(l1,0.5);\r
-- Rotate the line 90 degrees around the midpoint (perpendicular bisector)\r
- l1 = ST_Translate(ST_Rotate(ST_Translate(l1,-X(p1),-Y(p1)),pi()/2),X(p1),Y(p1));\r
+ l1 = ST_Translate(ST_Rotate(ST_Translate(l1,-ST_X(p1),-ST_Y(p1)),pi()/2),ST_X(p1),ST_Y(p1));\r
-- Compute the azimuth of the bisector\r
a1 = ST_Azimuth(ST_PointN(l1,1),ST_PointN(l1,2));\r
-- Extend the line in each direction the new computed distance to insure they will intersect\r
- l1 = ST_AddPoint(l1,ST_Makepoint(X(ST_PointN(l1,2))+sin(a1)*dist,Y(ST_PointN(l1,2))+cos(a1)*dist),-1);\r
- l1 = ST_AddPoint(l1,ST_Makepoint(X(ST_PointN(l1,1))-sin(a1)*dist,Y(ST_PointN(l1,1))-cos(a1)*dist),0);\r
+ l1 = ST_AddPoint(l1,ST_Makepoint(ST_X(ST_PointN(l1,2))+sin(a1)*dist,ST_Y(ST_PointN(l1,2))+cos(a1)*dist),-1);\r
+ l1 = ST_AddPoint(l1,ST_Makepoint(ST_X(ST_PointN(l1,1))-sin(a1)*dist,ST_Y(ST_PointN(l1,1))-cos(a1)*dist),0);\r
\r
-- Repeat for the line from the point to the other diameter point\r
l2 = ST_Makeline(ST_PointN(ring,idx2),ST_PointN(ring,k));\r
p2 = ST_Line_interpolate_point(l2,0.5);\r
- l2 = ST_Translate(ST_Rotate(ST_Translate(l2,-X(p2),-Y(p2)),pi()/2),X(p2),Y(p2));\r
+ l2 = ST_Translate(ST_Rotate(ST_Translate(l2,-ST_X(p2),-ST_Y(p2)),pi()/2),ST_X(p2),ST_Y(p2));\r
a2 = ST_Azimuth(ST_PointN(l2,1),ST_PointN(l2,2));\r
- l2 = ST_AddPoint(l2,ST_Makepoint(X(ST_PointN(l2,2))+sin(a2)*dist,Y(ST_PointN(l2,2))+cos(a2)*dist),-1);\r
- l2 = ST_AddPoint(l2,ST_Makepoint(X(ST_PointN(l2,1))-sin(a2)*dist,Y(ST_PointN(l2,1))-cos(a2)*dist),0);\r
+ l2 = ST_AddPoint(l2,ST_Makepoint(ST_X(ST_PointN(l2,2))+sin(a2)*dist,ST_Y(ST_PointN(l2,2))+cos(a2)*dist),-1);\r
+ l2 = ST_AddPoint(l2,ST_Makepoint(ST_X(ST_PointN(l2,1))-sin(a2)*dist,ST_Y(ST_PointN(l2,1))-cos(a2)*dist),0);\r
\r
-- The new center is the intersection of the two bisectors\r
center = ST_Intersection(l1,l2);\r
$BODY$\r
LANGUAGE 'plpgsql' IMMUTABLE STRICT;\r
\r
-CREATE OR REPLACE FUNCTION ST_MinimumBoundingCircle(geometry)\r
- RETURNS geometry AS\r
-'SELECT ST_MinimumBoundingCircle($1, 48)'\r
- LANGUAGE 'sql' IMMUTABLE STRICT;\r
\r
-- ST_ConcaveHull and Helper functions starts here --\r
-----------------------------------------------------------------------\r
DROP FUNCTION IF EXISTS jtsnoop(geometry);
DROP FUNCTION IF EXISTS st_noop(geometry);
DROP FUNCTION IF EXISTS st_max_distance(geometry, geometry);
+DROP FUNCTION IF EXISTS ST_MinimumBoundingCircle(geometry); --changed to use default parameters
-- Drop internals that should never have existed --
DROP FUNCTION IF EXISTS st_geometry_analyze(internal);
DROP FUNCTION IF EXISTS st_geometry_in(cstring);
DROP FUNCTION IF EXISTS st_geometry_gt(geometry, geometry);
DROP FUNCTION IF EXISTS st_geometry_ge(geometry, geometry);
DROP FUNCTION IF EXISTS st_geometry_eq(geometry, geometry);
-DROP FUNCTION IF EXISTS st_geometry_cmp(geometry, geometry);
\ No newline at end of file
+DROP FUNCTION IF EXISTS st_geometry_cmp(geometry, geometry);
+DROP FUNCTION IF EXISTS SnapToGrid(geometry, float8, float8);
\ No newline at end of file