public void Read_ReadsAllEntitiesFromRealGpxFile() { var data = TestDataReader.Open("gpx-real-file.gpx"); List <IGpxGeometry> parsed = new List <IGpxGeometry>(); GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = true }); IGpxGeometry geometry = null; while ((geometry = target.Read()) != null) { parsed.Add(geometry); } // waypoints Assert.Equal(3, parsed.Where(g => g.GeometryType == GpxGeometryType.Waypoint).Count()); // routes Assert.Equal(2, parsed.Where(g => g.GeometryType == GpxGeometryType.Route).Count()); // tracks Assert.Single(parsed.Where(g => g.GeometryType == GpxGeometryType.Track)); }
public void Read_ReadsAllEntitiesFromRealGpxFile() { MemoryStream data = new MemoryStream(GpxTestData.gpx_real_file); List <IGpxGeometry> parsed = new List <IGpxGeometry>(); GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = true }); IGpxGeometry geometry = null; while ((geometry = target.Read()) != null) { parsed.Add(geometry); } // waypoints Assert.Equal(3, parsed.Where(g => g.GeometryType == GpxGeometryType.Waypoint).Count()); // routes Assert.Equal(2, parsed.Where(g => g.GeometryType == GpxGeometryType.Route).Count()); // tracks Assert.Equal(1, parsed.Where(g => g.GeometryType == GpxGeometryType.Track).Count()); }
/// <summary> /// Loads Gpx data from reader to this instance of the GpxDocument class /// </summary> /// <param name="reader">The reader to read data from</param> private void LoadFromReader(IGpxReader reader) { IGpxGeometry geometry = null; while ((geometry = reader.Read()) != null) { switch (geometry.GeometryType) { case GpxGeometryType.Waypoint: this.Waypoints.Add((GpxPoint)geometry); break; case GpxGeometryType.Route: this.Routes.Add((GpxRoute)geometry); break; case GpxGeometryType.Track: this.Tracks.Add((GpxTrack)geometry); break; } } }