Destination controller から Location controller へGPS信号シミュレーションを変更
This commit is contained in:
@ -46,7 +46,8 @@ class DestinationController extends GetxController {
|
||||
List<Destination> destinations = <Destination>[].obs; // 目的地のリストを保持するObservable変数です。
|
||||
double currentLat = 0.0; // 現在の緯度と経度を保持する変数です。
|
||||
double currentLon = 0.0;
|
||||
double lastValidLat = 0.0; // 最後に中・強信号で拾ったGPS位置。ロゲ開始を屋内でやったら 0 のままなので、屋外で行うこと。
|
||||
double lastValidLat = 0.0; // 最後に中・強信号で拾ったGPS位置。
|
||||
// ロゲ開始を屋内でやったら 0 のままなので、屋外で行うこと。
|
||||
double lastValidLon = 0.0;
|
||||
DateTime lastGPSCollectedTime = DateTime.now(); // 最後にGPSデータが収集された時刻を保持する変数です。
|
||||
|
||||
@ -93,6 +94,7 @@ class DestinationController extends GetxController {
|
||||
int chekcs = 0; // チェックポイントの数を保持する変数です。
|
||||
var rogainingCounted = false.obs; // ロゲイニングがカウントされたかどうかを示すReactive変数です。
|
||||
|
||||
/*
|
||||
//==== Akira .. GPS信号シミュレーション用 ===== ここから、2024-4-5
|
||||
//
|
||||
|
||||
@ -106,6 +108,11 @@ class DestinationController extends GetxController {
|
||||
isSimulationMode.value = value;
|
||||
}
|
||||
|
||||
// 現在位置の取得メソッドを追加
|
||||
LatLng getCurrentLocation() {
|
||||
return LatLng(lastValidLat, lastValidLon);
|
||||
}
|
||||
|
||||
//
|
||||
// GPS信号の強弱を判断するメソッドを追加します。
|
||||
//
|
||||
@ -129,6 +136,7 @@ class DestinationController extends GetxController {
|
||||
|
||||
//
|
||||
//==== Akira .. GPS信号シミュレーション用 ======= ここまで
|
||||
*/
|
||||
|
||||
// 日時をフォーマットされた文字列に変換する関数です。
|
||||
//
|
||||
@ -919,6 +927,9 @@ class DestinationController extends GetxController {
|
||||
|
||||
// 要検討:エラーメッセージを表示するなどの適切な処理を追加することを検討してください。
|
||||
//
|
||||
// locationController からデバイスの受け取るGPS情報を取得し、
|
||||
// handleLocationUpdate を呼び出している。
|
||||
//
|
||||
locationController.locationMarkerPositionStream.listen(
|
||||
(locationMarkerPosition) {
|
||||
if (locationMarkerPosition != null) {
|
||||
@ -947,18 +958,17 @@ class DestinationController extends GetxController {
|
||||
void handleLocationUpdate(LocationMarkerPosition? position) async {
|
||||
try {
|
||||
final DestinationController destinationController = Get.find<DestinationController>();
|
||||
final signalStrength = destinationController.getGpsSignalStrength();
|
||||
okToUseGPS = false;
|
||||
double prevLat = lastValidLat; // 一つ前の位置情報を記録
|
||||
double prevLon = lastValidLon;
|
||||
//final signalStrength = locationController.getGpsSignalStrength();
|
||||
|
||||
if (position!=null && (signalStrength == 'high' || signalStrength == 'medium')) {
|
||||
// 信号強度が高いまたは中程度の場合、現在の位置情報を更新
|
||||
okToUseGPS = false;
|
||||
double prevLat = currentLat; // 直前の位置
|
||||
double prevLon = currentLon;
|
||||
|
||||
if (position!=null){
|
||||
currentLat = position.latitude;
|
||||
currentLon = position.longitude;
|
||||
lastValidLat = position.latitude;
|
||||
lastValidLon = position.longitude;
|
||||
okToUseGPS = true;
|
||||
|
||||
} else {
|
||||
// 信号強度が低い場合、最後に取得した高いまたは中程度の位置情報を使用
|
||||
// 但し、最初から高精度のものがない場合、どうするか?
|
||||
@ -1048,13 +1058,16 @@ class DestinationController extends GetxController {
|
||||
return distanceToDest;
|
||||
}
|
||||
|
||||
//final currentLocation = getCurrentLocation(); // GPS信号中以上での現在位置
|
||||
|
||||
Destination des = festuretoDestination(gfs);
|
||||
|
||||
//print("=== gfs == ${des.toMap()}");
|
||||
|
||||
var distance = const Distance();
|
||||
distanceToDest = distance.as(LengthUnit.Meter,
|
||||
LatLng(currentLat, currentLon), LatLng(des.lat!, des.lon!));
|
||||
LatLng(currentLat,currentLon), LatLng(des.lat!, des.lon!));
|
||||
// LatLng(currentLat, currentLon), LatLng(des.lat!, des.lon!));
|
||||
//print("==== dist==${distanceToDest}");
|
||||
return distanceToDest;
|
||||
}
|
||||
@ -1197,7 +1210,7 @@ class DestinationController extends GetxController {
|
||||
//
|
||||
void centerMapToCurrentLocation() {
|
||||
assert(() {
|
||||
print("center is ${currentLon}, ${currentLon}");
|
||||
print("center is ${currentLat}, ${currentLon}");
|
||||
return true;
|
||||
}());
|
||||
// Akira ... 状況によって呼ぶか呼ばないか
|
||||
|
||||
Reference in New Issue
Block a user