Let "when was I here" button query all device ids.

This commit is contained in:
voussoir 2023-12-24 19:29:04 -08:00
parent d5df922d3d
commit 70e6e64918
3 changed files with 24 additions and 8 deletions

View file

@ -101,18 +101,33 @@ class Database(val trackbook: Trackbook)
))
}
fun select_trkpt_bounding_box(device_id: String, north: Double, south: Double, east: Double, west: Double, max_accuracy: Float=Keys.DEFAULT_MAX_ACCURACY): Iterator<Trkpt>
fun select_trkpt_bounding_box(device_id: String?, north: Double, south: Double, east: Double, west: Double, max_accuracy: Float=Keys.DEFAULT_MAX_ACCURACY): Iterator<Trkpt>
{
Log.i("VOUSSOIR", "Track.trkpt_generator: Querying points between $north, $south, $east, $west.")
return _trkpt_generator(this.connection.rawQuery(
"""
if (device_id == null)
{
return _trkpt_generator(this.connection.rawQuery(
"""
SELECT device_id, lat, lon, time, provider, ele, accuracy, sat
FROM trkpt
WHERE lat >= ? AND lat <= ? AND lon >= ? AND lon <= ? AND accuracy <= ?
ORDER BY time ASC
""",
arrayOf(south.toString(), north.toString(), west.toString(), east.toString(), max_accuracy.toString())
))
}
else
{
return _trkpt_generator(this.connection.rawQuery(
"""
SELECT device_id, lat, lon, time, provider, ele, accuracy, sat
FROM trkpt
WHERE device_id = ? AND lat >= ? AND lat <= ? AND lon >= ? AND lon <= ? AND accuracy <= ?
ORDER BY time ASC
""",
arrayOf(device_id, south.toString(), north.toString(), west.toString(), east.toString(), max_accuracy.toString())
))
arrayOf(device_id, south.toString(), north.toString(), west.toString(), east.toString(), max_accuracy.toString())
))
}
}
fun _trkpt_generator(cursor: Cursor) = iterator<Trkpt>

View file

@ -32,7 +32,7 @@ import java.util.*
data class Track (
val database: Database,
val device_id: String,
var device_id: String,
var name: String = "",
var _start_time: Long = 0L,
var _end_time: Long = 0L,

View file

@ -323,8 +323,9 @@ class TrackFragment : Fragment(), MapListener, YesNoDialog.YesNoDialogListener
val polyline = selected.rendered_by_polyline
if (polyline != null)
{
track.device_id = selected.device_id
track.load_trkpts(trackbook.database.select_trkpt_start_end(
track.device_id,
selected.device_id,
start_time=(polyline.actualPoints.first() as Trkpt).time,
end_time=(polyline.actualPoints.last() as Trkpt).time,
max_accuracy=PreferencesHelper.load_max_accuracy(),
@ -342,7 +343,7 @@ class TrackFragment : Fragment(), MapListener, YesNoDialog.YesNoDialogListener
when_was_i_here_button.setOnClickListener {
Log.i("VOUSSOIR", "when_was_i_here_button.")
track.load_trkpts(trackbook.database.select_trkpt_bounding_box(
device_id=track.device_id,
device_id=null,
north=mapView.boundingBox.actualNorth,
south=mapView.boundingBox.actualSouth,
east=mapView.boundingBox.lonEast,