Skip to content

Commit

Permalink
remove Geography dimensions and nshape props
Browse files Browse the repository at this point in the history
  • Loading branch information
benbovy committed Dec 19, 2024
1 parent 627c714 commit 7017018
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 45 deletions.
2 changes: 0 additions & 2 deletions docs/api_hidden.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@
:toctree: _api_generated/

Geography
Geography.dimensions
Geography.nshape
19 changes: 0 additions & 19 deletions src/geography.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,25 +288,6 @@ void init_geography(py::module &m) {
)pbdoc");

pygeography.def_property_readonly("dimensions",
&Geography::dimension,
R"pbdoc(
Returns the inherent dimensionality of a geometry.
The inherent dimension is 0 for points, 1 for linestrings and 2 for
polygons. For geometry collections it returns either the dimension of
all their features (uniform collections) or -1 (collections with
features of different dimensions). Empty collections and None values
return -1.
)pbdoc");

pygeography.def_property_readonly("nshape", &Geography::num_shapes, R"pbdoc(
Returns the number of elements in the collection, or 1 for simple geography
objects.
)pbdoc");

pygeography.def("__repr__", [](const Geography &geog) {
s2geog::WKTWriter writer(6);
return writer.write_feature(geog.geog());
Expand Down
4 changes: 0 additions & 4 deletions src/spherely.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ EARTH_RADIUS_METERS: float = ...

class Geography:
def __init__(self, *args, **kwargs) -> None: ...
@property
def dimensions(self) -> int: ...
@property
def nshape(self) -> int: ...

class GeographyType:
__members__: ClassVar[dict] = ... # read-only
Expand Down
20 changes: 0 additions & 20 deletions tests/test_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

def test_point() -> None:
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")


Expand All @@ -27,8 +25,6 @@ def test_point_empty() -> None:
)
def test_multipoint(points) -> None:
multipoint = spherely.create_multipoint(points)
assert multipoint.dimensions == 0
assert multipoint.nshape == 1
assert repr(multipoint).startswith("MULTIPOINT ((5 50)")


Expand Down Expand Up @@ -74,8 +70,6 @@ def test_multipoint_invalid_geography() -> None:
)
def test_linestring(points) -> None:
line = spherely.create_linestring(points)
assert line.dimensions == 1
assert line.nshape == 1
assert repr(line).startswith("LINESTRING (5 50")


Expand Down Expand Up @@ -127,8 +121,6 @@ def test_linestring_invalid_geography() -> None:
)
def test_multilinestring(lines) -> None:
multiline = spherely.create_multilinestring(lines)
assert multiline.dimensions == 1
assert multiline.nshape == 2
assert repr(multiline).startswith("MULTILINESTRING ((5 50")


Expand Down Expand Up @@ -157,8 +149,6 @@ def test_multilinestring_invalid_geography() -> None:
)
def test_polygon(coords) -> None:
poly = spherely.create_polygon(coords)
assert poly.dimensions == 2
assert poly.nshape == 1
assert repr(poly).startswith("POLYGON ((0 0")


Expand Down Expand Up @@ -236,8 +226,6 @@ def test_polygon_normalize() -> None:
)
def test_polygon_holes(shell, holes) -> None:
poly = spherely.create_polygon(shell, holes=holes)
assert poly.dimensions == 2
assert poly.nshape == 1
assert repr(poly).startswith("POLYGON ((0 0")


Expand Down Expand Up @@ -335,8 +323,6 @@ def test_multipolygons() -> None:

multipoly = spherely.create_multipolygon([poly1, poly2])

assert multipoly.dimensions == 2
assert multipoly.nshape == 1
assert repr(multipoly).startswith("MULTIPOLYGON (((0 0")


Expand All @@ -360,19 +346,13 @@ def test_collection() -> None:

coll = spherely.create_collection(objs)

assert coll.dimensions == -1
assert coll.nshape == 3
assert repr(coll).startswith("GEOMETRYCOLLECTION (")

# TODO: more robust test than using the WKT repr
assert repr(coll).count("POINT") == 1
assert repr(coll).count("LINESTRING") == 1
assert repr(coll).count("POLYGON") == 1

# TODO: test objects are copied (if/when we can update them in place)
# (for now only test that original objects are preserved)
assert [o.nshape for o in objs] == [1, 1, 1]

# test nested collection
coll2 = spherely.create_collection(objs + [coll])

Expand Down

0 comments on commit 7017018

Please sign in to comment.