Skip to content

Commit c1e00ac

Browse files
committed
Update geospatial stage description for GEOSEARCH command usage and examples.
1 parent ae84812 commit c1e00ac

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

stage_descriptions/geospatial-08-rm9.md

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff 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.
22

33
### The GEOSEARCH command
44

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.
66

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.
88

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:
1010

1111
```bash
12-
> GEOSEARCH places FROMLONLAT 2 48 BYRADIUS 100000 m
12+
> GEOSEARCH places FROMLONLAT 2 48 BYRADIUS 100 m
1313
1) "Paris"
1414
```
1515

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+
1622
- `FROMLONLAT <longitude> <latitude>` — This option specifies the center point for the search.
1723
- `BYRADIUS <radius> <unit>` — This option searches within a circular area of the given radius and unit (m, km, mi, etc.).
1824

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`.
2226

2327
### Tests
28+
2429
The tester will execute your program like this:
2530

2631
```bash
@@ -36,7 +41,7 @@ $ redis-cli
3641
> GEOADD places -0.0884948 51.506479 "London"
3742
```
3843

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:
4045

4146
```bash
4247
> GEOSEARCH places FROMLONLAT 2 48 BYRADIUS 100000 m
@@ -49,7 +54,7 @@ The tester will then send multiple `GEOSEARCH` commands specifying a latitude an
4954
# Expecting ["Munich"]
5055
```
5156

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
5358

5459
```
5560
*2\r\n
@@ -59,6 +64,8 @@ $6\r\n
5964
London\r\n
6065
```
6166

67+
Locations can be returned in any order.
68+
6269
### 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

Comments
 (0)