OGR几何交集
OGRGeometry Intersection
我需要与 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 始终为 null,编译器抛出:
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] 点。
我需要与 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 始终为 null,编译器抛出:
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] 点。