Home » Server Options » Spatial » Reduce the number of vertices in representing the Geometry (Oracle 10g Spatial / MapInfo Professional)
Reduce the number of vertices in representing the Geometry [message #377792] Thu, 25 December 2008 03:09
kalkotarmr
Messages: 1
Registered: August 2006
Location: Noida
Junior Member

How can we enhance this function to get the maximum output?


FUNCTION Apply_Buffer (p_geom IN SDO_GEOMETRY, p_dist IN NUMBER) RETURN SDO_GEOMETRY IS

/*
The purpose of this function is to reduce the number of vertices used in representing a geometry object.
The function shall use the SDO_UTIL.SIMPLIFY function to do the task.
The returned geometry should be a proper polygon/multipolygon without any e.g. point or line-string elements.
When using the SDO_UTIL.SIMPLIFY operator, there is a risk that a subelement in the object collapses into a point or line. In that case, it should be filtered out.
The input parameter ‘p_dist’ has the same meaning as the corresponding parameter in the SDO_UTIL.SIMPLIFY function, and should be given in meters.
In case of problems/errors or if the complete input object collapses into e.g. point or lines the function shall return NULL.
*/

nElement NUMBER;
nNoOfElements NUMBER;
validateGeometry VARCHAR2(20000);
sElementGeom SDO_GEOMETRY;
vElementGeom1 SDO_GEOMETRY;
vElementGeom2 SDO_GEOMETRY;
vElementGeom3 SDO_GEOMETRY;
vElementGeom4 SDO_GEOMETRY;
vElementGeom5 SDO_GEOMETRY;
vElementGeom6 SDO_GEOMETRY;
subElementGeom SDO_GEOMETRY;
vSubElementGeom SDO_GEOMETRY;

BEGIN

vSubElementGeom := Null;

/* Returns the number of elements inside the geometry 'p_geom' */
nNoOfElements := SDO_UTIL.GETNUMELEM(p_geom);

FOR nElement IN 1..nNoOfElements LOOP

/*Simplify the geometries*/
vElementGeom1 := SDO_UTIL.SIMPLIFY (p_geom, p_dist);
vElementGeom2 := SDO_GEOM.SDO_BUFFER (vElementGeom1, p_dist, 0.00005, 'unit=m');
vElementGeom3 := SDO_GEOM.SDO_ARC_DENSIFY (vElementGeom2, 0.00005, ‘arc_tolerance=0.05 unit=m');
vElementGeom6 := SDO_UTIL.SIMPLIFY (vElementGeom3, p_dist);
vSubElementGeom := Polygon_Extract (vElementGeom6);

END LOOP;

/* Validate the Geometry */
validateGeometry := SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT (vSubElementGeom, 0.00005);

IF (validateGeometry = 'TRUE' AND vSubElementGeom is not null) THEN
RETURN vSubElementGeom;
ELSE
DBMS_OUTPUT.PUT_LINE ('Geometry validation exception: ' || validateGeometry);
RETURN NULL;
END IF;

EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE ('Exception in Apply_Buffer');
DBMS_OUTPUT.PUT_LINE (' ErrCode: ' || SQLCODE);
DBMS_OUTPUT.PUT_LINE (' ErrMess: ' || SQLERRM);
RETURN NULL;

END Apply_Buffer;


Thanks in advance....

Previous Topic: addition of ARCGIS inexisting instance
Next Topic: How to get a particular location from a spatial table (sdo_geometry)
Goto Forum:
  


Current Time: Thu Mar 28 18:13:02 CDT 2024