Skip to content

Commit 598f730

Browse files
committed
PoC consolidated geospatial section
1 parent b0fd78b commit 598f730

18 files changed

+920
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
A ``GeoCircle`` is a circular shape whose bounds originate from a central
2+
:objc-sdk:`RLMGeospatialPoint <Classes/RLMGeospatialPoint.html>`, and has a
3+
size corresponding to a radius measured in radians. You can use the SDK's
4+
convenience :objc-sdk:`RLMDistance <Classes/RLMDistance.html>` object to
5+
easily work with radii in different units.
6+
7+
``RLMDistance`` enables you to specify the radius distance for your geo shapes
8+
in one of four units:
9+
10+
- Radians
11+
- Degrees
12+
- Miles
13+
- Kilometers
14+
15+
You can use the supplied convenience methods to convert a measurement to
16+
different distance units.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
A :objc-sdk:`RLMGeospatialBox <Classes/RLMGeospatialBox.html>` is a
2+
rectangular shape whose bounds are determined by coordinates for a bottom-left
3+
and a top-right corner.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
A :objc-sdk:`RLMGeospatialPolygon <Classes/RLMGeospatialPolygon.html>` is a
2+
polygon shape whose bounds consist of an outer ring, and 0 or more inner holes
3+
to exclude from the geospatial query.
4+
5+
A polygon's outer ring must contain at least three segments. The last
6+
and the first :objc-sdk:`RLMGeospatialPoint <Classes/RLMGeospatialPoint.html>`
7+
must be the same, which indicates a closed polygon. This means that it takes
8+
at least four ``RLMGeospatialPoint`` values to construct a polygon.
9+
10+
Inner holes in a ``RLMGeospatialPolygon`` must be entirely contained within the
11+
outer ring.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
The SDK provides two specialized non-persistable data types to define shapes:
2+
3+
- :objc-sdk:`RLMGeospatialPoint <Classes/RLMGeospatialPoint.html>`: A
4+
class that represents the coordinates of a point formed by a pair of
5+
doubles consisting of these values:
6+
7+
- Latitude: ranges between -90 and 90 degrees, inclusive.
8+
- Longitude: ranges between -180 and 180 degrees, inclusive.
9+
- Altitude (optional): cannot be a negative value.
10+
- :objc-sdk:`RLMDistance <Classes/RLMDistance.html>`: A helper to represent
11+
and convert a distance.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
You can query geospatial data using :objc-sdk:`-objectsWithPredicate
2+
<Classes/RLMResults.html#/c:objc(cs)RLMResults(im)objectsWithPredicate:>`
3+
with an :ref:`NSPredicate query <sdks-nspredicate-query>` that uses
4+
``geoWithin``.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
The SDK provides two specialized non-persistable data types to define shapes:
2+
3+
- :swift-sdk:`GeoPoint <Typealiases.html#/s:10RealmSwift8GeoPointa>`: A
4+
struct that represents the coordinates of a point formed by a pair of
5+
doubles consisting of these values:
6+
7+
- Latitude: ranges between -90 and 90 degrees, inclusive.
8+
- Longitude: ranges between -180 and 180 degrees, inclusive.
9+
- :swift-sdk:`Distance <Typealiases.html#/s:10RealmSwift8Distancea>`: A helper
10+
struct to represent and convert a distance.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
A :swift-sdk:`GeoBox <Typealiases.html#/s:10RealmSwift6GeoBoxa>` is a
2+
rectangular shape whose bounds are determined by coordinates for a bottom-left
3+
and a top-right corner.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
A :swift-sdk:`GeoCircle <Typealiases.html#/s:10RealmSwift9GeoCirclea>` is a
2+
circular shape whose bounds originate from a central :swift-sdk:`GeoPoint
3+
<Typealiases.html#/s:10RealmSwift8GeoPointa>`, and has a size corresponding to
4+
a radius measured in radians. You can use the SDK's convenience
5+
:swift-sdk:`Distance <Typealiases.html#/s:10RealmSwift8Distancea>` structure to
6+
easily work with radii in different units.
7+
8+
``Distance`` enables you to specify the radius distance for your geo shapes
9+
in one of four units:
10+
11+
- ``.degrees``
12+
- ``.kilometers``
13+
- ``.miles``
14+
- ``.radians``
15+
16+
You can optionally use the supplied convenience methods to convert a
17+
measurement to a different distance units.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
A :swift-sdk:`GeoPolygon <Typealiases.html#/s:10RealmSwift10GeoPolygona>` is a
2+
polygon shape whose bounds consist of an outer ring, and 0 or more inner holes
3+
to exclude from the geospatial query.
4+
5+
A polygon's outer ring must contain at least three segments. The last
6+
and the first :swift-sdk:`GeoPoint <Typealiases.html#/s:10RealmSwift8GeoPointa>`
7+
must be the same, which indicates a closed polygon. This means that it takes
8+
at least four ``GeoPoint`` values to construct a polygon.
9+
10+
Inner holes in a ``GeoPolygon`` must be entirely contained within the
11+
outer ring.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
You can query geospatial data in two ways:
2+
3+
- Using the :swift-sdk:`.geoWithin()
4+
<Structs/Query.html#/s:10RealmSwift5QueryVA2A16OptionalProtocolRzSo0aB14EmbeddedObjectC7WrappedRczlE9geoWithinyACySbGqd__So13RLMGeospatialRd__lF>`
5+
operator with the type-safe :ref:`Swift Query API <sdks-swift-query-api>`
6+
- Using a :swift-sdk:`.filter()
7+
<Structs/ObservedResults.html#/s:10RealmSwift15ObservedResultsV6filterSo11NSPredicateCSgvp>`
8+
with an :ref:`NSPredicate query <sdks-nspredicate-query>` that uses
9+
``geoWithin``.
10+
11+
The examples below show the results of queries using these two ``Company``
12+
objects.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
.. tabs-drivers::
2+
3+
tabs:
4+
- id: cpp-sdk
5+
content: |
6+
7+
.. literalinclude:: /examples/generated/cpp/crud.snippet.read-map-value.cpp
8+
:language: cpp
9+
10+
- id: csharp
11+
content: |
12+
13+
.. literalinclude:: /examples/MissingPlaceholders/example.cs
14+
:language: csharp
15+
:copyable: false
16+
17+
- id: dart
18+
content: |
19+
20+
.. literalinclude:: /examples/generated/flutter/data_types_test.snippet.map-work-with.dart
21+
:language: dart
22+
23+
- id: java
24+
content: |
25+
26+
.. literalinclude:: /examples/MissingPlaceholders/example.java
27+
:language: java
28+
:copyable: false
29+
30+
- id: java-kotlin
31+
content: |
32+
33+
.. literalinclude:: /examples/MissingPlaceholders/example-java-kotlin.kt
34+
:language: kotlin
35+
:copyable: false
36+
37+
- id: javascript
38+
content: |
39+
40+
.. literalinclude:: /examples/generated/node/data-types.snippet.query-a-dictionary.js
41+
:language: javascript
42+
43+
- id: kotlin
44+
content: |
45+
46+
.. literalinclude:: /examples/generated/kotlin/ReadTest.snippet.read-realm-dictionary.kt
47+
:language: kotlin
48+
49+
- id: objectivec
50+
content: |
51+
52+
.. literalinclude:: /examples/MissingPlaceholders/example.m
53+
:language: objectivec
54+
:copyable: false
55+
56+
- id: swift
57+
content: |
58+
59+
.. literalinclude:: /examples/generated/code/start/Geospatial.snippet.geobox.swift
60+
:language: swift
61+
62+
- id: typescript
63+
content: |
64+
65+
.. literalinclude:: /examples/MissingPlaceholders/example.ts
66+
:language: typescript
67+
:copyable: false
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
.. tabs-drivers::
2+
3+
tabs:
4+
- id: cpp-sdk
5+
content: |
6+
7+
.. literalinclude:: /examples/generated/cpp/crud.snippet.read-map-value.cpp
8+
:language: cpp
9+
10+
- id: csharp
11+
content: |
12+
13+
.. literalinclude:: /examples/MissingPlaceholders/example.cs
14+
:language: csharp
15+
:copyable: false
16+
17+
- id: dart
18+
content: |
19+
20+
.. literalinclude:: /examples/generated/flutter/data_types_test.snippet.map-work-with.dart
21+
:language: dart
22+
23+
- id: java
24+
content: |
25+
26+
.. literalinclude:: /examples/MissingPlaceholders/example.java
27+
:language: java
28+
:copyable: false
29+
30+
- id: java-kotlin
31+
content: |
32+
33+
.. literalinclude:: /examples/MissingPlaceholders/example-java-kotlin.kt
34+
:language: kotlin
35+
:copyable: false
36+
37+
- id: javascript
38+
content: |
39+
40+
.. literalinclude:: /examples/generated/node/data-types.snippet.query-a-dictionary.js
41+
:language: javascript
42+
43+
- id: kotlin
44+
content: |
45+
46+
.. literalinclude:: /examples/generated/kotlin/ReadTest.snippet.read-realm-dictionary.kt
47+
:language: kotlin
48+
49+
- id: objectivec
50+
content: |
51+
52+
.. literalinclude:: /examples/MissingPlaceholders/example.m
53+
:language: objectivec
54+
:copyable: false
55+
56+
- id: swift
57+
content: |
58+
59+
.. literalinclude:: /examples/generated/code/start/Geospatial.snippet.geocircle.swift
60+
:language: swift
61+
62+
- id: typescript
63+
content: |
64+
65+
.. literalinclude:: /examples/MissingPlaceholders/example.ts
66+
:language: typescript
67+
:copyable: false
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
.. tabs-drivers::
2+
3+
tabs:
4+
- id: cpp-sdk
5+
content: |
6+
7+
.. literalinclude:: /examples/generated/cpp/crud.snippet.read-map-value.cpp
8+
:language: cpp
9+
10+
- id: csharp
11+
content: |
12+
13+
.. literalinclude:: /examples/MissingPlaceholders/example.cs
14+
:language: csharp
15+
:copyable: false
16+
17+
- id: dart
18+
content: |
19+
20+
.. literalinclude:: /examples/generated/flutter/data_types_test.snippet.map-work-with.dart
21+
:language: dart
22+
23+
- id: java
24+
content: |
25+
26+
.. literalinclude:: /examples/MissingPlaceholders/example.java
27+
:language: java
28+
:copyable: false
29+
30+
- id: java-kotlin
31+
content: |
32+
33+
.. literalinclude:: /examples/MissingPlaceholders/example-java-kotlin.kt
34+
:language: kotlin
35+
:copyable: false
36+
37+
- id: javascript
38+
content: |
39+
40+
.. literalinclude:: /examples/generated/node/data-types.snippet.query-a-dictionary.js
41+
:language: javascript
42+
43+
- id: kotlin
44+
content: |
45+
46+
.. literalinclude:: /examples/generated/kotlin/ReadTest.snippet.read-realm-dictionary.kt
47+
:language: kotlin
48+
49+
- id: objectivec
50+
content: |
51+
52+
.. literalinclude:: /examples/MissingPlaceholders/example.m
53+
:language: objectivec
54+
:copyable: false
55+
56+
- id: swift
57+
content: |
58+
59+
.. literalinclude:: /examples/generated/code/start/Geospatial.snippet.geopolygon.swift
60+
:language: swift
61+
62+
- id: typescript
63+
content: |
64+
65+
.. literalinclude:: /examples/MissingPlaceholders/example.ts
66+
:language: typescript
67+
:copyable: false
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
.. tabs-drivers::
2+
3+
tabs:
4+
- id: cpp-sdk
5+
content: |
6+
7+
.. literalinclude:: /examples/generated/cpp/crud.snippet.read-map-value.cpp
8+
:language: cpp
9+
10+
- id: csharp
11+
content: |
12+
13+
.. literalinclude:: /examples/MissingPlaceholders/example.cs
14+
:language: csharp
15+
:copyable: false
16+
17+
- id: dart
18+
content: |
19+
20+
.. literalinclude:: /examples/generated/flutter/data_types_test.snippet.map-work-with.dart
21+
:language: dart
22+
23+
- id: java
24+
content: |
25+
26+
.. literalinclude:: /examples/MissingPlaceholders/example.java
27+
:language: java
28+
:copyable: false
29+
30+
- id: java-kotlin
31+
content: |
32+
33+
.. literalinclude:: /examples/MissingPlaceholders/example-java-kotlin.kt
34+
:language: kotlin
35+
:copyable: false
36+
37+
- id: javascript
38+
content: |
39+
40+
.. literalinclude:: /examples/generated/node/data-types.snippet.query-a-dictionary.js
41+
:language: javascript
42+
43+
- id: kotlin
44+
content: |
45+
46+
.. literalinclude:: /examples/generated/kotlin/ReadTest.snippet.read-realm-dictionary.kt
47+
:language: kotlin
48+
49+
- id: objectivec
50+
content: |
51+
52+
.. literalinclude:: /examples/MissingPlaceholders/example.m
53+
:language: objectivec
54+
:copyable: false
55+
56+
- id: swift
57+
content: |
58+
59+
.. literalinclude:: /examples/generated/code/start/Geospatial.snippet.geobox-query.swift
60+
:language: swift
61+
62+
- id: typescript
63+
content: |
64+
65+
.. literalinclude:: /examples/MissingPlaceholders/example.ts
66+
:language: typescript
67+
:copyable: false

0 commit comments

Comments
 (0)