Skip to content

Commit

Permalink
add case 5.4 test
Browse files Browse the repository at this point in the history
  • Loading branch information
jGaboardi committed Dec 16, 2020
1 parent 24b8b45 commit b8280d6
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tigernet/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,28 @@ def setUp(self):
self.line17_idx = 16
geoms += [self.line15, self.line16, self.line17]
rings += ["False", "False", "False"]
# Case 5: complex intersection - line & line & line (camel humps)
self.line18, self.line18_idx = LineString(((0, 9), (3, 9))), 17
self.line19 = LineString(
(
(0.25, 9),
(0.5, 9),
(0.5, 9.5),
(1, 9.5),
(1, 9),
(1.5, 9),
(1.5, 9.5),
(2, 9.5),
(2, 9),
(2.25, 9),
(2.25, 8.5),
(2.75, 8.5),
(2.75, 9.25),
)
)
self.line19_idx = 17
geoms += [self.line18, self.line19]
rings += ["False", "False"]

self.gdf = geopandas.GeoDataFrame(geometry=geoms)
self.gdf["ring"] = rings
Expand Down Expand Up @@ -351,6 +373,25 @@ def test_split_line_case53(self):
for cidx, coord in enumerate(xy):
self.assertEqual(list(observed_case53[lidx].xy[cidx]), coord)

def test_split_line_case54(self):
known_case54 = [
[[0.0, 0.25], [9.0, 9.0]],
[[0.25, 0.5], [9.0, 9.0]],
[[0.5, 1.0], [9.0, 9.0]],
[[1.0, 1.5], [9.0, 9.0]],
[[1.5, 2.0], [9.0, 9.0]],
[[2.0, 2.25], [9.0, 9.0]],
[[2.25, 2.75], [9.0, 9.0]],
[[2.75, 3.0], [9.0, 9.0]],
]
idx = self.line19_idx
loi = self.gdf.loc[idx, self.g]
args, kwargs = (loi, idx), {"df": self.gdf, "geo_col": self.g}
observed_case54 = tigernet.utils._split_line(*args, **kwargs)
for lidx, xy in enumerate(known_case54):
for cidx, coord in enumerate(xy):
self.assertEqual(list(observed_case54[lidx].xy[cidx]), coord)


if __name__ == "__main__":
unittest.main()

0 comments on commit b8280d6

Please sign in to comment.