diff --git a/components/ActionSheetComponents/EachTrainInfo/EachStopList.js b/components/ActionSheetComponents/EachTrainInfo/EachStopList.js
index 5ffecb7..f5d3fb6 100644
--- a/components/ActionSheetComponents/EachTrainInfo/EachStopList.js
+++ b/components/ActionSheetComponents/EachTrainInfo/EachStopList.js
@@ -107,7 +107,7 @@ export const EachStopList = ({
{station}
- {points && points.findIndex((d) => d == index) >= 0 ? (
+ {points ? (
๐
) : null}
{!isNaN(currentTrainData?.delay) && currentTrainData?.delay != 0 && (
diff --git a/components/ActionSheetComponents/EachTrainInfoCore.js b/components/ActionSheetComponents/EachTrainInfoCore.js
index 0ef42bb..5c283d9 100644
--- a/components/ActionSheetComponents/EachTrainInfoCore.js
+++ b/components/ActionSheetComponents/EachTrainInfoCore.js
@@ -95,7 +95,7 @@ export const EachTrainInfoCore = ({
);
// ไฝฟ็จไพ
- const stopStationIDList = trainData.map((i) => {
+ const stopStationIDList = trainDataWidhThrough.map((i) => {
const [station, se, time] = i.split(",");
const Stations = stationList.map((a) =>
a.filter((d) => d.StationName == station)
@@ -104,9 +104,7 @@ export const EachTrainInfoCore = ({
Stations &&
Stations.reduce((newArray, e) => {
return newArray.concat(e);
- }, [])
- .filter((d) => d.StationNumber)
- .map((d) => d.StationNumber);
+ }, []).map((d) => d.StationNumber);
return StationNumbers;
});
useEffect(() => {
@@ -142,7 +140,6 @@ export const EachTrainInfoCore = ({
d.StationNumber > baseStationNumberFirst &&
d.StationNumber < baseStationNumberSecond
) {
- console.log(d.Station_JP);
allThroughStation.push(`${d.Station_JP},้้,`);
setHaveThrough(true);
reverse = false;
@@ -151,7 +148,6 @@ export const EachTrainInfoCore = ({
d.StationNumber < baseStationNumberFirst &&
d.StationNumber > baseStationNumberSecond
) {
- console.log(d.Station_JP);
allThroughStation.push(`${d.Station_JP},้้,`);
setHaveThrough(true);
reverse = true;
@@ -176,7 +172,7 @@ export const EachTrainInfoCore = ({
const points =
trainPositionSwitch == "true"
? findReversalPoints(currentPosition, stopStationIDList)
- : [];
+ : stopStationIDList.map(() => false);
const trainName = useMemo(() => {
if (!data.limited) return "";
const limitedArray = data.limited.split(":");
@@ -439,7 +435,7 @@ export const EachTrainInfoCore = ({
i,
index,
stationList,
- points,
+ points: points ? points[index] : false,
currentTrainData,
openStationACFromEachTrainInfo,
showThrew,
diff --git a/lib/eachTrainInfoCoreLib/findReversalPoints.js b/lib/eachTrainInfoCoreLib/findReversalPoints.js
index a7cd70e..353a75c 100644
--- a/lib/eachTrainInfoCoreLib/findReversalPoints.js
+++ b/lib/eachTrainInfoCoreLib/findReversalPoints.js
@@ -7,105 +7,43 @@ export const findReversalPoints = (array, stopStationIDList) => {
if (!array instanceof Array) return [];
if (!array) return [];
if (array[0] instanceof Array) return [];
- 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[0]
- .split("")
- .filter((s) => "A" < s && s < "Z")
- .join(""),
- ID: d[0]
- .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];
- }
- }
+ const index = stopStationIDList.map((d) => {
+ let a = false;
+ d.forEach((x) => {
+ if (x == array[0]) a = true;
+ });
+ return a;
+ });
+ if (index != -1) {
+ return index;
}
}
// ้ง
้ใฎๅ ดๅ
if (array.length == 2) {
- const index1 = stopStationIDList.indexOf(array[0]);
- const index2 = stopStationIDList.indexOf(array[1]);
- 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;
+
+ const allThroughStation = stopStationIDList.map((d) => {
+ if(array[0] == "M12" && array[1] == "Y09" || array[0] == "Y09" && array[1] == "M12"){
+ if(d[0] == "M12"){
+ return true;
}
+ else return false;
}
- 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 {
- const getNearStationID = (stationID) => {
- for (let i = 0; i <= stopStationIDListNumber.length; i++) {
- if (stopStationIDListNumber[i].ID < stationID) {
- if (stopStationIDListNumber[i + 1].ID > stationID) {
- return i + 1;
- }
- }
- if (stopStationIDListNumber[i].ID > stationID) {
- if (stopStationIDListNumber[i + 1].ID < stationID) {
- return i + 1;
- }
- }
- }
- };
- let newIndex1 = index1;
- let newIndex2 = index2;
- if (index1 == -1) {
- newIndex1 = getNearStationID(arrayNumber[0].ID);
- }
- if (index2 == -1) {
- newIndex2 = getNearStationID(arrayNumber[1].ID);
- }
- if (newIndex1 && newIndex2) {
- return [newIndex1, newIndex2];
+ if (d[0] < array[0] && d[0] > array[1]) {
+ return true;
+ } else if (d[0] < array[1] && d[0] > array[0]) {
+ return true;
+ }else if (d[0] < array[0] && d[0] == array[1]) {
+ return true;
+ } else if (d[0] == array[1] && d[0] > array[0]) {
+ return true;
}
- // ้้้ง
ใฎๅ ดๅ
- }
-
- return [];
+ return false;
+ });
+ return allThroughStation;
}
} catch (e) {
console.log(e);