diff --git a/src/conversion/from_geo_types.rs b/src/conversion/from_geo_types.rs index f7857940..0e9df050 100644 --- a/src/conversion/from_geo_types.rs +++ b/src/conversion/from_geo_types.rs @@ -185,7 +185,7 @@ where { vec![ create_point_type(&line_string.start_point()), - create_point_type(&line_string.start_point()), + create_point_type(&line_string.end_point()), ] } @@ -252,7 +252,7 @@ mod tests { use crate::{Geometry, Value}; use geo_types; use geo_types::{ - GeometryCollection, LineString, MultiLineString, MultiPoint, MultiPolygon, Point, Polygon, + GeometryCollection, LineString, Line, MultiLineString, MultiPoint, MultiPolygon, Point, Polygon, }; #[test] @@ -316,6 +316,24 @@ mod tests { } } + #[test] + fn geo_line_conversion_test() { + let p1 = Point::new(40.02f64, 116.34f64); + let p2 = Point::new(13.02f64, 24.34f64); + + let geo_line = Line::new(p1, p2); + let geojson_line_point = Value::from(&geo_line); + + if let Value::LineString(c) = geojson_line_point { + assert_almost_eq!(p1.x(), c[0][0], 1e-6); + assert_almost_eq!(p1.y(), c[0][1], 1e-6); + assert_almost_eq!(p2.x(), c[1][0], 1e-6); + assert_almost_eq!(p2.y(), c[1][1], 1e-6); + } else { + panic!("Not valid geometry {:?}", geojson_line_point); + } + } + #[test] fn geo_multi_line_string_conversion_test() { let p1 = Point::new(40.02f64, 116.34f64);