def test_tonumpy(): point = Point(10, 10) line = LineString([(0, 0), (0, 1), (1, 1), (1, 0), (0, 0)]) polygon = Polygon([(0, 0), (0, 1), (1, 1), (1, 0), (0, 0)]) mp = MultiPoint([(0, 0), (1, 1), (1, 2), (2, 2)]) ml = MultiLineString([[(0, 0), (1, 1)], [(1, 2), (2, 2)]]) polygon2 = Polygon([(0, 0), (0, 1), (1, 1), (1, 0), (0, 0)], [ LineString([(0.25, 0.25), (0.25, 0.75), (0.75, 0.75), (0.75, 0.25), (0.25, 0.25)]) ]) mpol = MultiPolygon([polygon, polygon2]) np.testing.assert_array_equal(point.np, np.array([[10, 10]])) np.testing.assert_array_equal( line.np, np.array([[0, 0, 0], [1, 0, 1], [2, 1, 1], [3, 1, 0], [0, 0, 0]])) np.testing.assert_almost_equal( line._np(isNorm=True), np.array([[0, 0., 0.0, 0.70710678, 0.70710678, 0., 0.], [1, 0, 1., 0.70710678, -0.70710678, 0., 1.], [2, 1., 1., -0.70710678, -0.70710678, 1., 1.], [3, 1., 0., -0.70710678, 0.70710678, 1., 0.], [0, 0, 0, 0.70710678, 0.70710678, 0., 0.]])) np.testing.assert_almost_equal( line._np(isNorm=True, onPoint=False), np.array([[0., 0., 0.5, 1., -0., 0., 0.], [1., 0.5, 1., 0., -1., 0., 1.], [2., 1., 0.5, -1., -0., 1., 1.], [3., 0.5, 0., 0., 1., 1., 0.], [0., 0., 0.5, 1., -0., 0., 0.]])) np.testing.assert_array_equal( polygon.np, np.array([[0, 0, 0, 0], [0, 1, 0, 1], [0, 2, 1, 1], [0, 3, 1, 0], [0, 0, 0, 0]])) np.testing.assert_array_equal(mp.np, np.array([[0, 0], [1, 1], [1, 2], [2, 2]])) np.testing.assert_array_equal( ml.np, np.array([ [0, 0, 0, 0], [0, 1, 1, 1], [1, 0, 1, 2], [1, 1, 2, 2], ])) np.testing.assert_array_equal( mpol.np, np.array([ [0., 0., 0., 0., 0.], [0., 0., 1., 0., 1.], [0., 0., 2., 1., 1.], [0., 0., 3., 1., 0.], [0., 0., 0., 0., 0.], [1., 0., 0., 0., 0.], [1., 0., 1., 0., 1.], [1., 0., 2., 1., 1.], [1., 0., 3., 1., 0.], [1., 0., 0., 0., 0.], [1., 1., 0., 0.25, 0.25], [1., 1., 1., 0.25, 0.75], [1., 1., 2., 0.75, 0.75], [1., 1., 3., 0.75, 0.25], [1., 1., 0, 0.25, 0.25], ])) np.testing.assert_array_equal( line._np(isSegment=True), np.array([ [0., 1., 0., 0.], [1., 1., 0., 1.], [2., 1., 1., 1.], [3., 1., 1., 0.], [0., 1., 0., 0.], ])) line1 = LineString([(0, 0), (1, 0), (3, 0), (6, 0), (9, 0)]) np.testing.assert_array_equal( line1._np(isSegment=True), np.array([ [0., 1., 0., 0.], [1., 1., 1., 0.], [2., 2., 3., 0.], [3., 3., 6., 0.], [4., 3., 9., 0.], ]))