该升压多边形库状态,有可能抵消多边形(对称),但我还没有发现的怎么办呢.Anyone可以确认加速几何形状可以做到这一点的API或示例中的任何方法?我也发现了这个问题:
/sf/ask/536783201/ 这似乎问了类似的问题.请记住,像Polygon Clipper这样的库可以做得非常好,但我对Boost感兴趣的是它很快并支持浮点数.感谢帮助.
更新:我正在谈论Boost几何和多边形库,因为我不确定哪一个包含或缺少此功能.
#include <iostream>
#include <vector>
#include <boost/geometry.hpp>
#include <boost/geometry/strategies/cartesian/distance_pythagoras.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/geometries/linestring.hpp>
#include <boost/geometry/multi/geometries/multi_polygon.hpp>
#include <boost/geometry/io/wkt/wkt.hpp>
#include <boost/foreach.hpp>
int main(int argc, char *argv[])
{
typedef boost::geometry::model::d2::point_xy<double> point;
typedef boost::geometry::model::polygon<point> polygon;
std::stringstream ss;
std::string sstring;
char *poly1 =
"POLYGON((45.4602851 9.1146293,45.4602851 9.1196293,45.4652851 9.1196293,45.4652851 9.1146293,45.4602851 9.1146293))";
char *buffer = NULL;
int poly1StrLen;
double tmp;
polygon poly, newPoly;
point p1;
boost::geometry::read_wkt(poly1, poly);
boost::geometry::correct(poly);
BOOST_FOREACH(point const & p, boost::geometry::exterior_ring(poly))
{
// ss << boost::geometry::wkt(p);
// p1.x(p.y());
// p1.y(p.x());
boost::geometry::append(boost::geometry::exterior_ring(newPoly), p);
}
ss << …Run Code Online (Sandbox Code Playgroud) 我有一个Polygon对象,我正在寻找一种有效的方法来找到严格位于其内部(而不是其边界上)的任何点。最好的方法是什么?
我有以下想法,但我不太喜欢:
是否可以boost::geometry使用 a定义对象boost::variant?
此代码无法编译,因为它不喜欢在geom::read_wkt().
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/linestring.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/variant/variant.hpp>
#include <boost/variant.hpp>
namespace geom = boost::geometry;
typedef geom::model::d2::point_xy<double> point_type;
typedef geom::model::linestring<point_type> linestring_type;
typedef geom::model::polygon<point_type> polygon_type;
typedef boost::variant
<
point_type,
linestring_type,
polygon_type,
>
geometryVariant;
int main() {
std::string wkt = "LINESTRING(0 0, 1 1, 2, 2)";
geometryVariant gv;
geom::read_wkt(wkt, gv);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
但是,如果我明确定义linestring_type它工作正常
int main() {
std::string wkt = "LINESTRING(0 0, 1 1, 2, 2)";
linestring_type ls;
geom::read_wkt(wkt, ls); …Run Code Online (Sandbox Code Playgroud) 是否存在使用 c++ 和 boost::geometry 库的所有可能无效几何图形的数据集?或者至少是我可以转换为 boost::geometry 的无效几何图形的多边形坐标示例:自交等我想使用至少所有可能的无效几何图形来测试我的应用程序。像这样的东西:
https://knowledge.safe.com/articles/21674/invalid-ogc-geometry-examples.html
但有更多带有内部和外部多边形的测试用例。