我在以下查询中遇到了关于纬度/经度顺序的问题,如果我将坐标以错误的顺序(经度,纬度)放置,它会起作用。但是 geography::Point 应该采用 lat 然后 lng,这很奇怪。我尝试在谷歌地图上检查纬度/经度,它的位置正确,多边形按顺时针顺序排列,一切看起来都很好,查询如下:
DECLARE @branch_id int = 0;
DECLARE @point geography;
SET @point = geography::Point(31.3353608924066, 30.0798141318826, 4326);
SELECT B.ID, B.DeliveryZone, A.LatLong
FROM [dbo].[Branches] AS B
INNER JOIN [dbo].Addresses AS A ON B.AddressID = A.ID
WHERE B.ServiceProviderID = 2 AND
B.Deleted = 0 AND
B.DeliveryZone.STBuffer(1000).STIntersects( @point ) > 0 ;