Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

位置情報サービスが正常に動作しない不具合を修正 #99

Merged
merged 31 commits into from
Nov 24, 2023
Merged
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7fa72db
Add TRViS.LocationService project to solution
TetsuOtter Nov 2, 2023
cd93cf3
Merge branch 'main' into 88-fix-location-service
TetsuOtter Nov 11, 2023
a56cd03
change line ending from CRLF to LF
TetsuOtter Nov 12, 2023
f993a48
Create CalculateDistance.cs
TetsuOtter Nov 12, 2023
8fcc611
Create IsNearBy.cs
TetsuOtter Nov 12, 2023
c4fd06b
add test project for TRViS.LocationService
TetsuOtter Nov 12, 2023
849edc5
Leave判定用の関数も追加
TetsuOtter Nov 15, 2023
0fa9659
Create ILocationService.cs
TetsuOtter Nov 15, 2023
a81e85f
Create StaLocationInfo.cs
TetsuOtter Nov 15, 2023
64c11f2
Create LonLatLocationService.cs
TetsuOtter Nov 15, 2023
b7709ec
Create LonLatLocationService.Tests.cs
TetsuOtter Nov 15, 2023
011ee09
インデントを修正
TetsuOtter Nov 15, 2023
e0a7f02
InfoRow等の「緯度経度が設定されていない駅」は無視するように修正
TetsuOtter Nov 15, 2023
f9c06f0
add ref to LocationService project
TetsuOtter Nov 15, 2023
bdff465
LocationServiceの判定ロジックをブロジェクト分離したため、本体側にそれを反映
TetsuOtter Nov 15, 2023
718461b
メインスレッド以外でUIを触っていたミスを修正
TetsuOtter Nov 16, 2023
4eeba60
位置情報のパーミッションを毎度確認するようにした
TetsuOtter Nov 16, 2023
6971347
列車データ変更後にボタンの「運転開始」ボタンをきちんと戻すようにした
TetsuOtter Nov 16, 2023
85988c2
ForceSetLocationInfoのテストを追加
TetsuOtter Nov 24, 2023
b238ff2
ログ出力を追加
TetsuOtter Nov 24, 2023
a7186b2
Merge branch 'main' into 88-fix-location-service
TetsuOtter Nov 24, 2023
ede7996
ログ出力でNullRefが起きるバグを修正
TetsuOtter Nov 24, 2023
06d98ee
駅が進むときにHaptic Feedbackを出すようにした
TetsuOtter Nov 24, 2023
7b471a8
Rowのダブルタップで強制的に現在駅をセットできるようにした
TetsuOtter Nov 24, 2023
4c9f153
LogViewに距離情報も出力するようにした
TetsuOtter Nov 24, 2023
7e7dba6
ForceLonLatまわりのテストを追加
TetsuOtter Nov 24, 2023
849cb2c
ログ出力を追加
TetsuOtter Nov 24, 2023
8af752f
ForceLonLatでRunningToNextStationにならない不具合を修正
TetsuOtter Nov 24, 2023
d4f70a2
現在位置更新時にスクロールしない問題を修正
TetsuOtter Nov 24, 2023
9908288
不要なプロパティを削除
TetsuOtter Nov 24, 2023
f7962aa
スクロール実行をUpdateCurrentRunningLocationVisualizer側に移動
TetsuOtter Nov 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rowのダブルタップで強制的に現在駅をセットできるようにした
  • Loading branch information
TetsuOtter committed Nov 24, 2023
commit 7b471a8016bf7e3eb9c6b2a8795301cd5cbb80d5
2 changes: 2 additions & 0 deletions TRViS.LocationService/ILocationService.cs
Original file line number Diff line number Diff line change
@@ -49,4 +49,6 @@ public interface ILocationService
bool IsRunningToNextStation { get; }

void ResetLocationInfo();

void ForceSetLocationInfo(int stationIndex, bool isRunningToNextStation);
}
28 changes: 28 additions & 0 deletions TRViS.LocationService/LonLatLocationService.cs
Original file line number Diff line number Diff line change
@@ -173,6 +173,34 @@ public void ForceSetLocationInfo(double lon_deg, double lat_deg)
LocationStateChanged?.Invoke(this, new(CurrentStationIndex, IsRunningToNextStation));
}

public void ForceSetLocationInfo(int stationIndex, bool isRunningToNextStation)
{
ResetLocationInfo(false);
if (StaLocationInfo is null)
{
LocationStateChanged?.Invoke(this, new(CurrentStationIndex, IsRunningToNextStation));
return;
}

if (stationIndex < 0 || StaLocationInfo.Length <= stationIndex)
{
LocationStateChanged?.Invoke(this, new(CurrentStationIndex, IsRunningToNextStation));
return;
}

bool isNextStationAvailable = 0 <= GetNextStationIndex(StaLocationInfo, stationIndex);
// 現在駅に位置情報がセットされていない場合、「IsNearby」判定ができないため、次の駅に走行中であると仮定する
// 但し、次の駅が存在しない場合は、次の駅のIsNearby判定ができないため、指定の駅に停車中であると仮定する
IsRunningToNextStation = isNextStationAvailable && isRunningToNextStation;
if (!StaLocationInfo[stationIndex].HasLonLatLocation)
{
IsRunningToNextStation = isNextStationAvailable;
}

CurrentStationIndex = stationIndex;
LocationStateChanged?.Invoke(this, new(CurrentStationIndex, IsRunningToNextStation));
}

double GetDistanceToStationAverage(in StaLocationInfo staLocationInfo, double lon_deg, double lat_deg)
{
double distanceToStation = Utils.CalculateDistance_m(lon_deg, lat_deg, staLocationInfo.Location_lon_deg, staLocationInfo.Location_lat_deg);
9 changes: 6 additions & 3 deletions TRViS/DTAC/VerticalTimetableView.cs
Original file line number Diff line number Diff line change
@@ -107,10 +107,13 @@ private void RowTapped(object? sender, EventArgs e)
logger.Trace("LocationService is not enabled");
}

if (IsLocationServiceEnabled)
logger.Info("Location Service disabled because of double tapping");
_lastTappInfo = null;
IsLocationServiceEnabled = false;
if (IsLocationServiceEnabled)
{
logger.Info("New LocationInfo is set because of double tapping (row:{0})", row.RowIndex);
LocationService.ForceSetLocationInfo(row.RowIndex, false);
return;
}

logger.Info("Tapped {0} -> set CurrentRunningRow to {0}", row.RowIndex);
switch (row.LocationState)
13 changes: 13 additions & 0 deletions TRViS/Services/LocationService.cs
Original file line number Diff line number Diff line change
@@ -112,6 +112,19 @@ public Task StartGPS()
return Task.Run(PositioningTask, gpsCancelation.Token);
}

public void ForceSetLocationInfo(int row, bool isRunningToNextStation)
{
if (!IsEnabled)
{
logger.Debug("IsEnabled is false -> do nothing");
return;
}

logger.Debug("ForceSetLocationInfo({0}, {1})", row, isRunningToNextStation);
LonLatLocationService.ForceSetLocationInfo(row, isRunningToNextStation);
logger.Debug("Done");
}

static Permissions.LocationWhenInUse LocationWhenInUsePermission { get; } = new();
async Task PositioningTask()
{