Skip to content

Commit 0ae5a38

Browse files
authored
test: add test for shapefile (#21)
1 parent edddff3 commit 0ae5a38

13 files changed

+19
-0
lines changed

fixtures/input_area.dbf

70 Bytes
Binary file not shown.

fixtures/input_area.prj

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
GEOGCS["WGS84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.017453292519943295]]

fixtures/input_area.shp

456 Bytes
Binary file not shown.

fixtures/input_area.shx

116 Bytes
Binary file not shown.

fixtures/input_line.dbf

68 Bytes
Binary file not shown.

fixtures/input_line.prj

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
GEOGCS["WGS84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.017453292519943295]]

fixtures/input_line.shp

188 Bytes
Binary file not shown.

fixtures/input_line.shx

108 Bytes
Binary file not shown.

fixtures/input_point.dbf

68 Bytes
Binary file not shown.

fixtures/input_point.prj

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
GEOGCS["WGS84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.017453292519943295]]

fixtures/input_point.shp

128 Bytes
Binary file not shown.

fixtures/input_point.shx

108 Bytes
Binary file not shown.

src/main.rs

+16
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,22 @@ mod test {
413413
);
414414
}
415415

416+
#[test]
417+
fn test_handle_shp() {
418+
let file_path = "./fixtures/input_point.shp";
419+
let points = handle_shp(file_path, 0., false).unwrap();
420+
let points = points.iter().filter(|g| matches!(g, GridGeom::Point(_)));
421+
let file_path = "./fixtures/input_line.shp";
422+
let lines = handle_shp(file_path, 0., false).unwrap();
423+
let lines = lines.iter().filter(|g| matches!(g, GridGeom::Line(_)));
424+
let file_path = "./fixtures/input_area.shp";
425+
let areas = handle_shp(file_path, 0., true).unwrap();
426+
let poly = areas.iter().filter(|g| matches!(g, GridGeom::Polygon(_)));
427+
assert_eq!(points.count(), 1);
428+
assert_eq!(lines.count(), 1);
429+
assert_eq!(poly.count(), 3);
430+
}
431+
416432
#[test]
417433
fn test_handle_wkt() {
418434
let input_str = include_str!("../fixtures/input.wkt").to_string();

0 commit comments

Comments
 (0)