-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Geospatial queries for points #6562
Conversation
Geospatial prototype
Merge master, adapt exceptions
…ort_for_geowithin Geospatial Polygon and CenterSphere support for geowithin operator
update from latest
* integrate Realm logging and assertions * remove some string utilities * remove encoder/decoder * remove some base files * remove hash * fix header search path for s2 swift builds
* scoped_ptr -> std::unique_ptr * use std type_traits * Replace deprecated is_pod with is_trivial --------- Co-authored-by: Kirill Burtsev <kirill.burtsev@mongodb.com>
…queries_for_points
* Don't use optional for sphere radius to reduce the size of Geospatial * Use radians for CenterSphere radius, expose constant * Add comments about points in Box and Polygon * Don't construct optional needlessly on Geospatial comparison
* geospatial query parser support WIP * some error handling * RQL geoSphere * RQL geoPolygon * query geospatial arguments * C-API geospatial in mixed * add a Geospatial type checking API * format * fix warnings on Windows * Alternative syntax definition * API changes from feedback and testing * remove type_GeoPoint as Geospatial is an umbrella for this * additional tests * fix an unused warning * review feedback * Use NaN for GeoPoint (#6490) * Use NaN for altitude, expose to public * Check for NaN for lat/lon --------- Co-authored-by: James Stone <james.stone@mongodb.com> * formatting * remove GeospatialRef and use Geospatial* remove wrong C-API implementation (#6518) --------- Co-authored-by: Jørgen Edelbo <jorgen.edelbo@mongodb.com> Co-authored-by: Kirill Burtsev <kirill.burtsev@mongodb.com>
* Allow to disable compilation of whole geospatial support * Turn on the geo feature for swift build by default
* Geospatial uses a variant polygon has holes * support holes in polygons in RQL * touch ups * Add REALM_ENABLE_GEOSPATIAL to config.h * add missing include * Fix test build for geo feature, optimize copying (#6550) * Fix build without geospatial * Don't force to copy primitives on get<> * Allow less curly braces for GeoPolygon on init * format --------- Co-authored-by: Jørgen Edelbo <jorgen.edelbo@mongodb.com> Co-authored-by: Kirill Burtsev <kirill.burtsev@mongodb.com>
We should exclude somehow s2 from CodeFactor, right? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice.
src/realm/data_type.hpp
Outdated
@@ -152,6 +153,9 @@ static constexpr DataType type_OldDateTime = DataType{7}; | |||
static_assert(!type_OldTable.is_valid()); | |||
static_assert(!type_OldDateTime.is_valid()); | |||
static constexpr DataType type_TypeOfValue = DataType{18}; | |||
#if REALM_ENABLE_GEOSPATIAL | |||
static constexpr DataType type_Geospatial = DataType{19}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will collide with nested collections, whoever gets first into master will have to adjust this value (nested collections are using 19,20,21) ... maybe we can agree to leave 19 free or whatever, also if we intend to keep this behind the GEOSPATIAL macro maybe it is better if we reserve the slot 22.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the heads up. The geospatial type is not part of the file format so its value doesn't really matter yet. I changed it to 22 so it doesn't conflict with nested collections.
{ | ||
return !(*this == other); | ||
} | ||
bool operator>(const Geospatial&) const = delete; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need to delete the operators? Is this done for better compiler error messages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, we don't want to allow these kinds of comparisons and by deleting them we make sure that they aren't being used anywhere in the query system or elsewhere.
return true; | ||
} | ||
|
||
Geospatial Geospatial::from_obj(const Obj& obj, ColKey type_col, ColKey coords_col) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So a Geospatial type is a Obj
which has a list of points (doubles) and a string to identify if it is longitude or latitude? Am I right? When it will come to deal with polygons, will you flatten a matrix into a list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The string is to identify what type of geometry is in this Geospatial type (polygon, line), but for now it's just 'point' which is supported. Second question is an open one. It remains to be seen how this is going to be implemented. Scope is yet to come for discussion.
Package.swift
Outdated
@@ -16,6 +16,7 @@ var cxxSettings: [CXXSetting] = [ | |||
.define("REALM_ENABLE_ASSERTIONS", to: "1"), | |||
.define("REALM_ENABLE_ENCRYPTION", to: "1"), | |||
.define("REALM_ENABLE_SYNC", to: "1"), | |||
.define("REALM_ENABLE_GEOSPATIAL", to: "1"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the intention is to have this disabled until we expose it in the SDK then it needs to be set to 0 here (and in tools/build-cocoa.sh).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes thanks. I updated both places to disable it by default for cocoa builds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there was such intention, we just added it this way to check that we can optionally disable whole geospatial if only through configure flag. Most of current implementation is useable without any work in sdks like rql queries on local data. Default was set to allow straight forward experimentation without official release of this feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cocoa does not use the core query parser.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right... @ironage i think that would need a bit more work to properly disable in in Package.swift. It's not just this define.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there's a reason to disable it by default. It doesn't upgrade the file format and the feature existing wouldn't impact Cocoa users besides a slight binary size increase. Whether we increase the binary size today or in a month when we add support for the feature is most likely inconsequential for the majority of our users.
I updated the project settings over at codefactor.io to ignore |
Initial implementation of geospatial queries for points. Most of the code additions come from adding the s2 library to our code base. Other changes have been reviewed in separate PRs previously.
☑️ ToDos