2013-07-21 59 views
-2

這裏是我的表的例子:返回結果/經度rectagle

CREATE TABLE [dbo].[Addresses] (
[Id] int NOT NULL IDENTITY(1,1) , 
[Latitude] float(53) NULL, 
[Longitude] float(53) NULL 
) 

從我們的應用程序,我又回到2套緯度和Logitude點在邊框的格式:

{"upperright":[32.91052662576775,-79.5290690551758],"lowerleft":[32.6420709033305,-80.33313094482423]} 

因此,根據邊界框結果返回的內容,我需要將該信息傳遞給SQL查詢以查找該矩形內的所有地址。

+0

這裏是一個開始:http://technet.microsoft.com/en-us/library/bb895265 (v = sql.105).aspx – siride

+0

[基於緯度經度執行半徑搜索的SQL查詢]的可能重複(http://stackoverflow.com/questions/1727137/sql-query-for-performing-radius-search-基於緯度和經度) – geocodezip

+0

@geocodezip,我正在尋找經緯/長,並非郵編 – DDiVita

回答

-1

這爲我工作:

Select * from Addresses 
Where Addresses.Longitude between -80.33313094482423 and -79.5290690551758 
And Addresses.Latitude between 32.6420709033305 and 32.91052662576775 
+0

這並不說明您可能正在尋找緯度359.2和0.12之間的地方。如果給出這些參數,它將返回與你想要的相反範圍內的所有地方 – OneChillDude

0

要獲得重複的緯度和經度

WITH Dup_LatLong AS 
(
SELECT row_number() OVER (PARTITION BY 
LATITUDE, LONGITUDE ORDER BY Rpropid1) AS RowNumber, UniqueValue, convert(Varchar(50),LATITUDE)+convert(Varchar(50),LONGITUDE) Check_Cond 
FROM YourTable) 
Select UniqueValue,LATITUDE, LONGITUDE, convert(Varchar(50),LATITUDE)+convert(Varchar(50),LONGITUDE) 
from YourTable 
where convert(Varchar(50),LATITUDE)+convert(Varchar(50),LONGITUDE) in (Select Check_Cond from Dup_LatLong where RowNumber > 1) 
order by 7