PostGis 如何判斷兩個多邊形是否有重疊的區域

select st_astext(

ST_Intersection(

ST_Multi(st_geomfromEWKT('SRID=32649;POLYGON((x1 y1, x2 y2, x3 y3, x4 y4, x5 x5, x1 y1))') ),the_geom

)

) from tableName where 條件


st_geomfromEWKT('SRID=32649;POLYGON((x1 y1, x2 y2, x3 y3, x4 y4, x5 x5, x1 y1))')  --> 將polygon字符串轉化爲32649標準下的地理信息

ST_Multi( )  --> 將polygon的地理信息轉換爲multipolygon

ST_Intersection(geom1, geom2)  --> 求兩個polygon的重疊區域

st_astext( ) --> 通過文本的方式返回 polygon


執行sql後返回重疊區域的polygon字符串,如果沒有重疊區域則返回"GEOMETRYCOLLECTION EMPTY"字符串

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章