• 请不要在回答技术问题时复制粘贴 AI 生成的内容
ackfin01
V2EX  ›  程序员

有老哥用过 postgis 的么

  •  
  •   ackfin01 · Jan 16, 2020 · 1464 views
    This topic created in 2333 days ago, the information mentioned may be changed or developed.

    建立了一个表,其中一个字段是 geometry(Polygon) 类型的,目前数据库里面有一条记录里面是包含两个矩形:

    'POLYGON((466.011 573.9911,503.4636 573.9911,503.4636 583.6541,466.011 583.6541,466.011 573.9911),(91.014 603.9088,116.8337 603.9088,116.8337 615.8859,91.014 615.8859,91.014 603.9088))'
    

    对应矩形是

    [[466.011, 573.9911, 503.4636, 583.6541], [91.014, 603.9088, 116.8337, 615.8859]]
    

    其中里面每一个 list 的每一项对应于矩形的 x,y,xx,yy

    在 QGIS 里面是这样的(红框框起来的这两个矩形)

    20200116163058.png

    问题来了,现在我通过和[466.011, 573.9911, 503.4636, 583.6541]是否相交可以查到这条记录

    但是通过

    [91.014, 603.9088, 116.8337, 615.8859]
    'POLYGON((91.014 603.9088,116.8337 603.9088,116.8337 615.8859,91.014 615.8859,91.014 603.9088))' 
    

    查不到,相交用的ST_Intersects或者&&,这是啥原因呀?

    1 replies    2020-01-19 12:48:15 +08:00
    ackfin01
        1
    ackfin01  
    OP
       Jan 19, 2020
    之前的理解有错:对于有多个矩形框的情况,应该使用 MULTIPOLYGON,而 POLYGON 的多个框是指由一个外环和 0 到多个内环组成的。

    https://skyrover.me/posts/101
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1226 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 17:48 · PVG 01:48 · LAX 10:48 · JFK 13:48
    ♥ Do have faith in what you're doing.