11package ch.bailu.aat_lib.file.xml.writer
22
33import ch.bailu.aat_lib.file.xml.parser.gpx.GpxListReaderXml
4+ import ch.bailu.aat_lib.gpx.GpxList
5+ import ch.bailu.aat_lib.gpx.GpxListIterator
46import ch.bailu.aat_lib.gpx.attributes.AutoPause
7+ import ch.bailu.aat_lib.gpx.attributes.GpxListAttributes
8+ import ch.bailu.aat_lib.gpx.interfaces.GpxType
59import ch.bailu.aat_lib.mock.MockAppConfig
610import ch.bailu.aat_lib.mock.MockFoc
711import ch.bailu.foc_extended.FocResource
@@ -16,12 +20,27 @@ class GpxListWriterTest {
1620 MockAppConfig .init ()
1721
1822 val mockFoc = MockFoc (" only-in-memory.gpx" )
19-
2023 val reader = GpxListReaderXml (FocResource (" test.gpx" ), AutoPause .NULL )
24+
2125 assertEquals(1855 , reader.gpxList.pointList.size())
2226
27+ val gpxList = GpxList (GpxType .TRACK , GpxListAttributes .NULL )
28+
2329 // Write and then close file
24- GpxListWriter (reader.gpxList, mockFoc).use { }
30+ GpxListWriter (gpxList, mockFoc).use {
31+ val gpxListIterator = GpxListIterator (reader.gpxList)
32+
33+ while (gpxListIterator.nextPoint()) {
34+ val point = gpxListIterator.getPoint()
35+
36+ if (gpxListIterator.isFirstInSegment) {
37+ gpxList.appendToNewSegment(point.point, point.getAttributes())
38+ } else {
39+ gpxList.appendToCurrentSegment(point.point, point.getAttributes())
40+ }
41+ it.writeNewPoints()
42+ }
43+ }
2544
2645 val linesWritten = mockFoc.getLines()
2746
0 commit comments