Skip to content

Add test for Shapefile #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added fixtures/input_area.dbf
Binary file not shown.
1 change: 1 addition & 0 deletions fixtures/input_area.prj
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GEOGCS["WGS84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.017453292519943295]]
Binary file added fixtures/input_area.shp
Binary file not shown.
Binary file added fixtures/input_area.shx
Binary file not shown.
Binary file added fixtures/input_line.dbf
Binary file not shown.
1 change: 1 addition & 0 deletions fixtures/input_line.prj
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GEOGCS["WGS84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.017453292519943295]]
Binary file added fixtures/input_line.shp
Binary file not shown.
Binary file added fixtures/input_line.shx
Binary file not shown.
Binary file added fixtures/input_point.dbf
Binary file not shown.
1 change: 1 addition & 0 deletions fixtures/input_point.prj
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GEOGCS["WGS84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.017453292519943295]]
Binary file added fixtures/input_point.shp
Binary file not shown.
Binary file added fixtures/input_point.shx
Binary file not shown.
16 changes: 16 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,22 @@ mod test {
);
}

#[test]
fn test_handle_shp() {
let file_path = "./fixtures/input_point.shp";
let points = handle_shp(file_path, 0., false).unwrap();
let points = points.iter().filter(|g| matches!(g, GridGeom::Point(_)));
let file_path = "./fixtures/input_line.shp";
let lines = handle_shp(file_path, 0., false).unwrap();
let lines = lines.iter().filter(|g| matches!(g, GridGeom::Line(_)));
let file_path = "./fixtures/input_area.shp";
let areas = handle_shp(file_path, 0., true).unwrap();
let poly = areas.iter().filter(|g| matches!(g, GridGeom::Polygon(_)));
assert_eq!(points.count(), 1);
assert_eq!(lines.count(), 1);
assert_eq!(poly.count(), 3);
}

#[test]
fn test_handle_wkt() {
let input_str = include_str!("../fixtures/input.wkt").to_string();
Expand Down