From 1f8970f6a536efeccafd1e23c9a78a6e6fbe5cba Mon Sep 17 00:00:00 2001 From: Matthieu Viry Date: Tue, 16 Apr 2024 18:54:02 +0200 Subject: [PATCH] Update to latest sfcgal-sys / to SFCGAL 1.5 - wrap `sfcgal_geometry_extrude_polygon_straight_skeleton` and `sfcgal_geometry_extrude_straight_skeleton` functions - change code for GeomType::Triangle to 17 (to follow upstream change) --- .github/workflows/build_doc.yml | 9 +- .github/workflows/test.yml | 9 +- src/conversion/coords.rs | 26 +++--- src/geometry.rs | 142 ++++++++++++++++++++++++++++---- src/lib.rs | 2 +- 5 files changed, 150 insertions(+), 38 deletions(-) diff --git a/.github/workflows/build_doc.yml b/.github/workflows/build_doc.yml index 1af650b77..2d564b76d 100644 --- a/.github/workflows/build_doc.yml +++ b/.github/workflows/build_doc.yml @@ -14,9 +14,12 @@ jobs: steps: - uses: actions/checkout@v3 - run: | - sudo apt-get install -y libcgal-dev libboost1.74-all-dev libmpfr-dev libgmp-dev cmake wget unzip clang libstdc++-11-dev - wget https://gitlab.com/Oslandia/SFCGAL/-/archive/v1.4.1/SFCGAL-v1.4.1.zip - unzip SFCGAL-v1.4.1.zip + sudo apt-get install -y libboost1.74-all-dev libmpfr-dev libgmp-dev cmake wget unzip clang libstdc++-11-dev + wget https://github.com/CGAL/cgal/releases/download/v5.6.1/CGAL-5.6.1-library.tar.xz + wget https://gitlab.com/SFCGAL/SFCGAL/-/archive/v1.5.0/SFCGAL-v1.5.0.zip + tar -xf CGAL-5.6.1-library.tar.xz + unzip SFCGAL-v1.5.0.zip + cd CGAL-5.6.1 && cmake . && sudo make install && cd .. cd $(ls -d */ | grep SFC) && cmake -DCMAKE_INSTALL_PREFIX=/usr . && make && sudo make install && cd .. - run: cargo test --all-features - run: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2e6ce7fae..d2f9fe15e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,8 +11,11 @@ jobs: steps: - uses: actions/checkout@v3 - run: | - sudo apt-get install -y libcgal-dev libboost1.74-all-dev libmpfr-dev libgmp-dev cmake wget unzip clang libstdc++-11-dev - wget https://gitlab.com/Oslandia/SFCGAL/-/archive/v1.4.1/SFCGAL-v1.4.1.zip - unzip SFCGAL-v1.4.1.zip + sudo apt-get install -y libboost1.74-all-dev libmpfr-dev libgmp-dev cmake wget unzip clang libstdc++-11-dev + wget https://github.com/CGAL/cgal/releases/download/v5.6.1/CGAL-5.6.1-library.tar.xz + wget https://gitlab.com/SFCGAL/SFCGAL/-/archive/v1.5.0/SFCGAL-v1.5.0.zip + tar -xf CGAL-5.6.1-library.tar.xz + unzip SFCGAL-v1.5.0.zip + cd CGAL-5.6.1 && cmake . && sudo make install && cd .. cd $(ls -d */ | grep SFC) && cmake -DCMAKE_INSTALL_PREFIX=/usr . && make && sudo make install && cd .. - run: cargo test --all-features diff --git a/src/conversion/coords.rs b/src/conversion/coords.rs index 5ce96bac7..4c7eae240 100644 --- a/src/conversion/coords.rs +++ b/src/conversion/coords.rs @@ -495,7 +495,7 @@ mod tests { #[test] fn point_3d_sfcgal_to_coordinates_to_sfcgal() { - let input_wkt = "POINT(0.1 0.9 1.0)"; + let input_wkt = "POINT Z(0.1 0.9 1.0)"; let pt_sfcgal = SFCGeometry::new(input_wkt).unwrap(); let coords: CoordSeq = pt_sfcgal.to_coordinates().unwrap(); if let CoordSeq::Point(ref coords) = coords { @@ -528,7 +528,7 @@ mod tests { #[test] fn multipoint_3d_sfcgal_to_coordinates_to_sfcgal() { - let input_wkt = "MULTIPOINT((3.5 5.6 1.0),(4.8 10.5 1.0))"; + let input_wkt = "MULTIPOINT Z((3.5 5.6 1.0),(4.8 10.5 1.0))"; let multipt_sfcgal = SFCGeometry::new(input_wkt).unwrap(); let coords: CoordSeq = multipt_sfcgal.to_coordinates().unwrap(); if let CoordSeq::Multipoint(ref coords) = coords { @@ -564,7 +564,7 @@ mod tests { #[test] fn linestring_3d_sfcgal_to_coordinates() { - let input_wkt = "LINESTRING(3.5 5.6 1.0,4.8 10.5 1.0)"; + let input_wkt = "LINESTRING Z(3.5 5.6 1.0,4.8 10.5 1.0)"; let linestring_sfcgal = SFCGeometry::new(input_wkt).unwrap(); let coords: CoordSeq = linestring_sfcgal.to_coordinates().unwrap(); if let CoordSeq::Linestring(ref coords) = coords { @@ -602,7 +602,7 @@ mod tests { #[test] fn multilinestring_3d_sfcgal_to_coordinates() { - let input_wkt = "MULTILINESTRING((3.5 5.6 1.0,4.8 10.5 1.0),(8.9 12.9 4.0,2.1 3.5 4.0),(1.1 4.8 4.0,6.2 7.5 4.0))"; + let input_wkt = "MULTILINESTRING Z((3.5 5.6 1.0,4.8 10.5 1.0),(8.9 12.9 4.0,2.1 3.5 4.0),(1.1 4.8 4.0,6.2 7.5 4.0))"; let multilinestring_sfcgal = SFCGeometry::new(input_wkt).unwrap(); let coords: CoordSeq = multilinestring_sfcgal.to_coordinates().unwrap(); if let CoordSeq::Multilinestring(ref coords) = coords { @@ -643,7 +643,7 @@ mod tests { #[test] fn solid_3d_sfcgal_to_coordinates() { - let input_wkt = "SOLID((((0 0 0,0 0 1,0 1 1,0 1 0,0 0 0)),\ + let input_wkt = "SOLID Z((((0 0 0,0 0 1,0 1 1,0 1 0,0 0 0)),\ ((0 0 0,0 1 0,1 1 0,1 0 0,0 0 0)),\ ((0 0 0,1 0 0,1 0 1,0 0 1,0 0 0)),\ ((1 0 0,1 1 0,1 1 1,1 0 1,1 0 0)),\ @@ -666,7 +666,7 @@ mod tests { #[test] fn solid_with_interior_shell_3d_sfcgal_to_coordinates() { - let input_wkt = "SOLID((\ + let input_wkt = "SOLID Z((\ ((0.0 0.0 0.0,0.0 1.0 0.0,1.0 1.0 0.0,1.0 0.0 0.0,0.0 0.0 0.0)),\ ((1.0 0.0 0.0,1.0 1.0 0.0,1.0 1.0 1.0,1.0 0.0 1.0,1.0 0.0 0.0)),\ ((0.0 1.0 0.0,0.0 1.0 1.0,1.0 1.0 1.0,1.0 1.0 0.0,0.0 1.0 0.0)),\ @@ -701,7 +701,7 @@ mod tests { #[test] fn geometrycollection_3d_sfcgal_to_coordinates() { let input_wkt = - "GEOMETRYCOLLECTION(POINT(4.0 6.0 1.0),LINESTRING(4.0 6.0 1.0,7.0 10.0 1.0))"; + "GEOMETRYCOLLECTION Z(POINT Z(4.0 6.0 1.0),LINESTRING Z(4.0 6.0 1.0,7.0 10.0 1.0))"; let gc_sfcgal = SFCGeometry::new(input_wkt).unwrap(); let coords: CoordSeq = gc_sfcgal.to_coordinates().unwrap(); if let CoordSeq::Geometrycollection(ref seq_coords) = coords { @@ -855,27 +855,27 @@ mod tests { let multipolygon_sfcgal = CoordSeq::Multipolygon(coords_multipolygon) .to_sfcgal() .unwrap(); - assert_eq!("POINT(1.1 1.1 1.1)", pt_sfcgal.to_wkt_decim(1).unwrap()); + assert_eq!("POINT Z(1.1 1.1 1.1)", pt_sfcgal.to_wkt_decim(1).unwrap()); assert_eq!( - "MULTIPOINT((1.1 1.1 5.0),(2.2 2.2 5.0))", + "MULTIPOINT Z((1.1 1.1 5.0),(2.2 2.2 5.0))", multipt_sfcgal.to_wkt_decim(1).unwrap() ); assert_eq!( - "LINESTRING(1.1 1.1 5.0,2.2 2.2 5.0)", + "LINESTRING Z(1.1 1.1 5.0,2.2 2.2 5.0)", line_sfcgal.to_wkt_decim(1).unwrap() ); assert_eq!( - "MULTILINESTRING((1.1 1.1 3.0,2.2 2.2 3.0),(3.1 3.1 3.0,5.2 5.2 3.0,5.2 5.2 3.0),\ + "MULTILINESTRING Z((1.1 1.1 3.0,2.2 2.2 3.0),(3.1 3.1 3.0,5.2 5.2 3.0,5.2 5.2 3.0),\ (1.1 1.1 3.0,2.2 2.2 3.0,5.2 5.2 3.0))", multiline_sfcgal.to_wkt_decim(1).unwrap(), ); assert_eq!( - "POLYGON((0.0 0.0 3.0,1.0 0.0 3.0,1.0 1.0 3.0,0.0 1.0 3.0,0.0 0.0 3.0),\ + "POLYGON Z((0.0 0.0 3.0,1.0 0.0 3.0,1.0 1.0 3.0,0.0 1.0 3.0,0.0 0.0 3.0),\ (0.1 0.1 3.0,0.1 0.9 3.0,0.9 0.9 3.0,0.9 0.1 3.0,0.1 0.1 3.0))", polygon_sfcgal.to_wkt_decim(1).unwrap(), ); assert_eq!( - "MULTIPOLYGON(((0.0 0.0 3.0,1.0 0.0 3.0,1.0 1.0 3.0,0.0 1.0 3.0,0.0 0.0 3.0),\ + "MULTIPOLYGON Z(((0.0 0.0 3.0,1.0 0.0 3.0,1.0 1.0 3.0,0.0 1.0 3.0,0.0 0.0 3.0),\ (0.1 0.1 3.0,0.1 0.9 3.0,0.9 0.9 3.0,0.9 0.1 3.0,0.1 0.1 3.0)),\ ((2.0 2.0 3.0,6.0 2.0 3.0,6.0 6.0 3.0,2.0 6.0 3.0,2.0 2.0 3.0)))", multipolygon_sfcgal.to_wkt_decim(1).unwrap(), diff --git a/src/geometry.rs b/src/geometry.rs index 00dc6f860..3be84455c 100644 --- a/src/geometry.rs +++ b/src/geometry.rs @@ -21,6 +21,7 @@ use sfcgal_sys::{ sfcgal_geometry_minkowski_sum, sfcgal_geometry_offset_polygon, sfcgal_geometry_optimal_alpha_shapes, sfcgal_geometry_orientation, sfcgal_geometry_straight_skeleton, sfcgal_geometry_straight_skeleton_distance_in_m, + sfcgal_geometry_extrude_straight_skeleton, sfcgal_geometry_extrude_polygon_straight_skeleton, sfcgal_geometry_t, sfcgal_geometry_tesselate, sfcgal_geometry_triangulate_2dz, sfcgal_geometry_type_id, sfcgal_geometry_union, sfcgal_geometry_union_3d, sfcgal_geometry_volume, sfcgal_io_read_wkt, sfcgal_multi_linestring_create, @@ -44,7 +45,7 @@ pub enum GeomType { Geometrycollection = 7, Polyhedralsurface = 15, Triangulatedsurface = 16, - Triangle = 100, + Triangle = 17, Solid = 101, Multisolid = 102, } @@ -140,7 +141,7 @@ impl SFCGeometry { } /// Returns a WKT representation of the given `SFCGeometry` using CGAL exact integer fractions as coordinate values. - /// ([C API reference](http://oslandia.github.io/SFCGAL/doxygen/group__capi.html#ga3bc1954e3c034b60f0faff5e8227c398)) + /// ([C API reference](https://sfcgal.gitlab.io/SFCGAL/doxygen/group__capi.html#ga3bc1954e3c034b60f0faff5e8227c398)) pub fn to_wkt(&self) -> Result { let mut ptr = MaybeUninit::<*mut c_char>::uninit(); let mut length: usize = 0; @@ -152,7 +153,7 @@ impl SFCGeometry { /// Returns a WKT representation of the given `SFCGeometry` using floating point coordinate values with /// the desired number of decimals. - /// ([C API reference](http://oslandia.github.io/SFCGAL/doxygen/group__capi.html#gaaf23f2c95fd48810beb37d07a9652253)) + /// ([C API reference](https://sfcgal.gitlab.io/SFCGAL/doxygen/group__capi.html#gaaf23f2c95fd48810beb37d07a9652253)) pub fn to_wkt_decim(&self, nb_decim: i32) -> Result { let mut ptr = MaybeUninit::<*mut c_char>::uninit(); let mut length: usize = 0; @@ -336,29 +337,44 @@ impl SFCGeometry { } /// Returns the straight skeleton of the given `SFCGeometry`. - /// ([C API reference](http://oslandia.github.io/SFCGAL/doxygen/group__capi.html#gaefaa76b61d66e2ad11d902e6b5a13635)) + /// ([C API reference](https://sfcgal.gitlab.io/SFCGAL/doxygen/group__capi.html#gaefaa76b61d66e2ad11d902e6b5a13635)) pub fn straight_skeleton(&self) -> Result { let result = unsafe { sfcgal_geometry_straight_skeleton(self.c_geom.as_ptr()) }; unsafe { SFCGeometry::new_from_raw(result, true) } } /// Returns the straight skeleton of the given `SFCGeometry` with the distance to the border as M coordinate. - /// ([C API reference](http://oslandia.github.io/SFCGAL/doxygen/group__capi.html#ga972ea9e378eb2dc99c00b6ad57d05e88)) + /// ([C API reference](https://sfcgal.gitlab.io/SFCGAL/doxygen/group__capi.html#ga972ea9e378eb2dc99c00b6ad57d05e88)) pub fn straight_skeleton_distance_in_m(&self) -> Result { let result = unsafe { sfcgal_geometry_straight_skeleton_distance_in_m(self.c_geom.as_ptr()) }; unsafe { SFCGeometry::new_from_raw(result, true) } } + /// Returns the extrude straight skeleton of the given Polygon. + /// ([C API reference](https://sfcgal.gitlab.io/SFCGAL/doxygen/group__capi.html#ga5389fd88daf80a8221a3ca619813a2be)) + pub fn extrude_straight_skeleton(&self, height: f64) -> Result { + let result = unsafe { sfcgal_geometry_extrude_straight_skeleton(self.c_geom.as_ptr(), height) }; + unsafe { SFCGeometry::new_from_raw(result, true) } + } + + /// Returns the union of the polygon z-extrusion (with respect to building_height) + /// and the extrude straight skeleton (with respect to roof_height) of the given Polygon. + /// ([C API reference](https://sfcgal.gitlab.io/SFCGAL/doxygen/group__capi.html#ga5389fd88daf80a8221a3ca619813a2be)) + pub fn extrude_polygon_straight_skeleton(&self, building_height: f64, roof_height: f64) -> Result { + let result = unsafe { sfcgal_geometry_extrude_polygon_straight_skeleton(self.c_geom.as_ptr(), building_height, roof_height) }; + unsafe { SFCGeometry::new_from_raw(result, true) } + } + /// Returns the approximate medial axis for the given `SFCGeometry` Polygon. - /// ([C API reference](http://oslandia.github.io/SFCGAL/doxygen/group__capi.html#ga16a9b4b1211843f8444284b1fefebc46)) + /// ([C API reference](https://sfcgal.gitlab.io/SFCGAL/doxygen/group__capi.html#ga16a9b4b1211843f8444284b1fefebc46)) pub fn approximate_medial_axis(&self) -> Result { let result = unsafe { sfcgal_geometry_approximate_medial_axis(self.c_geom.as_ptr()) }; unsafe { SFCGeometry::new_from_raw(result, true) } } /// Returns the offset polygon of the given `SFCGeometry`. - /// ([C API reference](http://oslandia.github.io/SFCGAL/doxygen/group__capi.html#ga9766f54ebede43a9b71fccf1524a1054)) + /// ([C API reference](https://sfcgal.gitlab.io/SFCGAL/doxygen/group__capi.html#ga9766f54ebede43a9b71fccf1524a1054)) pub fn offset_polygon(&self, radius: f64) -> Result { let result = unsafe { sfcgal_geometry_offset_polygon(self.c_geom.as_ptr(), radius) }; unsafe { SFCGeometry::new_from_raw(result, true) } @@ -372,7 +388,7 @@ impl SFCGeometry { } /// Returns a tesselation of the given `SFCGeometry`. - /// ([C API reference](http://oslandia.github.io/SFCGAL/doxygen/group__capi.html#ga570ce6214f305ed35ebbec62d366b588)) + /// ([C API reference](https://sfcgal.gitlab.io/SFCGAL/doxygen/group__capi.html#ga570ce6214f305ed35ebbec62d366b588)) pub fn tesselate(&self) -> Result { let result = unsafe { sfcgal_geometry_tesselate(self.c_geom.as_ptr()) }; unsafe { SFCGeometry::new_from_raw(result, true) } @@ -752,7 +768,7 @@ mod tests { let wkt = result.to_wkt_decim(1).unwrap(); assert_eq!( wkt, - "MULTILINESTRING((-0.0 -0.0,0.5 0.5),(1.0 -0.0,0.5 0.5),(1.0 1.0,0.5 0.5),(-0.0 1.0,0.5 0.5))", + "MULTILINESTRING((0.0 0.0,0.5 0.5),(1.0 0.0,0.5 0.5),(1.0 1.0,0.5 0.5),(0.0 1.0,0.5 0.5))", ); } @@ -764,10 +780,100 @@ mod tests { assert_eq!( wkt, "MULTILINESTRING M(\ - (-0.0 -0.0 0.0,0.5 0.5 0.5),\ - (1.0 -0.0 0.0,0.5 0.5 0.5),\ + (0.0 0.0 0.0,0.5 0.5 0.5),\ + (1.0 0.0 0.0,0.5 0.5 0.5),\ (1.0 1.0 0.0,0.5 0.5 0.5),\ - (-0.0 1.0 0.0,0.5 0.5 0.5))", + (0.0 1.0 0.0,0.5 0.5 0.5))", + ); + } + + #[test] + fn extrude_straight_skeleton() { + // Test adapted from https://gitlab.com/sfcgal/SFCGAL/-/blob/master/test/unit/SFCGAL/algorithm/StraightSkeletonTest.cpp#L275 + let geom = SFCGeometry::new("POLYGON ((0 0, 5 0, 5 5, 4 5, 4 4, 0 4, 0 0))").unwrap(); + let result = geom.extrude_straight_skeleton(2.).unwrap(); + let wkt = result.to_wkt_decim(2).unwrap(); + assert_eq!( + wkt, + "POLYHEDRALSURFACE Z(((4.00 5.00 0.00,5.00 5.00 0.00,4.00 4.00 0.00,4.00 \ + 5.00 0.00)),((0.00 4.00 0.00,4.00 4.00 0.00,0.00 0.00 0.00,0.00 4.00 \ + 0.00)),((4.00 4.00 0.00,5.00 0.00 0.00,0.00 0.00 0.00,4.00 4.00 \ + 0.00)),((5.00 5.00 0.00,5.00 0.00 0.00,4.00 4.00 0.00,5.00 5.00 \ + 0.00)),((0.00 4.00 0.00,0.00 0.00 0.00,2.00 2.00 2.00,0.00 4.00 \ + 0.00)),((0.00 0.00 0.00,5.00 0.00 0.00,3.00 2.00 2.00,0.00 0.00 \ + 0.00)),((2.00 2.00 2.00,0.00 0.00 0.00,3.00 2.00 2.00,2.00 2.00 \ + 2.00)),((4.50 3.50 0.50,5.00 5.00 0.00,4.50 4.50 0.50,4.50 3.50 \ + 0.50)),((3.00 2.00 2.00,5.00 0.00 0.00,4.50 3.50 0.50,3.00 2.00 \ + 2.00)),((4.50 3.50 0.50,5.00 0.00 0.00,5.00 5.00 0.00,4.50 3.50 \ + 0.50)),((5.00 5.00 0.00,4.00 5.00 0.00,4.50 4.50 0.50,5.00 5.00 \ + 0.00)),((4.50 4.50 0.50,4.00 4.00 0.00,4.50 3.50 0.50,4.50 4.50 \ + 0.50)),((4.50 4.50 0.50,4.00 5.00 0.00,4.00 4.00 0.00,4.50 4.50 \ + 0.50)),((4.00 4.00 0.00,0.00 4.00 0.00,2.00 2.00 2.00,4.00 4.00 \ + 0.00)),((4.50 3.50 0.50,4.00 4.00 0.00,3.00 2.00 2.00,4.50 3.50 \ + 0.50)),((3.00 2.00 2.00,4.00 4.00 0.00,2.00 2.00 2.00,3.00 2.00 \ + 2.00)))" + ); + } + + #[test] + fn extrude_polygon_straight_skeleton() { + // Test adapted from https://gitlab.com/sfcgal/SFCGAL/-/blob/master/test/unit/SFCGAL/algorithm/StraightSkeletonTest.cpp#L354 + let geom = SFCGeometry::new("POLYGON (( 0 0, 5 0, 5 5, 4 5, 4 4, 0 4, 0 0 ), (1 1, 1 2, 2 2, 2 1, 1 1))").unwrap(); + let result = geom.extrude_polygon_straight_skeleton(9., 2.).unwrap(); + let wkt = result.to_wkt_decim(1).unwrap(); + assert_eq!( + wkt, + "POLYHEDRALSURFACE Z(((0.0 0.0 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 + ((3.0 3.0 10.0,0.0 4.0 9.0,1.0 3.0 10.0,3.0 3.0 10.0)),\ + ((3.5 2.5 10.5,4.5 3.5 9.5,3.0 3.0 10.0,3.5 2.5 10.5)),\ + ((3.0 3.0 10.0,4.0 4.0 9.0,0.0 4.0 9.0,3.0 3.0 10.0)),\ + ((4.5 3.5 9.5,4.0 4.0 9.0,3.0 3.0 10.0,4.5 3.5 9.5)),\ + ((2.0 1.0 9.0,1.0 1.0 9.0,0.5 0.5 9.5,2.0 1.0 9.0)),\ + ((2.5 0.5 9.5,2.0 1.0 9.0,0.5 0.5 9.5,2.5 0.5 9.5)),\ + ((1.0 1.0 9.0,1.0 2.0 9.0,0.5 2.5 9.5,1.0 1.0 9.0)),\ + ((0.5 0.5 9.5,1.0 1.0 9.0,0.5 2.5 9.5,0.5 0.5 9.5)),\ + ((1.0 3.0 10.0,2.0 2.0 9.0,3.0 3.0 10.0,1.0 3.0 10.0)),\ + ((0.5 2.5 9.5,1.0 2.0 9.0,1.0 3.0 10.0,0.5 2.5 9.5)),\ + ((1.0 3.0 10.0,1.0 2.0 9.0,2.0 2.0 9.0,1.0 3.0 10.0)),\ + ((2.0 2.0 9.0,2.0 1.0 9.0,2.5 0.5 9.5,2.0 2.0 9.0)),\ + ((3.5 2.5 10.5,3.0 3.0 10.0,3.5 1.5 10.5,3.5 2.5 10.5)),\ + ((3.5 1.5 10.5,2.0 2.0 9.0,2.5 0.5 9.5,3.5 1.5 10.5)),\ + ((3.0 3.0 10.0,2.0 2.0 9.0,3.5 1.5 10.5,3.0 3.0 10.0)))" ); } @@ -810,11 +916,11 @@ mod tests { #[test] fn line_substring() { - let g = SFCGeometry::new("LINESTRING(10.0 1.0 2.0, 1.0 2.0 1.7)").unwrap(); + let g = SFCGeometry::new("LINESTRING Z(10.0 1.0 2.0, 1.0 2.0 1.7)").unwrap(); let result = g.line_substring(-0.2, 0.2).unwrap(); assert_eq!( result.to_wkt_decim(1).unwrap(), - "LINESTRING(2.8 1.8 1.8,8.2 1.2 1.9)" + "LINESTRING Z(2.8 1.8 1.8,8.2 1.2 1.9)" ); // With "start" or "end" point not in [-1; 1] assert_eq!( @@ -941,11 +1047,11 @@ mod tests { #[test] fn create_collection_heterogenous() { let a = SFCGeometry::new("POINT(1.0 1.0)").unwrap(); - let b = SFCGeometry::new("LINESTRING(10.0 1.0 2.0, 1.0 2.0 1.7)").unwrap(); + let b = SFCGeometry::new("LINESTRING Z(10.0 1.0 2.0, 1.0 2.0 1.7)").unwrap(); let g = SFCGeometry::create_collection(&mut [a, b]).unwrap(); assert_eq!( g.to_wkt_decim(1).unwrap(), - "GEOMETRYCOLLECTION(POINT(1.0 1.0),LINESTRING(10.0 1.0 2.0,1.0 2.0 1.7))", + "GEOMETRYCOLLECTION(POINT(1.0 1.0),LINESTRING Z(10.0 1.0 2.0,1.0 2.0 1.7))", ); } @@ -967,7 +1073,7 @@ mod tests { let g = SFCGeometry::create_collection(&mut [a, b]).unwrap(); assert_eq!( g.to_wkt_decim(1).unwrap(), - "MULTILINESTRING((10.0 1.0 2.0,1.0 2.0 1.7),(10.0 1.0 2.0,1.0 2.0 1.7))", + "MULTILINESTRING Z((10.0 1.0 2.0,1.0 2.0 1.7),(10.0 1.0 2.0,1.0 2.0 1.7))", ); } @@ -994,7 +1100,7 @@ mod tests { let g = SFCGeometry::create_collection(&mut [a, b]).unwrap(); assert_eq!( g.to_wkt_decim(1).unwrap(), - "MULTISOLID(\ + "MULTISOLID Z(\ ((\ ((0.0 0.0 0.0,0.0 0.0 1.0,0.0 1.0 1.0,0.0 1.0 0.0,0.0 0.0 0.0)),\ ((0.0 0.0 0.0,0.0 1.0 0.0,1.0 1.0 0.0,1.0 0.0 0.0,0.0 0.0 0.0)),\ diff --git a/src/lib.rs b/src/lib.rs index 5f52ec7e1..84c5a219f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -91,6 +91,6 @@ mod tests { use super::version; #[test] fn display_version() { - assert!(version().contains("1.4.")); + assert!(version().contains("1.5.")); } }