gpt4 book ai didi

c++ - OGR几何交集

转载 作者:行者123 更新时间:2023-11-30 03:26:54 25 4
gpt4 key购买 nike

我需要与 2 个 OGRGeometry 相交。在我的代码中,我定义了一个将与其他 OGRGeometry 相交的 OGRPolygon。

这是我的 OGRPolygon:

    OGRLinearRing ring;
OGRPolygon poly;
ring.addPoint(-300, 300);
ring.addPoint(300, 300);
ring.addPoint(-300, -300);
ring.addPoint(300, -300);
ring.closeRings();
poly.addRing(&ring);

这是交集代码:

 for (int i = 0; i < geo5.size(); i++)
{
qDebug() << geo5[i]->Intersect(&poly);
if (geo5[i]->Intersect(&poly)) {
qDebug() << "El tipo es "<< geo5[i]->Intersection(&poly);
OGRGeometry* newGeo = geo5[i]->Intersection(&poly);
}

}

newGeo 始终为空,编译器抛出:

Exception thrown at 0x00007FFE11593FB8 in ShapeViewer.exe: Microsoft C++ exception: geos::util::TopologyException at memory location 0x000000370A0FE5C0.

有人可以帮我解决这个问题吗?谢谢大家!

最佳答案

环的定义无效

-300,300 [1]    300,300 [2]


-300,-300 [3] 300,-300 [4]

[1] 与 [4] 点连接后,线 [2,3] 和 [4,1] 之间有交点。您应该在添加 [3] 之前添加 [4] 点。

关于c++ - OGR几何交集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47865232/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com