Was ist der korrekte zythoische Weg, um die folgenden Elementfunktionen eines boost::geometry::Point
zu wickeln? Das Code-Snippet kommt von here.Cythonic Weg, um zu wickeln Boost :: Geometrie :: Punkt Zugriffsmethoden
/// @brief Get a coordinate
/// @tparam K coordinate to get
/// @return the coordinate
template <std::size_t K>
inline CoordinateType const& get() const
{
#if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING)
BOOST_GEOMETRY_ASSERT(m_created == 1);
BOOST_GEOMETRY_ASSERT(m_values_initialized[K] == 1);
#endif
BOOST_STATIC_ASSERT(K < DimensionCount);
return m_values[K];
}
/// @brief Set a coordinate
/// @tparam K coordinate to set
/// @param value value to set
template <std::size_t K>
inline void set(CoordinateType const& value)
{
#if defined(BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING)
BOOST_GEOMETRY_ASSERT(m_created == 1);
m_values_initialized[K] = 1;
#endif
BOOST_STATIC_ASSERT(K < DimensionCount);
m_values[K] = value;
}
Ich versuchte zuerst mit:
cdef extern from "s57/data/geometries.h" namespace "bg::model":
cdef cppclass _Geo2 "bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree>>":
_Geo2()
_Geo2(const _Geo2& other)
const double get[size_t]() except +
void set[size_t](double) except +
aber dann weiß ich nicht, wo, wie dies seit etwas gehen:
property x:
def __set__(self, double value):
deref(self._p).set[0](value)
gibt mir diesen Fehler:
Error compiling Cython file:
------------------------------------------------------------
...
property x:
def __set__(self, double value):
deref(self._p).set[0](value)
^
------------------------------------------------------------
c:\XXXX\x.pyx:24:31: not parsable as a type
Meine aktuelle Arbeit so lution wurde wie einige Hilfsfunktionen zu erstellen:
double get_geo2_x(geo2& pnt);
double get_geo2_y(geo2& pnt);
void set_geo2_x(geo2& pnt, double value);
void set_geo2_y(geo2& pnt, double value);
Hat jemand daran eine elegantere Lösung?