petern48 commented on code in PR #288:
URL: https://github.com/apache/sedona-db/pull/288#discussion_r2507393504
##########
c/sedona-geos/src/st_reverse.rs:
##########
@@ -104,19 +104,29 @@ mod tests {
let result = tester
.invoke_scalar("POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))")
.unwrap();
- tester.assert_scalar_result_equals(result, "POINT (0.5 0.5)");
+ tester.assert_scalar_result_equals(result, "POLYGON ((0 0, 1 0, 1 1, 0
1, 0 0))");
let result = tester.invoke_scalar(ScalarValue::Null).unwrap();
assert!(result.is_null());
let input_wkt = vec![
Some("POLYGON ((2 2, 2 3, 3 3, 3 2, 2 2))"),
Some("POINT EMPTY"),
+ Some("POINT (1 2)"),
+ Some("LINESTRING (1 2, 1 10)"),
+ Some("GEOMETRYCOLLECTION (MULTIPOINT (3 4, 1 2, 7 8, 5 6),
LINESTRING (1 10, 1 2))"),
None,
];
let expected = create_array(
- &[Some("POINT (2.5 2.5)"), Some("POINT EMPTY"), None],
+ &[
+ Some("POLYGON ((2 2, 3 2, 3 3, 2 3, 2 2))"),
Review Comment:
In the last commit, I implemented the actual tests for ST_Reverse, since
previously the tests were left over from when we copy-pasted from ST_Centroid.
Here, the top variable represents the inputs and the bottom represents the
expected output. e.g Reading the tests, this means inputting the polygon at
line 113 (the first geom of the input array) is expected to return the polygon
at 123. This makes sense since the expected result is the same as the input
except with it's xy, coords are reversed.
I'm testing this using `cargo test`. I keep going until they pass, and I
feel like I've written a few decent cases.
Optional but useful:
Oftentimes, I'm running queries against a PostGIS docker container to check
what the expected results are for this function (e.g testing edge cases). I'm
spinning up a PostGIS docker container using
```
docker compose up -d
```
And then enter the PostGIS shell (where I can run SQL queries) with this.
Extremely high chance it's the exact same command for you.
```
docker exec -it sedona-db-postgis-1 psql -U postgres
```
```sql
-- next line is my Spatial SQL query
SELECT ST_AsText(ST_Reverse(ST_GeomFromText('POLYGON ((2 2, 2 3, 3 3, 3 2, 2
2))')));
-- Below is the output
st_astext
--------------------------------
POLYGON((2 2,3 2,3 3,2 3,2 2))
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]