Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changes

## Unreleased

* Fix `geo_rect_conversion_test` to conform to the correctly-wound `Polygon` output from `geo_types::geometry::Rect.to_polygon`
* See https://github.com/georust/geojson/issues/257

## 0.24.2 - 2025-02-24

* Add `to_feature` to convert a single S: Serialize to a Feature
Expand Down
14 changes: 8 additions & 6 deletions src/conversion/from_geo_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,24 +381,26 @@ mod tests {

#[test]
fn geo_rect_conversion_test() {
// Same rect as geo_types::geometry::Rect::to_polygon doctest
let c1: Coord<f64> = Coord { x: 0., y: 0. };
let c2: Coord<f64> = Coord { x: 10., y: 20. };
let c2: Coord<f64> = Coord { x: 1., y: 2. };

let rect = Rect::new(c1, c2);

let geojson_polygon = Value::from(&rect);

// Geo-types Polygon construction introduces an extra vertex: let's check it!
if let Value::Polygon(c) = geojson_polygon {
assert_almost_eq!(c1.x, c[0][0][0], 1e-6);
// checks are in the same order as the geo_types::geometry::Rect.to_polygon doctest
assert_almost_eq!(c2.x, c[0][0][0], 1e-6);
assert_almost_eq!(c1.y, c[0][0][1], 1e-6);
assert_almost_eq!(c1.x, c[0][1][0], 1e-6);
assert_almost_eq!(c2.x, c[0][1][0], 1e-6);
assert_almost_eq!(c2.y, c[0][1][1], 1e-6);
assert_almost_eq!(c2.x, c[0][2][0], 1e-6);
assert_almost_eq!(c1.x, c[0][2][0], 1e-6);
assert_almost_eq!(c2.y, c[0][2][1], 1e-6);
assert_almost_eq!(c2.x, c[0][3][0], 1e-6);
assert_almost_eq!(c1.x, c[0][3][0], 1e-6);
assert_almost_eq!(c1.y, c[0][3][1], 1e-6);
assert_almost_eq!(c1.x, c[0][4][0], 1e-6);
assert_almost_eq!(c2.x, c[0][4][0], 1e-6);
assert_almost_eq!(c1.y, c[0][4][1], 1e-6);
} else {
panic!("Not valid geometry {:?}", geojson_polygon);
Expand Down