1

a の次のメンバー関数をラップする正しい cythonic の方法は何boost::geometry::Pointですか? コード スニペットはhereから取得されます。

    /// @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;
    }

私は最初に使用しようとしました:

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 +

しかし、次のようなことから、どこに行けばよいかわかりません。

property x:
    def __set__(self, double value):
        deref(self._p).set[0](value)

私にこの失敗を与えます:

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

私の現在の実用的な解決策は、次のようなヘルパー関数を作成することです。

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 );

誰かがよりエレガントなソリューションを考えていますか?

4

1 に答える 1