diff --git a/docs/api.rst b/docs/api.rst index 42938bf..0395f45 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -19,6 +19,9 @@ Geography properties get_type_id get_x get_y + is_prepared + prepare + destroy_prepared .. _api_creation: @@ -28,15 +31,13 @@ Geography creation .. autosummary:: :toctree: _api_generated/ - point - linestring - multipoint - multilinestring - polygon - collection - is_prepared - prepare - destroy_prepared + create_point + create_multipoint + create_linestring + create_multilinestring + create_polygon + create_multipolygon + create_collection .. _api_io: diff --git a/src/creation.cpp b/src/creation.cpp index c60ab8e..4a92e16 100644 --- a/src/creation.cpp +++ b/src/creation.cpp @@ -153,7 +153,7 @@ py::array_t points(const py::array_t &coords) { } template -std::unique_ptr multipoint(const std::vector &pts) { +std::unique_ptr create_multipoint(const std::vector &pts) { try { return make_geography(make_s2points(pts)); } catch (const EmptyGeographyException &error) { @@ -162,7 +162,7 @@ std::unique_ptr multipoint(const std::vector &pts) { } template -std::unique_ptr linestring(const std::vector &pts) { +std::unique_ptr create_linestring(const std::vector &pts) { if (pts.size() == 0) { // empty linestring std::vector> empty; @@ -181,7 +181,7 @@ std::unique_ptr linestring(const std::vector &pts) { } template -std::unique_ptr multilinestring(const std::vector> &lines) { +std::unique_ptr create_multilinestring(const std::vector> &lines) { std::vector> polylines(lines.size()); auto func = [](const std::vector &pts) { @@ -198,7 +198,7 @@ std::unique_ptr multilinestring(const std::vector> &li return make_geography(std::move(polylines)); } -std::unique_ptr multilinestring(const std::vector &lines) { +std::unique_ptr create_multilinestring(const std::vector &lines) { std::vector> polylines(lines.size()); auto func = [](const Geography *line_ptr) { @@ -221,8 +221,8 @@ std::unique_ptr multilinestring(const std::vector &lines } template -std::unique_ptr polygon(const std::vector &shell, - const std::optional>> &holes) { +std::unique_ptr create_polygon(const std::vector &shell, + const std::optional>> &holes) { // fastpath empty polygon if (shell.empty()) { if (holes.has_value() && !holes.value().empty()) { @@ -248,7 +248,7 @@ std::unique_ptr polygon(const std::vector &shell, return make_geography(make_s2polygon(std::move(loops))); } -std::unique_ptr multipolygon(const std::vector &polygons) { +std::unique_ptr create_multipolygon(const std::vector &polygons) { std::vector> loops; for (const auto *poly_ptr : polygons) { @@ -264,7 +264,7 @@ std::unique_ptr multipolygon(const std::vector &polygons return make_geography(make_s2polygon(std::move(loops))); } -std::unique_ptr collection(const std::vector &features) { +std::unique_ptr create_collection(const std::vector &features) { std::vector> features_copy; features_copy.reserve(features.size()); @@ -286,7 +286,7 @@ void init_creation(py::module &m) { // ----- scalar Geography creation functions m.def( - "point", + "create_point", [](py::object longitude, py::object latitude) { if (longitude.is_none() && latitude.is_none()) { // empty point @@ -302,7 +302,7 @@ void init_creation(py::module &m) { }, py::arg("longitude") = py::none(), py::arg("latitude") = py::none(), - R"pbdoc(point(longitude: float | None = None, latitude: float | None = None) -> Geography + R"pbdoc(create_point(longitude: float | None = None, latitude: float | None = None) -> Geography Create a POINT geography. Parameters @@ -314,10 +314,10 @@ void init_creation(py::module &m) { )pbdoc"); - m.def("multipoint", - &multipoint>, + m.def("create_multipoint", + &create_multipoint>, py::arg("points"), - R"pbdoc(multipoint(points: Sequence) -> Geography + R"pbdoc(create_multipoint(points: Sequence) -> Geography Create a MULTIPOINT geography. Parameters @@ -327,13 +327,13 @@ void init_creation(py::module &m) { POINT :class:`~spherely.Geography` objects. )pbdoc") - .def("multipoint", &multipoint, py::arg("points")); + .def("create_multipoint", &create_multipoint, py::arg("points")); m.def( - "linestring", + "create_linestring", [](py::none) { return make_geography(std::make_unique()); }, py::arg("vertices") = py::none(), - R"pbdoc(linestring(vertices: Sequence | None = None) -> Geography + R"pbdoc(create_linestring(vertices: Sequence | None = None) -> Geography Create a LINESTRING geography. Parameters @@ -343,13 +343,14 @@ void init_creation(py::module &m) { POINT :class:`~spherely.Geography` objects. )pbdoc") - .def("linestring", &linestring>, py::arg("vertices")) - .def("linestring", &linestring, py::arg("vertices")); + .def( + "create_linestring", &create_linestring>, py::arg("vertices")) + .def("create_linestring", &create_linestring, py::arg("vertices")); - m.def("multilinestring", - &multilinestring>, + m.def("create_multilinestring", + &create_multilinestring>, py::arg("lines"), - R"pbdoc(multilinestring(lines: Sequence) -> Geography + R"pbdoc(create_multilinestring(lines: Sequence) -> Geography Create a MULTILINESTRING geography. Parameters @@ -360,14 +361,14 @@ void init_creation(py::module &m) { a sequence of LINESTRING :class:`~spherely.Geography` objects. )pbdoc") - .def("multilinestring", &multilinestring, py::arg("lines")) + .def("create_multilinestring", &create_multilinestring, py::arg("lines")) .def( - "multilinestring", - [](const std::vector lines) { return multilinestring(lines); }, + "create_multilinestring", + [](const std::vector lines) { return create_multilinestring(lines); }, py::arg("lines")); m.def( - "polygon", + "create_polygon", [](py::none, py::none) { // TODO: remove explicit creation of S2Polygon, see // https://github.com/paleolimbot/s2geography/pull/31 @@ -377,7 +378,7 @@ void init_creation(py::module &m) { }, py::arg("shell") = py::none(), py::arg("holes") = py::none(), - R"pbdoc(polygon(shell: Sequence | None = None, holes: Sequence | None = None) -> Geography + R"pbdoc(create_polygon(shell: Sequence | None = None, holes: Sequence | None = None) -> Geography Create a POLYGON geography. Parameters @@ -390,16 +391,19 @@ void init_creation(py::module &m) { requirements as the ``shell`` argument. )pbdoc") - .def("polygon", - &polygon>, + .def("create_polygon", + &create_polygon>, py::arg("shell"), py::arg("holes") = py::none()) - .def("polygon", &polygon, py::arg("shell"), py::arg("holes") = py::none()); + .def("create_polygon", + &create_polygon, + py::arg("shell"), + py::arg("holes") = py::none()); - m.def("multipolygon", - &multipolygon, + m.def("create_multipolygon", + &create_multipolygon, py::arg("polygons"), - R"pbdoc(multipolygon(polygons: Sequence) -> Geography + R"pbdoc(create_multipolygon(polygons: Sequence) -> Geography Create a MULTIPOLYGON geography. Parameters @@ -409,10 +413,10 @@ void init_creation(py::module &m) { )pbdoc"); - m.def("collection", - &collection, + m.def("create_collection", + &create_collection, py::arg("geographies"), - R"pbdoc(collection(geographies: Sequence) -> Geography + R"pbdoc(create_collection(geographies: Sequence) -> Geography Create a GEOMETRYCOLLECTION geography from arbitrary geographies. Parameters diff --git a/src/spherely.pyi b/src/spherely.pyi index a663d6c..00fcba5 100644 --- a/src/spherely.pyi +++ b/src/spherely.pyi @@ -150,16 +150,16 @@ get_type_id: _VFunc_Nin1_Nout1[Literal["get_type_id"], int, np.int8] # Geography creation (scalar) -def point( +def create_point( longitude: float | None = None, latitude: float | None = None ) -> Geography: ... -def multipoint( +def create_multipoint( points: Iterable[Sequence[float]] | Iterable[PointGeography], ) -> MultiPointGeography: ... -def linestring( +def create_linestring( vertices: Iterable[Sequence[float]] | Iterable[PointGeography] | None = None, ) -> LineStringGeography: ... -def multilinestring( +def create_multilinestring( vertices: ( Iterable[Iterable[Sequence[float]]] | Iterable[Iterable[PointGeography]] @@ -167,22 +167,24 @@ def multilinestring( ), ) -> MultiLineStringGeography: ... @overload -def polygon( +def create_polygon( shell: None = None, holes: None = None, ) -> PolygonGeography: ... @overload -def polygon( +def create_polygon( shell: Iterable[Sequence[float]], holes: Iterable[Iterable[Sequence[float]]] | None = None, ) -> PolygonGeography: ... @overload -def polygon( +def create_polygon( shell: Iterable[PointGeography], holes: Iterable[Iterable[PointGeography]] | None = None, ) -> PolygonGeography: ... -def multipolygon(polygons: Iterable[PolygonGeography]) -> MultiPolygonGeography: ... -def collection(geographies: Iterable[Geography]) -> GeometryCollection: ... +def create_multipolygon( + polygons: Iterable[PolygonGeography], +) -> MultiPolygonGeography: ... +def create_collection(geographies: Iterable[Geography]) -> GeometryCollection: ... # Geography creation (vectorized) diff --git a/tests/test_accessors.py b/tests/test_accessors.py index 4d02d5f..cdc9f4c 100644 --- a/tests/test_accessors.py +++ b/tests/test_accessors.py @@ -9,14 +9,14 @@ @pytest.mark.parametrize( "geog, expected", [ - (spherely.point(0, 0), spherely.point(0, 0)), + (spherely.create_point(0, 0), spherely.create_point(0, 0)), ( - spherely.linestring([(0, 0), (2, 0)]), - spherely.point(1, 0), + spherely.create_linestring([(0, 0), (2, 0)]), + spherely.create_point(1, 0), ), ( - spherely.polygon([(0, 0), (0, 2), (2, 2), (2, 0)]), - spherely.point(1, 1), + spherely.create_polygon([(0, 0), (0, 2), (2, 2), (2, 0)]), + spherely.create_point(1, 1), ), ], ) @@ -38,10 +38,13 @@ def test_centroid(geog, expected) -> None: @pytest.mark.parametrize( "geog, expected", [ - (spherely.point(0, 0), "GEOMETRYCOLLECTION EMPTY"), - (spherely.linestring([(0, 0), (2, 0), (2, 2)]), "MULTIPOINT ((0 0), (2 2))"), + (spherely.create_point(0, 0), "GEOMETRYCOLLECTION EMPTY"), ( - spherely.polygon([(0, 0), (0, 2), (2, 2), (0.5, 1.5)]), + spherely.create_linestring([(0, 0), (2, 0), (2, 2)]), + "MULTIPOINT ((0 0), (2 2))", + ), + ( + spherely.create_polygon([(0, 0), (0, 2), (2, 2), (0.5, 1.5)]), "LINESTRING (0.5 1.5, 2 2, 0 2, 0 0, 0.5 1.5)", ), ], @@ -61,12 +64,12 @@ def test_boundary(geog, expected) -> None: "geog, expected", [ ( - spherely.linestring([(0, 0), (2, 0), (2, 2)]), - spherely.polygon([(0, 0), (2, 0), (2, 2)]), + spherely.create_linestring([(0, 0), (2, 0), (2, 2)]), + spherely.create_polygon([(0, 0), (2, 0), (2, 2)]), ), ( - spherely.polygon([(0, 0), (0, 2), (2, 2), (0.5, 1.5)]), - spherely.polygon([(0, 0), (0, 2), (2, 2)]), + spherely.create_polygon([(0, 0), (0, 2), (2, 2), (0.5, 1.5)]), + spherely.create_polygon([(0, 0), (0, 2), (2, 2)]), ), ], ) @@ -86,12 +89,18 @@ def test_convex_hull(geog, expected) -> None: def test_get_x_y() -> None: # scalar - a = spherely.point(1.5, 2.6) + a = spherely.create_point(1.5, 2.6) assert spherely.get_x(a) == pytest.approx(1.5, abs=1e-14) assert spherely.get_y(a) == pytest.approx(2.6, abs=1e-14) # array - arr = np.array([spherely.point(0, 1), spherely.point(1, 2), spherely.point(2, 3)]) + arr = np.array( + [ + spherely.create_point(0, 1), + spherely.create_point(1, 2), + spherely.create_point(2, 3), + ] + ) actual = spherely.get_x(arr) expected = np.array([0, 1, 2], dtype="float64") @@ -103,28 +112,28 @@ def test_get_x_y() -> None: # only points are supported with pytest.raises(ValueError): - spherely.get_x(spherely.linestring([(0, 1), (1, 2)])) + spherely.get_x(spherely.create_linestring([(0, 1), (1, 2)])) with pytest.raises(ValueError): - spherely.get_y(spherely.linestring([(0, 1), (1, 2)])) + spherely.get_y(spherely.create_linestring([(0, 1), (1, 2)])) @pytest.mark.parametrize( "geog_a, geog_b, expected", [ ( - spherely.point(0, 0), - spherely.point(0, 90), + spherely.create_point(0, 0), + spherely.create_point(0, 90), np.pi / 2 * spherely.EARTH_RADIUS_METERS, ), ( - spherely.point(0, 90), - spherely.point(90, 30), + spherely.create_point(0, 90), + spherely.create_point(90, 30), np.pi / 3 * spherely.EARTH_RADIUS_METERS, ), ( - spherely.polygon([(0, 0), (30, 60), (60, -30)]), - spherely.point(0, 90), + spherely.create_polygon([(0, 0), (30, 60), (60, -30)]), + spherely.create_point(0, 90), np.pi / 6 * spherely.EARTH_RADIUS_METERS, ), ], @@ -145,8 +154,8 @@ def test_distance(geog_a, geog_b, expected) -> None: def test_distance_with_custom_radius() -> None: actual = spherely.distance( - spherely.point(0, 90), - spherely.point(0, 0), + spherely.create_point(0, 90), + spherely.create_point(0, 0), radius=1, ) assert isinstance(actual, float) @@ -155,7 +164,7 @@ def test_distance_with_custom_radius() -> None: def test_area(): # scalar - geog = spherely.polygon([(0, 0), (90, 0), (0, 90), (0, 0)]) + geog = spherely.create_polygon([(0, 0), (90, 0), (0, 90), (0, 0)]) result = spherely.area(geog, radius=1) assert isinstance(result, float) expected = 4 * math.pi / 8 @@ -187,7 +196,7 @@ def test_area_empty(geog): def test_length(): - geog = spherely.linestring([(0, 0), (1, 0)]) + geog = spherely.create_linestring([(0, 0), (1, 0)]) result = spherely.length(geog, radius=1) assert isinstance(result, float) expected = 1.0 * np.pi / 180.0 @@ -214,7 +223,7 @@ def test_length_invalid(geog): def test_perimeter(): - geog = spherely.polygon([(0, 0), (0, 90), (90, 90), (90, 0), (0, 0)]) + geog = spherely.create_polygon([(0, 0), (0, 90), (90, 90), (90, 0), (0, 0)]) result = spherely.perimeter(geog, radius=1) assert isinstance(result, float) expected = 3 * 90 * np.pi / 180.0 diff --git a/tests/test_creation.py b/tests/test_creation.py index f0c0681..243d4f4 100644 --- a/tests/test_creation.py +++ b/tests/test_creation.py @@ -4,17 +4,17 @@ def test_point() -> None: - point = spherely.point(40.2, 5.2) + point = spherely.create_point(40.2, 5.2) assert point.dimensions == 0 assert point.nshape == 1 assert repr(point).startswith("POINT (40.2 5.2") def test_point_empty() -> None: - point = spherely.point() + point = spherely.create_point() assert repr(point).startswith("POINT EMPTY") - point = spherely.point(None, None) + point = spherely.create_point(None, None) assert repr(point).startswith("POINT EMPTY") @@ -22,91 +22,93 @@ def test_point_empty() -> None: "points", [ [(5, 50), (6, 51)], - [spherely.point(5, 50), spherely.point(6, 51)], + [spherely.create_point(5, 50), spherely.create_point(6, 51)], ], ) def test_multipoint(points) -> None: - multipoint = spherely.multipoint(points) + multipoint = spherely.create_multipoint(points) assert multipoint.dimensions == 0 assert multipoint.nshape == 1 assert repr(multipoint).startswith("MULTIPOINT ((5 50)") def test_multipoint_invalid_geography() -> None: - point = spherely.point(5, 50) + point = spherely.create_point(5, 50) # all types other than points to test the error formatting - multipoint = spherely.multipoint([(5, 50), (6, 61)]) - line = spherely.linestring([(5, 50), (6, 61)]) - multiline = spherely.multilinestring([line, line]) - polygon = spherely.polygon([(5, 50), (6, 61), (5, 61)]) - collection = spherely.collection([point, line]) + multipoint = spherely.create_multipoint([(5, 50), (6, 61)]) + line = spherely.create_linestring([(5, 50), (6, 61)]) + multiline = spherely.create_multilinestring([line, line]) + polygon = spherely.create_polygon([(5, 50), (6, 61), (5, 61)]) + collection = spherely.create_collection([point, line]) with pytest.raises( TypeError, match=r"invalid Geography type \(expected POINT, found MULTIPOINT\)" ): - spherely.multipoint([point, multipoint]) + spherely.create_multipoint([point, multipoint]) with pytest.raises( TypeError, match=r"invalid Geography type \(expected POINT, found LINESTRING\)" ): - spherely.multipoint([point, line]) + spherely.create_multipoint([point, line]) with pytest.raises( TypeError, match=r"invalid Geography type \(expected POINT, found MULTILINESTRING\)", ): - spherely.multipoint([point, multiline]) + spherely.create_multipoint([point, multiline]) with pytest.raises( TypeError, match=r"invalid Geography type \(expected POINT, found POLYGON\)" ): - spherely.multipoint([point, polygon]) + spherely.create_multipoint([point, polygon]) with pytest.raises( TypeError, match=r"invalid Geography type \(expected POINT, found GEOMETRYCOLLECTION\)", ): - spherely.multipoint([point, collection]) + spherely.create_multipoint([point, collection]) @pytest.mark.parametrize( "points", [ [(5, 50), (6, 51)], - [spherely.point(5, 50), spherely.point(6, 51)], + [spherely.create_point(5, 50), spherely.create_point(6, 51)], ], ) def test_linestring(points) -> None: - line = spherely.linestring(points) + line = spherely.create_linestring(points) assert line.dimensions == 1 assert line.nshape == 1 assert repr(line).startswith("LINESTRING (5 50") def test_linestring_empty() -> None: - line = spherely.linestring() + line = spherely.create_linestring() assert repr(line).startswith("LINESTRING EMPTY") - line = spherely.linestring(None) + line = spherely.create_linestring(None) assert repr(line).startswith("LINESTRING EMPTY") - line = spherely.linestring([]) + line = spherely.create_linestring([]) assert repr(line).startswith("LINESTRING EMPTY") with pytest.raises(ValueError, match="with empty component"): - spherely.linestring([spherely.point(5, 50), spherely.point()]) + spherely.create_linestring( + [spherely.create_point(5, 50), spherely.create_point()] + ) def test_linestring_error() -> None: with pytest.raises(ValueError, match="at least 2 vertices"): - spherely.linestring([(5, 50)]) + spherely.create_linestring([(5, 50)]) def test_linestring_invalid_geography() -> None: - point = spherely.point(5, 50) - line = spherely.linestring([(5, 50), (6, 61)]) + point = spherely.create_point(5, 50) + line = spherely.create_linestring([(5, 50), (6, 61)]) with pytest.raises( TypeError, match=r"invalid Geography type \(expected POINT, found LINESTRING\)", ): - spherely.linestring([point, line]) + spherely.create_linestring([point, line]) @pytest.mark.parametrize( @@ -114,31 +116,31 @@ def test_linestring_invalid_geography() -> None: [ [[(5, 50), (6, 51)], [(15, 60), (16, 61)]], [ - [spherely.point(5, 50), spherely.point(6, 51)], - [spherely.point(15, 60), spherely.point(16, 61)], + [spherely.create_point(5, 50), spherely.create_point(6, 51)], + [spherely.create_point(15, 60), spherely.create_point(16, 61)], ], [ - spherely.linestring([(5, 50), (6, 51)]), - spherely.linestring([(15, 60), (16, 61)]), + spherely.create_linestring([(5, 50), (6, 51)]), + spherely.create_linestring([(15, 60), (16, 61)]), ], ], ) def test_multilinestring(lines) -> None: - multiline = spherely.multilinestring(lines) + multiline = spherely.create_multilinestring(lines) assert multiline.dimensions == 1 assert multiline.nshape == 2 assert repr(multiline).startswith("MULTILINESTRING ((5 50") def test_multilinestring_invalid_geography() -> None: - line = spherely.linestring([(5, 50), (6, 61)]) - polygon = spherely.polygon([(5, 50), (6, 61), (5, 61)]) + line = spherely.create_linestring([(5, 50), (6, 61)]) + polygon = spherely.create_polygon([(5, 50), (6, 61), (5, 61)]) with pytest.raises( TypeError, match=r"invalid Geography type \(expected LINESTRING, found POLYGON\)", ): - spherely.multilinestring([line, polygon]) + spherely.create_multilinestring([line, polygon]) @pytest.mark.parametrize( @@ -146,15 +148,15 @@ def test_multilinestring_invalid_geography() -> None: [ [(0, 0), (2, 0), (2, 2), (0, 2)], [ - spherely.point(0, 0), - spherely.point(2, 0), - spherely.point(2, 2), - spherely.point(0, 2), + spherely.create_point(0, 0), + spherely.create_point(2, 0), + spherely.create_point(2, 2), + spherely.create_point(0, 2), ], ], ) def test_polygon(coords) -> None: - poly = spherely.polygon(coords) + poly = spherely.create_polygon(coords) assert poly.dimensions == 2 assert poly.nshape == 1 assert repr(poly).startswith("POLYGON ((0 0") @@ -169,34 +171,34 @@ def test_polygon(coords) -> None: ) def test_polygon_closing(coords) -> None: # support both manual and automated closing - ring = spherely.polygon(coords) + ring = spherely.create_polygon(coords) assert repr(ring).startswith("POLYGON ((0 0") assert repr(ring).endswith("0 0))") def test_polygon_error() -> None: with pytest.raises(ValueError, match="polygon is not valid.*duplicate vertex.*"): - spherely.polygon([(0, 0), (0, 2), (0, 2), (2, 0)]) + spherely.create_polygon([(0, 0), (0, 2), (0, 2), (2, 0)]) with pytest.raises(ValueError, match="polygon is not valid.*at least 3 vertices.*"): - spherely.polygon([(0, 0), (0, 2)]) + spherely.create_polygon([(0, 0), (0, 2)]) with pytest.raises(ValueError, match="polygon is not valid.*Edge.*crosses.*"): - spherely.polygon([(0, 0), (2, 0), (1, 2), (1, -2)]) + spherely.create_polygon([(0, 0), (2, 0), (1, 2), (1, -2)]) with pytest.raises(ValueError, match="polygon is not valid.*crosses.*"): # shell/hole rings are crossing each other - spherely.polygon( + spherely.create_polygon( shell=[(0, 0), (0, 4), (4, 4), (4, 0)], holes=[[(0, 1), (0, 5), (5, 5), (5, 1)]], ) def test_polygon_normalize() -> None: - poly_ccw = spherely.polygon([(0, 0), (2, 0), (2, 2), (0, 2)]) - poly_cw = spherely.polygon([(0, 0), (0, 2), (2, 2), (2, 0)]) + poly_ccw = spherely.create_polygon([(0, 0), (2, 0), (2, 2), (0, 2)]) + poly_cw = spherely.create_polygon([(0, 0), (0, 2), (2, 2), (2, 0)]) - point = spherely.point(1, 1) + point = spherely.create_point(1, 1) # CW and CCW polygons should be both valid assert spherely.contains(poly_ccw, point) @@ -216,24 +218,24 @@ def test_polygon_normalize() -> None: ), ( [ - spherely.point(0, 0), - spherely.point(2, 0), - spherely.point(2, 2), - spherely.point(0, 2), + spherely.create_point(0, 0), + spherely.create_point(2, 0), + spherely.create_point(2, 2), + spherely.create_point(0, 2), ], [ [ - spherely.point(0.5, 0.5), - spherely.point(1.5, 0.5), - spherely.point(1.5, 1.5), - spherely.point(0.5, 1.5), + spherely.create_point(0.5, 0.5), + spherely.create_point(1.5, 0.5), + spherely.create_point(1.5, 1.5), + spherely.create_point(0.5, 1.5), ] ], ), ], ) def test_polygon_holes(shell, holes) -> None: - poly = spherely.polygon(shell, holes=holes) + poly = spherely.create_polygon(shell, holes=holes) assert poly.dimensions == 2 assert poly.nshape == 1 assert repr(poly).startswith("POLYGON ((0 0") @@ -241,22 +243,22 @@ def test_polygon_holes(shell, holes) -> None: def test_polygon_mixed_types_not_supported() -> None: shell = [ - spherely.point(0, 0), - spherely.point(2, 0), - spherely.point(2, 2), - spherely.point(0, 2), + spherely.create_point(0, 0), + spherely.create_point(2, 0), + spherely.create_point(2, 2), + spherely.create_point(0, 2), ] holes = [[(0.5, 0.5), (1.5, 0.5), (1.5, 1.5), (0.5, 1.5)]] with pytest.raises(TypeError, match="incompatible function arguments"): - spherely.polygon(shell, holes=holes) # type: ignore + spherely.create_polygon(shell, holes=holes) # type: ignore with pytest.raises(TypeError, match="incompatible function arguments"): - spherely.polygon(None, holes=holes) # type: ignore + spherely.create_polygon(None, holes=holes) # type: ignore def test_polygon_normalize_holes() -> None: - poly_hole_ccw = spherely.polygon( + poly_hole_ccw = spherely.create_polygon( shell=[(0, 0), (2, 0), (2, 2), (0, 2)], holes=[[(0.5, 0.5), (1.5, 0.5), (1.5, 1.5), (0.5, 1.5)]], ) @@ -270,18 +272,22 @@ def test_polygon_normalize_holes() -> None: def test_polygon_empty() -> None: - poly = spherely.polygon() + poly = spherely.create_polygon() assert repr(poly).startswith("POLYGON EMPTY") - poly = spherely.polygon(None) + poly = spherely.create_polygon(None) assert repr(poly).startswith("POLYGON EMPTY") - poly = spherely.polygon([]) + poly = spherely.create_polygon([]) assert repr(poly).startswith("POLYGON EMPTY") with pytest.raises(ValueError, match="with empty component"): - spherely.polygon( - [spherely.point(5, 50), spherely.point(6, 50), spherely.point()] + spherely.create_polygon( + [ + spherely.create_point(5, 50), + spherely.create_point(6, 50), + spherely.create_point(), + ] ) @@ -289,45 +295,45 @@ def test_polygon_empty_shell_with_holes() -> None: holes = [[(0.5, 0.5), (1.5, 0.5), (1.5, 1.5), (0.5, 1.5)]] with pytest.raises(ValueError, match="polygon shell is empty but found holes"): - spherely.polygon([], holes=holes) + spherely.create_polygon([], holes=holes) def test_polygon_invalid_geography() -> None: shell_points = [ - spherely.point(0, 0), - spherely.point(2, 0), - spherely.point(2, 2), - spherely.point(0, 2), + spherely.create_point(0, 0), + spherely.create_point(2, 0), + spherely.create_point(2, 2), + spherely.create_point(0, 2), ] hole_points = [ - spherely.point(0.5, 0.5), - spherely.point(1.5, 0.5), - spherely.point(1.5, 1.5), - spherely.point(0.5, 1.5), + spherely.create_point(0.5, 0.5), + spherely.create_point(1.5, 0.5), + spherely.create_point(1.5, 1.5), + spherely.create_point(0.5, 1.5), ] - line = spherely.linestring([(3, 0), (3, 1)]) + line = spherely.create_linestring([(3, 0), (3, 1)]) with pytest.raises( TypeError, match=r"invalid Geography type \(expected POINT, found LINESTRING\)", ): - spherely.polygon(shell_points + [line]) + spherely.create_polygon(shell_points + [line]) with pytest.raises( TypeError, match=r"invalid Geography type \(expected POINT, found LINESTRING\)", ): - spherely.polygon(shell=shell_points, holes=[hole_points + [line]]) + spherely.create_polygon(shell=shell_points, holes=[hole_points + [line]]) def test_multipolygons() -> None: - poly1 = spherely.polygon([(0, 0), (2, 0), (2, 2), (0, 2)]) - poly2 = spherely.polygon( + poly1 = spherely.create_polygon([(0, 0), (2, 0), (2, 2), (0, 2)]) + poly2 = spherely.create_polygon( shell=[(4, 0), (6, 0), (6, 2), (4, 2)], holes=[[(4.5, 0.5), (5.5, 0.5), (5.5, 1.5), (4.5, 1.5)]], ) - multipoly = spherely.multipolygon([poly1, poly2]) + multipoly = spherely.create_multipolygon([poly1, poly2]) assert multipoly.dimensions == 2 assert multipoly.nshape == 1 @@ -335,24 +341,24 @@ def test_multipolygons() -> None: def test_multipolygon_invalid_geography() -> None: - poly = spherely.polygon([(0, 0), (2, 0), (2, 2), (0, 2)]) - line = spherely.linestring([(3, 0), (3, 1)]) + poly = spherely.create_polygon([(0, 0), (2, 0), (2, 2), (0, 2)]) + line = spherely.create_linestring([(3, 0), (3, 1)]) with pytest.raises( TypeError, match=r"invalid Geography type \(expected POLYGON, found LINESTRING\)", ): - spherely.multipolygon([poly, line]) + spherely.create_multipolygon([poly, line]) def test_collection() -> None: objs = [ - spherely.point(0, 0), - spherely.linestring([(0, 0), (1, 1)]), - spherely.polygon([(0, 0), (1, 0), (1, 1)]), + spherely.create_point(0, 0), + spherely.create_linestring([(0, 0), (1, 1)]), + spherely.create_polygon([(0, 0), (1, 0), (1, 1)]), ] - coll = spherely.collection(objs) + coll = spherely.create_collection(objs) assert coll.dimensions == -1 assert coll.nshape == 3 @@ -368,7 +374,7 @@ def test_collection() -> None: assert [o.nshape for o in objs] == [1, 1, 1] # test nested collection - coll2 = spherely.collection(objs + [coll]) + coll2 = spherely.create_collection(objs + [coll]) assert repr(coll2).count("POINT") == 2 assert repr(coll2).count("LINESTRING") == 2 diff --git a/tests/test_geoarrow.py b/tests/test_geoarrow.py index 37fcaea..12ecc3d 100644 --- a/tests/test_geoarrow.py +++ b/tests/test_geoarrow.py @@ -78,13 +78,13 @@ def test_from_geoarrow_oriented(): def test_from_wkt_planar(): arr = ga.as_geoarrow(["LINESTRING (-64 45, 0 45)"]) result = spherely.from_geoarrow(arr) - assert spherely.distance(result, spherely.point(-30.1, 45)) > 10000 + assert spherely.distance(result, spherely.create_point(-30.1, 45)) > 10000 result = spherely.from_geoarrow(arr, planar=True) - assert spherely.distance(result, spherely.point(-30.1, 45)) < 100 + assert spherely.distance(result, spherely.create_point(-30.1, 45)) < 100 result = spherely.from_geoarrow(arr, planar=True, tessellate_tolerance=10) - assert spherely.distance(result, spherely.point(-30.1, 45)) < 10 + assert spherely.distance(result, spherely.create_point(-30.1, 45)) < 10 def test_from_geoarrow_projection(): diff --git a/tests/test_geography.py b/tests/test_geography.py index aee22b8..c812926 100644 --- a/tests/test_geography.py +++ b/tests/test_geography.py @@ -5,7 +5,7 @@ def test_is_geography() -> None: - arr = np.array([1, 2.33, spherely.point(30, 6)]) + arr = np.array([1, 2.33, spherely.create_point(30, 6)]) actual = spherely.is_geography(arr) expected = np.array([False, False, True]) @@ -13,7 +13,7 @@ def test_is_geography() -> None: def test_not_geography_raise() -> None: - arr = np.array([1, 2.33, spherely.point(30, 6)]) + arr = np.array([1, 2.33, spherely.create_point(30, 6)]) with pytest.raises(TypeError, match="not a Geography object"): spherely.get_dimensions(arr) @@ -23,23 +23,25 @@ def test_get_type_id() -> None: # array geog = np.array( [ - spherely.point(45, 50), - spherely.multipoint([(5, 50), (6, 51)]), - spherely.linestring([(5, 50), (6, 51)]), - spherely.multilinestring([[(5, 50), (6, 51)], [(15, 60), (16, 61)]]), - spherely.polygon([(5, 50), (5, 60), (6, 60), (6, 51)]), + spherely.create_point(45, 50), + spherely.create_multipoint([(5, 50), (6, 51)]), + spherely.create_linestring([(5, 50), (6, 51)]), + spherely.create_multilinestring([[(5, 50), (6, 51)], [(15, 60), (16, 61)]]), + spherely.create_polygon([(5, 50), (5, 60), (6, 60), (6, 51)]), # with hole - spherely.polygon( + spherely.create_polygon( shell=[(5, 60), (6, 60), (6, 50), (5, 50)], holes=[[(5.1, 59), (5.9, 59), (5.9, 51), (5.1, 51)]], ), - spherely.multipolygon( + spherely.create_multipolygon( [ - spherely.polygon([(5, 50), (5, 60), (6, 60), (6, 51)]), - spherely.polygon([(10, 100), (10, 160), (11, 160), (11, 100)]), + spherely.create_polygon([(5, 50), (5, 60), (6, 60), (6, 51)]), + spherely.create_polygon( + [(10, 100), (10, 160), (11, 160), (11, 100)] + ), ] ), - spherely.collection([spherely.point(40, 50)]), + spherely.create_collection([spherely.create_point(40, 50)]), ] ) actual = spherely.get_type_id(geog) @@ -58,7 +60,7 @@ def test_get_type_id() -> None: np.testing.assert_array_equal(actual, expected) # scalar - geog2 = spherely.point(45, 50) + geog2 = spherely.create_point(45, 50) assert spherely.get_type_id(geog2) == spherely.GeographyType.POINT.value @@ -67,20 +69,25 @@ def test_get_dimensions() -> None: expected = np.array([[0, 0], [1, 0]], dtype=np.int32) geog = np.array( [ - [spherely.point(5, 40), spherely.point(6, 30)], - [spherely.linestring([(5, 50), (6, 51)]), spherely.point(4, 20)], + [spherely.create_point(5, 40), spherely.create_point(6, 30)], + [ + spherely.create_linestring([(5, 50), (6, 51)]), + spherely.create_point(4, 20), + ], ] ) actual = spherely.get_dimensions(geog) np.testing.assert_array_equal(actual, expected) # test scalar - assert spherely.get_dimensions(spherely.point(5, 40)) == 0 + assert spherely.get_dimensions(spherely.create_point(5, 40)) == 0 def test_prepare() -> None: # test array - geog = np.array([spherely.point(50, 45), spherely.linestring([(5, 50), (6, 51)])]) + geog = np.array( + [spherely.create_point(50, 45), spherely.create_linestring([(5, 50), (6, 51)])] + ) np.testing.assert_array_equal(spherely.is_prepared(geog), np.array([False, False])) spherely.prepare(geog) @@ -101,22 +108,22 @@ def test_prepare() -> None: def test_equality() -> None: - p1 = spherely.point(1, 1) - p2 = spherely.point(1, 1) - p3 = spherely.point(2, 2) + p1 = spherely.create_point(1, 1) + p2 = spherely.create_point(1, 1) + p3 = spherely.create_point(2, 2) assert p1 == p1 assert p1 == p2 assert not p1 == p3 - line1 = spherely.linestring([(1, 1), (2, 2), (3, 3)]) - line2 = spherely.linestring([(3, 3), (2, 2), (1, 1)]) + line1 = spherely.create_linestring([(1, 1), (2, 2), (3, 3)]) + line2 = spherely.create_linestring([(3, 3), (2, 2), (1, 1)]) assert line1 == line2 - poly1 = spherely.polygon([(1, 1), (3, 1), (2, 3)]) - poly2 = spherely.polygon([(2, 3), (1, 1), (3, 1)]) - poly3 = spherely.polygon([(2, 3), (3, 1), (1, 1)]) + poly1 = spherely.create_polygon([(1, 1), (3, 1), (2, 3)]) + poly2 = spherely.create_polygon([(2, 3), (1, 1), (3, 1)]) + poly3 = spherely.create_polygon([(2, 3), (3, 1), (1, 1)]) assert p1 != poly1 assert line1 != poly1 diff --git a/tests/test_io.py b/tests/test_io.py index 5f1c8d3..f428472 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -64,15 +64,15 @@ def test_from_wkt_oriented(): def test_from_wkt_planar(): result = spherely.from_wkt("LINESTRING (-64 45, 0 45)") - assert spherely.distance(result, spherely.point(-30.1, 45)) > 10000 + assert spherely.distance(result, spherely.create_point(-30.1, 45)) > 10000 result = spherely.from_wkt("LINESTRING (-64 45, 0 45)", planar=True) - assert spherely.distance(result, spherely.point(-30.1, 45)) < 100 + assert spherely.distance(result, spherely.create_point(-30.1, 45)) < 100 result = spherely.from_wkt( "LINESTRING (-64 45, 0 45)", planar=True, tessellate_tolerance=10 ) - assert spherely.distance(result, spherely.point(-30.1, 45)) < 10 + assert spherely.distance(result, spherely.create_point(-30.1, 45)) < 10 def test_to_wkt(): @@ -132,28 +132,28 @@ def test_from_wkb_invalid_type(): @pytest.mark.parametrize( "geog", [ - spherely.point(45, 50), - spherely.multipoint([(5, 50), (6, 51)]), - spherely.linestring([(5, 50), (6, 51)]), - spherely.multilinestring([[(5, 50), (6, 51)], [(15, 60), (16, 61)]]), - spherely.polygon([(5, 50), (5, 60), (6, 60), (6, 51)]), + spherely.create_point(45, 50), + spherely.create_multipoint([(5, 50), (6, 51)]), + spherely.create_linestring([(5, 50), (6, 51)]), + spherely.create_multilinestring([[(5, 50), (6, 51)], [(15, 60), (16, 61)]]), + spherely.create_polygon([(5, 50), (5, 60), (6, 60), (6, 51)]), # with hole - spherely.polygon( + spherely.create_polygon( shell=[(5, 60), (6, 60), (6, 50), (5, 50)], holes=[[(5.1, 59), (5.9, 59), (5.9, 51), (5.1, 51)]], ), - spherely.multipolygon( + spherely.create_multipolygon( [ - spherely.polygon([(5, 50), (5, 60), (6, 60), (6, 51)]), - spherely.polygon([(10, 100), (10, 160), (11, 160), (11, 100)]), + spherely.create_polygon([(5, 50), (5, 60), (6, 60), (6, 51)]), + spherely.create_polygon([(10, 100), (10, 160), (11, 160), (11, 100)]), ] ), - spherely.collection([spherely.point(40, 50)]), - spherely.collection( + spherely.create_collection([spherely.create_point(40, 50)]), + spherely.create_collection( [ - spherely.point(0, 0), - spherely.linestring([(0, 0), (1, 1)]), - spherely.polygon([(0, 0), (1, 0), (1, 1)]), + spherely.create_point(0, 0), + spherely.create_linestring([(0, 0), (1, 1)]), + spherely.create_polygon([(0, 0), (1, 0), (1, 1)]), ] ), ], @@ -176,21 +176,21 @@ def test_from_wkb_oriented(): result = spherely.from_wkb(wkb) # by default re-oriented to take the smaller polygon assert str(result) == "POLYGON ((10 0, 10 10, 0 10, 0 0, 10 0))" - assert spherely.within(spherely.point(5, 5), result) + assert spherely.within(spherely.create_point(5, 5), result) result = spherely.from_wkb(wkb, oriented=True) assert str(result) == "POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))" - assert not spherely.within(spherely.point(5, 5), result) + assert not spherely.within(spherely.create_point(5, 5), result) def test_from_wkb_planar(): wkb = spherely.to_wkb(spherely.from_wkt("LINESTRING (-64 45, 0 45)")) result = spherely.from_wkb(wkb) - assert spherely.distance(result, spherely.point(-30.1, 45)) > 10000 + assert spherely.distance(result, spherely.create_point(-30.1, 45)) > 10000 result = spherely.from_wkb(wkb, planar=True) - assert spherely.distance(result, spherely.point(-30.1, 45)) < 100 + assert spherely.distance(result, spherely.create_point(-30.1, 45)) < 100 result = spherely.from_wkb(wkb, planar=True, tessellate_tolerance=10) - assert spherely.distance(result, spherely.point(-30.1, 45)) < 10 + assert spherely.distance(result, spherely.create_point(-30.1, 45)) < 10 diff --git a/tests/test_predicates.py b/tests/test_predicates.py index c7ceb65..d35441f 100644 --- a/tests/test_predicates.py +++ b/tests/test_predicates.py @@ -8,19 +8,19 @@ def test_intersects() -> None: # test array + scalar a = np.array( [ - spherely.linestring([(40, 8), (60, 8)]), - spherely.linestring([(20, 0), (30, 0)]), + spherely.create_linestring([(40, 8), (60, 8)]), + spherely.create_linestring([(20, 0), (30, 0)]), ] ) - b = spherely.linestring([(50, 5), (50, 10)]) + b = spherely.create_linestring([(50, 5), (50, 10)]) actual = spherely.intersects(a, b) expected = np.array([True, False]) np.testing.assert_array_equal(actual, expected) # two scalars - a2 = spherely.point(50, 8) - b2 = spherely.point(20, 5) + a2 = spherely.create_point(50, 8) + b2 = spherely.create_point(20, 5) assert not spherely.intersects(a2, b2) @@ -28,19 +28,19 @@ def test_equals() -> None: # test array + scalar a = np.array( [ - spherely.linestring([(40, 8), (60, 8)]), - spherely.linestring([(20, 0), (30, 0)]), + spherely.create_linestring([(40, 8), (60, 8)]), + spherely.create_linestring([(20, 0), (30, 0)]), ] ) - b = spherely.point(50, 8) + b = spherely.create_point(50, 8) actual = spherely.equals(a, b) expected = np.array([False, False]) np.testing.assert_array_equal(actual, expected) # two scalars - a2 = spherely.point(50, 8) - b2 = spherely.point(50, 8) + a2 = spherely.create_point(50, 8) + b2 = spherely.create_point(50, 8) assert spherely.equals(a2, b2) @@ -48,42 +48,42 @@ def test_contains(): # test array + scalar a = np.array( [ - spherely.linestring([(40, 8), (60, 8)]), - spherely.linestring([(20, 0), (30, 0)]), + spherely.create_linestring([(40, 8), (60, 8)]), + spherely.create_linestring([(20, 0), (30, 0)]), ] ) - b = spherely.point(40, 8) + b = spherely.create_point(40, 8) actual = spherely.contains(a, b) expected = np.array([True, False]) np.testing.assert_array_equal(actual, expected) # two scalars - a2 = spherely.linestring([(50, 8), (60, 8)]) - b2 = spherely.point(50, 8) + a2 = spherely.create_linestring([(50, 8), (60, 8)]) + b2 = spherely.create_point(50, 8) assert spherely.contains(a2, b2) def test_contains_polygon(): # plain vs. hole polygon - poly_plain = spherely.polygon(shell=[(0, 0), (4, 0), (4, 4), (0, 4)]) + poly_plain = spherely.create_polygon(shell=[(0, 0), (4, 0), (4, 4), (0, 4)]) - poly_hole = spherely.polygon( + poly_hole = spherely.create_polygon( shell=[(0, 0), (4, 0), (4, 4), (0, 4)], holes=[[(1, 1), (3, 1), (3, 3), (1, 3)]], ) - assert spherely.contains(poly_plain, spherely.point(2, 2)) - assert not spherely.contains(poly_hole, spherely.point(2, 2)) + assert spherely.contains(poly_plain, spherely.create_point(2, 2)) + assert not spherely.contains(poly_hole, spherely.create_point(2, 2)) def test_within(): # test array + scalar - a = spherely.point(40, 8) + a = spherely.create_point(40, 8) b = np.array( [ - spherely.linestring([(40, 8), (60, 8)]), - spherely.linestring([(20, 0), (30, 0)]), + spherely.create_linestring([(40, 8), (60, 8)]), + spherely.create_linestring([(20, 0), (30, 0)]), ] ) @@ -92,30 +92,30 @@ def test_within(): np.testing.assert_array_equal(actual, expected) # two scalars - a2 = spherely.point(50, 8) - b2 = spherely.linestring([(50, 8), (60, 8)]) + a2 = spherely.create_point(50, 8) + b2 = spherely.create_linestring([(50, 8), (60, 8)]) assert spherely.within(a2, b2) def test_within_polygon(): # plain vs. hole polygon - poly_plain = spherely.polygon(shell=[(0, 0), (4, 0), (4, 4), (0, 4)]) + poly_plain = spherely.create_polygon(shell=[(0, 0), (4, 0), (4, 4), (0, 4)]) - poly_hole = spherely.polygon( + poly_hole = spherely.create_polygon( shell=[(0, 0), (4, 0), (4, 4), (0, 4)], holes=[[(1, 1), (3, 1), (3, 3), (1, 3)]], ) - assert spherely.within(spherely.point(2, 2), poly_plain) - assert not spherely.within(spherely.point(2, 2), poly_hole) + assert spherely.within(spherely.create_point(2, 2), poly_plain) + assert not spherely.within(spherely.create_point(2, 2), poly_hole) def test_disjoint(): - a = spherely.point(40, 9) + a = spherely.create_point(40, 9) b = np.array( [ - spherely.linestring([(40, 8), (60, 8)]), - spherely.linestring([(20, 0), (30, 0)]), + spherely.create_linestring([(40, 8), (60, 8)]), + spherely.create_linestring([(20, 0), (30, 0)]), ] ) @@ -124,17 +124,17 @@ def test_disjoint(): np.testing.assert_array_equal(actual, expected) # two scalars - a2 = spherely.point(50, 9) - b2 = spherely.linestring([(50, 8), (60, 8)]) + a2 = spherely.create_point(50, 9) + b2 = spherely.create_linestring([(50, 8), (60, 8)]) assert spherely.disjoint(a2, b2) def test_touches(): - a = spherely.polygon([(0.0, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 0.0)]) + a = spherely.create_polygon([(0.0, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 0.0)]) b = np.array( [ - spherely.polygon([(1.0, 1.0), (1.0, 2.0), (2.0, 2.0), (2.0, 1.0)]), - spherely.polygon([(0.5, 0.5), (0.5, 1.5), (1.5, 1.5), (1.5, 0.5)]), + spherely.create_polygon([(1.0, 1.0), (1.0, 2.0), (2.0, 2.0), (2.0, 1.0)]), + spherely.create_polygon([(0.5, 0.5), (0.5, 1.5), (1.5, 1.5), (1.5, 0.5)]), ] ) @@ -142,20 +142,20 @@ def test_touches(): expected = np.array([True, False]) np.testing.assert_array_equal(actual, expected) - a_p = spherely.point(1.0, 1.0) - b_p = spherely.point(1.0, 1.0) + a_p = spherely.create_point(1.0, 1.0) + b_p = spherely.create_point(1.0, 1.0) # Points do not have a boundary, so they cannot touch per definition # This is consistent with PostGIS for example # (cmp. https://postgis.net/docs/ST_Touches.html) assert not spherely.touches(a_p, b_p) - b_line = spherely.linestring([(1.0, 1.0), (1.0, 2.0)]) + b_line = spherely.create_linestring([(1.0, 1.0), (1.0, 2.0)]) assert spherely.touches(a_p, b_line) @pytest.fixture def parent_poly(): - return spherely.polygon( + return spherely.create_polygon( [ (-118.0, 60.0), (-118.0, 40.0), @@ -172,15 +172,15 @@ def geographies_covers_contains(): return np.array( [ # Basic point covers tests, outside, on boundary and interior - spherely.point(-120.0, 70.0), - spherely.point(-118.0, 41.0), - spherely.point(-116.0, 37.0), + spherely.create_point(-120.0, 70.0), + spherely.create_point(-118.0, 41.0), + spherely.create_point(-116.0, 37.0), # Basic polyline tests, crossing, on boundary and interior - spherely.linestring([(-120.0, 70.0), (-116.0, 37.0)]), - spherely.linestring([(-118.0, 41.0), (-118.0, 23.0)]), - spherely.linestring([(-117.0, 39.0), (-115.0, 37.0)]), + spherely.create_linestring([(-120.0, 70.0), (-116.0, 37.0)]), + spherely.create_linestring([(-118.0, 41.0), (-118.0, 23.0)]), + spherely.create_linestring([(-117.0, 39.0), (-115.0, 37.0)]), # Basic polygon test, crossing, shared boundary and interior - spherely.polygon( + spherely.create_polygon( [(-120.0, 41.0), (-120.0, 35.0), (-115.0, 35.0), (-115.0, 41.0)] ), # TODO: This case is currently not fully correct. Supplying a @@ -197,10 +197,10 @@ def geographies_covers_contains(): # be covered anymore, even if it would be in reality. Therefor, # these tests assume identical shared edges between polygons `a` and `b`, # which does work as intended. - spherely.polygon( + spherely.create_polygon( [(-118.0, 40.0), (-118.0, 23.0), (34.0, 23.0), (34.0, 40.0)] ), - spherely.polygon( + spherely.create_polygon( [(-117.0, 40.0), (-117.0, 35.0), (-115.0, 35.0), (-115.0, 40.0)] ), ]