Skip to content
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

Merged
merged 43 commits into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
5c08b06
Add s2geometry sources for geo queries support from mongodb repo as is
kiburtse Feb 1, 2023
41edb32
s2: cleanup/remove unneeded files
kiburtse Feb 1, 2023
ca39b9f
s2: add to build
kiburtse Feb 1, 2023
f941de7
Add basic test for s2geometry link
kiburtse Feb 1, 2023
3bc4421
Object store Geospatial mappings
ironage Feb 1, 2023
de502cc
starting queries
ironage Feb 7, 2023
3ef4a4b
Merge pull request #6284 from realm/js/geospatial
ironage Feb 14, 2023
726bb9c
s2: cleanup tests related functions
kiburtse Mar 2, 2023
57d1ccc
Merge branch 'master' into kb/geospatial_merge_master
kiburtse Mar 3, 2023
8c1d759
Fix build due to removed error categories
kiburtse Mar 3, 2023
3f13ca9
Replace std exceptions with realm specific
kiburtse Mar 3, 2023
d949d83
Merge pull request #6361 from realm/kb/geospatial_merge_master
kiburtse Mar 13, 2023
5792653
Move geo query tests to separate test file for future expansion
kiburtse Feb 28, 2023
388090d
Add init types for polygon and center sphere
kiburtse Mar 1, 2023
95b55b8
Add basic geo_within support for Polygon and CenterSphere
kiburtse Mar 1, 2023
13d0ec6
Fix windows build
kiburtse Mar 13, 2023
70f2a8f
Style: rename geo constants
kiburtse Mar 13, 2023
0d102f8
Fix MacOS compatibility build issue
kiburtse Mar 13, 2023
60933bd
More win/mac build fixes
kiburtse Mar 14, 2023
018c63e
Add s2geometry library for swift package build
kiburtse Mar 21, 2023
c2a7376
Suppress s2 warnings for gcc
kiburtse Mar 21, 2023
c985968
Merge pull request #6346 from realm/kb/geospatial_polygon_sphere_supp…
kiburtse Mar 23, 2023
fa7d977
Merge branch 'master' into js/update-from-base
ironage Mar 28, 2023
bd5267a
fix clang-format complaint
ironage Mar 29, 2023
13ad86a
Merge branch 'master' into js/update-from-base
ironage Mar 29, 2023
e97c98d
Merge pull request #6450 from realm/js/update-from-base
ironage Mar 29, 2023
314121b
Trim down unnecessary S2 sources (#6456)
ironage Apr 3, 2023
29b8d2e
Fix include of external when built as subproject of sdk
kiburtse Apr 4, 2023
8130093
Use modern language features (#6466)
ironage Apr 4, 2023
ff7d333
Merge remote-tracking branch 'origin/master' into feature/geospatial_…
kiburtse Apr 11, 2023
9324e22
Use radians for CenterSphere to be unit-neutral (#6496)
kiburtse Apr 13, 2023
ebeed43
Geospatial RQL (#6352)
ironage Apr 20, 2023
e079865
Add REALM_ENABLE_GEOSPATIAL cmake option to disable feature (#6525)
kiburtse Apr 21, 2023
eb37390
Remove non-compiling hash_value function (#6533)
nirinchev Apr 25, 2023
0c042a7
Geospatial Polygons support holes (#6529)
ironage May 2, 2023
1d670f9
Merge branch 'master' into feature/geospatial_queries_for_points
ironage May 2, 2023
46c0a73
changelog and test without geospatial on CI
ironage May 2, 2023
cdef8e0
disable geospatial by default for cocoa builds, review feedback
ironage May 3, 2023
0e73ede
Merge branch 'master' into feature/geospatial_queries_for_points
ironage May 3, 2023
5b3b87b
Merge branch 'master' into feature/geospatial_queries_for_points
ironage May 4, 2023
0c255ad
turn off geospatial in swift builds for now
ironage May 4, 2023
a3c8cd8
formatting
ironage May 4, 2023
420fb0c
Merge branch 'master' into feature/geospatial_queries_for_points
ironage May 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# NEXT RELEASE

### Enhancements
* <New feature description> (PR [#????](https://github.com/realm/realm-core/pull/????))
* None.
* The query engine now supports `geowithin` queries on points. Points are embedded objects conforming to the geoJSON format, trying to use a geospatial query on data in the incorrect format produces a run time exception. Example RQL query: `location geoWithin geoPolygon({{-178.0, 10.0}, {178.0, 10.0}, {178.0, -10.0}, {-178.0, -10.0}, {-178.0, 10.0}})`. For SDKs who do not wish to add this yet, the feature can be compiled out by adding `-DREALM_ENABLE_GEOSPATIAL=OFF` to the cmake config. ([#6562](https://github.com/realm/realm-core/issues/6562))

### Fixed
* <How do the end-user experience this issue? what was the impact?> ([#????](https://github.com/realm/realm-core/issues/????), since v?.?.?)
Expand Down
20 changes: 14 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ elseif(APPLE)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
endif()

# Sets/clears the {FLAG} variable if the compiler flag is supported or not
# The compiler flag check is only performed once and the value is cached as the out variable name
function(check_if_cxx_compiler_flag_supported flag out_var)
if(flag MATCHES "^-Wno-")
# Compilers ignore unknown -Wno-foo flags, so look for -Wfoo instead.
Expand All @@ -58,8 +56,8 @@ function(check_if_cxx_compiler_flag_supported flag out_var)
endfunction()

function(add_cxx_flag_if_supported flag)
check_if_cxx_compiler_flag_supported(${flag} HAVE${flag})
if(HAVE${flag})
check_if_cxx_compiler_flag_supported(${flag} HAVE_${flag})
if(HAVE_${flag})
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:${flag}>)
endif()
endfunction()
Expand Down Expand Up @@ -91,6 +89,15 @@ function(append_source_file_compile_options)
endforeach()
endfunction()

function(add_target_option_if_supported target option_scope)
foreach(option ${ARGN})
check_if_cxx_compiler_flag_supported(${option} HAVE_${option})
if(HAVE_${option})
target_compile_options(${target} ${option_scope} ${option})
endif()
endforeach()
endfunction()

function(use_faster_linker)
# If a linker has already been set, don't override.
if ("${CMAKE_EXE_LINKER_FLAGS}" MATCHES "-fuse-ld=")
Expand Down Expand Up @@ -125,7 +132,7 @@ else()
if(ANDROID)
add_compile_options(-Wno-uninitialized)
elseif(${CMAKE_CXX_COMPILER_ID} MATCHES ".*[Cc]lang")
# FIXME: Re-introduce -Wold-style-cast
# FIXME: Re-introduce -Wold-style-cast
add_compile_options(-Wunreachable-code -Wshorten-64-to-32 -Wconditional-uninitialized -Wextra-semi -Wno-nested-anon-types -Wdocumentation -Wthread-safety -Wthread-safety-negative -Wmissing-prototypes)
endif()

Expand Down Expand Up @@ -162,7 +169,7 @@ if(ANDROID)
# - `-fomit-frame-pointer` is inherited from NDK r10e.
# - On some architectures char is unsigned by default. Make it signed
# - Compile with -Oz in Release because on Android we favor code size over performance
#
#
add_compile_options(-fdata-sections -ffunction-sections -fomit-frame-pointer -fsigned-char -fstrict-aliasing -funwind-tables -no-canonical-prefixes $<$<CONFIG:Release>:-Oz>)
endif()

Expand Down Expand Up @@ -248,6 +255,7 @@ option(REALM_METRICS "Enable various metric tracking" ON)
option(REALM_INCLUDE_CERTS "Include a list of trust certificates in the build for SSL certificate verification" ${REALM_INCLUDE_CERTS_DEFAULT})
option(REALM_ENABLE_SYNC_MULTIPLEXING "Enables sync session multi-plexing by default")
set(REALM_MAX_BPNODE_SIZE "1000" CACHE STRING "Max B+ tree node size.")
option(REALM_ENABLE_GEOSPATIAL "Enable geospatial types and queries." ON)

# Find dependencies
set(THREADS_PREFER_PTHREAD_FLAG ON)
Expand Down
15 changes: 14 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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: "0"),

.define("REALM_VERSION_MAJOR", to: String(versionCompontents[0])),
.define("REALM_VERSION_MINOR", to: String(versionCompontents[1])),
Expand Down Expand Up @@ -386,6 +387,14 @@ let package = Package(
exclude: bidExcludes,
publicHeadersPath: "."
),
.target(
name: "s2geometry",
path: "src/external/s2",
publicHeadersPath: ".",
cxxSettings: ([
.headerSearchPath(".."),
.headerSearchPath("../.."),
] + cxxSettings) as [CXXSetting]),
.target(
name: "RealmCore",
dependencies: ["Bid"],
Expand All @@ -395,6 +404,7 @@ let package = Package(
"external",
"realm/CMakeLists.txt",
"realm/exec",
"realm/geospatial.cpp",
"realm/metrics",
"realm/object-store/CMakeLists.txt",
"realm/object-store/c_api",
Expand All @@ -410,7 +420,9 @@ let package = Package(
"win32",
] + syncExcludes + syncServerSources) as [String],
publicHeadersPath: ".",
cxxSettings: cxxSettings,
cxxSettings: ([
.headerSearchPath("external"),
] + cxxSettings) as [CXXSetting],
linkerSettings: [
.linkedLibrary("compression"),
.linkedLibrary("z"),
Expand Down Expand Up @@ -515,6 +527,7 @@ let package = Package(
"backup.cpp",
"benchmarks",
"c_api",
"geospatial.cpp",
"notifications-fuzzer",
"query.json",
"sync-metadata-v4.realm",
Expand Down
3 changes: 2 additions & 1 deletion evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,7 @@ buildvariants:
run_tests_against_baas: On
c_compiler: "./clang_binaries/bin/clang"
cxx_compiler: "./clang_binaries/bin/clang++"
extra_flags: -DREALM_ENABLE_GEOSPATIAL=OFF # can be removed once SDKs pick this feature up
tasks:
- name: compile_test

Expand Down Expand Up @@ -1245,7 +1246,7 @@ buildvariants:
max_jobs: $(sysctl -n hw.logicalcpu)
run_tests_against_baas: On
xcode_developer_dir: /Applications/Xcode13.1.app/Contents/Developer
extra_flags: -DCMAKE_SYSTEM_NAME=Darwin -DCMAKE_OSX_ARCHITECTURES=arm64
extra_flags: -DCMAKE_SYSTEM_NAME=Darwin -DCMAKE_OSX_ARCHITECTURES=arm64 -DREALM_ENABLE_GEOSPATIAL=OFF
kiburtse marked this conversation as resolved.
Show resolved Hide resolved
tasks:
- name: compile_test
distros:
Expand Down
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
add_subdirectory(realm)
add_subdirectory(external/IntelRDFPMathLib20U2)

if (REALM_ENABLE_GEOSPATIAL)
add_subdirectory(external/s2)
endif()

if(CMAKE_SYSTEM_NAME MATCHES "^Windows")
add_subdirectory(win32)
endif()
Expand Down
60 changes: 60 additions & 0 deletions src/external/s2/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
cmake_minimum_required(VERSION 3.15)

project(s2geometry)

set(S2_SOURCES
s1angle.cc
s2.cc
s2cellid.cc
s2latlng.cc
s1interval.cc
s2cap.cc
s2cell.cc
s2cellunion.cc
s2edgeindex.cc
s2edgeutil.cc
s2latlngrect.cc
s2loop.cc
s2pointregion.cc
s2polygon.cc
s2polygonbuilder.cc
s2polyline.cc
s2r2rect.cc
s2region.cc
s2regioncoverer.cc
s2regionintersection.cc
s2regionunion.cc
)

set(S2_UTIL_MATH_SOURCES
util/math/mathutil.cc
util/math/mathlimits.cc
)

add_library(s2geometry OBJECT
${S2_SOURCES}
${S2_UTIL_MATH_SOURCES}
)

target_include_directories(s2geometry PRIVATE "." "..")

# suppress s2 specific warnings (lib is very noisy)
target_compile_options(s2geometry PRIVATE
$<$<CXX_COMPILER_ID:MSVC>: /wd4068 /wd4244 /wd4267 /wd4305>
)
if (NOT MSVC)
set(CMAKE_REQUIRED_QUIET ON)
add_target_option_if_supported(s2geometry PRIVATE
-Wno-deprecated-declarations
-Wno-ignored-qualifiers
-Wno-macro-redefined
-Wno-missing-prototypes
-Wno-shorten-64-to-32
-Wno-undefined-var-template
-Wno-unknown-pragmas
-Wno-unused-const-variable
-Wno-unused-function
-Wno-unused-local-typedefs
-Wno-unused-parameter
)
endif()
Loading