private Postcode BuildPostcodeFromFields(String[] fields) { if (fields == null) { throw new ArgumentNullException("fields is null"); } Postcode newPostcode = new Postcode(); newPostcode.Value = fields[PostcodeIndex]; newPostcode.Value = Regex.Replace(newPostcode.Value, @"\s+", " "); double latitude = double.Parse(fields[LatitudeIndex]); if (!DecimalGeoCoordinate.IsValidLatitude(latitude)) { latitude = 0f; } double longitude = double.Parse(fields[LongitudeIndex]); if (!DecimalGeoCoordinate.IsValidLongitude(longitude)) { longitude = 0f; } newPostcode.Location = new DecimalGeoCoordinate(latitude, longitude); return(newPostcode); }
/// <summary> /// Get the elevation profile for a list of coordinates /// </summary> /// <param name="requiredFiles"></param> /// <param name="coordinates"></param> /// <returns></returns> private ElevationProfilePoint[] GetElevationProfileForCoordinates(ElevationFile[] requiredFiles, DecimalGeoCoordinate[] coordinates) { if (coordinates == null || coordinates.Length == 0) { return(new ElevationProfilePoint[0]); } List <ElevationProfilePoint> results = new List <ElevationProfilePoint>(); double distance = 0; DecimalGeoCoordinate previousPoint = coordinates[0]; for (int index = 0; index < coordinates.Length; index++) { var coordinate = coordinates[index]; var elevation = GetElevationAtCoordinate(requiredFiles, coordinate); distance += index == 0 ? 0 : Math.Round(coordinate.DistanceTo(coordinates[index - 1])); results.Add(new ElevationProfilePoint(coordinate, elevation, distance)); } return(results.ToArray()); }
/// <summary> /// Does the tile contain the specified co-ordinate? /// </summary> /// <param name="targetLocation"></param> /// <returns></returns> public bool ContainsCoordinate(DecimalGeoCoordinate targetLocation) { if (targetLocation == null) { throw new ArgumentNullException("targetLocation is null"); } if (targetLocation.Latitude < Location.Latitude) { return(false); } if (targetLocation.Latitude > Location.Latitude + 1) { return(false); } if (targetLocation.Longitude < Location.Longitude) { return(false); } if (targetLocation.Longitude > Location.Longitude + 1) { return(false); } return(true); }
private IEnumerable<DecimalGeoCoordinate> BuildLinePoints(double x1, double y1, double x2, double y2, int lineSegments) { List<DecimalGeoCoordinate> points = new List<DecimalGeoCoordinate>(); double dx = Math.Abs(x2 - x1); double dy = Math.Abs(y2 - y1); DecimalGeoCoordinate startPoint = new DecimalGeoCoordinate(x1, y1); DecimalGeoCoordinate endPoint = new DecimalGeoCoordinate(x2, y2); double lineIncrements = startPoint.DistanceTo(endPoint) / lineSegments; double xIncrement = (x2 > x1) ? dx / lineSegments : -(dx / lineSegments); double yIncrement = (y2 > y1) ? dy / lineSegments : -(dy / lineSegments); double currentX = startPoint.Latitude; double currentY = startPoint.Longitude; points.Add(startPoint); if (startPoint == endPoint) return points; for (double pointCount = 0; pointCount < lineSegments - 1; pointCount++) { currentX += xIncrement; currentY += yIncrement; points.Add(new DecimalGeoCoordinate(currentX, currentY)); } points.Add(endPoint); return points; }
/// <summary> /// Does the repository contain an elevation data set for the specified coordinate /// </summary> /// <param name="testCoordinate"></param> /// <returns></returns> public bool IsElevationDataSetAvailable(DecimalGeoCoordinate testCoordinate) { String fullFilePath = GetFullFilePathFromTileCoordinate(testCoordinate); if (String.IsNullOrEmpty(fullFilePath)) return false; return true; }
public void Constructor_InitialiseWithInvalidLongitude_ThrowArgumentOutOfRangeException() { // Arrange double longitude = -180.01; double latitude = 0; // Act _sut = new DecimalGeoCoordinate(latitude, longitude); }
public void Constructor_InitialiseWithParams_HasValidParamsAfterInitialisation() { DecimalGeoCoordinate geoCoordinate = new DecimalGeoCoordinate(1.5, 1.8); short elevation = 1555; ElevationDataPoint sut = new ElevationDataPoint(geoCoordinate, elevation); Assert.IsTrue(sut.Coordinates == geoCoordinate); Assert.IsTrue(sut.ElevationInMetres == elevation); }
/// <summary> /// Get an elevation data set for the requested coordinate /// </summary> /// <param name="dataSetLocation"></param> /// <returns></returns> public IElevationDataSet GetElevationDataSet(DecimalGeoCoordinate dataSetLocation) { if (dataSetLocation == null) throw new ArgumentNullException("dataSetLocation is null"); DecimalGeoCoordinate roundedCoordinate = new DecimalGeoCoordinate( Math.Floor(dataSetLocation.Latitude), Math.Floor(dataSetLocation.Longitude)); return LoadElevationDataSetFromStore(roundedCoordinate); }
public void Constructor_PassZeroRowLength_ThrowInvalidOperationException() { // Arrange List<Int16> data = new List<Int16>(); ArcSecondResolution resolution = ArcSecondResolution.One; DecimalGeoCoordinate coordinate = new DecimalGeoCoordinate(); int rowLength = 0; // Act _sut = new ElevationDataSet("", data, resolution, coordinate, rowLength); }
/// <summary> /// Retrieve the elevation for the specified coordinate /// </summary> /// <param name="dataSetLocation"></param> /// <returns></returns> public int GetElevationAtCoordinate(DecimalGeoCoordinate coordinate) { if (coordinate == null) { throw new NullReferenceException("location is null"); } var index = ElevationFile.GetIndexAtCoordinate(coordinate); return(_data[index]); }
public IElevationProfile GetElevationProfile(DecimalGeoCoordinate startCoordinate, DecimalGeoCoordinate endCoordinate, int lineSegments) { if (startCoordinate == null) throw new ArgumentNullException("startCoordinate is null"); if (endCoordinate == null) throw new ArgumentNullException("endCoordinate, is null"); List<ElevationDataPoint> elevationProfilePoints = BuildElevationProfileSection(startCoordinate, endCoordinate, lineSegments); return new ElevationProfile(elevationProfilePoints.AsReadOnly()); }
/// <summary> /// Get the elevation at the specified coordinates /// </summary> /// <param name="targetLocation"></param> /// <returns></returns> public Int16 GetElevationAtCoordinate(DecimalGeoCoordinate targetLocation) { if (targetLocation == null) throw new ArgumentNullException("targetLocation"); IElevationDataSet targetDataSet = GetElevationDataSet(targetLocation); if (targetDataSet == null) throw new ElevationDataSetNotLoadedException(String.Format("Unable to load a data set for the location {0}.", targetLocation.ToString())); return targetDataSet.GetElevationAtCoordinate(targetLocation); }
/// <summary> /// Get an elevation data set for the specified coordinates. /// </summary> /// <param name="dataSetLocation"></param> /// <returns></returns> public IElevationDataSet GetElevationDataSetAtCoordinate(DecimalGeoCoordinate dataSetLocation) { if (dataSetLocation == null) throw new ArgumentNullException("dataSetLocation is null"); IElevationDataSet targetDataSet = GetElevationDataSet(dataSetLocation); if (targetDataSet == null) throw new ElevationDataSetNotLoadedException(String.Format("No data set for the specified location {0} exists.", dataSetLocation.ToString())); return targetDataSet; }
public void EqualsOperator_CompareEqualDecimalGeoCoordinates_ReturnsTrue() { // Arrange DecimalGeoCoordinate testCoordinate = new DecimalGeoCoordinate(1.50000001, 5.9); _sut = new DecimalGeoCoordinate(1.50000001, 5.9); // Act bool areEqual = _sut == testCoordinate; // Assert Assert.IsTrue(areEqual); }
public void Constructor_InitialiseWithValidLatitudeAndLongitude_PropertiesCorrectlyInitialised() { // Arrange double longitude = 1.5; double latitude = 18.88; // Act _sut = new DecimalGeoCoordinate(latitude, longitude); Assert.AreEqual(_sut.Latitude, latitude); Assert.AreEqual(_sut.Longitude, longitude); }
public void DistanceTo_PassValidCoordinate_ReturnsCorrectDistance() { // Arrange DecimalGeoCoordinate testCoordinate = new DecimalGeoCoordinate(1.6, 15.0); _sut = new DecimalGeoCoordinate(11.2, 12.0); // Act double distance = _sut.DistanceTo(testCoordinate); // Assert Assert.IsTrue(Math.Truncate(distance) == 1117643); }
public void BuildPath_PassEqualStartAndEndCoordinates_ReturnsOnlyStartCoordinate() { // Arrange DecimalGeoCoordinate startCoordinate = new DecimalGeoCoordinate(1, 1); DecimalGeoCoordinate endCoordinate = new DecimalGeoCoordinate(1, 1); // Act List<DecimalGeoCoordinate> linePoints = new List<DecimalGeoCoordinate>(_sut.BuildPath(startCoordinate, endCoordinate, 1)); // Assert Assert.IsTrue(linePoints.Count == 1); Assert.IsTrue(linePoints[0] == startCoordinate); }
/// <summary> /// Creates a correctly formated .hgt filename from a geo-coordinate /// </summary> /// <param name="geoCoordinate"></param> /// <returns></returns> public string ParseFileNameFromGeoCoordinate(DecimalGeoCoordinate geoCoordinate) { bool isSouth = geoCoordinate.Latitude <= 0; bool isWest = geoCoordinate.Longitude < 0; double roundedLatitude = Math.Floor(geoCoordinate.Latitude); double roundedLongitude = Math.Floor(geoCoordinate.Longitude); String latitudeString = GetLatitudeAsString(roundedLatitude, isSouth); String longitudeString = GetLongitudeAsString(roundedLongitude, isWest); return($"{latitudeString}{longitudeString}.hgt"); }
/// <summary> /// Build a straight line between startCoordinate/endCoordinate with the resolution defined by the lineSegments /// </summary> /// <param name="startCoordinate"></param> /// <param name="endCoordinate"></param> /// <param name="lineSegments"></param> /// <returns></returns> public IEnumerable<DecimalGeoCoordinate> BuildPath(DecimalGeoCoordinate coord1, DecimalGeoCoordinate coord2, int lineSegments) { if (coord1 == null) throw new ArgumentNullException("coord1 is null"); if (coord2 == null) throw new ArgumentNullException("coord2 is null"); return BuildLinePoints( coord1.Latitude, coord1.Longitude, coord2.Latitude, coord2.Longitude, lineSegments); }
public ElevationDataSet(String name, IEnumerable<Int16> rawData, ArcSecondResolution resolution, DecimalGeoCoordinate location, int rowLength) { if (rawData == null) throw new ArgumentNullException("rawData is null"); if (rowLength <= 0) throw new InvalidOperationException("rowLength <= 0"); _rawData = new List<Int16>(rawData); _rowLength = rowLength; Name = name; Resolution = resolution; Location = location; IsEmptyDataSet = false; }
static void Main(string[] args) { String demDataFolder = @"D:\\Code\\Projects\\DEMData\\"; IHgtFileNameParser fileNameParser = new HgtFileNameParser(); IHgtByteConverter byteConverter = new HgtByteConverter(); IAzureFileStorageShareProvider azureStorageProvider = new AzureFileStorageShareProvider( System.Configuration.ConfigurationManager.AppSettings["StorageConnectionString"], "hgt"); IElevationFileReader elevationFileReader = new LocalFileStorageHgtElevationFileReader(fileNameParser, byteConverter); IElevationFileReader azureFileReader = new AzureFileStorageHgtElevationFileReader(fileNameParser, byteConverter, azureStorageProvider); CloudFileDirectory cloudDirectoryRoot = azureStorageProvider.GetCloudFileShare().GetRootDirectoryReference(); IElevationDataSet azureTestSet = azureFileReader.LoadDataSet( Path.Combine(cloudDirectoryRoot.Uri.ToString(), "N48E000.hgt")); IElevationDataSetRepository dataSetRepository = new ElevationDataSetFileSystemRepository( azureFileReader, fileNameParser, demDataFolder); IElevationDataManager elevationDataManager = new ElevationDataManager(dataSetRepository); DecimalGeoCoordinate testCoordinate = new DecimalGeoCoordinate(54.5, -2.5); int elevation; if (elevationDataManager.IsElevationDataSetAvailable(testCoordinate)) elevation = elevationDataManager.GetElevationAtCoordinate(testCoordinate); IElevationProfiler elevationProfiler = new ElevationProfiler( elevationDataManager, new SimplePathPlotter()); // Used to draw the line by the elevation profiler IElevationProfile elevationProfile = elevationProfiler.GetElevationProfile( new DecimalGeoCoordinate(55.1, -2.1), // Start of line new DecimalGeoCoordinate(55.2, -2.2), // End of line 100); // Number of segments or 'resolution' of the profile IElevationProfile elevationProfile2 = elevationProfiler.GetElevationProfile( new List<DecimalGeoCoordinate>() { new DecimalGeoCoordinate(52, -1), new DecimalGeoCoordinate(52.2, -1.2), new DecimalGeoCoordinate(52.2, -1.4) }, 10); foreach (ElevationDataPoint point in elevationProfile.Points) Console.WriteLine("{0} {1}", point.Coordinates, point.ElevationInMetres); Console.ReadKey(); }
public ElevationFile(String filePath, DecimalGeoCoordinate location, TileResolution resolution) { if (filePath == null) { throw new ArgumentNullException("filePath"); } if (!File.Exists(filePath)) { throw new FileNotFoundException(filePath); } Resolution = resolution; Location = location; FilePath = filePath; }
public void Constructor_PassValidParameters_PropertiesAreCorrectlyAssigned() { // Arrange List<Int16> data = new List<Int16>(); ArcSecondResolution resolution = ArcSecondResolution.Three; DecimalGeoCoordinate coordinate = new DecimalGeoCoordinate(); int rowLength = ElevationDataConstants.ThreeArcSecondResolutionRowLength; // Act _sut = new ElevationDataSet("", data, resolution, coordinate, rowLength); // Assert Assert.AreEqual(_sut.Resolution, resolution); Assert.IsTrue(_sut.Location.Equals(coordinate)); }
/// <summary> /// Get the elevation reading at the specified coordinate /// </summary> /// <param name="index"></param> /// <returns></returns> public short GetElevationAtCoordinate(DecimalGeoCoordinate coordinate) { int index = GetIndexAtCoordinate(coordinate); using (var fileStream = File.Open(FilePath, FileMode.Open, FileAccess.Read, FileShare.Read)) { fileStream.Seek(index * 2, SeekOrigin.Begin); byte[] byteData = new byte[2]; fileStream.Read(byteData, 0, 2); short elevation = ConvertToShort(byteData); return(elevation); } }
public bool DoesContainCoordinate(DecimalGeoCoordinate targetLocation) { if (targetLocation == null) throw new ArgumentNullException("targetLocation is null"); if (targetLocation.Latitude < Location.Latitude) return false; if (targetLocation.Latitude > Location.Latitude + 1) return false; if (targetLocation.Longitude < Location.Longitude) return false; if (targetLocation.Longitude > Location.Longitude + 1) return false; return true; }
public void DoesContainCoordinate_LatAndLongAreInsideDataSetCoverage_ReturnsTrue() { // Arrange List<Int16> data = new List<Int16>(); ArcSecondResolution resolution = ArcSecondResolution.Three; DecimalGeoCoordinate coordinate = new DecimalGeoCoordinate(5, 5); DecimalGeoCoordinate targetLocation = new DecimalGeoCoordinate(5.99, 5.01); _sut = new ElevationDataSet("", data, resolution, coordinate, 1); // Act bool isContainedInDataSet = _sut.DoesContainCoordinate(targetLocation); // Assert Assert.IsTrue(isContainedInDataSet); }
/// <summary> /// Try to parse out a DecimalGeoCoordinate from a string /// </summary> /// <param name="coordString"></param> /// <param name="geoCoordinate"></param> /// <returns></returns> private bool TryParseDecimalGeoCoordinateFromString(String coordString, out DecimalGeoCoordinate geoCoordinate) { geoCoordinate = new DecimalGeoCoordinate(0, 0); String pattern = @"^-?\d{1,}\.?\d*,-?\d{1,}\.?\d*$"; if (!Regex.IsMatch(coordString, pattern)) return false; String[] splitCoordString = coordString.Split(','); double latitude = double.Parse(splitCoordString[0]); double longitude = double.Parse(splitCoordString[1]); geoCoordinate = new DecimalGeoCoordinate(latitude, longitude); return true; }
/// <summary> /// Get the relative file index for the specified coordinate within the tile /// </summary> /// <param name="coordinate"></param> /// <returns></returns> public int GetIndexAtCoordinate(DecimalGeoCoordinate coordinate) { if (coordinate == null) { throw new NullReferenceException("location is null"); } if (!ContainsCoordinate(coordinate)) { throw new ArgumentOutOfRangeException($"'{coordinate.ToString()}' is not contained within specified file '{FilePath}'."); } double relativeLatitude = (coordinate.Latitude - Location.Latitude); double relativeLongitude = (coordinate.Longitude - Location.Longitude); int latitudeRow = (int)Math.Round(relativeLatitude * (Resolution.RowLength - 1)); int longitudeColumn = (int)Math.Round(relativeLongitude * (Resolution.RowLength - 1)); latitudeRow = InvertIndex(latitudeRow, Resolution.RowLength - 1); return(ConvertXYtoIndex(longitudeColumn, latitudeRow, Resolution.RowLength)); }
public void BuildPath_ThirdQuadrantLine_ReturnsValidLinePoints() { // Arrange DecimalGeoCoordinate startCoordinate = new DecimalGeoCoordinate(0, 0); DecimalGeoCoordinate endCoordinate = new DecimalGeoCoordinate(-1, -1); List<DecimalGeoCoordinate> testDataList = new List<DecimalGeoCoordinate>(); testDataList.Add(new DecimalGeoCoordinate(0, 0)); testDataList.Add(new DecimalGeoCoordinate(-0.2, -0.2)); testDataList.Add(new DecimalGeoCoordinate(-0.4, -0.4)); testDataList.Add(new DecimalGeoCoordinate(-0.6, -0.6)); testDataList.Add(new DecimalGeoCoordinate(-0.8, -0.8)); testDataList.Add(new DecimalGeoCoordinate(-1, -1)); // Act List<DecimalGeoCoordinate> linePoints = new List<DecimalGeoCoordinate>( _sut.BuildPath(startCoordinate, endCoordinate, 5)); // Assert Assert.IsTrue(AreDecimalGeoCoordinateListsEqual(linePoints, testDataList)); }
/// <summary> /// Creates a correctly formated .hgt filename from a geo-coordinate /// </summary> /// <param name="geoCoordinate"></param> /// <returns></returns> public string ParseFileNameFromGeoCoordinate(DecimalGeoCoordinate geoCoordinate) { if (geoCoordinate == null) throw new ArgumentNullException("geoCoordinate is null"); bool isSouth = geoCoordinate.Latitude <= 0; bool isWest = geoCoordinate.Longitude < 0; double roundedLatitude = Math.Floor(geoCoordinate.Latitude); double roundLongitude = Math.Floor(geoCoordinate.Longitude); String latitudeString = GetLatitudeAsString(roundedLatitude, isSouth); String longitudeString = GetLongitudeAsString(roundLongitude, isWest); String fileName = String.Format("{0}{1}", latitudeString, longitudeString); if (!IsValidHGTFileNameFormat(fileName)) throw new ArgumentException(String.Format("'{0}' is and invalid file name format for a .hgt file", fileName)); fileName += ".hgt"; return fileName; }
/// <summary> /// Load an elevation data set from a file. /// </summary> /// <param name="tileCoordinate"></param> /// <returns></returns> private IElevationDataSet LoadElevationDataSetFromStore(DecimalGeoCoordinate tileCoordinate) { String fullFilePath = GetFullFilePathFromTileCoordinate(tileCoordinate); return _elevationFileReader.LoadDataSet(fullFilePath); }
public ElevationProfilePoint(DecimalGeoCoordinate coordinate, short elevation, double distance) { Coordinate = coordinate; ElevationInMetres = elevation; Distance = distance; }
public void EqualsOperator_CompareNonEqualDecimalGeoCoordinates_ReturnsFalse() { // Arrange DecimalGeoCoordinate testCoordinate = new DecimalGeoCoordinate(1.6, 15.0); _sut = new DecimalGeoCoordinate(11.2, 12.0); // Act bool areEqual = _sut == testCoordinate; // Assert Assert.IsFalse(areEqual); }
public EmptyElevationDataSet(DecimalGeoCoordinate location) : base() { Location = location; }
public Task BindModelAsync(ModelBindingContext bindingContext) { if (bindingContext == null) { throw new ArgumentNullException(nameof(bindingContext)); } var modelName = bindingContext.BinderModelName; if (String.IsNullOrEmpty(modelName)) { modelName = "coordinates"; } var valueProviderResult = bindingContext.ValueProvider.GetValue(modelName); if (valueProviderResult == ValueProviderResult.None) { return(TaskCache.CompletedTask); } bindingContext.ModelState.SetModelValue(modelName, valueProviderResult); var value = valueProviderResult.FirstValue; if (String.IsNullOrEmpty(value)) { return(TaskCache.CompletedTask); } var coordinates = new List <DecimalGeoCoordinate>(); var coordinateStrings = value.Split('|'); foreach (var coordinateString in coordinateStrings) { string[] latAndLong = coordinateString.Split(','); if (latAndLong.Length != 2) { bindingContext.ModelState.TryAddModelError(bindingContext.ModelName, "Invalid coordinate format."); return(TaskCache.CompletedTask); } var latitudeString = latAndLong[0]; var longitudeString = latAndLong[1]; DecimalGeoCoordinate coordinate; if (!DecimalGeoCoordinate.TryParse(latitudeString, longitudeString, out coordinate)) { bindingContext.ModelState.TryAddModelError(bindingContext.ModelName, $"Invalid coordinate: {latitudeString}, {longitudeString}"); return(TaskCache.CompletedTask); } coordinates.Add(coordinate); } bindingContext.Result = ModelBindingResult.Success(coordinates.ToArray()); return(TaskCache.CompletedTask); }
public override short GetElevationAtCoordinate(DecimalGeoCoordinate targetLocation) { return short.MinValue; }
public ElevationPoint(DecimalGeoCoordinate coordinates, short elevationInMetres) : this() { Coordinates = coordinates; ElevationInMetres = elevationInMetres; }
/// <summary> /// Retrieve the elevation at a specified Longitude and Latitude in decimal format /// </summary> /// <param name="dataSetLocation"></param> /// <returns></returns> public virtual Int16 GetElevationAtCoordinate(DecimalGeoCoordinate targetLocation) { if(targetLocation == null) throw new NullReferenceException("location is null"); if (!this.DoesContainCoordinate(targetLocation)) throw new ArgumentOutOfRangeException("targetLocation is not contained within this data set"); double relativeLatitude = (targetLocation.Latitude - Location.Latitude); double relativeLongitude = (targetLocation.Longitude - Location.Longitude); int latitudeRow = (int)Math.Round(relativeLatitude * (_rowLength - 1)); int longitudeColumn = (int)Math.Round(relativeLongitude * (_rowLength - 1)); latitudeRow = InvertIndex(latitudeRow, _rowLength - 1); int index = ConvertXYtoIndex(longitudeColumn, latitudeRow, _rowLength); return _rawData[index]; }
/// <summary> /// Check whether an elevation data set is available in the data manager or the repository /// </summary> /// <param name="dataSetLocation"></param> /// <returns></returns> public bool IsElevationDataSetAvailable(DecimalGeoCoordinate dataSetLocation) { if (_dataSetRepository.IsElevationDataSetAvailable(dataSetLocation)) return true; return false; }
/// <summary> /// Build a section of an elevation profile /// </summary> /// <param name="startCoordinate"></param> /// <param name="endCoordinate"></param> /// <param name="lineSegments"></param> /// <returns></returns> private List<ElevationDataPoint> BuildElevationProfileSection(DecimalGeoCoordinate startCoordinate, DecimalGeoCoordinate endCoordinate, int lineSegments) { IEnumerable<DecimalGeoCoordinate> points = _pathPlotter.BuildPath(startCoordinate, endCoordinate, lineSegments); List<ElevationDataPoint> elevationProfilePoints = new List<ElevationDataPoint>(); foreach (DecimalGeoCoordinate pt in points) { Int16 elevation = _elevationDataManager.GetElevationAtCoordinate(pt); elevationProfilePoints.Add(new ElevationDataPoint(pt, elevation)); } return elevationProfilePoints; }
/// <summary> /// Retrieve the elevation for a coordinate from a set of elevation data sets /// </summary> /// <param name="elevationFiles"></param> /// <param name="coordinate"></param> /// <returns></returns> private short GetElevationAtCoordinate(ElevationFile[] elevationFiles, DecimalGeoCoordinate coordinate) { var fileContainingCoordinate = elevationFiles.FirstOrDefault(f => f.ContainsCoordinate(coordinate)); return(fileContainingCoordinate.GetElevationAtCoordinate(coordinate)); }
/// <summary> /// Attempts to retrieve an elevation data set if already loaded, if not tries from the repository /// </summary> /// <param name="targetLocation"></param> /// <returns></returns> private IElevationDataSet GetElevationDataSet(DecimalGeoCoordinate targetLocation) { IElevationDataSet targetDataSet = _loadedDataSets .Where(d => d.DoesContainCoordinate(targetLocation)) .FirstOrDefault(); if (targetDataSet == null) { targetDataSet = _dataSetRepository.GetElevationDataSet(targetLocation); _loadedDataSets.Add(targetDataSet); } return targetDataSet; }