Created
June 4, 2012 19:51
-
-
Save tugberkugurlu/2870461 to your computer and use it in GitHub Desktop.
System.Data.Spatial.DbGeography sample (Latitude and Longitude).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program { | |
public class Db { | |
public static Dictionary<string, DbGeography> Locations = new Dictionary<string, DbGeography>() { | |
//instert the place locations here... | |
}; | |
} | |
static void Main(string[] args) { | |
// POINT(Long Lat) | |
var myLocation = DbGeography.FromText("POINT(-117.861328 34.089061)"); | |
//Order by distance (nearest one is at the top) | |
var locations = from location in Db.Locations | |
orderby location.Value.Distance(myLocation) | |
select location; | |
//get the nearest 10 hotels | |
foreach (var hotelLocation in locations.Take(10)) { | |
Console.WriteLine(hotelLocation.Key); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good example, Thanks