【问题标题】:OGRGeometry IntersectionOGRG几何交叉口
【发布时间】:2017-12-18 09:17:03
【问题描述】:

我需要相交 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 总是为空,编译器会抛出这个:

在 ShapeViewer.exe 中的 0x00007FFE11593FB8 处引发异常: Microsoft C++ 异常:内存中的 geos::util::TopologyException 位置 0x000000370A0FE5C0。

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

【问题讨论】:

    标签: c++ ogr


    【解决方案1】:

    环的定义无效

    -300,300 [1]    300,300 [2]
    
    
    -300,-300 [3]   300,-300 [4]
    

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

    【讨论】:

    • 非常感谢!!我以为他们自己订的
    猜你喜欢
    • 1970-01-01
    • 2015-03-15
    • 1970-01-01
    • 2017-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多