-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH: add projection support in geoarrow output
- Loading branch information
1 parent
1217af5
commit ae00163
Showing
6 changed files
with
136 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include "projections.hpp" | ||
|
||
#include <s2/s2projections.h> | ||
#include <s2geography.h> | ||
|
||
#include "geography.hpp" | ||
#include "pybind11.hpp" | ||
|
||
namespace py = pybind11; | ||
namespace s2geog = s2geography; | ||
using namespace spherely; | ||
|
||
// std::tuple<double, double> project_mercator(py::object obj) { | ||
// auto geog = (static_cast<PyObjectGeography&>(obj)).as_geog_ptr(); | ||
// if (geog->geog_type() != GeographyType::Point) { | ||
// throw py::value_error("test"); | ||
// } | ||
// auto point = static_cast<Point*>(geog); | ||
// auto s2point = point->s2point(); | ||
|
||
// auto projection = S2::MercatorProjection(20037508.3427892); | ||
// auto r2point = projection.Project(s2point); | ||
// double x = r2point.x(); | ||
// double y = r2point.y(); | ||
|
||
// return std::make_tuple(x, y); | ||
// } | ||
|
||
void init_projections(py::module& m) { | ||
// m.def("project_mercator", &project_mercator); | ||
py::class_<Projection>(m, "Projection") | ||
.def("lnglat", &Projection::lnglat) | ||
.def("pseudo_mercator", &Projection::pseudo_mercator) | ||
.def("orthographic", &Projection::orthographic); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#ifndef SPHERELY_PROJECTIONS_H_ | ||
#define SPHERELY_PROJECTIONS_H_ | ||
|
||
#include <s2/s2latlng.h> | ||
#include <s2/s2projections.h> | ||
#include <s2geography.h> | ||
|
||
#include "pybind11.hpp" | ||
|
||
namespace py = pybind11; | ||
namespace s2geog = s2geography; | ||
using namespace spherely; | ||
|
||
class Projection { | ||
public: | ||
Projection(std::shared_ptr<S2::Projection> projection) | ||
: m_s2_projection(std::move(projection)) {} | ||
|
||
std::shared_ptr<S2::Projection> s2_projection() { | ||
return m_s2_projection; | ||
} | ||
|
||
static Projection lnglat() { | ||
return Projection(std::move(s2geog::lnglat())); | ||
} | ||
static Projection pseudo_mercator() { | ||
return Projection(std::move(s2geog::pseudo_mercator())); | ||
} | ||
static Projection orthographic(double longitude, double latitude) { | ||
return Projection( | ||
std::move(s2geog::orthographic(S2LatLng::FromDegrees(latitude, longitude)))); | ||
} | ||
|
||
private: | ||
std::shared_ptr<S2::Projection> m_s2_projection; | ||
}; | ||
|
||
#endif // SPHERELY_PROJECTIONS_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters