This repository has been archived by the owner on May 12, 2023. It is now read-only.
forked from kb0/dart-gpx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
220 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
library gpx.test.gpx_reader_test; | ||
|
||
import 'dart:convert'; | ||
import 'dart:io'; | ||
|
||
import 'package:gpx/gpx.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
import 'utils.dart'; | ||
|
||
void main() { | ||
test('read gpx with multiply points', () async { | ||
final gpx = await GpxReader() | ||
.fromStream(File('test/assets/wpt.gpx').openRead() | ||
.transform(utf8.decoder)); | ||
final src = createGPXWithWpt(); | ||
|
||
expect(gpx, src); | ||
}); | ||
|
||
test('read gpx with multiply routes', () async { | ||
final gpx = await GpxReader() | ||
.fromStream(File('test/assets/rte.gpx').openRead() | ||
.transform(utf8.decoder)); | ||
final src = createGPXWithRte(); | ||
|
||
expect(gpx, src); | ||
}); | ||
|
||
test('read gpx with multiply tracks', () async { | ||
final gpx = await GpxReader() | ||
.fromStream(File('test/assets/trk.gpx').openRead() | ||
.transform(utf8.decoder)); | ||
final src = createGPXWithTrk(); | ||
|
||
expect(gpx, src); | ||
}); | ||
|
||
test('read complex gpx', () async { | ||
final gpx = await GpxReader() | ||
.fromStream(File('test/assets/complex.gpx').openRead() | ||
.transform(utf8.decoder)); | ||
final src = createComplexGPX(); | ||
|
||
expect(gpx.metadata, src.metadata); | ||
expect(gpx.extensions, src.extensions); | ||
expect(gpx.wpts, src.wpts); | ||
expect(gpx.trks, src.trks); | ||
expect(gpx.rtes, src.rtes); | ||
expect(gpx, src); | ||
}); | ||
|
||
test('read metadata gpx', () async { | ||
final gpx = await GpxReader() | ||
.fromStream(File('test/assets/metadata.gpx').openRead() | ||
.transform(utf8.decoder)); | ||
final src = createMetadataGPX(); | ||
|
||
expect(gpx.metadata, src.metadata); | ||
expect(gpx, src); | ||
}); | ||
|
||
test('read large', () async { | ||
final gpx = await GpxReader() | ||
.fromStream(File('test/assets/large.gpx').openRead() | ||
.transform(utf8.decoder)); | ||
|
||
expect(gpx.trks.length, 1); | ||
expect(gpx.trks.first.trksegs.length, 1); | ||
expect(gpx.trks.first.trksegs.first.trkpts.length, 8139); | ||
}); | ||
|
||
test('issue-4 FixType', () async { | ||
final gpx = await GpxReader() | ||
.fromStream(File('test/assets/fix.gpx').openRead() | ||
.transform(utf8.decoder)); | ||
|
||
expect(gpx.wpts[0].fix, FixType.fix_2d); | ||
expect(gpx.wpts[1].fix, FixType.fix_3d); | ||
expect(gpx.wpts[2].fix, FixType.none); | ||
|
||
final gpxUnknown = GpxReader() | ||
.fromString(await File('test/assets/fix_unknown.gpx').readAsString()); | ||
expect(gpxUnknown.wpts[0].fix, null); | ||
}); | ||
|
||
test('issue-4', () async { | ||
final gpx = await GpxReader() | ||
.fromStream(File('test/assets/20160617-La-Hermida-to-Bejes.gpx').openRead() | ||
.transform(utf8.decoder)); | ||
|
||
expect(gpx.creator, 'MapGazer 1.86'); | ||
expect(gpx.metadata!.links.length, 1); | ||
expect(gpx.metadata!.links.first.text, 'MapGazer website'); | ||
expect(gpx.metadata!.links.first.href, 'http://speleotrove.com/mapgazer/'); | ||
|
||
expect(gpx.wpts.length, 3); | ||
expect(gpx.wpts.first.fix, FixType.fix_3d); | ||
expect(gpx.wpts.first.name, 'La Hermida'); | ||
expect(gpx.wpts.first.desc, 'At 43.25473N, 4.61518W'); | ||
|
||
expect(gpx.trks.length, 1); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
library kml.test.kml_reader_test; | ||
|
||
import 'dart:convert'; | ||
import 'dart:io'; | ||
|
||
import 'package:gpx/gpx.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
import 'kml_utils.dart'; | ||
|
||
void main() { | ||
test('read kml with multiply points', () async { | ||
final kml = await KmlReader() | ||
.fromStream(File('test/assets/wpt.kml').openRead() | ||
.transform(utf8.decoder)); | ||
final src = createKmlWithWpt(); | ||
|
||
expect(kml, src); | ||
}); | ||
|
||
test('read kml with multiply routes', () async { | ||
final kml = await KmlReader() | ||
.fromStream(File('test/assets/rte.kml').openRead() | ||
.transform(utf8.decoder)); | ||
final src = createGPXWithRte(); | ||
|
||
expect(kml, src); | ||
}); | ||
|
||
test('read kml with multiply tracks', () async { | ||
final kml = await KmlReader() | ||
.fromStream(File('test/assets/trk.kml').openRead() | ||
.transform(utf8.decoder)); | ||
final src = createGPXWithTrk(); | ||
|
||
expect(kml, src); | ||
}); | ||
|
||
test('read complex kml', () async { | ||
final kml = await KmlReader() | ||
.fromStream(File('test/assets/complex.kml').openRead() | ||
.transform(utf8.decoder)); | ||
final src = createComplexKml(); | ||
|
||
expect(kml.metadata, src.metadata); | ||
expect(kml.extensions, src.extensions); | ||
expect(kml.wpts, src.wpts); | ||
expect(kml.rtes, src.rtes); | ||
expect(kml, src); | ||
}); | ||
|
||
test('read metadata kml', () async { | ||
final kml = await KmlReader() | ||
.fromStream(File('test/assets/metadata.kml').openRead() | ||
.transform(utf8.decoder)); | ||
final src = createMetadataKml(); | ||
|
||
expect(kml.metadata, src.metadata); | ||
expect(kml, src); | ||
}); | ||
|
||
test('read large', () async { | ||
//final kml = await KmlReader().fromStream(File('test/assets/large.kml').readAsString().asStream()); | ||
|
||
final kml = await KmlReader() | ||
.fromStream(File('test/assets/metadata.kml').openRead() | ||
.transform(utf8.decoder)); | ||
|
||
expect(kml.rtes.length, 1); | ||
expect(kml.rtes.first.rtepts.length, 8139); | ||
}); | ||
} |