我一個應用程序,我需要得到附近的地點工作最接近的位置, 我的web服務將接收2個參數(十進制經度,數字緯度)查找經度和緯度
我有一個表,其中位置被保存在經度和緯度字段的數據庫中,
我想檢索最近的位置。
任何人都可以幫忙嗎?
這是我的代碼:
var locations = from l in locations
select l
以下是有關這個進一步的細節: 我有一個2名的字段(十進制(18,2)空)1個緯度,一個數據庫表內2經度,
和我有一個方法
public List<Locations> GetLocation(decimal? Long, decimal? lat)
{
var Loc = from l in Locations
//// now here is how to get nearest location ? how to query?
//// i have also tried Math.Abs(l.Lat - lat) its giving error about nullable decimal always hence i have seted decimal to nullable or converted to nullable
//// also i have tried where (l.lat - Lat) * (l.lon - Long) this is also giving error about can not convert decimal to bool
return Loc.ToList();
}
代碼?非常簡短......你有什麼嘗試過的嗎? – lboshuizen