【发布时间】:2018-07-09 00:03:01
【问题描述】:
我有一个包含地理区域的数据库,每行包含以下内容,例如:
多边形((-9.001111 40.624981,-9.251389 40.64887,-9.368056 40.382203,-9.4425 40.199703,-9.118056 40.14887,-9.001111 40.624981)
多边形((-8.75 38.216667,-8.75 38.3,-8.85 38.3,-8.85 38.216667,-8.75 38.216667))
多边形((-8.935001 38.909424,-9.002501 38.944424,-9.083056 38.848591,-9.015556 38.813591,-8.935001 38.909424))
等等
我需要一个查询,通过提供纬度、经度和半径来返回最近的查询。
这是我到目前为止的结果,但结果并不如预期:
declare
@radius int = 200,
@latitude decimal = 37.016758,
@longitude decimal = -7.930886;
DECLARE @point geography;
SET @point = geography::Point(@latitude, @longitude, 4326);
SELECT b.idFeature, a.idFeatureGeometry, a.placemark,
c.name, c.stroke, c.stroke_opacity, c.stroke_width, c.fill, c.fill_opacity
FROM FeaturesGeometries a
inner join Features b on a.idFeature = b.idFeature
inner join FeaturesProperties c on a.idFeature = c.idFeature
WHERE @point.STIntersects([placemark].STAsText()) <> 0;
关于如何改进查询的任何想法?
【问题讨论】:
标签: sql-server geometry geospatial