0
這是計算距離從當前位置到另一個列表中的距離的JSON結果,但我有一個問題,我無法將距離單位(度)轉換爲從dbgeography.location.distance到km的問題這是我的代碼:在dbgeography中如何返回距離km?
string CurrentLocation = String.Format("POINT(" + CurrentLat + " " + CurrentLng + ")", 4326);
DbGeography point = DbGeography.PointFromText(CurrentLocation, DbGeography.DefaultCoordinateSystemId);
var places = (from u in context.schoolinfo
orderby u.Location.Distance(point.Buffer(dist))
select u).Take(10).Select(x => new schoollinfo() { Name = x.name, Lat = x.Location.Latitude, Lng = x.Location.Longitude, Distance = x.Location.Distance(point.Buffer(dist)) }); ;
var nearschools = places.ToList();
return Json(nearschools, JsonRequestBehavior.AllowGet);
是否https://earthscience.stackexchange.com /曲estions/7350/convert-grid-resolution-from-degrees-to-kilocity或https://stackoverflow.com/questions/13934169/system-data-spatial-dbgeography-distance-units help? – mjwills
@mjwills第一個鏈接它interessant,但它仍然很難.. –