列車アイコンの位置を変更
This commit is contained in:
parent
64d56d3df6
commit
b6ba770a8a
@ -107,7 +107,7 @@ export const EachStopList = ({
|
|||||||
{station}
|
{station}
|
||||||
</Text>
|
</Text>
|
||||||
<View style={{ flex: 1 }} />
|
<View style={{ flex: 1 }} />
|
||||||
{points && points.findIndex((d) => d == index) >= 0 ? (
|
{points ? (
|
||||||
<Text style={{ fontSize: 20, marginRight: 70 }}>🚊</Text>
|
<Text style={{ fontSize: 20, marginRight: 70 }}>🚊</Text>
|
||||||
) : null}
|
) : null}
|
||||||
{!isNaN(currentTrainData?.delay) && currentTrainData?.delay != 0 && (
|
{!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 [station, se, time] = i.split(",");
|
||||||
const Stations = stationList.map((a) =>
|
const Stations = stationList.map((a) =>
|
||||||
a.filter((d) => d.StationName == station)
|
a.filter((d) => d.StationName == station)
|
||||||
@ -104,9 +104,7 @@ export const EachTrainInfoCore = ({
|
|||||||
Stations &&
|
Stations &&
|
||||||
Stations.reduce((newArray, e) => {
|
Stations.reduce((newArray, e) => {
|
||||||
return newArray.concat(e);
|
return newArray.concat(e);
|
||||||
}, [])
|
}, []).map((d) => d.StationNumber);
|
||||||
.filter((d) => d.StationNumber)
|
|
||||||
.map((d) => d.StationNumber);
|
|
||||||
return StationNumbers;
|
return StationNumbers;
|
||||||
});
|
});
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -142,7 +140,6 @@ export const EachTrainInfoCore = ({
|
|||||||
d.StationNumber > baseStationNumberFirst &&
|
d.StationNumber > baseStationNumberFirst &&
|
||||||
d.StationNumber < baseStationNumberSecond
|
d.StationNumber < baseStationNumberSecond
|
||||||
) {
|
) {
|
||||||
console.log(d.Station_JP);
|
|
||||||
allThroughStation.push(`${d.Station_JP},通過,`);
|
allThroughStation.push(`${d.Station_JP},通過,`);
|
||||||
setHaveThrough(true);
|
setHaveThrough(true);
|
||||||
reverse = false;
|
reverse = false;
|
||||||
@ -151,7 +148,6 @@ export const EachTrainInfoCore = ({
|
|||||||
d.StationNumber < baseStationNumberFirst &&
|
d.StationNumber < baseStationNumberFirst &&
|
||||||
d.StationNumber > baseStationNumberSecond
|
d.StationNumber > baseStationNumberSecond
|
||||||
) {
|
) {
|
||||||
console.log(d.Station_JP);
|
|
||||||
allThroughStation.push(`${d.Station_JP},通過,`);
|
allThroughStation.push(`${d.Station_JP},通過,`);
|
||||||
setHaveThrough(true);
|
setHaveThrough(true);
|
||||||
reverse = true;
|
reverse = true;
|
||||||
@ -176,7 +172,7 @@ export const EachTrainInfoCore = ({
|
|||||||
const points =
|
const points =
|
||||||
trainPositionSwitch == "true"
|
trainPositionSwitch == "true"
|
||||||
? findReversalPoints(currentPosition, stopStationIDList)
|
? findReversalPoints(currentPosition, stopStationIDList)
|
||||||
: [];
|
: stopStationIDList.map(() => false);
|
||||||
const trainName = useMemo(() => {
|
const trainName = useMemo(() => {
|
||||||
if (!data.limited) return "";
|
if (!data.limited) return "";
|
||||||
const limitedArray = data.limited.split(":");
|
const limitedArray = data.limited.split(":");
|
||||||
@ -439,7 +435,7 @@ export const EachTrainInfoCore = ({
|
|||||||
i,
|
i,
|
||||||
index,
|
index,
|
||||||
stationList,
|
stationList,
|
||||||
points,
|
points: points ? points[index] : false,
|
||||||
currentTrainData,
|
currentTrainData,
|
||||||
openStationACFromEachTrainInfo,
|
openStationACFromEachTrainInfo,
|
||||||
showThrew,
|
showThrew,
|
||||||
|
@ -7,105 +7,43 @@ export const findReversalPoints = (array, stopStationIDList) => {
|
|||||||
if (!array instanceof Array) return [];
|
if (!array instanceof Array) return [];
|
||||||
if (!array) return [];
|
if (!array) return [];
|
||||||
if (array[0] instanceof 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) {
|
if (array.length == 1) {
|
||||||
const index = stopStationIDList.indexOf(array[0]);
|
const index = stopStationIDList.map((d) => {
|
||||||
if (index != -1) return [index];
|
let a = false;
|
||||||
// 通過駅の場合
|
d.forEach((x) => {
|
||||||
for (let i = 0; i < stopStationIDListNumber.length - 1; i++) {
|
if (x == array[0]) a = true;
|
||||||
if (stopStationIDListNumber[i].ID < arrayNumber[0].ID) {
|
});
|
||||||
if (stopStationIDListNumber[i + 1].ID > arrayNumber[0].ID) {
|
return a;
|
||||||
return [i + 1];
|
});
|
||||||
}
|
if (index != -1) {
|
||||||
}
|
return index;
|
||||||
if (stopStationIDListNumber[i].ID > arrayNumber[0].ID) {
|
|
||||||
if (stopStationIDListNumber[i + 1].ID < arrayNumber[0].ID) {
|
|
||||||
return [i + 1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 駅間の場合
|
// 駅間の場合
|
||||||
if (array.length == 2) {
|
if (array.length == 2) {
|
||||||
const index1 = stopStationIDList.indexOf(array[0]);
|
|
||||||
const index2 = stopStationIDList.indexOf(array[1]);
|
const allThroughStation = stopStationIDList.map((d) => {
|
||||||
if (index1 != -1 && index2 != -1) {
|
if(array[0] == "M12" && array[1] == "Y09" || array[0] == "Y09" && array[1] == "M12"){
|
||||||
// 駅間で通過駅も無い場合
|
if(d[0] == "M12"){
|
||||||
if (index1 < index2) {
|
return true;
|
||||||
if (index1 + 1 == index2) {
|
|
||||||
return [index2];
|
|
||||||
} else {
|
|
||||||
const returnArray = [];
|
|
||||||
for (let i = index1 + 1; i <= index2; i++) {
|
|
||||||
returnArray.push(i);
|
|
||||||
}
|
|
||||||
return returnArray;
|
|
||||||
}
|
}
|
||||||
|
else return false;
|
||||||
}
|
}
|
||||||
if (index1 > index2) {
|
if (d[0] < array[0] && d[0] > array[1]) {
|
||||||
if (index2 + 1 == index1) return [index1];
|
return true;
|
||||||
else {
|
} else if (d[0] < array[1] && d[0] > array[0]) {
|
||||||
const returnArray = [];
|
return true;
|
||||||
for (let i = index2 + 1; i <= index1; i++) {
|
}else if (d[0] < array[0] && d[0] == array[1]) {
|
||||||
returnArray.push(i);
|
return true;
|
||||||
}
|
} else if (d[0] == array[1] && d[0] > array[0]) {
|
||||||
return returnArray;
|
return true;
|
||||||
}
|
|
||||||
}
|
|
||||||
} 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];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 通過駅の場合
|
return false;
|
||||||
}
|
});
|
||||||
|
return allThroughStation;
|
||||||
return [];
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
Loading…
Reference in New Issue
Block a user