Skip to content
This repository was archived by the owner on Aug 16, 2025. It is now read-only.

Commit dc35dd6

Browse files
committed
trackPoint -> trackpoint
1 parent d56ee12 commit dc35dd6

File tree

6 files changed

+81
-87
lines changed

6 files changed

+81
-87
lines changed

src/main/kotlin/de/storchp/opentracks/osmplugin/MapsActivity.kt

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ import de.storchp.opentracks.osmplugin.utils.MapMode
3939
import de.storchp.opentracks.osmplugin.utils.MapUtils
4040
import de.storchp.opentracks.osmplugin.utils.PreferencesUtils
4141
import de.storchp.opentracks.osmplugin.utils.TrackColorMode
42-
import de.storchp.opentracks.osmplugin.utils.TrackPointsDebug
4342
import de.storchp.opentracks.osmplugin.utils.TrackStatistics
43+
import de.storchp.opentracks.osmplugin.utils.TrackpointsDebug
4444
import okhttp3.Cache
4545
import okhttp3.OkHttpClient
4646
import org.oscim.android.MapPreferences
@@ -126,11 +126,11 @@ open class MapsActivity : BaseActivity(), OnItemGestureListener<MarkerInterface?
126126
private var mapMode: MapMode = MapMode.NORTH
127127
private var contentObserver: OpenTracksContentObserver? = null
128128
private var tracksUri: Uri? = null
129-
private var trackPointsUri: Uri? = null
129+
private var trackpointsUri: Uri? = null
130130
private var waypointsUri: Uri? = null
131131
private var strokeWidth = 0
132132
private var protocolVersion = 1
133-
private var trackPointsDebug: TrackPointsDebug? = null
133+
private var trackpointsDebug: TrackpointsDebug? = null
134134

135135
override fun onCreate(savedInstanceState: Bundle?) {
136136
super.onCreate(savedInstanceState)
@@ -212,15 +212,15 @@ open class MapsActivity : BaseActivity(), OnItemGestureListener<MarkerInterface?
212212
intent.getParcelableArrayListExtra<Uri>(APIConstants.ACTION_DASHBOARD_PAYLOAD)!!
213213
protocolVersion = intent.getIntExtra(EXTRAS_PROTOCOL_VERSION, 1)
214214
tracksUri = APIConstants.getTracksUri(uris)
215-
trackPointsUri = APIConstants.getTrackPointsUri(uris)
215+
trackpointsUri = APIConstants.getTrackpointsUri(uris)
216216
waypointsUri = APIConstants.getWaypointsUri(uris)
217217
keepScreenOn(intent.getBooleanExtra(EXTRAS_SHOULD_KEEP_SCREEN_ON, false))
218218
showOnLockScreen(intent.getBooleanExtra(EXTRAS_SHOW_WHEN_LOCKED, false))
219219
showFullscreen(intent.getBooleanExtra(EXTRAS_SHOW_FULLSCREEN, false))
220220
isOpenTracksRecordingThisTrack =
221221
intent.getBooleanExtra(EXTRAS_OPENTRACKS_IS_RECORDING_THIS_TRACK, false)
222222

223-
trackPointsUri?.let { readTrackpoints(it, false, protocolVersion) }
223+
trackpointsUri?.let { readTrackpoints(it, false, protocolVersion) }
224224
readTracks(tracksUri!!)
225225
waypointsUri?.let { readWaypoints(it) }
226226
} else if ("geo" == intent.scheme && intent.data != null) {
@@ -563,7 +563,7 @@ open class MapsActivity : BaseActivity(), OnItemGestureListener<MarkerInterface?
563563

564564
try {
565565
val trackpointsBySegments: TrackpointsBySegments =
566-
TrackpointReader.readTrackPointsBySegments(
566+
TrackpointReader.readTrackpointsBySegments(
567567
contentResolver,
568568
data,
569569
lastTrackPointId,
@@ -582,22 +582,23 @@ open class MapsActivity : BaseActivity(), OnItemGestureListener<MarkerInterface?
582582
trackColorMode = DEFAULT_TRACK_COLOR_MORE
583583
}
584584

585-
for (trackPoints in trackpointsBySegments.segments) {
586-
var trackPoints = trackPoints
585+
trackpointsBySegments.segments.map { trackpoints ->
587586
if (!update) {
588587
polyline = null // cut polyline on new segment
589588
if (tolerance > 0) { // smooth track
590-
trackPoints = MapUtils.decimate(tolerance, trackPoints)
589+
return@map MapUtils.decimate(tolerance, trackpoints)
591590
}
592591
}
593-
for (trackPoint in trackPoints) {
594-
lastTrackPointId = trackPoint.trackPointId
592+
return@map trackpoints
593+
}.forEach { trackpoints ->
594+
trackpoints.forEach { trackpoint ->
595+
lastTrackPointId = trackpoint.id
595596

596-
if (trackPoint.trackId != lastTrackId) {
597+
if (trackpoint.trackId != lastTrackId) {
597598
if (trackColorMode == TrackColorMode.BY_TRACK) {
598599
trackColor = colorCreator!!.nextColor()
599600
}
600-
lastTrackId = trackPoint.trackId
601+
lastTrackId = trackpoint.trackId
601602
polyline = null // reset current polyline when trackId changes
602603
startPos = null
603604
endPos = null
@@ -607,7 +608,7 @@ open class MapsActivity : BaseActivity(), OnItemGestureListener<MarkerInterface?
607608
trackColor = MapUtils.getTrackColorBySpeed(
608609
average,
609610
averageToMaxSpeed,
610-
trackPoint
611+
trackpoint
611612
)
612613
polyline = addNewPolyline(trackColor)
613614
if (endPos != null) {
@@ -622,12 +623,12 @@ open class MapsActivity : BaseActivity(), OnItemGestureListener<MarkerInterface?
622623
}
623624
}
624625

625-
endPos = trackPoint.latLong
626+
endPos = trackpoint.latLong
626627
polyline!!.addPoint(endPos)
627628
movementDirection.updatePos(endPos)
628629

629-
if (trackPoint.isPause && showPauseMarkers) {
630-
val marker = MapUtils.createPauseMarker(this, trackPoint.latLong)
630+
if (trackpoint.isPause && showPauseMarkers) {
631+
val marker = MapUtils.createPauseMarker(this, trackpoint.latLong)
631632
waypointsLayer!!.addItem(marker)
632633
}
633634

@@ -639,9 +640,9 @@ open class MapsActivity : BaseActivity(), OnItemGestureListener<MarkerInterface?
639640
startPos = endPos
640641
}
641642
}
642-
trackpointsBySegments.debug.trackpointsDrawn += trackPoints.size
643+
trackpointsBySegments.debug.trackpointsDrawn += trackpoints.size
643644
}
644-
trackPointsDebug!!.add(trackpointsBySegments.debug)
645+
trackpointsDebug!!.add(trackpointsBySegments.debug)
645646
} catch (e: SecurityException) {
646647
Toast.makeText(
647648
this,
@@ -683,7 +684,7 @@ open class MapsActivity : BaseActivity(), OnItemGestureListener<MarkerInterface?
683684
unregisterContentObserver()
684685

685686
tracksUri = null
686-
trackPointsUri = null
687+
trackpointsUri = null
687688
waypointsUri = null
688689

689690
val layers = map.layers()
@@ -706,7 +707,7 @@ open class MapsActivity : BaseActivity(), OnItemGestureListener<MarkerInterface?
706707
endMarker = null
707708
boundingBox = null
708709
movementDirection = MovementDirection()
709-
trackPointsDebug = TrackPointsDebug()
710+
trackpointsDebug = TrackpointsDebug()
710711

711712
// waypoints
712713
if (waypointsLayer != null) {
@@ -723,11 +724,11 @@ open class MapsActivity : BaseActivity(), OnItemGestureListener<MarkerInterface?
723724
if (PreferencesUtils.isDebugTrackPoints()) {
724725
binding.map.trackpointsDebugInfo.text = getString(
725726
R.string.debug_trackpoints_info,
726-
trackPointsDebug!!.trackpointsReceived,
727-
trackPointsDebug!!.trackpointsInvalid,
728-
trackPointsDebug!!.trackpointsDrawn,
729-
trackPointsDebug!!.trackpointsPause,
730-
trackPointsDebug!!.segments,
727+
trackpointsDebug!!.trackpointsReceived,
728+
trackpointsDebug!!.trackpointsInvalid,
729+
trackpointsDebug!!.trackpointsDrawn,
730+
trackpointsDebug!!.trackpointsPause,
731+
trackpointsDebug!!.segments,
731732
protocolVersion
732733
)
733734
} else {
@@ -880,17 +881,17 @@ open class MapsActivity : BaseActivity(), OnItemGestureListener<MarkerInterface?
880881
override fun onStart() {
881882
super.onStart()
882883

883-
if (tracksUri != null && trackPointsUri != null && waypointsUri != null) {
884+
if (tracksUri != null && trackpointsUri != null && waypointsUri != null) {
884885
contentObserver = OpenTracksContentObserver(
885886
tracksUri!!,
886-
trackPointsUri!!,
887+
trackpointsUri!!,
887888
waypointsUri!!,
888889
protocolVersion
889890
)
890891
try {
891892
contentResolver.registerContentObserver(tracksUri!!, false, contentObserver!!)
892893
contentResolver.registerContentObserver(
893-
trackPointsUri!!,
894+
trackpointsUri!!,
894895
false,
895896
contentObserver!!
896897
)

src/main/kotlin/de/storchp/opentracks/osmplugin/dashboardapi/APIConstants.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ object APIConstants {
1313

1414
fun getTracksUri(uris: ArrayList<Uri>) = uris[0]
1515

16-
fun getTrackPointsUri(uris: ArrayList<Uri>) = uris[1]
16+
fun getTrackpointsUri(uris: ArrayList<Uri>) = uris[1]
1717

1818
/**
1919
* Waypoints are only available in newer versions of OpenTracks.

src/main/kotlin/de/storchp/opentracks/osmplugin/dashboardapi/Trackpoint.kt

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ package de.storchp.opentracks.osmplugin.dashboardapi
33
import android.content.ContentResolver
44
import android.net.Uri
55
import de.storchp.opentracks.osmplugin.utils.MapUtils
6-
import de.storchp.opentracks.osmplugin.utils.TrackPointsDebug
6+
import de.storchp.opentracks.osmplugin.utils.TrackpointsDebug
77
import org.oscim.core.GeoPoint
88

9-
data class TrackPoint(
9+
data class Trackpoint(
1010
val trackId: Long,
11-
val trackPointId: Long,
11+
val id: Long,
1212
private val latitude: Double,
1313
private val longitude: Double,
1414
val type: Int?,
@@ -55,17 +55,17 @@ object TrackpointReader {
5555
)
5656

5757
/**
58-
* Reads the TrackPoints from the Content Uri and split by segments.
59-
* Pause TrackPoints and different Track IDs split the segments.
58+
* Reads the Trackpoints from the Content Uri and split by segments.
59+
* Pause Trackpoints and different Track IDs split the segments.
6060
*/
61-
fun readTrackPointsBySegments(
61+
fun readTrackpointsBySegments(
6262
resolver: ContentResolver,
6363
data: Uri,
64-
lastTrackPointId: Long,
64+
lastId: Long,
6565
protocolVersion: Int
6666
): TrackpointsBySegments {
67-
val debug = TrackPointsDebug()
68-
val segments: MutableList<MutableList<TrackPoint>> = mutableListOf()
67+
val debug = TrackpointsDebug()
68+
val segments: MutableList<MutableList<Trackpoint>> = mutableListOf()
6969
var projection = PROJECTION_V2
7070
var typeQuery = " AND $TYPE IN (-2, -1, 0, 1, 3)"
7171
if (protocolVersion < 2) { // fallback to old Dashboard API
@@ -76,14 +76,14 @@ object TrackpointReader {
7676
data,
7777
projection,
7878
"$_ID> ?$typeQuery",
79-
arrayOf<String>(lastTrackPointId.toString()),
79+
arrayOf<String>(lastId.toString()),
8080
null
8181
).use { cursor ->
82-
var lastTrackPoint: TrackPoint? = null
83-
var segment: MutableList<TrackPoint>? = null
82+
var lastTrackpoint: Trackpoint? = null
83+
var segment: MutableList<Trackpoint>? = null
8484
while (cursor!!.moveToNext()) {
8585
debug.trackpointsReceived++
86-
val trackPointId = cursor.getLong(cursor.getColumnIndexOrThrow(_ID))
86+
val id = cursor.getLong(cursor.getColumnIndexOrThrow(_ID))
8787
val trackId = cursor.getLong(cursor.getColumnIndexOrThrow(TRACKID))
8888
val latitude =
8989
cursor.getInt(cursor.getColumnIndexOrThrow(LATITUDE)) / APIConstants.LAT_LON_FACTOR
@@ -97,28 +97,28 @@ object TrackpointReader {
9797
type = cursor.getInt(typeIndex)
9898
}
9999

100-
if (lastTrackPoint == null || lastTrackPoint.trackId != trackId) {
100+
if (lastTrackpoint == null || lastTrackpoint.trackId != trackId) {
101101
segment = mutableListOf()
102102
segments.add(segment)
103103
}
104104

105-
lastTrackPoint =
106-
TrackPoint(trackId, trackPointId, latitude, longitude, type, speed)
107-
if (lastTrackPoint.latLong != null) {
108-
segment!!.add(lastTrackPoint)
109-
} else if (!lastTrackPoint.isPause) {
105+
lastTrackpoint =
106+
Trackpoint(trackId, id, latitude, longitude, type, speed)
107+
if (lastTrackpoint.latLong != null) {
108+
segment!!.add(lastTrackpoint)
109+
} else if (!lastTrackpoint.isPause) {
110110
debug.trackpointsInvalid++
111111
}
112-
if (lastTrackPoint.isPause) {
112+
if (lastTrackpoint.isPause) {
113113
debug.trackpointsPause++
114-
if (lastTrackPoint.latLong == null) {
114+
if (lastTrackpoint.latLong == null) {
115115
if (segment!!.isNotEmpty()) {
116116
val previousTrackpoint = segment[segment.size - 1]
117117
previousTrackpoint.latLong?.let {
118118
segment.add(
119-
TrackPoint(
119+
Trackpoint(
120120
trackId = trackId,
121-
trackPointId = trackPointId,
121+
id = id,
122122
latitude = it.latitude,
123123
longitude = it.longitude,
124124
type = type,
@@ -128,7 +128,7 @@ object TrackpointReader {
128128
}
129129
}
130130
}
131-
lastTrackPoint = null
131+
lastTrackpoint = null
132132
}
133133
}
134134
}

src/main/kotlin/de/storchp/opentracks/osmplugin/dashboardapi/TrackpointsBySegments.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package de.storchp.opentracks.osmplugin.dashboardapi
22

3-
import de.storchp.opentracks.osmplugin.utils.TrackPointsDebug
3+
import de.storchp.opentracks.osmplugin.utils.TrackpointsDebug
44

55
data class TrackpointsBySegments(
6-
val segments: List<List<TrackPoint>>,
7-
val debug: TrackPointsDebug,
8-
) : List<List<TrackPoint>> by segments {
6+
val segments: List<List<Trackpoint>>,
7+
val debug: TrackpointsDebug,
8+
) : List<List<Trackpoint>> by segments {
99

1010
fun calcAverageSpeed() = speeds().average()
1111

0 commit comments

Comments
 (0)