Improve isolate_trkseg feature by querying its endpoints for more.
This commit is contained in:
parent
01a313a69c
commit
1637ef16d6
4 changed files with 46 additions and 8 deletions
|
@ -85,11 +85,11 @@ class Database(val trackbook: Trackbook)
|
||||||
connection.insert("trkpt", null, values)
|
connection.insert("trkpt", null, values)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun select_trkpt_start_end(device_id: String, start_time: Long, end_time: Long): Iterator<Trkpt>
|
fun select_trkpt_start_end(device_id: String, start_time: Long, end_time: Long, order: String="ASC"): Iterator<Trkpt>
|
||||||
{
|
{
|
||||||
Log.i("VOUSSOIR", "Track.trkpt_generator: Querying points between ${start_time} -- ${end_time}.")
|
Log.i("VOUSSOIR", "Track.trkpt_generator: Querying points between ${start_time} -- ${end_time}.")
|
||||||
return _trkpt_generator(this.connection.rawQuery(
|
return _trkpt_generator(this.connection.rawQuery(
|
||||||
"SELECT device_id, lat, lon, time, provider, ele, accuracy, sat FROM trkpt WHERE device_id = ? AND time >= ? AND time <= ? ORDER BY time ASC",
|
"SELECT device_id, lat, lon, time, provider, ele, accuracy, sat FROM trkpt WHERE device_id = ? AND time >= ? AND time <= ? ORDER BY time ${order}",
|
||||||
arrayOf(device_id, start_time.toString(), end_time.toString())
|
arrayOf(device_id, start_time.toString(), end_time.toString())
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,10 +36,42 @@ data class Track (
|
||||||
var name: String = "",
|
var name: String = "",
|
||||||
var _start_time: Long = 0L,
|
var _start_time: Long = 0L,
|
||||||
var _end_time: Long = 0L,
|
var _end_time: Long = 0L,
|
||||||
val trkpts: ArrayList<Trkpt> = ArrayList<Trkpt>(),
|
val trkpts: ArrayDeque<Trkpt> = ArrayDeque<Trkpt>(),
|
||||||
var trackFormatVersion: Int = Keys.CURRENT_TRACK_FORMAT_VERSION,
|
var trackFormatVersion: Int = Keys.CURRENT_TRACK_FORMAT_VERSION,
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Discover the true bounds of this trkseg by querying for points until the stop over threshold.
|
||||||
|
* This is extremely helpful when using the "when was I here" button on an area, then expanding
|
||||||
|
* the trkseg to its ends.
|
||||||
|
*/
|
||||||
|
fun expand_to_trkseg_bounds()
|
||||||
|
{
|
||||||
|
if (trkpts.isEmpty())
|
||||||
|
{
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var previous = trkpts.first()
|
||||||
|
for (trkpt in database.select_trkpt_start_end(device_id, start_time=0L, end_time=trkpts.first().time, order="DESC"))
|
||||||
|
{
|
||||||
|
if ((previous.time - trkpt.time) > Keys.STOP_OVER_THRESHOLD)
|
||||||
|
{
|
||||||
|
break
|
||||||
|
}
|
||||||
|
trkpts.addFirst(trkpt)
|
||||||
|
previous = trkpt
|
||||||
|
}
|
||||||
|
previous = trkpts.last()
|
||||||
|
for (trkpt in database.select_trkpt_start_end(device_id, start_time=trkpts.last().time, end_time=Long.MAX_VALUE, order="ASC"))
|
||||||
|
{
|
||||||
|
if ((trkpt.time - previous.time) > Keys.STOP_OVER_THRESHOLD)
|
||||||
|
{
|
||||||
|
break
|
||||||
|
}
|
||||||
|
trkpts.add(trkpt)
|
||||||
|
previous = trkpt
|
||||||
|
}
|
||||||
|
}
|
||||||
fun export_gpx(context: Context, fileuri: Uri): Uri?
|
fun export_gpx(context: Context, fileuri: Uri): Uri?
|
||||||
{
|
{
|
||||||
if (! database.ready)
|
if (! database.ready)
|
||||||
|
@ -133,7 +165,7 @@ data class Track (
|
||||||
}
|
}
|
||||||
|
|
||||||
data class TrackStatistics(
|
data class TrackStatistics(
|
||||||
val trkpts: ArrayList<Trkpt>,
|
val trkpts: ArrayDeque<Trkpt>,
|
||||||
var distance: Double = 0.0,
|
var distance: Double = 0.0,
|
||||||
var duration: Long = 0,
|
var duration: Long = 0,
|
||||||
var pause_duration: Long = 0,
|
var pause_duration: Long = 0,
|
||||||
|
|
|
@ -311,6 +311,9 @@ class TrackFragment : Fragment(), MapListener, YesNoDialog.YesNoDialogListener
|
||||||
(polyline.actualPoints.first() as Trkpt).time,
|
(polyline.actualPoints.first() as Trkpt).time,
|
||||||
(polyline.actualPoints.last() as Trkpt).time,
|
(polyline.actualPoints.last() as Trkpt).time,
|
||||||
))
|
))
|
||||||
|
|
||||||
|
track.expand_to_trkseg_bounds()
|
||||||
|
|
||||||
set_datetimes_from_track()
|
set_datetimes_from_track()
|
||||||
render_track()
|
render_track()
|
||||||
}
|
}
|
||||||
|
@ -468,10 +471,7 @@ class TrackFragment : Fragment(), MapListener, YesNoDialog.YesNoDialogListener
|
||||||
delete_selected_trkpt_button.visibility = View.VISIBLE
|
delete_selected_trkpt_button.visibility = View.VISIBLE
|
||||||
use_trkpt_as_start_button.visibility = View.VISIBLE
|
use_trkpt_as_start_button.visibility = View.VISIBLE
|
||||||
use_trkpt_as_end_button.visibility = View.VISIBLE
|
use_trkpt_as_end_button.visibility = View.VISIBLE
|
||||||
if (track_segment_overlays.size > 1)
|
|
||||||
{
|
|
||||||
isolate_trkseg_button.visibility = View.VISIBLE
|
isolate_trkseg_button.visibility = View.VISIBLE
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -20,6 +20,7 @@ import android.location.Location
|
||||||
import org.osmdroid.util.GeoPoint
|
import org.osmdroid.util.GeoPoint
|
||||||
import org.osmdroid.views.overlay.Polyline
|
import org.osmdroid.views.overlay.Polyline
|
||||||
import net.voussoir.trkpt.helpers.getNumberOfSatellites
|
import net.voussoir.trkpt.helpers.getNumberOfSatellites
|
||||||
|
import net.voussoir.trkpt.helpers.iso8601_local
|
||||||
|
|
||||||
class Trkpt(
|
class Trkpt(
|
||||||
val device_id: String,
|
val device_id: String,
|
||||||
|
@ -53,4 +54,9 @@ class Trkpt(
|
||||||
location.time = this.time
|
location.time = this.time
|
||||||
return location
|
return location
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun toString(): String
|
||||||
|
{
|
||||||
|
return "${device_id} ${iso8601_local(time)} ${latitude}/${longitude}"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue