Skip to content

Commit ae84812

Browse files
committed
Fix typos and improve clarity in geospatial stage description for GEODIST.
1 parent 182e0d2 commit ae84812

File tree

1 file changed

+18
-23
lines changed

1 file changed

+18
-23
lines changed
Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
In this stage, you'll add support for calculating the distance between two locations using the `GEODIST` comamnd.
1+
In this stage, you'll add support for calculating the distance between two locations using the `GEODIST` command.
22

33
### The `GEODIST` command
4-
The `GEODIST` command returns the distance between two members of a key. The default unit of the distance which is returned, is meters.
4+
5+
The `GEODIST` command returns the distance between two members of a key.
56

67
Example usage:
78

@@ -10,50 +11,44 @@ Example usage:
1011
"682477.7582"
1112
```
1213

13-
It returns the distance as a string, encoded as a RESP Bulk String.
14+
The distance is returned in meters, encoded as a [RESP bulk string](https://redis.io/docs/latest/develop/reference/protocol-spec/#bulk-strings).
1415

1516
Redis uses the [Haversine's Formula](https://en.wikipedia.org/wiki/Haversine_formula#Example) to calculate the distance between two points. You can see how this is done in the Redis source code [here](https://github.com/redis/redis/blob/4322cebc1764d433b3fce3b3a108252648bf59e7/src/geohash_helper.c#L228C1-L228C72).
1617

1718
### Tests
19+
1820
The tester will execute your program like this:
21+
1922
```bash
2023
$ ./your_program.sh
2124
```
2225

23-
It will add multiple locations using the `GEOADD` command.
26+
It will then add multiple locations using the `GEOADD` command:
27+
2428
```bash
2529
$ redis-cli
2630
> GEOADD places 11.5030378 48.164271 "Munich"
2731
> GEOADD places 2.2944692 48.8584625 "Paris"
2832
```
2933

30-
The tester will then send multiple `GEODIST` commands specifying two locations. For example, the tester might send your program a command like this:
34+
The tester will then send multiple `GEODIST` commands specifying two locations:
3135

3236
```bash
3337
> GEODIST places Munich Paris
3438
# Expecting "682477.7582"
3539
```
3640

37-
The value is a RESP bulk string encoded as:
41+
The tester will validate that the response is a RESP bulk string that contains the distance between the two locations, for example:
3842

39-
```
40-
$11\r\n
41-
682477.7582\r\n
43+
```bash
44+
$11\r\n682477.7582\r\n
4245
```
4346

4447
### Notes
45-
- The tester will be lenient when validating the distance returned by the `GEODIST` command. The distance should match the actual distance between the provided locations with a precision of **up to 2 decimal places after rounding**.
46-
47-
* This means that minor floating-point differences are acceptable as long as the values, when rounded to two decimal places, are the same.
48-
49-
* For example, if the expected distance is `12345.67`, any of the following returned values will be accepted:
50-
51-
* `12345.67001`
52-
* `12345.674`
53-
* `12345.6659`
54-
* `12345.6666`
55-
* `12345.669`
56-
57-
* However, values like `12345.64`, `12345.70`, or `12345.61` would be considered incorrect.
5848

59-
- If one or both of the location specified in the `GEODIST` command does not exist, it should return a null bulk string `($-1\r\n)`.
49+
- The distance should match the actual distance between the provided locations with a precision of **up to 2 decimal places after rounding**. For example, if the expected distance is `12345.67`, any of the following returned values will be accepted:
50+
- `12345.67001`
51+
- `12345.674`
52+
- `12345.6659`
53+
- `12345.6666`
54+
- `12345.669`

0 commit comments

Comments
 (0)