Here at AU 2008 in Las Vegas, I was having a dicussion about Oracle Spatial with Lance Maidlow of Landor Investments Ltd. We were discussing converting a Line in Oracle and using LRS function to get the CENTROID on the line (geographic center of the object).
Well he suggested that rather than getting the start and end point of the line with LRS and dividing by 2 – which may not land on the line, that I should use the SDO_LRS.LOCATE_PT function that will find a point on a line based on how far down the line you want to go.
So.. you get the length of the line, divide by 2 and then use the SDO_LRS.LOCATE_PT to get the middle point on the line…oh and convert it to LL if you need. See below:
select sdo_cs.transform(SDO_LRS.CONVERT_TO_STD_GEOM(SDO_LRS.LOCATE_PT(SDO_LRS.CONVERT_TO_LRS_GEOM(GEOM, 3), SDO_GEOM.SDO_LENGTH(GEOM,3)/2)),8307).SDO_POINT.X as LON,
sdo_cs.transform(SDO_LRS.CONVERT_TO_STD_GEOM(SDO_LRS.LOCATE_PT(SDO_LRS.CONVERT_TO_LRS_GEOM(GEOM, 3), SDO_GEOM.SDO_LENGTH(GEOM,3)/2)),8307).SDO_POINT.Y as LAT
from DUBLIN_CALIFORNIA_CA83IIIF.sewer_pipe
I was lazy and set the toleraces to 3 rather than query the SDO_METADATA…
Thanks Lance!
gordon