我正在将geoFences转换为Sql地理实例。目前的问题是某些情况。地理位置非常奇怪且不准确。
第一个(绿色区域)是有效的地理围栏,第二个是在sql中创建的。
坐标是: -
Long Lat
51.576004 24.125605, 51.580467 24.122041, 51.585875 24.119730, 51.591239 24.118751, 51.597633 24.120043, 51.603470 24.123843, 51.607161 24.126114, 51.609950 24.126976, 51.616087 24.127133, 51.625915 24.125997, 51.639776 24.119691, 51.576004 24.125605
偏差,即缓冲区为100米。
Sql代码: -
geography::STGeomFromText('POLYGON((51.576004 24.125605, 51.580467 24.122041,51.585875 24.11973,51.591239 24.118751,51.597633 24.120043,51.60347 24.123843,51.607161 24.126114,51.60995 24.126976,51.616087 24.127133,51.625915 24.125997,51.639776 24.119691,51.576004 24.125605))', 4120).MakeValid().STBuffer(100)
答案 0 :(得分:2)
多边形是一个闭环。这意味着你的围栏应该是一个环绕道路的环。在这种情况下,你有一条路在路上,然后重复第一点,即
POLYGON((51.576004 24.125605, ... ,51.576004 24.125605))
如果将其更改为LINESTRING
geography::STGeomFromText('LINESTRING(51.576004 24.125605, 51.580467 24.122041,51.585875 24.11973,51.591239 24.118751,51.597633 24.120043,51.60347 24.123843,51.607161 24.126114,51.60995 24.126976,51.616087 24.127133,51.625915 24.125997,51.639776 24.119691,51.576004 24.125605)', 4120)
看起来像这样
哪个应该解释你最终会得到的形状。
要获得所需的结果,您可以转换为线串,删除最后一个点,然后应用缓冲区。
geography::STGeomFromText('LINESTRING(51.576004 24.125605, 51.580467 24.122041,51.585875 24.11973,51.591239 24.118751,51.597633 24.120043,51.60347 24.123843,51.607161 24.126114,51.60995 24.126976,51.616087 24.127133,51.625915 24.125997,51.639776 24.119691)', 4120).STBuffer(100)