Re: converting points to circles
- From: Benjamin Hell <bhell@xxxxxxxxxxxxx>
- Date: Wed, 09 Nov 2005 13:53:18 +0100
Hi Erik!
> we need to transform points in Oracle spatial to circles with a
> given radius in Oracle spatial.
The following function should do it. It is pretty rudimentary (e.g.
no check whether input geometry is really a point), but could be a
starting point. The closest built-in solution I know is
SDO_GEOM.SDO_BUFFER() which creates a polygon shaped buffer zone
around the point.
Regards,
Ben
-- test table
CREATE TABLE SPATIAL_TEST (
GEOMETRY SDO_GEOMETRY
);
-- test data
INSERT INTO SPATIAL_TEST
VALUES (
SDO_GEOMETRY (
2001,
NULL,
NULL,
SDO_ELEM_INFO_ARRAY (1, 1, 1),
SDO_ORDINATE_ARRAY (10, 10)
)
);
-- function to convert point to circle
CREATE OR REPLACE FUNCTION Point2Circle(
point SDO_GEOMETRY,
radius NUMBER)
RETURN SDO_GEOMETRY IS
BEGIN
DECLARE
xorig NUMBER;
yorig NUMBER;
circle SDO_GEOMETRY;
BEGIN
SELECT t.X, t.Y INTO xorig, yorig
FROM SPATIAL_TEST s,
TABLE (SDO_UTIL.GETVERTICES(s.GEOMETRY)) t;
circle := SDO_GEOMETRY (
2003,
NULL,
NULL,
SDO_ELEM_INFO_ARRAY (1, 2003, 4),
SDO_ORDINATE_ARRAY (
xorig - radius, yorig,
xorig + radius, yorig,
xorig, yorig + radius
)
);
RETURN circle;
END;
END;
/
-- test it, radius = 5
SELECT GEOMETRY, Point2Circle(GEOMETRY, 5) FROM SPATIAL_TEST;
-- clean up
DROP TABLE SPATIAL_TEST;
DROP FUNCTION Point2Circle;
.
- References:
- converting points to circles
- From: Erik
- converting points to circles
- Prev by Date: Re: How do I script object creation?
- Next by Date: Re: database link
- Previous by thread: converting points to circles
- Next by thread: classic ora-00904 & Crystal
- Index(es):
Relevant Pages
|