def test_merge_multipoints_different_crs(self): mp1 = Multipoint(zip(np.arange(0, 5), np.arange(3, 8)), data={ "A": np.arange(5), "B": np.arange(10, 15) }, crs=LonLatWGS84) mp2 = Multipoint(zip(np.arange(0, 5) + 1, np.arange(3, 8) - 2), data={ "A": np.arange(5), "C": np.arange(15, 20) }, crs=WebMercator) mp = Multipoint.merge(mp1, mp2, crs=WebMercator) self.assertTrue(len(mp), 10) self.assertEqual(set(mp.data.fields), set(["A"])) self.assertEqual(mp.crs, WebMercator) self.assertTrue( np.allclose( mp.coords(), np.array([[ 0.00000000e+00, 1.11319491e+05, 2.22638982e+05, 3.33958472e+05, 4.45277963e+05, 1.00000000e+00, 2.00000000e+00, 3.00000000e+00, 4.00000000e+00, 5.00000000e+00 ], [ 3.34111171e+05, 4.45640110e+05, 5.57305257e+05, 6.69141057e+05, 7.81182214e+05, 1.00000000e+00, 2.00000000e+00, 3.00000000e+00, 4.00000000e+00, 5.00000000e+00 ]])))
def test_merge_multipoints(self): mp1 = Multipoint(zip(np.arange(0, 5), np.arange(3, 8)), data={"A": np.arange(5), "B": np.arange(10, 15)}) mp2 = Multipoint(zip(np.arange(0, 5)+1, np.arange(3, 8)-2), data={"A": np.arange(5), "C": np.arange(15, 20)}) mp = Multipoint.merge(mp1, mp2) self.assertTrue(len(mp), 10) self.assertEqual(set(mp.data.fields), set(["A"]))
def test_merge_points(self): pt1 = Point((1, 2), properties={"number": 16}) mp1 = Multipoint([(5, 6), (5, 4), (4, 3)], data={"number": [2, 76, 4]}) pt2 = Point((3, 4, 5), properties={"number": 22, "temperature": "hot"}) mp2 = Multipoint([(5, 6), (4, 7), (3, 9), (4, 9)], data={"number": [4, 674, 32, 56], "temperature": ["cool", "hot", "scorching", "mild"]}) merged = Multipoint.merge(pt1, mp1, pt2, mp2) self.assertEqual(len(merged), 9) self.assertEqual(merged.vertices.asarray().shape, (9, 2)) self.assertEqual(merged.d["number"], [16, 2, 76, 4, 22, 4, 674, 32, 56])
def test_merge_multipoints(self): mp1 = Multipoint(zip(np.arange(0, 5), np.arange(3, 8)), data={ "A": np.arange(5), "B": np.arange(10, 15) }) mp2 = Multipoint(zip(np.arange(0, 5) + 1, np.arange(3, 8) - 2), data={ "A": np.arange(5), "C": np.arange(15, 20) }) mp = Multipoint.merge(mp1, mp2) self.assertTrue(len(mp), 10) self.assertEqual(set(mp.data.fields), set(["A"]))
def test_merge_multipoints_different_crs(self): mp1 = Multipoint(zip(np.arange(0, 5), np.arange(3, 8)), data={"A": np.arange(5), "B": np.arange(10, 15)}, crs=LonLatWGS84) mp2 = Multipoint(zip(np.arange(0, 5)+1, np.arange(3, 8)-2), data={"A": np.arange(5), "C": np.arange(15, 20)}, crs=WebMercator) mp = Multipoint.merge(mp1, mp2, crs=WebMercator) self.assertTrue(len(mp), 10) self.assertEqual(set(mp.data.fields), set(["A"])) self.assertEqual(mp.crs, WebMercator) self.assertTrue(np.allclose(mp.coords(), np.array([[0.00000000e+00, 1.11319491e+05, 2.22638982e+05, 3.33958472e+05, 4.45277963e+05, 1.00000000e+00, 2.00000000e+00, 3.00000000e+00, 4.00000000e+00, 5.00000000e+00], [3.34111171e+05, 4.45640110e+05, 5.57305257e+05, 6.69141057e+05, 7.81182214e+05, 1.00000000e+00, 2.00000000e+00, 3.00000000e+00, 4.00000000e+00, 5.00000000e+00]])))