1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#![doc(html_root_url = "https://docs.rs/shape-contour/0.2.1")]
//! Rust crate shape-contour supports ESRI J shapefile (C bindings)
//!
//! # Requirements
//!
//! - [ shapelib-rs ]( https://crates.io/crates/shapelib-rs )
//! - [ OSGeo ]( https://OSGeo.org/ )
//! - [ OSGeo shapelib (C) ]( https://github.com/OSGeo/shapelib )
//! - [ shapelib ]( http://shapelib.maptools.org/ )
//! - [ ESRI J shapefile ]( https://www.esrij.com/products/japan-shp/ )
//!
//! link shapelib_i.lib
//!

pub mod contours;

#[cfg(test)]
mod tests {
  use super::contours::{self, shape};
  use std::path::PathBuf;

  /// with [-- --nocapture] or with [-- --show-output]
  #[test]
  fn check_shape_contour() {
    let rp = "../shapelib-rs";
    let s_path: String = if cfg!(docsrs) {
      std::env::var("OUT_DIR").unwrap()
    }else{
      rp.to_string()
    }; // to keep lifetime
    let o_path: &str = s_path.as_str();
    if o_path != rp { return; }
    let bp = PathBuf::from(o_path).join("shp").join("ESRIJ_com_japan_ver84");
    println!("{}", bp.join("japan_ver84.shp").to_str().unwrap());
    println!("{}", bp.join("japan_ver84.dbf").to_str().unwrap());
    let s = bp.join("japan_ver84"); // to keep lifetime
    let u = s.to_str().unwrap(); // to keep lifetime
    let shp = shape::ShapeF::new(u, "cp932").unwrap();
    shp.disp_record_inf().unwrap();
    let sci = shp.get_shp_contours().unwrap();
    drop(shp);
    let mut gci = contours::GrpContoursInf::new(sci).unwrap();
    gci.grp_contours.clear();
    gci.get_grp_contours(26, 343).unwrap();
    println!("n_grp_contours: {}", gci.grp_contours.len());
    gci.grp_contours.clear();
    gci.get_grp_contours(0, 0).unwrap(); // 1-47, 0
    println!("n_grp_contours: {}", gci.grp_contours.len());
  }
}