Skip to content

Commit

Permalink
remove s2geography <0.2.0 backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
benbovy committed Dec 3, 2024
1 parent 345323d commit fe8b690
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 24 deletions.
18 changes: 0 additions & 18 deletions src/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,13 @@ using namespace spherely;
class FromWKT {
public:
FromWKT(bool oriented, bool planar, float tessellate_tolerance = 100.0) {
#if defined(S2GEOGRAPHY_VERSION_MAJOR) && \
(S2GEOGRAPHY_VERSION_MAJOR >= 1 || S2GEOGRAPHY_VERSION_MINOR >= 2)
s2geog::geoarrow::ImportOptions options;
options.set_oriented(oriented);
if (planar) {
auto tol = S1Angle::Radians(tessellate_tolerance / EARTH_RADIUS_METERS);
options.set_tessellate_tolerance(tol);
}
m_reader = std::make_shared<s2geog::WKTReader>(options);
#else
if (planar || oriented) {
throw std::invalid_argument(
"planar and oriented options are only available with s2geography >= 0.2");
}
m_reader = std::make_shared<s2geog::WKTReader>();
#endif
}

PyObjectGeography operator()(py::str a) const {
Expand All @@ -54,8 +45,6 @@ class ToWKT {
std::shared_ptr<s2geog::WKTWriter> m_writer;
};

#if defined(S2GEOGRAPHY_VERSION_MAJOR) && \
(S2GEOGRAPHY_VERSION_MAJOR >= 1 || S2GEOGRAPHY_VERSION_MINOR >= 2)
class FromWKB {
public:
FromWKB(bool oriented, bool planar, float tessellate_tolerance = 100.0) {
Expand Down Expand Up @@ -90,8 +79,6 @@ class ToWKB {
std::shared_ptr<s2geog::WKBWriter> m_writer;
};

#endif

void init_io(py::module& m) {
m.def(
"from_wkt",
Expand Down Expand Up @@ -148,9 +135,6 @@ void init_io(py::module& m) {
)pbdoc");

#if defined(S2GEOGRAPHY_VERSION_MAJOR) && \
(S2GEOGRAPHY_VERSION_MAJOR >= 1 || S2GEOGRAPHY_VERSION_MINOR >= 2)

m.def(
"from_wkb",
[](py::array_t<py::bytes> a, bool oriented, bool planar, float tessellate_tolerance) {
Expand Down Expand Up @@ -199,6 +183,4 @@ void init_io(py::module& m) {
Geography object(s)
)pbdoc");

#endif
}
6 changes: 0 additions & 6 deletions src/spherely.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ void init_predicates(py::module&);
void init_boolean_operations(py::module&);
void init_accessors(py::module&);
void init_io(py::module&);
#if defined(S2GEOGRAPHY_VERSION_MAJOR) && \
(S2GEOGRAPHY_VERSION_MAJOR >= 1 || S2GEOGRAPHY_VERSION_MINOR >= 2)
void init_geoarrow(py::module&);
void init_projections(py::module&);
#endif

PYBIND11_MODULE(spherely, m) {
m.doc() = R"pbdoc(
Expand All @@ -32,11 +29,8 @@ PYBIND11_MODULE(spherely, m) {
init_boolean_operations(m);
init_accessors(m);
init_io(m);
#if defined(S2GEOGRAPHY_VERSION_MAJOR) && \
(S2GEOGRAPHY_VERSION_MAJOR >= 1 || S2GEOGRAPHY_VERSION_MINOR >= 2)
init_projections(m);
init_geoarrow(m);
#endif

#ifdef VERSION_INFO
m.attr("__version__") = MACRO_STRINGIFY(VERSION_INFO);
Expand Down

0 comments on commit fe8b690

Please sign in to comment.