cqengine
cqengine copied to clipboard
Can we use geolocation operation?
The answer to this question right now is: kind of. It's definitely something I'd like to support better in future.
The situation right now is, you can perform geographic proximity lookup, as long as (1) you can provide a locationId for each object you store in the IndexedCollection, and (2) you will manintain a mapping of locationId to/from latitude + longitude coordinates outside of CQEngine, and (3) your external system can compute for you the set of locationIds which fall within a radius of any particular latitude + longitude coordinate.
So let's say you had an IndexedCollection of GroceryStore objects. Each GroceryStore object has a locationId which you assigned using the system above, and you defined a LOCATION_ID attribute for use in queries which returns it.
If you then had a User at a certain latitude + longitude coordinate, and you wanted to retrieve the set of GroceryStore objects which are located nearby, you would ask your mapping system for the set of locationIds which lie within an appropriate radius of the user's coordinate. You could then retrieve the set of nearby GroceryStore objects from the IndexedCollection using a query 'in(LOCATION_ID, setOfNearbyLocationIds)'.
I'm considering bringing some of this functionality into CQEngine itself in future. Effectively, the idea is to provide an R-Tree type index. But for now it's not something which is particularly well supported natively, and if you need this functionality you have to apply a kind of workaround as above.
I'll keep this issue open to bookmark it as a request for enhancement.
+1 for the feature.