(self, geometries, buffer_method_name)
| 936 | ) |
| 937 | |
| 938 | def _test_buffer(self, geometries, buffer_method_name): |
| 939 | for bg in geometries: |
| 940 | g = fromstr(bg.wkt) |
| 941 | |
| 942 | # The buffer we expect |
| 943 | exp_buf = fromstr(bg.buffer_wkt) |
| 944 | |
| 945 | # Constructing our buffer |
| 946 | buf_kwargs = { |
| 947 | kwarg_name: getattr(bg, kwarg_name) |
| 948 | for kwarg_name in ( |
| 949 | "width", |
| 950 | "quadsegs", |
| 951 | "end_cap_style", |
| 952 | "join_style", |
| 953 | "mitre_limit", |
| 954 | ) |
| 955 | if hasattr(bg, kwarg_name) |
| 956 | } |
| 957 | buf = getattr(g, buffer_method_name)(**buf_kwargs) |
| 958 | with self.subTest(bg=bg): |
| 959 | self.assertEqual(exp_buf.num_coords, buf.num_coords) |
| 960 | self.assertEqual(len(exp_buf), len(buf)) |
| 961 | |
| 962 | # Now assuring that each point in the buffer is almost equal |
| 963 | for exp_ring, buf_ring in zip(exp_buf, buf, strict=True): |
| 964 | for exp_point, buf_point in zip(exp_ring, buf_ring, strict=True): |
| 965 | # Asserting the X, Y of each point are almost equal |
| 966 | # (due to floating point imprecision). |
| 967 | self.assertAlmostEqual(exp_point[0], buf_point[0], 9) |
| 968 | self.assertAlmostEqual(exp_point[1], buf_point[1], 9) |
| 969 | |
| 970 | def test_covers(self): |
| 971 | poly = Polygon(((0, 0), (0, 10), (10, 10), (10, 0), (0, 0))) |
no test coverage detected