How can I get lat and long from point in oracle?
Like this:
MDSYS.SDO_GEOMETRY(2001,4326,NULL,
MDSYS.SDO_ELEM_INFO_ARRAY(1,1,1),
MDSYS.SDO_ORDINATE_ARRAY(51.702814,32.624736))
How can I get lat and long from point in oracle?
Like this:
MDSYS.SDO_GEOMETRY(2001,4326,NULL,
MDSYS.SDO_ELEM_INFO_ARRAY(1,1,1),
MDSYS.SDO_ORDINATE_ARRAY(51.702814,32.624736))
You can use sdo_util.getvertices. Example from the documentation
SELECT c.mkt_id, c.name, t.X, t.Y, t.id
FROM cola_markets c,
TABLE(SDO_UTIL.GETVERTICES(c.shape)) t
ORDER BY c.mkt_id, t.id;
The notation you show is not the best one for representing single 2D or 3D points. The common and most efficient way to encode those points is this:
All the GIS tools I have seen use this notation. The one you show is valid too - it just uses more storage. But the two notations are fully functionally equivalent.
Using the compact notation, getting the individual coordinates out is trivial. For example, considering that US_CITIES contains point in the compact notation above:
Getting the same result from the more complex array-based notation you use is more convoluted. You can use the SDO_UTIL.GETVERTICES approach. For example, assuming US_CITIES_A contains the same points but in the array-based notation:
Another approach I actually find simpler is to just define a couple of simple functions to extract the values from the array:
and
Then using the functions makes for a simpler syntax: