Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/152.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ boost缓冲区调用后丢失自定义点类型中的数据_C++_Boost_Boost Geometry - Fatal编程技术网

C++ boost缓冲区调用后丢失自定义点类型中的数据

C++ boost缓冲区调用后丢失自定义点类型中的数据,c++,boost,boost-geometry,C++,Boost,Boost Geometry,我有自己的观点 class LocationWayPoint { public: latlong_container location; WORD index; PWeakBasicStation station; }; namespace boost { namespace geometry { namespace traits { BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_TRA

我有自己的观点

class LocationWayPoint
{
    public:
        latlong_container location;
        WORD index;
        PWeakBasicStation station;      
};

namespace boost { namespace geometry { namespace traits {
    BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_TRAITS(LocationWayPoint, 2, double, cs::cartesian)

    template<> struct access<LocationWayPoint, 0> {
        static inline double get(LocationWayPoint const& p) {return p.location.longitude; }
        static inline void set(LocationWayPoint& p, double const& value) {p.location.longitude = value; }
    };
    template<> struct access<LocationWayPoint, 1> {
        static inline double get(LocationWayPoint const& p) {return p.location.latitude; }
        static inline void set(LocationWayPoint& p, double const& value) {p.location.latitude = value; }
    };
}}}
typedef bg::model::linestring<LocationWayPoint> location_linestring_t;
我这样(在循环中)完成了这一点

当我使用ls1时,向后推_(点);我可以访问索引值

LOG4CPLUS_DEBUG(logger,  "LocationWay::LoaderWay in " << bg::get<0>(ls1[0]) << " d2 "  << bg::get<1>(ls1[0]) << " index "<< ls1[0].index);

out = DEBUG - LocationWay::LoaderWay in xxx d2 xxx index 7777
我明白了

DEBUG - LocationWay::LoaderWay in xxx d2 xxx index 17 <--uninit value

DEBUG-LocationWay::LoaderWay in xxx d2 xxx index 17我认为您已经直接诊断出了问题:使用该算法“丢失”了附加的外部信息,原因很简单,即创建的点是新点

顺便说一句,这是初始化所有成员数据的一个很好的理由——即使在POD结构中也是如此

因此,您的问题的基础似乎是假设缓冲区算法以某种方式保留原始点-只是移动它们并保留其包含的其余值。这个假设是不正确的

我可以推测原因:可能是为了适应使用共享点/几何体和(因此?)不变数据的自定义几何体模型

文件支持 文档没有直接描述这一限制(作为限制)。但这是关键点:它没有描述任何关于允许/处理无关数据的点概念,这肯定是图书馆不处理的迹象。举例来说,这里是一个例子:


请注意它是如何具有
traits::access
的,但它没有克隆点的概念(包括无关数据?)。

感谢您的解释!在这种情况下,我看不出使用BOOST\u GEOMETRY\u DETAIL\u SPECIALIZE\u POINT\u TRAITS这样的宏来重写点类有什么意义这没关系。是的,希望你也同意:)
LOG4CPLUS_DEBUG(logger,  "LocationWay::LoaderWay in " << bg::get<0>(ls1[0]) << " d2 "  << bg::get<1>(ls1[0]) << " index "<< ls1[0].index);

out = DEBUG - LocationWay::LoaderWay in xxx d2 xxx index 7777
bg::append(ls1, point);  
DEBUG - LocationWay::LoaderWay in xxx d2 xxx index 17 <--uninit value
boost::geometry::model::multi_polygon<location_polygon_t> result; 

    boost::geometry::buffer(ls1, result,
                distance_strategy, side_strategy,
                join_strategy, end_strategy, circle_strategy);