简体   繁体   中英

Query by distance between two objects without using Oracle Spatial functionality?

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!

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

如果无法更改目标表上的列,则可以使用触发器将单独的表中的数据具体化为sdo_geometry,使用sdo_within_distance,然后将这些行连接到原始表中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM