update gps collection time and distance
This commit is contained in:
@ -36,6 +36,7 @@ class DestinationController extends GetxController {
|
|||||||
List<Destination> destinations = <Destination>[].obs;
|
List<Destination> destinations = <Destination>[].obs;
|
||||||
double currentLat = 0.0;
|
double currentLat = 0.0;
|
||||||
double currentLon = 0.0;
|
double currentLon = 0.0;
|
||||||
|
DateTime lastGPSCollectedTime = DateTime.now();
|
||||||
|
|
||||||
static bool gps_push_started = false;
|
static bool gps_push_started = false;
|
||||||
static bool game_started = false;
|
static bool game_started = false;
|
||||||
@ -524,9 +525,10 @@ class DestinationController extends GetxController {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
//print("--- 000 ---- $skip_gps----");
|
//print("--- 000 ---- $skip_gps----");
|
||||||
await Future.delayed(const Duration(milliseconds: 2500));
|
await Future.delayed(const Duration(milliseconds: 3000));
|
||||||
Position position = await Geolocator.getCurrentPosition(
|
Position position = await Geolocator.getCurrentPosition(
|
||||||
desiredAccuracy: LocationAccuracy.bestForNavigation);
|
desiredAccuracy: LocationAccuracy.bestForNavigation);
|
||||||
|
|
||||||
currentLat = position.latitude;
|
currentLat = position.latitude;
|
||||||
currentLon = position.longitude;
|
currentLon = position.longitude;
|
||||||
final la = position.latitude;
|
final la = position.latitude;
|
||||||
@ -535,7 +537,22 @@ class DestinationController extends GetxController {
|
|||||||
//print("--- gps is ${la}, ${ln}");
|
//print("--- gps is ${la}, ${ln}");
|
||||||
|
|
||||||
//add gps to database
|
//add gps to database
|
||||||
|
//check distance to previous point
|
||||||
|
var distance = const Distance();
|
||||||
|
double distanceToDest = distance.as(
|
||||||
|
LengthUnit.Meter,
|
||||||
|
LatLng(position.latitude, position.longitude),
|
||||||
|
LatLng(currentLat, currentLon));
|
||||||
|
Duration difference =
|
||||||
|
lastGPSCollectedTime.difference(DateTime.now()).abs();
|
||||||
|
if (difference.inSeconds >= 10 || distanceToDest >= 10) {
|
||||||
|
print(
|
||||||
|
"^^^^^^^^ GPS data collected ${DateFormat('kk:mm:ss \n EEE d MMM').format(DateTime.now())}, ^^^ ${position.latitude}, ${position.longitude}");
|
||||||
|
|
||||||
await addGPStoDB(la, ln);
|
await addGPStoDB(la, ln);
|
||||||
|
lastGPSCollectedTime = DateTime.now();
|
||||||
|
}
|
||||||
|
|
||||||
// GpsDatabaseHelper db = GpsDatabaseHelper.instance;
|
// GpsDatabaseHelper db = GpsDatabaseHelper.instance;
|
||||||
// final team_name = indexController.currentUser[0]["user"]['team_name'];
|
// final team_name = indexController.currentUser[0]["user"]['team_name'];
|
||||||
// final event_code = indexController.currentUser[0]["user"]["event_code"];
|
// final event_code = indexController.currentUser[0]["user"]["event_code"];
|
||||||
|
|||||||
@ -498,6 +498,8 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
|||||||
// ),
|
// ),
|
||||||
|
|
||||||
destinationController.rogainingCounted.value == true &&
|
destinationController.rogainingCounted.value == true &&
|
||||||
|
destinationController.distanceToStart() <=
|
||||||
|
500 &&
|
||||||
destination.cp == -1
|
destination.cp == -1
|
||||||
? ElevatedButton(
|
? ElevatedButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
@ -604,10 +606,14 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
|||||||
),
|
),
|
||||||
|
|
||||||
// forced start / checkin
|
// forced start / checkin
|
||||||
Obx(() => ElevatedButton(
|
distanceToDest <=
|
||||||
|
destinationController
|
||||||
|
.getForcedChckinDistance(destination)
|
||||||
|
? Obx(() => ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor:
|
backgroundColor: Theme.of(context)
|
||||||
Theme.of(context).colorScheme.secondary),
|
.colorScheme
|
||||||
|
.secondary),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
//print("~~~~ manual checkin button ~~~~");
|
//print("~~~~ manual checkin button ~~~~");
|
||||||
if (destination.cp == -1 &&
|
if (destination.cp == -1 &&
|
||||||
@ -636,7 +642,8 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
|||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
destination.cp == -1 &&
|
destination.cp == -1 &&
|
||||||
destinationController.isInRog.value ==
|
destinationController
|
||||||
|
.isInRog.value ==
|
||||||
false &&
|
false &&
|
||||||
destinationController
|
destinationController
|
||||||
.rogainingCounted.value ==
|
.rogainingCounted.value ==
|
||||||
@ -653,8 +660,7 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
|||||||
color: Theme.of(context)
|
color: Theme.of(context)
|
||||||
.colorScheme
|
.colorScheme
|
||||||
.onSecondary))))
|
.onSecondary))))
|
||||||
// ElevatedButton(
|
: Container(),
|
||||||
// onPressed: () {}, child: const Text("ゲーム中")),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
|
|||||||
Reference in New Issue
Block a user