当前位置: 首页>>代码示例>>Python>>正文


Python QgsGeometry.shortestLine方法代码示例

本文整理汇总了Python中qgis.core.QgsGeometry.shortestLine方法的典型用法代码示例。如果您正苦于以下问题:Python QgsGeometry.shortestLine方法的具体用法?Python QgsGeometry.shortestLine怎么用?Python QgsGeometry.shortestLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在qgis.core.QgsGeometry的用法示例。


在下文中一共展示了QgsGeometry.shortestLine方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: traf

# 需要导入模块: from qgis.core import QgsGeometry [as 别名]
# 或者: from qgis.core.QgsGeometry import shortestLine [as 别名]

#.........这里部分代码省略.........
            conn.commit()
            buf1= QgsGeometry.fromWkt(resultat[0][0])
            
        if m3<m4:
            texte="select asText(st_line_substring(st_geomfromtext('"+buf.asWkt()+"',"+proj+")"+','+str(m3)+','+str(m4)+"))"
            rs = c.execute(texte)
            resultat=c.fetchall()
            conn.commit()
            buf2= QgsGeometry.fromWkt(resultat[0][0])


        else:

            texte="select astext(st_union(g)) from (select st_line_substring(st_geomfromtext('"+buf.asWkt()+"',"+proj+"),0,"+str(m4)+") as \"g\" union all select st_line_substring(st_geomfromtext('"+buf.asWkt()+"',"+proj+"),"+str(m3)+",1) as \"g\" )"
            rs = c.execute(texte)
            resultat=c.fetchall()
            conn.commit()
            buf2= QgsGeometry.fromWkt(resultat[0][0])
            texte="select astext(st_union(st_snap(st_line_substring(geomfromtext('"+buf.asWkt()+"',"+proj+"),0,"+str(m4)+"),st_line_substring(geomfromtext('"+buf.asWkt()+"',"+proj+"),"+str(m3)+",1),1),st_line_substring(geomfromtext('"+buf.asWkt()+"',"+proj+"),"+str(m3)+",1)))"

            rs = c.execute(texte)
            resultat=c.fetchall()
            conn.commit()
            buf2= QgsGeometry.fromWkt(resultat[0][0])

        


        


        
        g1=buf
        g2=buf.shortestLine(int1)
        g2=g2.combine(g1)
        g3=buf.shortestLine(int2)
        g3=g3.combine(g2)
        g3=g3.combine(pt1.shortestLine(int1))
        g3=g3.combine(pt2.shortestLine(int2))
        g3=g3.combine(pt1.shortestLine(geometry.geometry()))
        g3=g3.combine(pt2.shortestLine(geometry.geometry()))
        g3=g3.combine(geometry.geometry())
        buf3=buf1.asWkt()
        buf4=buf2.asWkt()
        if double_sens==False:
            if m5>0:
                texte="select astext(st_union(st_snap(geomfromtext('"+geometry.geometry().asWkt()+"',"+proj+"),geomfromtext('"+pt1.shortestLine(int5).asWkt()+"',"+proj+"),1),geomfromtext('"+pt1.shortestLine(int5).asWkt()+"',"+proj+")))"
                rs = c.execute(texte)
                resultat=c.fetchall()
                conn.commit()
                buf3= resultat[0][0]
                texte="select astext(st_union(st_snap(geomfromtext('"+buf3+"',"+proj+"),geomfromtext('"+pt2.shortestLine(int5).asWkt()+"',"+proj+"),1),geomfromtext('"+pt2.shortestLine(int5).asWkt()+"',"+proj+")))"
                rs = c.execute(texte)
                resultat=c.fetchall()
                conn.commit()
                buf3= resultat[0][0]        
            else:
                texte="select astext(st_union(st_snap(geomfromtext('"+buf3+"',"+proj+"),geomfromtext('"+buf1.shortestLine(int1).asWkt()+"',"+proj+"),1),geomfromtext('"+buf1.shortestLine(int1).asWkt()+"',"+proj+")))"
                rs = c.execute(texte)
                resultat=c.fetchall()
                conn.commit()
                buf3= resultat[0][0]
                texte="select astext(st_union(st_snap(geomfromtext('"+buf3+"',"+proj+"),geomfromtext('"+buf1.shortestLine(int2).asWkt()+"',"+proj+"),1),geomfromtext('"+buf1.shortestLine(int2).asWkt()+"',"+proj+")))"
                rs = c.execute(texte)
                resultat=c.fetchall()
                conn.commit()
开发者ID:crocovert,项目名称:networks,代码行数:70,代码来源:trafic.py


注:本文中的qgis.core.QgsGeometry.shortestLine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。