标签: boost-geometry

提升几何+ WGS84,做经度和纬度,但不是高度?

我想在WGS84椭球上做几个计算,包括:表面上的多边形点,点之间的距离计算,以及笛卡尔坐标的转换.看起来有一个GIS扩展来提升几何,基本上可以满足我的需要 - 除了它似乎不会将高度转换为笛卡尔坐标/从笛卡尔坐标转换 - 只有X/Y和Lat/Lon.我错过了什么吗?这可能吗?有没有人有什么建议?谢谢!

c++ gis boost latitude-longitude boost-geometry

5
推荐指数
1
解决办法
1880
查看次数

如何从 boost::geometry::model::point 继承?

我想从bg::model::point继承以使用自己的功能扩展它。*point*s 应存储在rtree 中

以下最小示例无法编译我的派生点(boost 1.54,gcc 4.7.2)的用法:

#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point.hpp>
#include <boost/geometry/geometries/box.hpp>
#include <boost/geometry/index/rtree.hpp>
#include <iostream>
#include <boost/shared_ptr.hpp>

namespace bg = boost::geometry;
namespace bgi = boost::geometry::index;

namespace boost { namespace geometry { namespace index {

// apparently necessary:
template <typename Box>
struct indexable< boost::shared_ptr<Box> >
{
    typedef boost::shared_ptr<Box> V;

    typedef Box const& result_type;
    result_type operator()(V const& v) const { return *v; }
};

}}} // namespace boost::geometry::index


namespace { // anonymous namespace

// myPoint
template<typename CoordinateType, …
Run Code Online (Sandbox Code Playgroud)

c++ inheritance boost boost-geometry

5
推荐指数
1
解决办法
1823
查看次数

使用boost几何来检查两条线是否有交点

是否可以使用boost :: geometry来检查两个线段(每个由2D中的两个点给出)是否相互交叉?如果可能的话,boost :: geometry是否也允许检查特殊情况,例如在另一条线上只有一个点(数字),或两条线是否相等?

c++ geometry boost numerical-methods boost-geometry

5
推荐指数
1
解决办法
5750
查看次数

为什么boost :: geometry地理Vincenty距离在赤道附近不正确?

我需要一个函数来高精度地计算一对WGS 84位置之间的距离,并且我打算使用Boost几何中geographic函数。

升压几何设计合理的状态:

有Andoyer方法,既快速又精确,还有Vincenty方法,又慢又精确。

但是,在boost::geometry::distance同时使用AndoyerVincenty策略测试功能时,我得到了以下结果:

WGS 84 values (metres)
    Semimajor axis:         6378137.000000
    Flattening:             0.003353
    Semiminor axis:         6356752.314245

    Semimajor distance:     20037508.342789
    Semiminor distance:     19970326.371123

Boost geometry near poles
Andoyer function:
    Semimajor distance:     20037508.151445
    Semiminor distance:     20003917.164970
Vincenty function:
    Semimajor distance:     **19970326.180419**
    Semiminor distance:     20003931.266635

Boost geometry at poles
Andoyer function:
    Semimajor distance:     0.000000
    Semiminor distance:     0.000000
Vincenty function:
    Semimajor distance:     **19970326.371122**
    Semiminor distance:     20003931.458623
Run Code Online (Sandbox Code Playgroud)

Vincenty沿半长轴(即在赤道附近)距离小于周围的短半轴的距离北极和南极之间的轴。那是不正确的。 …

c++ gis wgs84 boost boost-geometry

5
推荐指数
1
解决办法
2046
查看次数

boost :: geometry :: union_产生自相交

我有两个有效的多边形。当我接受他们的并集时,会得到一个无效的多边形(存在自相交)。这是错误吗?我希望联合操作将始终产生有效的多边形。我在下面提供了可视化示例。谁能解释为什么这不是错误,或者是否有办法解决?

#include <fstream>
#include <iostream>

#include <boost/geometry.hpp> // read_wkt
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/geometries/multi_polygon.hpp>
#include <boost/geometry/algorithms/union.hpp>

using PointType = boost::geometry::model::d2::point_xy<double>;
using PolygonType = boost::geometry::model::polygon<PointType>;
using MultiPolygonType = boost::geometry::model::multi_polygon<PolygonType>;

template <typename TPolygon>
void WritePolygonsToSVG(const std::vector<TPolygon>& polygons, const std::string& filename)
{
    std::ofstream svg(filename);

    boost::geometry::svg_mapper<PointType> mapper(svg, 400, 400);

    for(unsigned int i = 0; i < polygons.size(); ++i) {
        mapper.add(polygons[i]);
        mapper.map(polygons[i], "fill:rgb(255,128,0);stroke:rgb(0,0,100);stroke-width:1");
    }

}

int main(int, char**)
{
    /// Create two polygons
    PolygonType singlePolygon1;
    PolygonType singlePolygon2;

    boost::geometry::read_wkt("POLYGON((-52.8018 -26.744,-57.5465 -27.9916,-62.2844 -29.2642,-63.19 -26.066,-57.564 -24.5243,-53.7273 -23.3394,-52.8018 …
Run Code Online (Sandbox Code Playgroud)

c++ boost c++11 boost-geometry

5
推荐指数
1
解决办法
586
查看次数

在boost :: geometry中初始化多边形

我是通用几何库的新手,建议包含在boost中:

http://geometrylibrary.geodan.nl/
Run Code Online (Sandbox Code Playgroud)

我有两个向量vector<int> Xb, Yb,我试图从中创建一个多边形.我试图获得以下代码片段的内容:

 polygon_2d P;

 vector<double>::const_iterator xi;
 vector<double>::const_iterator yi;

 for (xi=Xb.begin(), yi=Yb.begin(); xi!=Xb.end(); ++xi, ++yi)
  P.push_back (make<point_2d>(*xi, *yi));
Run Code Online (Sandbox Code Playgroud)

上面的代码不起作用,抱怨P没有push_back成员函数.如何从具有坐标的点初始化多边形vector<int> Xb,vector<int> Yb

c++ boost polygon boost-geometry

4
推荐指数
2
解决办法
9236
查看次数

如何创建一个隐藏多层向量并将其作为单个Range公开的Boost.Range?

我有一个遗产类层次结构,我无法修改.由于外部库的要求,我需要为Line和Ring定义Boost.Ranges,其中两者仅在一次运行中暴露点(即,它应该是Line和Ring的Boost.Range of Points) .

伪代码说明:

Line l1 = Line{{1.0,2.0},{3.0,4.0},{5.0,6.0}} // init Line with three Points
Line l2 = Line{{7.0,8.0},{9.0,10.0},{11.0,12.0}} // init Line with three Points

auto lit = boost::begin(l1); // points to the Point{1.0,2.0}
++lit; // points to the Point{3.0,4.0}

Ring r1 = Ring{l1,l2} // init Ring with two Lines

auto rit = boost::begin(r1); // points to the Point{1.0,2.0}
++rit; // points to the Point{3.0,4.0}
++rit; // points to the Point{5.0,6.0}
++rit; // points to the Point{7.0,8.0}
++rit; // points …
Run Code Online (Sandbox Code Playgroud)

c++ boost boost-range boost-geometry

4
推荐指数
1
解决办法
1504
查看次数

提升多边形序列化:环

根据这个相关问题(Boost Polygon Serialization).我试图用Boost序列化多边形.我现在的问题是我正在尝试使用自定义X,Y,点的多边形编译示例,但编译器在编译时抛出此错误:

error: 'class boost::geometry::model::ring<boost::geometry::model::d2::point_xy<double> >' has no member named 'serialize'
Run Code Online (Sandbox Code Playgroud)

就像没有定义任何序列化环的功能一样.由于环从std :: vector扩展,并且如相关问题中所述,因此没有必要为其序列化定义方法.但是编译器抱怨道.

这里我有一个关于定义多边形及其序列化的完整示例:

#include <fstream>

#include <boost/serialization/vector.hpp>
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/version.hpp>
#include <boost/serialization/tracking.hpp>

#include <boost/geometry/geometry.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/io/wkt/wkt.hpp>
#include <boost/geometry/multi/geometries/multi_polygon.hpp>
#include <boost/geometry/geometries/ring.hpp>

#include <boost/archive/xml_iarchive.hpp>
#include <boost/archive/xml_oarchive.hpp>

typedef boost::geometry::model::d2::point_xy< double > point;
typedef boost::geometry::model::ring< point > ring;
typedef boost::geometry::model::polygon< point > polygon;

namespace boost{
        namespace serialization{

                template<class Archive>
                inline void serialize(Archive & ar, point &point, const unsigned int file_version)
                {
                        std::cout << "Point: …
Run Code Online (Sandbox Code Playgroud)

c++ serialization boost boost-serialization boost-geometry

4
推荐指数
1
解决办法
1103
查看次数

c ++ Boost循环通过model :: point的维度

我想知道是否有办法循环升级点模型的维度.我正在尝试创建一个函数来对两个自定义点进行计算,并具有可定义的维数.换句话说,每个点的维数将匹配,但它们不是恒定值.我想在每个维度上执行相同的操作,因此我需要执行循环才能实现此目的.

我想要做的一个例子是:

for(std::size_t dim = 0; dim < D; dim++){
    CoordinateType d = get<dim>();

    //do stuff to d

    set<dim>(d);

}
Run Code Online (Sandbox Code Playgroud)

我知道这不会起作用,因为d它不是编译时常量.

谢谢!

c++ boost boost-geometry

4
推荐指数
1
解决办法
405
查看次数

为什么boost.geometry.index.rtree比superliminal.RTree慢

我测试了boost.geometry.index.rtree(boost 1.59 www.boost.org)和superliminal.RTree(http://superliminal.com/sources/sources.htm#C_Code).

令我惊讶的是,superliminal.RTree比boost.geometry.index.rtree更快.

环境设置

  • 将相同的空间索引数据添加到superliminal.RTree和boost.geometry.index.rtree对象中.
  • 测试相同的空间索引查询100次并获得消耗的时间.
  • GCC版本是"gcc版本4.4.6 20110731(Red Hat 4.4.6-4)(GCC)",使用"-g -o2 -Wall -finline-functions"编译器标志.
  • 使用RTree <uint64_t,int,2,int64_t>

提升代码

namespace bg = boost::geometry; 
namespace bgi = boost::geometry::index; 

typedef bg::model::point < int, 2, bg::cs::cartesian > point_t; 
typedef bg::model::box < point_t > box_t; 
typedef std::pair < box_t, uint64_t > value_t; 
typedef bgi::rtree < value_t, bgi::quadratic < 8, 4 > > rtree_t; 
Run Code Online (Sandbox Code Playgroud)

结果是:

superliminal.RTree 0.029s

boost.geometry.index.rtree 0.12s.

c c++ r-tree boost-geometry

4
推荐指数
1
解决办法
3132
查看次数