Add interpolate button, adds point between two points.

This commit is contained in:
voussoir 2023-04-05 18:04:27 -07:00
parent cee0f7bef4
commit a8e2bb26fd
3 changed files with 63 additions and 4 deletions

View file

@ -86,6 +86,8 @@ class TrackFragment : Fragment(), MapListener, YesNoDialog.YesNoDialogListener
lateinit var use_trkpt_as_end_button: ImageButton lateinit var use_trkpt_as_end_button: ImageButton
lateinit var isolate_trkseg_button: ImageButton lateinit var isolate_trkseg_button: ImageButton
lateinit var when_was_i_here_button: ImageButton lateinit var when_was_i_here_button: ImageButton
lateinit var interpolate_points_button: ImageButton
var ready_to_interpolate: Boolean = false
var track_query_start_time_previous: Int = 0 var track_query_start_time_previous: Int = 0
var track_query_end_time_previous: Int = 0 var track_query_end_time_previous: Int = 0
private lateinit var mapView: MapView private lateinit var mapView: MapView
@ -342,6 +344,20 @@ class TrackFragment : Fragment(), MapListener, YesNoDialog.YesNoDialogListener
render_track() render_track()
} }
interpolate_points_button = rootView.findViewById(R.id.interpolate_points_button)
interpolate_points_button.setOnClickListener {
Log.i("VOUSSOIR", "interpolate_points_button.")
if (ready_to_interpolate)
{
interpolate_points_button.setColorFilter(null)
}
else
{
interpolate_points_button.setColorFilter(resources.getColor(R.color.fuchsia))
}
ready_to_interpolate = !ready_to_interpolate
}
save_track_button.setOnClickListener { save_track_button.setOnClickListener {
val dialog = Dialog(activity as Context) val dialog = Dialog(activity as Context)
dialog.setContentView(R.layout.dialog_rename_track) dialog.setContentView(R.layout.dialog_rename_track)
@ -433,7 +449,10 @@ class TrackFragment : Fragment(), MapListener, YesNoDialog.YesNoDialogListener
mapView.overlays.remove(selected_trkpt_marker) mapView.overlays.remove(selected_trkpt_marker)
mapView.invalidate() mapView.invalidate()
} }
ready_to_interpolate = false
interpolate_points_button.setColorFilter(null)
delete_selected_trkpt_button.visibility = View.GONE delete_selected_trkpt_button.visibility = View.GONE
interpolate_points_button.visibility = View.GONE
use_trkpt_as_start_button.visibility = View.GONE use_trkpt_as_start_button.visibility = View.GONE
use_trkpt_as_end_button.visibility = View.GONE use_trkpt_as_end_button.visibility = View.GONE
isolate_trkseg_button.visibility = View.GONE isolate_trkseg_button.visibility = View.GONE
@ -527,6 +546,20 @@ class TrackFragment : Fragment(), MapListener, YesNoDialog.YesNoDialogListener
} }
val trkpt = (points[point]) as Trkpt val trkpt = (points[point]) as Trkpt
Log.i("VOUSSOIR", "Clicked ${trkpt.device_id} ${trkpt.time}") Log.i("VOUSSOIR", "Clicked ${trkpt.device_id} ${trkpt.time}")
if (ready_to_interpolate)
{
val mid_location = Location("interpolated")
mid_location.latitude = (selected_trkpt!!.latitude + trkpt.latitude) / 2
mid_location.longitude = (selected_trkpt!!.longitude + trkpt.longitude) / 2
mid_location.altitude = (selected_trkpt!!.altitude + trkpt.altitude) / 2
mid_location.time = (selected_trkpt!!.time + trkpt.time) / 2
mid_location.accuracy = 0f
val mid_trkpt = Trkpt(trkpt.device_id, mid_location)
deselect_trkpt()
trackbook.database.insert_trkpt(mid_trkpt, commit=true)
handler.post(requery_and_render)
return
}
selected_trkpt = trkpt selected_trkpt = trkpt
selected_trkpt_info.text = "${trkpt.time}\n${iso8601_local(trkpt.time)}\n${trkpt.latitude}\n${trkpt.longitude}\n${trkpt.accuracy}" selected_trkpt_info.text = "${trkpt.time}\n${iso8601_local(trkpt.time)}\n${trkpt.latitude}\n${trkpt.longitude}\n${trkpt.accuracy}"
selected_trkpt_marker.position = trkpt selected_trkpt_marker.position = trkpt
@ -534,6 +567,7 @@ class TrackFragment : Fragment(), MapListener, YesNoDialog.YesNoDialogListener
{ {
mapView.overlays.add(selected_trkpt_marker) mapView.overlays.add(selected_trkpt_marker)
} }
interpolate_points_button.visibility = View.VISIBLE
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

View file

@ -0,0 +1,12 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="vector"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:name="path_1"
android:pathData="M 11.059 4.479 L 11.059 6.958 L 8.578 6.958 L 8.578 8.958 L 11.059 8.958 L 11.059 11.438 L 13.059 11.438 L 13.059 8.958 L 15.539 8.958 L 15.539 6.958 L 13.059 6.958 L 13.059 4.479 Z M 12 13.385 C 11.07 13.385 10.268 13.938 9.891 14.729 L 1.76 14.729 L 1.76 16.729 L 9.891 16.729 C 10.268 17.519 11.07 18.072 12 18.072 C 12.93 18.072 13.731 17.519 14.109 16.729 L 22.357 16.729 L 22.357 14.729 L 14.109 14.729 C 13.731 13.938 12.93 13.385 12 13.385 Z"
android:fillColor="@color/icon_default" />
</vector>

View file

@ -91,8 +91,8 @@
android:src="@drawable/ic_end_here_24dp" android:src="@drawable/ic_end_here_24dp"
android:visibility="gone" android:visibility="gone"
app:backgroundTint="@color/default_transparent" app:backgroundTint="@color/default_transparent"
app:layout_constraintTop_toBottomOf="@+id/when_was_i_here_button" app:layout_constraintTop_toTopOf="@+id/when_was_i_here_button"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toStartOf="@+id/when_was_i_here_button"
app:srcCompat="@drawable/ic_end_here_24dp" /> app:srcCompat="@drawable/ic_end_here_24dp" />
<ImageButton <ImageButton
@ -116,10 +116,23 @@
android:tooltipText="Isolate track segment" android:tooltipText="Isolate track segment"
android:visibility="gone" android:visibility="gone"
app:backgroundTint="@color/default_transparent" app:backgroundTint="@color/default_transparent"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintTop_toBottomOf="@+id/when_was_i_here_button"
app:layout_constraintEnd_toStartOf="@+id/delete_selected_trkpt_button" app:layout_constraintEnd_toEndOf="@+id/when_was_i_here_button"
app:srcCompat="@drawable/ic_timeline_24dp" /> app:srcCompat="@drawable/ic_timeline_24dp" />
<ImageButton
android:id="@+id/interpolate_points_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="Interpolate between two points"
android:tooltipText="Interpolate between two points"
android:src="@drawable/ic_interpolate_24dp"
android:visibility="gone"
app:backgroundTint="@color/default_transparent"
app:layout_constraintTop_toTopOf="@+id/isolate_trkseg_button"
app:layout_constraintEnd_toStartOf="@+id/isolate_trkseg_button"
app:srcCompat="@drawable/ic_bug_report_24dp" />
<ImageButton <ImageButton
android:id="@+id/delete_selected_trkpt_button" android:id="@+id/delete_selected_trkpt_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"