Lanes
This commit is contained in:
@@ -43,6 +43,7 @@ import com.kouros.data.R
|
||||
import com.kouros.navigation.MainApplication.Companion.navigationViewModel
|
||||
import com.kouros.navigation.data.Constants
|
||||
import com.kouros.navigation.data.Constants.DESTINATION_ARRIVAL_DISTANCE
|
||||
import com.kouros.navigation.data.Constants.home2Location
|
||||
import com.kouros.navigation.data.Constants.homeLocation
|
||||
import com.kouros.navigation.data.StepData
|
||||
import com.kouros.navigation.model.BaseStyleModel
|
||||
@@ -61,6 +62,7 @@ import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import org.joda.time.DateTime
|
||||
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||
import org.maplibre.compose.camera.CameraPosition
|
||||
import org.maplibre.compose.location.DesiredAccuracy
|
||||
import org.maplibre.compose.location.Location
|
||||
@@ -76,7 +78,7 @@ class MainActivity : ComponentActivity() {
|
||||
|
||||
val routeModel = RouteModel()
|
||||
var tilt = 50.0
|
||||
val useMock = true
|
||||
val useMock = false
|
||||
val stepData: MutableLiveData<StepData> by lazy {
|
||||
MutableLiveData<StepData>()
|
||||
}
|
||||
@@ -90,7 +92,7 @@ class MainActivity : ComponentActivity() {
|
||||
routeData.value = routeModel.route.routeGeoJson
|
||||
simulate()
|
||||
//test()
|
||||
//gpx(applicationContext)
|
||||
///gpx(applicationContext)
|
||||
}
|
||||
}
|
||||
val cameraPosition = MutableLiveData(
|
||||
@@ -130,8 +132,8 @@ class MainActivity : ComponentActivity() {
|
||||
if (useMock) {
|
||||
mock = MockLocation(locationManager)
|
||||
mock.setMockLocation(
|
||||
location?.latitude ?: homeLocation.latitude,
|
||||
location?.longitude ?: homeLocation.longitude
|
||||
home2Location.latitude,
|
||||
home2Location.longitude
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -153,6 +155,10 @@ class MainActivity : ComponentActivity() {
|
||||
requiredPermissions = listOf(permissions.first()),
|
||||
onGranted = {
|
||||
Content()
|
||||
// auto navigate
|
||||
if (useMock) {
|
||||
//navigationViewModel.loadRoute(applicationContext, homeLocation, home2Location, 0F)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -172,7 +178,7 @@ class MainActivity : ComponentActivity() {
|
||||
)
|
||||
val userLocationState = rememberUserLocationState(locationProvider)
|
||||
val locationState = locationProvider.location.collectAsState()
|
||||
updateLocation(locationState.value)
|
||||
updateLocation(locationState.value)
|
||||
var latitude by remember { mutableDoubleStateOf(0.0) }
|
||||
if (locationState.value != null) {
|
||||
latitude = locationState.value!!.position.latitude
|
||||
@@ -271,7 +277,7 @@ class MainActivity : ComponentActivity() {
|
||||
)
|
||||
lastLocation = currentLocation
|
||||
if (!loadRecentPlaces) {
|
||||
navigationViewModel.loadRecentPlaces(applicationContext, lastLocation)
|
||||
navigationViewModel.loadRecentPlaces(applicationContext, lastLocation, 0F)
|
||||
loadRecentPlaces = true
|
||||
}
|
||||
}
|
||||
@@ -333,21 +339,34 @@ class MainActivity : ComponentActivity() {
|
||||
|
||||
fun test() {
|
||||
for ((index, step) in routeModel.legs.steps.withIndex()) {
|
||||
for ((windex, waypoint) in step.maneuver.waypoints.withIndex()) {
|
||||
routeModel.updateLocation(location(waypoint[0], waypoint[1]), navigationViewModel)
|
||||
val step = routeModel.currentStep()
|
||||
println("Street: ${step.instruction} Dist: ${step.leftStepDistance} ${step.currentManeuverType}")
|
||||
if (index + 1 <= routeModel.legs.steps.size) {
|
||||
//nextStepData.value = routeModel.nextStep()
|
||||
if (index in 3..3) {
|
||||
for ((windex, waypoint) in step.maneuver.waypoints.withIndex()) {
|
||||
routeModel.updateLocation(
|
||||
location(waypoint[0], waypoint[1]),
|
||||
navigationViewModel
|
||||
)
|
||||
val step = routeModel.currentStep()
|
||||
if (step.leftStepDistance == 70.0) {
|
||||
println("")
|
||||
}
|
||||
if (index + 1 <= routeModel.legs.steps.size) {
|
||||
//nextStepData.value = routeModel.nextStep()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test2() {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
// Balanstr.
|
||||
mock.setMockLocation( 48.119357, 11.599130)
|
||||
}
|
||||
}
|
||||
fun gpx(context: Context) {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
val parser = GPXParser()
|
||||
val input = context.resources.openRawResource(R.raw.vh)
|
||||
val input = context.resources.openRawResource(R.raw.hv)
|
||||
val parsedGpx: Gpx? = parser.parse(input) // consider using a background thread
|
||||
parsedGpx?.let {
|
||||
val tracks = parsedGpx.tracks
|
||||
|
||||
@@ -96,7 +96,7 @@ fun Home(
|
||||
Button(onClick = {
|
||||
val places = viewModel.loadRecentPlace()
|
||||
val toLocation = location(places.first()!!.longitude, places.first()!!.latitude)
|
||||
viewModel.loadRoute(applicationContext, location, toLocation)
|
||||
viewModel.loadRoute(applicationContext, location, toLocation, 0F)
|
||||
closeSheet()
|
||||
}) {
|
||||
Icon(
|
||||
@@ -207,7 +207,7 @@ private fun SearchPlaces(
|
||||
viewModel.saveRecent(pl)
|
||||
val toLocation =
|
||||
location(place.lon.toDouble(), place.lat.toDouble())
|
||||
viewModel.loadRoute(context, location, toLocation)
|
||||
viewModel.loadRoute(context, location, toLocation, 0F)
|
||||
closeSheet()
|
||||
}
|
||||
.fillMaxWidth()
|
||||
@@ -245,7 +245,7 @@ private fun RecentPlaces(
|
||||
modifier = Modifier
|
||||
.clickable {
|
||||
val toLocation = location(place.longitude, place.latitude)
|
||||
viewModel.loadRoute(context, location, toLocation)
|
||||
viewModel.loadRoute(context, location, toLocation, 0F)
|
||||
closeSheet()
|
||||
}
|
||||
.fillMaxWidth()
|
||||
|
||||
Reference in New Issue
Block a user