My CENTROID package is a very popular download from my website.
In this article I want to expose a couple of issues that catch new users of my package. These issues are documented in the header of the relevant functions but because there is no separate end user documentation (other than the blog articles on this website), these issues are often missed and so cause problems.
When using the CENTROID package be careful of the following two things.
CENTROID does not support polygons or linestrings with circular arcs. Before calling the SDO_CENTROID function (or more directly, the CENTROID_L or CENTROID_A functions), you have to convert (or stroke) them to their vertex-to-vertex equivalent beforehand either by using Oracle’s sdo_geom.sdo_arc_densify function or CENTROID.ConvertGeometry() function.
Prompt ConvertGeometry - Compound linestring
SDO_ELEM_INFO_ARRAY(1,4,2,1,2,1,3,2,2),-- compound line string
The CENTROID package exposes two methods for defining the precision of the data you are working with.
Where a function takes a p_tolerance value, the value represents the precision of an ordinate as a decimal value expressed in the same units as the data. So, for planar data in meters, a tolerance of 0.001 (or 0.0005) says the ordinate is precise to 1mm. For data expressed in decimal degrees, the same principle applies so if a longitude is accurate to 7 decimal digits one would use supply p_tolerance with a 0.0000001 decimal degree value. Oracle tolerances for long/lat data are provided in meters eg 0.05m (5 cm) – this is not supported by the CENTROID package functions.
Where a function takes p_round_x/p_round_y parameter values these are integer values that represent the number of decimal digits of precision of each ordinate. So, for planar (eg UTM) metric data a value of 3 represents 1mm (or p_tolerance == 0.001 ). For long/lat data you should use something like 6-9 digits of precision. If you use the default values, then you will most likely get an exception with a warning.
If you find a problem with the Windows installation script (though not the Linux/Unix script) or the code itself, please contact me immediately as I normally fix this stuff within a few hours of receiving the email. The CENTROID code has been stable for many years except that during February/March 2012 I homogenized all my code’s (including PL/SQL packages other than GEOM) use of a common set of TYPEs and this has led to one or two minor issues which were picked up by some users in Europe and which I fixed overnight. I expect any issues have now settled down and so you shouldn’t have any issues: but if you do contact me via email.