Skip to content

Commit b237be3

Browse files
authored
Fix geo_rect_conversion test (#258)
Fixes #257
1 parent 5380bfd commit b237be3

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

CHANGES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changes
22

3+
## Unreleased
4+
5+
* Fix `geo_rect_conversion_test` to conform to the correctly-wound `Polygon` output from `geo_types::geometry::Rect.to_polygon`
6+
* See https://github.com/georust/geojson/issues/257
7+
38
## 0.24.2 - 2025-02-24
49

510
* Add `to_feature` to convert a single S: Serialize to a Feature

src/conversion/from_geo_types.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -381,24 +381,26 @@ mod tests {
381381

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

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

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

391392
// Geo-types Polygon construction introduces an extra vertex: let's check it!
392393
if let Value::Polygon(c) = geojson_polygon {
393-
assert_almost_eq!(c1.x, c[0][0][0], 1e-6);
394+
// checks are in the same order as the geo_types::geometry::Rect.to_polygon doctest
395+
assert_almost_eq!(c2.x, c[0][0][0], 1e-6);
394396
assert_almost_eq!(c1.y, c[0][0][1], 1e-6);
395-
assert_almost_eq!(c1.x, c[0][1][0], 1e-6);
397+
assert_almost_eq!(c2.x, c[0][1][0], 1e-6);
396398
assert_almost_eq!(c2.y, c[0][1][1], 1e-6);
397-
assert_almost_eq!(c2.x, c[0][2][0], 1e-6);
399+
assert_almost_eq!(c1.x, c[0][2][0], 1e-6);
398400
assert_almost_eq!(c2.y, c[0][2][1], 1e-6);
399-
assert_almost_eq!(c2.x, c[0][3][0], 1e-6);
401+
assert_almost_eq!(c1.x, c[0][3][0], 1e-6);
400402
assert_almost_eq!(c1.y, c[0][3][1], 1e-6);
401-
assert_almost_eq!(c1.x, c[0][4][0], 1e-6);
403+
assert_almost_eq!(c2.x, c[0][4][0], 1e-6);
402404
assert_almost_eq!(c1.y, c[0][4][1], 1e-6);
403405
} else {
404406
panic!("Not valid geometry {:?}", geojson_polygon);

0 commit comments

Comments
 (0)