public void ReadGpxFromFileTest_ReadFile() { var gpxBytes = CreateAnGpx.Bytes; MemoryStream stream = new MemoryStream(gpxBytes); var returnItem = ReadMetaGpx.ReadGpxFile(stream); Assert.AreEqual(5.485941, returnItem.FirstOrDefault().Longitude, 0.001); Assert.AreEqual(51.809360, returnItem.FirstOrDefault().Latitude, 0.001); DateTime.TryParseExact("2018-09-05T17:31:53Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out var expectDateTime); // gpx is always utc Assert.AreEqual(expectDateTime, returnItem.FirstOrDefault().DateTime); Assert.AreEqual("_20180905-fietsen-oss", returnItem.FirstOrDefault().Title); Assert.AreEqual(7.263, returnItem.FirstOrDefault().Altitude, 0.001); }
private List <GeoListItem> GetGpxFile(List <FileIndexItem> metaFilesInDirectory) { var geoList = new List <GeoListItem>(); foreach (var metaFileItem in metaFilesInDirectory) { if (!ExtensionRolesHelper.IsExtensionForceGpx(metaFileItem.FileName)) { continue; } if (!_iStorage.ExistFile(metaFileItem.FilePath)) { continue; } using (var stream = _iStorage.ReadStream(metaFileItem.FilePath)) { geoList.AddRange(ReadMetaGpx.ReadGpxFile(stream, geoList)); } } return(geoList); }