You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: stage_descriptions/geospatial-08-rm9.md
+19-12Lines changed: 19 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,26 +1,31 @@
1
-
In this stage, you'll add support for searching locations near a coordinate within a given radius using the `GEOSEARCH` command.
1
+
In this stage, you'll add support for searching locations within a given radius using the `GEOSEARCH` command.
2
2
3
3
### The GEOSEARCH command
4
4
5
-
The `GEOSEARCH` command lets you search for locations near a given coordinate within a specified area.
5
+
The `GEOSEARCH` command lets you search for locations within a given radius.
6
6
7
-
It supports several search modes. In our implementation, we'll focus only on the `FROMLONLAT` mode with distance unit in meters. The `FROMLONLAT` mode searching by directly specifying longitude and latitude.
7
+
It supports several search modes. In our implementation, we'll focus only on the `FROMLONLAT` mode. The `FROMLONLAT` mode searches by directly specifying longitude and latitude.
8
8
9
-
For example, to search for locations within 100000 meters of the point (longitude: 2, latitude: 48) stored in the `places` key, you can use:
9
+
Example usage:
10
10
11
11
```bash
12
-
> GEOSEARCH places FROMLONLAT 2 48 BYRADIUS 100000 m
12
+
> GEOSEARCH places FROMLONLAT 2 48 BYRADIUS 100 m
13
13
1) "Paris"
14
14
```
15
15
16
+
The example command above searches for locations in the `places` key that are within 100 meters of the point (longitude: 2, latitude: 48).
17
+
18
+
The response is a RESP array containing the names of the locations that match the search criteria, each encoded as a [RESP bulk string](https://redis.io/docs/latest/develop/reference/protocol-spec/#bulk-strings).
19
+
20
+
Note that there are two options we passed to the command:
21
+
16
22
-`FROMLONLAT <longitude> <latitude>` — This option specifies the center point for the search.
17
23
-`BYRADIUS <radius> <unit>` — This option searches within a circular area of the given radius and unit (m, km, mi, etc.).
18
24
19
-
Redis supports other values for search origin option and shape option, but here we'll only use `FROMLONLAT` and `BYRADIUS`.
20
-
21
-
It returns a RESP Array of member names, where each member's name is a encoded as a bulk string.
25
+
Redis supports other such options, but in this challenge we'll only use `FROMLONLAT` and `BYRADIUS`.
22
26
23
27
### Tests
28
+
24
29
The tester will execute your program like this:
25
30
26
31
```bash
@@ -36,7 +41,7 @@ $ redis-cli
36
41
> GEOADD places -0.0884948 51.506479 "London"
37
42
```
38
43
39
-
The tester will then send multiple `GEOSEARCH` commands specifying a latitude and longitude pair with `BYRADIUS` option specifying the distance and unit. For example, it may send the following command.
44
+
The tester will then send multiple `GEOSEARCH` commands:
40
45
41
46
```bash
42
47
> GEOSEARCH places FROMLONLAT 2 48 BYRADIUS 100000 m
@@ -49,7 +54,7 @@ The tester will then send multiple `GEOSEARCH` commands specifying a latitude an
49
54
# Expecting ["Munich"]
50
55
```
51
56
52
-
The value is a RESP array, which is encoded as:
57
+
The tester will validate that the response is a RESP array, for example
53
58
54
59
```
55
60
*2\r\n
@@ -59,6 +64,8 @@ $6\r\n
59
64
London\r\n
60
65
```
61
66
67
+
Locations can be returned in any order.
68
+
62
69
### Notes
63
-
- The tester will only test using the `meters` unit.
64
-
- The locations returned can be in any order since we are not implementing `ASC` or `DESC` option.
70
+
71
+
- The tester will always use the `FROMLONLAT` and `BYRADIUS` options when sending a `GEOSEARCH` command.
0 commit comments