Question

Right now I have table in Oracle 10g database with LAT(FLOAT) and LNG(FLOAT) columns.

Task is to find all entries within a specific distance (radius) of a given point (center). Application itself is in Java, Hibernate is used as JPA implementation.

After some research I've found that Oracle Spatial needs to be used. However, there is no way to convert my columns to SDO_GEOMETRY, so I am not able to use Oracle's SDO_WITHIN_DISTANCE function.

Is there any workaround to implement such functionality?

Currently I am just querying all entries and iterating over them with Haversine formula - and this will become bottleneck very soon :-)

Thanks for your assistance!

Was it helpful?

Solution 2

If you can't change the columns on the target table, you could use a trigger to materialise the data in a separate table as an sdo_geometry, use sdo_within_distance and then join the rows to your original table.

OTHER TIPS

Using existing spatial data encoded in X and Y columns without introducing additional columns is easy: just use a function-based index.

This means no change on the existing tables: just adding a function and the function-based index together with possibly a view to make everything more transparent.

See the full answer here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top