objectbox / objectbox-java

Android Database - first and fast, lightweight on-device vector database
https://objectbox.io
Apache License 2.0
4.38k stars 302 forks source link

Geospatial queries #411

Open Queatz opened 6 years ago

Queatz commented 6 years ago

Would love to have easy geospatial queries locally in my app.

Might want to look into open source ArangoDB's implementation:

https://docs.arangodb.com/3.3/AQL/Tutorial/Geospatial.html

https://github.com/arangodb/arangodb/blob/devel/arangod/RocksDBEngine/RocksDBGeoIndex.cpp

greenrobot commented 6 years ago

What is your usecase? E.g. you can use a superfast bounding box query using x1,y1,x2,y2 coordinates and then filter on those results (using query filters).

Queatz commented 6 years ago

@greenrobot geoqueries are a bit different, i.e.

greenrobot commented 6 years ago

You could do some lat/lon pre-processing to get a bounding box to query within an area.

Still, it would be good to collect some use cases to identify most important use cases.

Queatz commented 6 years ago

My specific use case is getting the 10 closest to a lat/lng. It could span 100m or 1000000m. With bounding boxes one would have to progressively requery with a larger bounding until a total of 10 are found. There are performance hits because if you're far from i.e. a city with many data points, then by the time your progressively bigger bounding box includes the city, it includes the entire city, and then the data points are sorted in code.

greenrobot commented 6 years ago

I would also go for an increasing bounding box. You could mitigate the "city effect" by setting a limit of results, e.g. to 100. The quality sacrifice may be acceptable depending on your use case.

Queatz commented 6 years ago

Agreed, that is what I will be doing for now.