Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into from_wkt
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisvandenbossche committed Oct 22, 2024
2 parents 6825e27 + a1f86f9 commit 02f5b60
Show file tree
Hide file tree
Showing 14 changed files with 1,325 additions and 406 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
uses: actions/checkout@v3
with:
repository: paleolimbot/s2geography
ref: master
ref: main
path: deps/s2geography
fetch-depth: 0
if: |
Expand Down
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ endif()
# Build

add_library(spherely MODULE
src/geography.cpp
src/accessors-geog.cpp
src/creation.cpp
src/geography.cpp
src/io.cpp
src/predicates.cpp
src/spherely.cpp
Expand Down
18 changes: 6 additions & 12 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,6 @@ API reference

.. currentmodule:: spherely

.. _api_types:

Geography types
---------------

.. autosummary::
:toctree: _api_generated/

Point
LineString
Polygon

.. _api_properties:

Geography properties
Expand All @@ -38,6 +26,12 @@ Geography creation
.. autosummary::
:toctree: _api_generated/

point
linestring
multipoint
multilinestring
polygon
geography_collection
is_prepared
prepare
destroy_prepared
Expand Down
15 changes: 5 additions & 10 deletions src/accessors-geog.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <s2geography.h>
#include <s2geography/geography.h>

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

Expand All @@ -11,24 +13,17 @@ using namespace spherely;
PyObjectGeography centroid(PyObjectGeography a) {
const auto& a_ptr = a.as_geog_ptr()->geog();
auto s2_point = s2geog::s2_centroid(a_ptr);
std::unique_ptr<Point> point =
make_geography<s2geog::PointGeography, spherely::Point>(s2_point);
return PyObjectGeography::from_geog(std::move(point));
return make_py_geography<s2geog::PointGeography>(s2_point);
}

PyObjectGeography boundary(PyObjectGeography a) {
const auto& a_ptr = a.as_geog_ptr()->geog();
auto s2_obj = s2geog::s2_boundary(a_ptr);
// TODO return specific subclass
auto geog_ptr = std::make_unique<spherely::Geography>(std::move(s2_obj));
return PyObjectGeography::from_geog(std::move(geog_ptr));
return make_py_geography(s2geog::s2_boundary(a_ptr));
}

PyObjectGeography convex_hull(PyObjectGeography a) {
const auto& a_ptr = a.as_geog_ptr()->geog();
auto s2_obj = s2geog::s2_convex_hull(a_ptr);
auto geog_ptr = std::make_unique<spherely::Polygon>(std::move(s2_obj));
return PyObjectGeography::from_geog(std::move(geog_ptr));
return make_py_geography(s2geog::s2_convex_hull(a_ptr));
}

double distance(PyObjectGeography a, PyObjectGeography b, double radius = EARTH_RADIUS_METERS) {
Expand Down
Loading

0 comments on commit 02f5b60

Please sign in to comment.