Search code examples
orientdbspatial

orient-db: does the 2.2 Spatial Module provide a new way to achieve NEAR functionality?


i'm looking to do queries similar to those described in the pre-2.2 spatial-index documentation:

SELECT *, $distance FROM Class WHERE [<lat-field>,<long-field>,$spatial] NEAR [lat,lon,{"maxDistance": distance}]

(i would also like to sort by $distance which i haven't tried yet, but hope works)

this documentation for the 2.2 spatial-module says that it is a "replacement" for the spatial-index feature mentioned above.

if spatial-module is a replacement for spatial-index, is there a new way to achieve the spatial-index NEAR functionality with spatial-module, or is the older spatial-index NEAR syntax still the way to go?

if the answer is "yes", use the older syntax, does this mean that i would need both discrete lat/lon fields and an embedded OPoint to use both feature sets?

if the answer is "no", use newer syntax for NEAR functionality, can someone provide an example?

thanks!


Solution

  • There is a new SpatialFunction to do that with the new Module.It wasn't documented. It's called STDWithin.

    I've updated the docs here https://github.com/orientechnologies/orientdb-docs/blob/master/Spatial-Index.md#st_dwithin

    It will be in the official docs in a couple of hours