DataQueryFindNearestLines Method (LatLon, String, Double, CancellationToken) |
Namespace: Telogis.GeoBase
public static Line[] FindNearestLines( LatLon location, string tableName, double simplificationLevel, CancellationToken token )
// Query a location in Los Angeles, USA LatLon queryLocation = new LatLon(33.767528,-118.092072); CancellationToken token = new CancellationToken(); // Get the first line result from the array. 500 meters per pixel // Available line tables 'all', 'railways', 'rivers', 'canals' Line result = DataQuery.FindNearestLines(queryLocation, "railways", 500, token)[0]; // Convert to human-friendly number Double dist = result.DistanceTo(queryLocation, DistanceUnit.MILES); Decimal distShort = (Decimal)(Math.Truncate((Double)dist * 100.0) / 100.0); // Write the distance to the console Console.WriteLine("The nearest railway line is {0} miles from the query location", distShort); // 'The nearest railway line is 5.36 miles from the query location'