diff --git a/components/ActionSheetComponents/EachTrainInfo.js b/components/ActionSheetComponents/EachTrainInfo.js
index 83bf1b4..73972f0 100644
--- a/components/ActionSheetComponents/EachTrainInfo.js
+++ b/components/ActionSheetComponents/EachTrainInfo.js
@@ -81,11 +81,89 @@ export const EachTrainInfo = ({
return StationNumbers[0];
});
function findReversalPoints(array) {
- return null;
+ // arrayは現在位置の駅ID(駅在宅の場合は1つの配列、駅間の場合は2つの配列)
+ // stopStationIDListは停車駅の駅IDの配列
+ const arrayNumber = array.map((d) => ({
+ line: d
+ .split("")
+ .filter((s) => "A" < s && s < "Z")
+ .join(""),
+ ID: d
+ .split("")
+ .filter((s) => "0" <= s && s <= "9")
+ .join(""),
+ }));
+ const stopStationIDListNumber = stopStationIDList.map((d) => {
+ if (!d) return { line: [], ID: [] };
+ return {
+ line: d
+ .split("")
+ .filter((s) => "A" < s && s < "Z")
+ .join(""),
+ ID: d
+ .split("")
+ .filter((s) => "0" <= s && s <= "9")
+ .join(""),
+ };
+ });
+ // 完全一致
+ if (array.length == 1) {
+ const index = stopStationIDList.indexOf(array[0]);
+ if (index != -1) return [index];
+ // 通過駅の場合
+ for (let i = 0; i < stopStationIDListNumber.length - 1; i++) {
+ if (stopStationIDListNumber[i].ID < arrayNumber[0].ID) {
+ if (stopStationIDListNumber[i + 1].ID > arrayNumber[0].ID) {
+ return [i + 1];
+ }
+ }
+ if (stopStationIDListNumber[i].ID > arrayNumber[0].ID) {
+ if (stopStationIDListNumber[i + 1].ID < arrayNumber[0].ID) {
+ return [i + 1];
+ }
+ }
+ }
+ }
+ // 駅間の場合
+ if (array.length == 2) {
+ const index1 = stopStationIDList.indexOf(array[0]);
+ const index2 = stopStationIDList.indexOf(array[1]);
+ console.log(index1, index2);
+ if (index1 != -1 && index2 != -1) {
+ // 駅間で通過駅も無い場合
+ if (index1 < index2) {
+ if (index1 + 1 == index2) {
+ return [index2];
+ } else {
+ const returnArray = [];
+ for (let i = index1 + 1; i <= index2; i++) {
+ returnArray.push(i);
+ }
+ return returnArray;
+ }
+ }
+ if (index1 > index2) {
+ if (index2 + 1 == index1) return [index1];
+ else {
+ const returnArray = [];
+ for (let i = index2 + 1; i <= index1; i++) {
+ returnArray.push(i);
+ }
+ return returnArray;
+ }
+ }
+ } else {
+ }
+
+ // 通過駅の場合
+ }
+
+ return [];
}
// 使用例
const points = findReversalPoints(currentPosition);
+ console.log(points);
useEffect(() => {
console.log(data);
@@ -435,7 +513,7 @@ export const EachTrainInfo = ({
>
見込
- 着発
+
@@ -537,6 +615,9 @@ export const EachTrainInfo = ({
>
{station}
+ {points.findIndex((d) => d == index) >= 0 ? (
+ ほげ
+ ) : null}
{!isNaN(data.trainData?.delay) &&
data.trainData?.delay != 0 && (
{timeString[0]}:{timeString[1]}
- ({se})
+
+ {se?.replace("発", "出発").replace("着", "到着")}
+