shape_contour/
lib.rs

1#![doc(html_root_url = "https://docs.rs/shape-contour/0.2.2")]
2//! Rust crate shape-contour supports ESRI J shapefile (C bindings)
3//!
4//! # Requirements
5//!
6//! - [ shapelib-rs ]( https://crates.io/crates/shapelib-rs )
7//! - [ OSGeo ]( https://OSGeo.org/ )
8//! - [ OSGeo shapelib (C) ]( https://github.com/OSGeo/shapelib )
9//! - [ shapelib ]( http://shapelib.maptools.org/ )
10//! - [ ESRI J shapefile ]( https://www.esrij.com/products/japan-shp/ )
11//!
12//! link shapelib_i.lib
13//!
14
15pub mod contours;
16
17#[cfg(test)]
18mod tests {
19  use super::contours::{self, shape};
20  use std::path::PathBuf;
21
22  /// with [-- --nocapture] or with [-- --show-output]
23  #[test]
24  fn check_shape_contour() {
25    let rp = "../shapelib-rs";
26    let s_path: String = if cfg!(docsrs) {
27      std::env::var("OUT_DIR").unwrap()
28    }else{
29      rp.to_string()
30    }; // to keep lifetime
31    let o_path: &str = s_path.as_str();
32    if o_path != rp { return; }
33    let bp = PathBuf::from(o_path).join("shp").join("ESRIJ_com_japan_ver84");
34    println!("{}", bp.join("japan_ver84.shp").to_str().unwrap());
35    println!("{}", bp.join("japan_ver84.dbf").to_str().unwrap());
36    let s = bp.join("japan_ver84"); // to keep lifetime
37    let u = s.to_str().unwrap(); // to keep lifetime
38    let shp = shape::ShapeF::new(u, "cp932").unwrap();
39    shp.disp_record_inf().unwrap();
40    let sci = shp.get_shp_contours(false).unwrap();
41    drop(shp);
42    let mut gci = contours::GrpContoursInf::new(sci).unwrap();
43    gci.grp_contours.clear();
44    gci.get_grp_contours(50.0, 26, 343, false).unwrap(); // 50.0 (1600, 1200)
45    println!("n_grp_contours: {}", gci.grp_contours.len());
46    gci.grp_contours.clear();
47    gci.get_grp_contours(50.0, 0, 0, false).unwrap(); // 1-47, 0
48    println!("n_grp_contours: {}", gci.grp_contours.len());
49  }
50}