def test_split_3(self): wkt = "MULTIPOLYGON (((40 40, 20 45, 45 30, 40 40)), ((-172 53, 175 53, 175 48, -172 48, -172 53)), ((20 35, 10 30, 10 10, 30 5, 45 20, 20 35), (30 20, 20 15, 20 25, 30 20)))" islands_shape = loads(wkt) result = MetadataService._dateline_intersection((172, 53), (-172, 53)) self.assertIsNotNone(result) self.assertEqual((180, 53), result[0]) self.assertEqual((-180, 53), result[1]) result = MetadataService._dateline_intersection((-172, 53), (172, 53)) self.assertIsNotNone(result) self.assertEqual((180, 53), result[1]) self.assertEqual((-180, 53), result[0]) result = MetadataService._dateline_intersection((-172, 55), (172, 53)) self.assertIsNotNone(result) self.assertEqual((180, 54), result[1]) self.assertEqual((-180, 54), result[0]) result = MetadataService._dateline_intersection((172, 53), (-172, -53)) self.assertIsNotNone(result) self.assertEqual((180, 0), result[0]) self.assertEqual((-180, 0), result[1]) result = MetadataService._dateline_intersection((172, 53), (172, -53)) self.assertIsNone(result) result = MetadataService._dateline_intersection((-172, 53), (-172, -53)) self.assertIsNone(result) for geom in islands_shape.geoms: # self.assertFalse(geom.exterior.is_ccw) clean_poly = MetadataService.split_by_dateline(geom) self.assertIsNotNone(clean_poly) if clean_poly: for geom_result in clean_poly: self.assertTrue(geom_result.exterior.is_ccw) results = MetadataService.split_all_by_dateline([islands_shape.wkb]) for geom_result in results: self.assertIsNotNone(geom_result) self.assertTrue(geom_result.exterior.is_ccw)
def test_split_2(self): wkt = "MULTIPOLYGON (((40 40, 20 45, 45 30, 40 40)), ((20 35, 10 30, 10 10, 30 5, 45 20, 20 35), (30 20, 20 15, 20 25, 30 20)))" islands_shape = loads(wkt) for geom in islands_shape.geoms: self.assertIsNotNone(MetadataService.split_by_dateline(geom))
def test_split_1(self): wkt = "MULTIPOLYGON (((40 40, 20 45, 45 30, 40 40)), ((-172 53, 175 53, 175 48, -172 48, -172 53)), ((20 35, 10 30, 10 10, 30 5, 45 20, 20 35), (30 20, 20 15, 20 25, 30 20)))" islands_shape = loads(wkt) with self.assertRaises(ValueError): MetadataService.split_by_dateline(islands_shape)