列車アイコンの位置を変更
This commit is contained in:
parent
64d56d3df6
commit
b6ba770a8a
@ -107,7 +107,7 @@ export const EachStopList = ({
|
||||
{station}
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
{points && points.findIndex((d) => d == index) >= 0 ? (
|
||||
{points ? (
|
||||
<Text style={{ fontSize: 20, marginRight: 70 }}>🚊</Text>
|
||||
) : null}
|
||||
{!isNaN(currentTrainData?.delay) && currentTrainData?.delay != 0 && (
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
||||
const allThroughStation = stopStationIDList.map((d) => {
|
||||
if(array[0] == "M12" && array[1] == "Y09" || array[0] == "Y09" && array[1] == "M12"){
|
||||
if(d[0] == "M12"){
|
||||
return true;
|
||||
}
|
||||
return returnArray;
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user