Skip to content

Commit

Permalink
Update to latest sfcgal-sys / to SFCGAL 1.5
Browse files Browse the repository at this point in the history
- 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)
  • Loading branch information
mthh committed Apr 16, 2024
1 parent 5f73283 commit 1f8970f
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 38 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/build_doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
26 changes: 13 additions & 13 deletions src/conversion/coords.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Point3d> = pt_sfcgal.to_coordinates().unwrap();
if let CoordSeq::Point(ref coords) = coords {
Expand Down Expand Up @@ -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<Point3d> = multipt_sfcgal.to_coordinates().unwrap();
if let CoordSeq::Multipoint(ref coords) = coords {
Expand Down Expand Up @@ -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<Point3d> = linestring_sfcgal.to_coordinates().unwrap();
if let CoordSeq::Linestring(ref coords) = coords {
Expand Down Expand Up @@ -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<Point3d> = multilinestring_sfcgal.to_coordinates().unwrap();
if let CoordSeq::Multilinestring(ref coords) = coords {
Expand Down Expand Up @@ -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)),\
Expand All @@ -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)),\
Expand Down Expand Up @@ -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<Point3d> = gc_sfcgal.to_coordinates().unwrap();
if let CoordSeq::Geometrycollection(ref seq_coords) = coords {
Expand Down Expand Up @@ -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(),
Expand Down
Loading

0 comments on commit 1f8970f

Please sign in to comment.