Skip to content

Commit

Permalink
updates after merged creation PR
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisvandenbossche committed Oct 22, 2024
1 parent 02f5b60 commit 6a5ba23
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
5 changes: 2 additions & 3 deletions src/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <s2geography.h>

#include "constants.hpp"
#include "creation.hpp"
#include "geography.hpp"
#include "pybind11.hpp"

Expand Down Expand Up @@ -31,9 +32,7 @@ class FromWKT {
}

PyObjectGeography operator()(py::str a) const {
std::unique_ptr<s2geog::Geography> s2geog = m_reader->read_feature(a);
auto geog_ptr = std::make_unique<spherely::Geography>(std::move(s2geog));
return PyObjectGeography::from_geog(std::move(geog_ptr));
return make_py_geography(m_reader->read_feature(a));
}

private:
Expand Down
12 changes: 6 additions & 6 deletions tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

def test_from_wkt():
result = spherely.from_wkt(["POINT (1 1)", "POINT(2 2)", "POINT(3 3)"])
expected = spherely.create([1, 2, 3], [1, 2, 3])
expected = spherely.points([1, 2, 3], [1, 2, 3])
# object equality does not yet work
# np.testing.assert_array_equal(result, expected)
assert spherely.equals(result, expected).all()
Expand Down Expand Up @@ -70,20 +70,20 @@ 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(45, -30.1)) > 10000
assert spherely.distance(result, spherely.point(-30.1, 45)) > 10000

result = spherely.from_wkt("LINESTRING (-64 45, 0 45)", planar=True)
assert spherely.distance(result, spherely.Point(45, -30.1)) < 100
assert spherely.distance(result, spherely.point(-30.1, 45)) < 100

result = spherely.from_wkt(
"LINESTRING (-64 45, 0 45)", planar=True, tessellate_tol_m=10
)
assert spherely.distance(result, spherely.Point(45, -30.1)) < 10
assert spherely.distance(result, spherely.point(-30.1, 45)) < 10


@pytest.mark.skipif(
Version(spherely.__s2geography_version__) >= Version("0.2.0"),
reason="Needs s2geography >= 0.2.0",
reason="Needs s2geography < 0.2.0",
)
def test_from_wkt_unsupported_keywords():

Expand All @@ -95,7 +95,7 @@ def test_from_wkt_unsupported_keywords():


def test_to_wkt():
arr = spherely.create([1.1, 2, 3], [1.1, 2, 3])
arr = spherely.points([1.1, 2, 3], [1.1, 2, 3])
result = spherely.to_wkt(arr)
expected = np.array(["POINT (1.1 1.1)", "POINT (2 2)", "POINT (3 3)"], dtype=object)
np.testing.assert_array_equal(result, expected)

0 comments on commit 6a5ba23

Please sign in to comment.