- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我尝试使用 Boost::geometry 将负缓冲区应用于多面体。当我运行下面的代码时,我得到了正确的结果。但是,如果我删除标记的 block ,它只是导出并重新导入 WKT 中的几何图形,我会在 tmp_erosion 几何图形中得到一个空的 MultiPolygon。我尝试使用 boost::geometry::correct() 函数,但它没有任何改变。你知道如何解决这个问题吗?此外,我尝试将几何图形导出到 WKB,在导出-然后-导入-WKT 之前和之后是不同的。我猜这是由于某处进行了舍入操作,这可能与我的问题有关吗?
std::string wkt = "MULTIPOLYGON(((-203.3984972480392 326.87043766411114,-234.3294031269611 350.72117460025004,-234.32940582512484 350.7211767561067,-234.59541944833873 350.9413566745228,-234.5954246133754 350.9413612592119,-234.8456066177885 351.1793768235705,-234.84561145406377 351.179381753826,-235.078768547128 351.43409770182103,-235.07877303157431 351.43410295412707,-235.29379312442313 351.70430436766964,-235.29379723565108 351.7043099169743,-235.39951413618792 351.85781786966413,-240.86780715032046 350.38218215855835,-241.2049443604434 350.30361570297174,-241.20495115354115 350.3036143659985,-241.5467165739732 350.24856362767656,-241.54672344329876 350.24856276394,-241.89147886679623 350.21729162130026,-241.89148577942245 350.2172912349408,-242.23758558935015 350.20994967493,-242.58335698974216 350.2265727030494,-242.5833638895166 350.22657327470256,-242.9271563937872 350.26708130353956,-242.92716323747084 350.2670823512364,-243.26732892181855 350.3312812109238,-243.26733567660713 350.3312827296422,-243.60225063542637 350.4188666739157,-243.93029626301933 350.52941192532916,-243.93030274346452 350.52941436202866,-244.24991952642313 350.66239589829064,-244.55956286161836 350.81717054531686,-244.55956894361645 350.81717385333343,-244.8577608930744 350.99300259862656,-244.85776673160544 350.99300631954446,-245.14307795174008 351.18904635131906,-245.1430835188178 351.18905046730254,-245.41415167705114 351.40436658497003,-245.6696669314724 351.6379177381484,-245.66967187701746 351.63792258327567,-245.90841706208894 351.88859631483484,-266.58920031948566 375.16554041806563,-266.58920258870927 375.16554306360825,-266.8114462984894 375.433970996735,-266.8114505535744 375.43397651693255,-267.0144568842047 375.7172330288498,-267.0144607444406 375.7172388320306,-267.19724352509485 376.01394790994334,-267.1972469717292 376.0139539679166,-267.358918274207 376.32267424871253,-267.35892129049665 376.3226805320497,-267.49869574263016 376.6419123042001,-267.4986983139225 376.6419187823777,-267.6158969147833 376.97011127128593,-267.6158990285875 376.970117912834,-267.7099540930073 377.30568358689385,-267.7804054331035 377.6469788117333,-267.780406603398 377.6469856825949,-267.8269143132387 377.99236621139704,-267.8492510917757 378.34014040558645,-267.84925129584775 378.3401473724138,-267.84730904189666 378.68863970288874,-267.8210977526416 379.03614335774023,-267.8210969865306 379.036150285323,-267.7707424635338 379.3809909713855,-267.6964900867632 379.72148658265553,-267.59870274954784 380.0559764307823,-267.5987005618558 380.05598304835985,-267.4778489339802 380.38285544057135,-267.3345253662763 380.7005096185073,-267.334522280147 380.700515867838,-267.1694203712224 381.00741516970913,-267.1694168572867 381.0074211888939,-266.9833347199501 381.3020805089815,-266.77718414040345 381.58305694993714,-266.7771798240608 381.58306242236944,-266.5519583226944 381.8489968074004,-266.5519536356491 381.8490019658822,-266.30875282540296 382.09860488379184,-232.51589024775978 414.4450812583296,-232.51588002802416 414.4450898114167,-232.51586876173633 414.4450969296367,-232.51585664898366 414.445102486571,-232.51584390488657 414.4451063835295,-232.5158373664838 414.445107686701,-211.12681324719696 417.9713206571314,-211.12680695294904 417.97132149052527,-211.1267942693878 417.9713219522357,-211.12678793120457 417.971321578691,-211.1267816295017 417.9713208036793,-211.12676923690148 417.97131806335767,-211.1267572912145 417.97131377541353,-211.12675154646425 417.9713110717222,-177.1106691504801 400.6223337146699,-177.1106636027793 400.62233015463886,-177.11065830167098 400.6223262368518,-177.11064853019522 400.6223173975823,-177.11064000569968 400.62230735032404,-177.11063625823746 400.6223019274713,-177.11063287618194 400.6222962695118,-177.11062726542067 400.6222843475245,-177.11062327082684 400.622271791345,-177.11062190239758 400.6222653432285,-165.59426937600804 335.9234066092942,-162.6596781566315 302.06171116087233,-162.6596788436905 302.0616975137797,-162.65967988463825 302.06169075731424,-162.65968333706937 302.06167753627386,-162.65968573241835 302.0616711334854,-162.6596885596208 302.06166490931287,-162.65969545477958 302.06165311219564,-162.65970389380263 302.0616423651924,-162.65970864407186 302.06163744906183,-162.65971909523134 302.0616286463092,-162.65973064885196 302.0616213504858,-162.65974308921002 302.0616156978157,-162.6597561840252 302.0616117938428,-162.65976290080164 302.0616105217139,-162.65977651628992 302.06160936686865,-162.65979016210093 302.0616100789291,-162.65979691664793 302.06161113225346,-162.65981013134098 302.0616146089008,-162.65982274871268 302.0616198545771,-204.8758528204258 323.10306070098704,-204.8758584840069 323.10306427432,-204.87586903132672 323.1030725164298,-204.87587838335946 323.10308209337154,-204.87588255785658 323.1030873296329,-204.87588981029387 323.1030985804321,-204.8758928557106 323.103104544516,-204.87589549513 323.1031106990528,-204.87589771671574 323.10311701644275,-204.87590086845387 323.1031300258577,-204.87590225445257 323.1031433396602,-204.8759018498778 323.10315671929584,-204.8444560373964 323.42562807154223,-204.84445513319602 323.42563489982314,-204.78751382477697 323.76528940556193,-204.78751245267617 323.76529615540176,-204.70732324106254 324.10023186228716,-204.60427022620226 324.42884648764846,-204.60426794001853 324.4288529850604,-204.47883820282144 324.74959412196023,-204.47883547479194 324.74960044658303,-204.33162256579686 325.0609494910012,-203.3984972480392 326.87043766411114)))";
typedef double coordinate_2d;
typedef boost::geometry::model::d2::point_xy<coordinate_2d> point_2d;
typedef boost::geometry::model::polygon<point_2d> polygon_2d;
typedef boost::geometry::model::multi_polygon<polygon_2d> multi_polygon_2d;
multi_polygon_2d test_erosion, tmp_erosion;
// Read WKT
boost::geometry::read_wkt(wkt, test_erosion);
// Check validity
std::cout<<boost::geometry::is_valid(test_erosion)<<std::endl;
//////////////////////////////////////////////
// WHY DO I NEED THIS BLOCK???
//////////////////////////////////////////////
// Export to wkt
std::ostringstream tmp_wkt;
tmp_wkt << boost::geometry::wkt(test_erosion);
// And read it again
boost::geometry::read_wkt(tmp_wkt.str(), test_erosion);
std::cout<<boost::geometry::is_valid(test_erosion)<<std::endl;
//////////////////////////////////////////////
// Apply buffer
boost::geometry::buffer(test_erosion, tmp_erosion,
boost::geometry::strategy::buffer::distance_symmetric<double>(-0.00001),
boost::geometry::strategy::buffer::side_straight(),
boost::geometry::strategy::buffer::join_round(),
boost::geometry::strategy::buffer::end_round(),
boost::geometry::strategy::buffer::point_circle(360)
);
// Print result
std::cout<<boost::geometry::wkt(test_erosion)<<std::endl;
std::cout<<boost::geometry::wkt(tmp_erosion)<<std::endl;
最佳答案
But if I remove the marked block, which just export and re-import the geometry in WKT, I get an empty MultiPolygon in the tmp_erosion geometry.
tmp_erosion
在这种情况下是空的,因为 boost::geometry::buffer
没有向它写入任何内容。
没有写的原因是因为 boost::geometry::strategy::buffer::distance_symmetric<double>(-0.00001)
太粗糙了。带有更多小数位的 boost::geometry::strategy::buffer::distance_symmetric<double>(-0.0000001)
可以工作。
I guess it is due to some rounding operation somewhere
是的。
std::ostringstream tmp_wkt;
有一个 default precision 集。目前该程序不会写入所有数字,因此会应用四舍五入。
在 tmp_wkt.precision(16);
之前添加 tmp_wkt << boost::geometry::wkt(test_erosion);
将导致与没有 block 相同的行为,因为现在所有数字都已写入。
这是一个更新的程序,用于显示这些要点:
#include <iostream>
#include <sstream>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
int main()
{
std::string wkt = "MULTIPOLYGON(((-203.3984972480392 326.87043766411114,-234.3294031269611 350.72117460025004,-234.32940582512484 350.7211767561067,-234.59541944833873 350.9413566745228,-234.5954246133754 350.9413612592119,-234.8456066177885 351.1793768235705,-234.84561145406377 351.179381753826,-235.078768547128 351.43409770182103,-235.07877303157431 351.43410295412707,-235.29379312442313 351.70430436766964,-235.29379723565108 351.7043099169743,-235.39951413618792 351.85781786966413,-240.86780715032046 350.38218215855835,-241.2049443604434 350.30361570297174,-241.20495115354115 350.3036143659985,-241.5467165739732 350.24856362767656,-241.54672344329876 350.24856276394,-241.89147886679623 350.21729162130026,-241.89148577942245 350.2172912349408,-242.23758558935015 350.20994967493,-242.58335698974216 350.2265727030494,-242.5833638895166 350.22657327470256,-242.9271563937872 350.26708130353956,-242.92716323747084 350.2670823512364,-243.26732892181855 350.3312812109238,-243.26733567660713 350.3312827296422,-243.60225063542637 350.4188666739157,-243.93029626301933 350.52941192532916,-243.93030274346452 350.52941436202866,-244.24991952642313 350.66239589829064,-244.55956286161836 350.81717054531686,-244.55956894361645 350.81717385333343,-244.8577608930744 350.99300259862656,-244.85776673160544 350.99300631954446,-245.14307795174008 351.18904635131906,-245.1430835188178 351.18905046730254,-245.41415167705114 351.40436658497003,-245.6696669314724 351.6379177381484,-245.66967187701746 351.63792258327567,-245.90841706208894 351.88859631483484,-266.58920031948566 375.16554041806563,-266.58920258870927 375.16554306360825,-266.8114462984894 375.433970996735,-266.8114505535744 375.43397651693255,-267.0144568842047 375.7172330288498,-267.0144607444406 375.7172388320306,-267.19724352509485 376.01394790994334,-267.1972469717292 376.0139539679166,-267.358918274207 376.32267424871253,-267.35892129049665 376.3226805320497,-267.49869574263016 376.6419123042001,-267.4986983139225 376.6419187823777,-267.6158969147833 376.97011127128593,-267.6158990285875 376.970117912834,-267.7099540930073 377.30568358689385,-267.7804054331035 377.6469788117333,-267.780406603398 377.6469856825949,-267.8269143132387 377.99236621139704,-267.8492510917757 378.34014040558645,-267.84925129584775 378.3401473724138,-267.84730904189666 378.68863970288874,-267.8210977526416 379.03614335774023,-267.8210969865306 379.036150285323,-267.7707424635338 379.3809909713855,-267.6964900867632 379.72148658265553,-267.59870274954784 380.0559764307823,-267.5987005618558 380.05598304835985,-267.4778489339802 380.38285544057135,-267.3345253662763 380.7005096185073,-267.334522280147 380.700515867838,-267.1694203712224 381.00741516970913,-267.1694168572867 381.0074211888939,-266.9833347199501 381.3020805089815,-266.77718414040345 381.58305694993714,-266.7771798240608 381.58306242236944,-266.5519583226944 381.8489968074004,-266.5519536356491 381.8490019658822,-266.30875282540296 382.09860488379184,-232.51589024775978 414.4450812583296,-232.51588002802416 414.4450898114167,-232.51586876173633 414.4450969296367,-232.51585664898366 414.445102486571,-232.51584390488657 414.4451063835295,-232.5158373664838 414.445107686701,-211.12681324719696 417.9713206571314,-211.12680695294904 417.97132149052527,-211.1267942693878 417.9713219522357,-211.12678793120457 417.971321578691,-211.1267816295017 417.9713208036793,-211.12676923690148 417.97131806335767,-211.1267572912145 417.97131377541353,-211.12675154646425 417.9713110717222,-177.1106691504801 400.6223337146699,-177.1106636027793 400.62233015463886,-177.11065830167098 400.6223262368518,-177.11064853019522 400.6223173975823,-177.11064000569968 400.62230735032404,-177.11063625823746 400.6223019274713,-177.11063287618194 400.6222962695118,-177.11062726542067 400.6222843475245,-177.11062327082684 400.622271791345,-177.11062190239758 400.6222653432285,-165.59426937600804 335.9234066092942,-162.6596781566315 302.06171116087233,-162.6596788436905 302.0616975137797,-162.65967988463825 302.06169075731424,-162.65968333706937 302.06167753627386,-162.65968573241835 302.0616711334854,-162.6596885596208 302.06166490931287,-162.65969545477958 302.06165311219564,-162.65970389380263 302.0616423651924,-162.65970864407186 302.06163744906183,-162.65971909523134 302.0616286463092,-162.65973064885196 302.0616213504858,-162.65974308921002 302.0616156978157,-162.6597561840252 302.0616117938428,-162.65976290080164 302.0616105217139,-162.65977651628992 302.06160936686865,-162.65979016210093 302.0616100789291,-162.65979691664793 302.06161113225346,-162.65981013134098 302.0616146089008,-162.65982274871268 302.0616198545771,-204.8758528204258 323.10306070098704,-204.8758584840069 323.10306427432,-204.87586903132672 323.1030725164298,-204.87587838335946 323.10308209337154,-204.87588255785658 323.1030873296329,-204.87588981029387 323.1030985804321,-204.8758928557106 323.103104544516,-204.87589549513 323.1031106990528,-204.87589771671574 323.10311701644275,-204.87590086845387 323.1031300258577,-204.87590225445257 323.1031433396602,-204.8759018498778 323.10315671929584,-204.8444560373964 323.42562807154223,-204.84445513319602 323.42563489982314,-204.78751382477697 323.76528940556193,-204.78751245267617 323.76529615540176,-204.70732324106254 324.10023186228716,-204.60427022620226 324.42884648764846,-204.60426794001853 324.4288529850604,-204.47883820282144 324.74959412196023,-204.47883547479194 324.74960044658303,-204.33162256579686 325.0609494910012,-203.3984972480392 326.87043766411114)))";
typedef double coordinate_2d;
typedef boost::geometry::model::d2::point_xy<coordinate_2d> point_2d;
typedef boost::geometry::model::polygon<point_2d> polygon_2d;
typedef boost::geometry::model::multi_polygon<polygon_2d> multi_polygon_2d;
multi_polygon_2d test_erosion, tmp_erosion;
// Read WKT
boost::geometry::read_wkt(wkt, test_erosion);
// Check validity
std::cout << boost::geometry::is_valid(test_erosion) << std::endl;
//////////////////////////////////////////////
// WHY DO I NEED THIS BLOCK???
//////////////////////////////////////////////
// Export to wkt
std::ostringstream tmp_wkt;
tmp_wkt.precision(16); // changing the precision to include all digits will render this block moot
tmp_wkt << boost::geometry::wkt(test_erosion); // this will round according to the precision for the stream
// And read it again
boost::geometry::read_wkt(tmp_wkt.str(), test_erosion);
std::cout << boost::geometry::is_valid(test_erosion) << std::endl;
//////////////////////////////////////////////
// Apply buffer
boost::geometry::buffer(test_erosion, tmp_erosion,
boost::geometry::strategy::buffer::distance_symmetric<double>(-0.0000001), // this will produce output in tmp_erosion, even with all the digits
//boost::geometry::strategy::buffer::distance_symmetric<double>(-0.00001), // this will not produce output if the coordinates are not rounded
boost::geometry::strategy::buffer::side_straight(),
boost::geometry::strategy::buffer::join_round(),
boost::geometry::strategy::buffer::end_round(),
boost::geometry::strategy::buffer::point_circle(360)
);
// Print result
std::cout << boost::geometry::wkt(test_erosion) << std::endl;
std::cout << boost::geometry::wkt(tmp_erosion) << std::endl;;
关于c++ - Boost::geometry::multi_polygon 的负缓冲区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39354086/
这个问题在这里已经有了答案: Possible to make an event handler wait until async / Promise-based code is done? (2
我经常有多个运行的进程(R,Python,eshell/shell),对于每个进程,我经常都有一个相关的脚本,可以从中发送摘要。为此,我通常将每个框架垂直地分成两个窗口,以便脚本文件(例如.py)位于
如何修改 emacs 在关闭缓冲区后选择要显示的缓冲区的方式? 当我有多个列显示相同的缓冲区,然后在其中一个缓冲区中打开另一个文件,然后关闭新打开的缓冲区时,它不会切换回前一个缓冲区,而是切换到另一个
如何将 ex 命令复制到剪贴板或粘贴到缓冲区? 在 Windows 上使用 gvim。 最佳答案 windows剪贴板可以通过the buffer + 访问.因此,可以使用 + 将剪贴板粘贴为前命令。
在 javascript 中如何以比以下更简单的方式获取 b 缓冲区? var num=6553599 var a = new Buffer(4); a.writeInt32LE(num)
每次我在 Google 上搜索有关 OpenGL 编程的文章时,我都会找到一些文章,但似乎所有文章都提到了着色器和缓冲区。那些是什么?你能解释其中的一些吗: 深度缓冲区 模板缓冲区 像素着色器 帧缓冲
我有java考试,当我学习时,我看到了这个练习,我尝试解决它,但我发现一些困难,所以请帮助我考虑实用程序中方法的以下注释、 header 和部分代码名为 Atbash 的加密类。 /**
每次我在 Google 上搜索有关 OpenGL 编程的文章时,我都会找到一些文章,但似乎所有文章都提到了着色器和缓冲区。那些是什么?你能解释其中的一些吗: 深度缓冲区 模板缓冲区 像素着色器 帧缓冲
对于每个属性使用跨步顶点缓冲区与紧密打包缓冲区有何优缺点?我的意思是例如: 步幅:xyzrgb xyzrgb xyzrgb 紧:xyzxyzxyz rgbrgbrgb 乍一看,使用步幅时您似乎可以轻松
我正在尝试将文本文件中每行的数字读取到 ArrayList 中。当我执行以下函数时,它总是跳过最后一个元素。有人可以帮我吗?因为我在这里没有遇到问题,因为它读取直到缓冲区为空,所以他应该在到达 Fil
#include #include int main () { time_t time_raw_format; struct tm * ptr_time; char *buff
基本上我有一个包含不同类型数据的自定义结构。例如: typedef struct example_structure{ uint8_t* example_1[4]; int example_2[4];
我之前的列表实现是一个简单的 LinearLayout,位于一个装满我的项目的 ScrollView 中。 我切换到 ListView 的 Android 实现以简单地使用 CursorAdapter
我想创建一个可变长度的输入事件窗口/缓冲区,当它接收到额外的事件时会变长。 这是为了实现“键入时搜索”功能。我想捕获点击,但为了不给服务器造成压力,我想明智地进行服务调用。 我想到的逻辑是缓冲击键,从
我想将 yuv420P 像素写入缓冲区而不是二进制文件。假设我在指针中存储了 luma 、 Cb 和 Cr。 luma = output_pixel.luma; cb = output_pixel.c
我想在 Go 中构建一个支持多个并发读取器和一个写入器的缓冲区。所有写入缓冲区的内容都应由所有读者读取。允许新读者随时加入,这意味着已经写入的数据必须能够为迟到的读者回放。 缓冲区应满足以下接口(in
本文转载自微信公众号「小明菜市场」,作者小明菜市场。转载本文请联系小明菜市场公众号。 前言 Java NIO 需要理解的主要有缓冲区,通道,选择器,这三个主要的部分。 基础
一 点睛 NIO,可以称为 New IO 或 Non Blocking IO,是在 JDK 1.4 后提供的新 API。传统的I/O 是阻塞式的 I/O、面向流的操作;而 NIO 是非阻塞 I/O 、
我正在寻找一种切换到包含搜索文本的缓冲区的方法。 例如。如果我打开了 100 个缓冲区,我想切换到一个包含 'fooBar = 1' 的缓冲区 最佳答案 我写了一个 Vim 插件来做到这一点:buff
我正在尝试将提取的视频帧(我使用 ffmpeg)推送到 FFMPEG 缓冲区中。我已经查看了 ffmpeg 的缓冲区源文件,例如 buffersrc.c 和 fifo.c,以确定我是否可以这样做,但我
我是一名优秀的程序员,十分优秀!