realm / realm-java

Realm is a mobile database: a replacement for SQLite & ORMs
http://realm.io
Apache License 2.0
11.45k stars 1.75k forks source link

Add RealmGeoPoint as first class citizen #1772

Open dadino opened 8 years ago

dadino commented 8 years ago

Looking at your welcome page, it's clear you see value in queries for maps, but there is some friction in this library when it comes to these things (#1765). Other libraries (eg. Parse, MongoDB) have the concept of points with coordinates, with operators that make these kind of queries pretty easy. I'm proposing a RealmGeoPoint, with latitude and longitude (maybe altitude, I can't see a use for that), with a set of operators to apply on the RealmQuery.

Possible operators:

I guess this could be even better if these comes from core, but (as we say here) it's not always Christmas.

bmunkholm commented 8 years ago

Absolutely something we have on the roadmap - it will be very useful! We already have issues for this in our core, but tracking it here is great as well. It's very unlikely to happen before this Christmas though, but definitely before next :-)

efkan commented 8 years ago

I guess if the code at the below address works it can be converted to Java (Android). https://github.com/mhergon/RealmGeoQueries/blob/master/GeoQueries.swift

Zhuinden commented 8 years ago

This would actually be pretty cool, the evaluation of RealmResults in a circle, sorted by distance

sharathp commented 7 years ago

any updates on this issue please? any ETA?

Zhuinden commented 7 years ago

@sharathp there's an issue for geospatial indexing in the core, but I think the sync support is getting all the attention at the moment.

kimdv commented 7 years ago

Anyone who have converted the link @efkan have linked? Or have any qeoquery extension to Realm?

Zhuinden commented 7 years ago

I think I've only seen people use square cutoff instead of a radial cutoff, unfortunately.

I tried figuring out that swift code, but it seems to use some kind of NSPredicate that doesn't translate to Java.

There was also an open issue in iOS https://github.com/realm/realm-cocoa/issues/2569 and in core https://github.com/realm/realm-core/issues/1184

marynovskyi commented 7 years ago

@Zhuinden this swift code can be converted into kotlin code

Zhuinden commented 7 years ago

@marinovskiy but can the NSPredicate be converted to an equivalent Realm-Java query?

marynovskyi commented 7 years ago

@Zhuinden Realm is fully compatible with Kotlin. And you can use kotlin code with java code in one project, so if you want you can just convert this swift code into kotlin code and add one kotlin file to project

Zhuinden commented 7 years ago

@marinovskiy now that I read the code a bit more, yeah it creates a "GeoBox" to limit the objects into a box defined by lat/lon, and then iterates the result set manually and filters for circular radius.

https://github.com/mhergon/RealmGeoQueries/blob/master/GeoQueries.swift#L139-L144

That doesn't scale that well because you need an O(n) iteration to filter the elements, and every proxy has to be created and the whole dataset must be read to evaluate the results directly, but otherwise it's ok because it can work

mdumrauf commented 7 years ago

Almost two years, any news on this?

CeccoCQ commented 6 years ago

+1

ghost commented 6 years ago

Guys please update on this, it is very important feature for mobile applications and will very helpful to reduce manual calculations.

KhoaSuperman commented 6 years ago

+1

lordplagus02 commented 6 years ago

Consider using the Google Maps APIs and Fused Location Provider to work with geopoints and distance etc, at least while Realm catches up with this issue. They even have a Java client for consuming these APIs: https://github.com/googlemaps/google-maps-services-java/ Hope this helps somebody...

mdumrauf commented 6 years ago

@lordplagus02 this is a good solution for applications which would work online. Offline applications would still have this problem.

CeccoCQ commented 6 years ago

+1

felipesanti commented 5 years ago

Hi, any news on this? This feature would be great for a year end gift! Thanks.

ajonno commented 5 years ago

We need this too

landsman commented 5 years ago

We need this too, please :pray:

filipef101 commented 5 years ago

@bmunkholm 3 years later and nothing?

bmunkholm commented 5 years ago

@filipef101 That's correct ;-) Time since a feature request was first made is not a big factor in prioritizing. While we would still love to make this, it's not currently highest on the priority list, unfortunately.

filipef101 commented 5 years ago

Okay, thanks for the reply :)

landsman commented 5 years ago

We have to did SQLite for tables which are needs to be sorted this way.

Pei116 commented 4 years ago

It loses a point when a db engine doesn't support geospatial queries.

ElyasMTarek commented 3 years ago

Highly needed!!

wedkemail commented 1 year ago

Would love to see this happen for RealmSwift! it would simplify everything. Any update on the progress of this issue? IMO this should be high on the priority list of features realm is missing. Love <3