mysql stdistance_postgis的geography_columns和geometry_columns有什么区别
1、先說說Sql Server中g(shù)eometry和geography的區(qū)別:
geometry:planar??? 平面坐標(biāo)系【supported by SQL Server conforms to the Open Geospatial Consortium (OGC) Simple Features for SQL Specification version 1.1.0.】
geography: terrestrial?? 地理坐標(biāo)系【stores ellipsoidal (round-earth) data, such as GPS latitude and longitude coordinates.】
如果要計算兩個lat/lon點(diǎn)之間的實(shí)際距離就需要將geometry類型轉(zhuǎn)成geography類型,不然結(jié)果肯定不正確。
2、geometry轉(zhuǎn)geography的方法:
geography::STGeomFromText(boundary.ToString(),?4326)
boundary是geometry類型的,4326是坐標(biāo)系的參數(shù),4326代表GCS-WGS-1984坐標(biāo)系,是系統(tǒng)默認(rèn)的坐標(biāo)系。
可以通過這個sql獲得系統(tǒng)的坐標(biāo)系(Sql server中):Select * from sys.spatial_reference_systems where authorized_spatial_reference_id=4326
3、STDistance的用法:
https://msdn.microsoft.com/zh-cn/library/bb933952(v=sql.110).aspx
按照里面的例子能夠計算出距離,但是如果輸入的是經(jīng)緯度的值,得出的結(jié)果總是覺得不對,值比較小,實(shí)際上需要按照第二步轉(zhuǎn)化為geography類型再計算就可以了,4326坐標(biāo)系默認(rèn)返回距離的單位【unit】是米【meter】。
STDistance也可以計算點(diǎn)到面的最短距離。
總結(jié)
以上是生活随笔為你收集整理的mysql stdistance_postgis的geography_columns和geometry_columns有什么区别的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 证书体系: PFX 文件格式解析
- 下一篇: 2021年程序员1月薪资统计,你在哪一档