/// <summary> /// Gets a list of coordinates that are related to the returned index of the elevation data. /// </summary> /// <returns>A list of coordinates that are related to the index of the returned elevation data.</returns> public List <Coordinate> GetElevationCoordinates() { if (Points != null && Points.Count > 0) { if (GetGeoidOffset || samples == 0) { return(Points); } else { //Calculate distance of polyline double totalDistance = 0; for (int i = 0; i < Points.Count - 1; i++) { totalDistance += SpatialTools.HaversineDistance(Points[i], Points[i + 1], DistanceUnitType.Kilometers); } double segementLength = totalDistance / samples; var coords = new List <Coordinate>(samples); coords.Add(Points[0]); int idx = 0; //Calculate equally spaced coordinates along polyline for (var s = 0; s < samples; s++) { double dist = 0; double travel = segementLength * s; double dx = travel; for (var i = 0; i < Points.Count - 1; i++) { dist += SpatialTools.HaversineDistance(Points[i], Points[i + 1], DistanceUnitType.Kilometers); if (dist >= travel) { idx = i; break; } dx = travel - dist; } if (dx != 0 && idx < Points.Count - 1) { var bearing = SpatialTools.CalculateBearing(Points[idx], Points[idx + 1]); coords.Add(SpatialTools.CalculateCoord(Points[idx], bearing, dx, DistanceUnitType.Kilometers)); } } return(coords); } } else if (Bounds != null) { double dLat = Math.Abs(Bounds.NorthLatitude - Bounds.SouthLatitude) / row; double dLon = Math.Abs(Bounds.WestLongitude - Bounds.EastLongitude) / col; double x, y; var coords = new Coordinate[row * col]; //The elevation values are ordered starting with the southwest corner, and then proceed west to east and south to north. for (int r = 0; r < row; r++) { y = Bounds.SouthLatitude + (dLat * r); for (int c = 0; c < col; c++) { x = Bounds.WestLongitude + (dLon * c); int idx = r * row + c; coords[idx] = new Coordinate() { Latitude = y, Longitude = x }; } } return(new List <Coordinate>(coords)); } return(null); }