Compare commits
6 Commits
4e367d1e3c
...
e5da54da85
Author | SHA1 | Date | |
---|---|---|---|
|
e5da54da85 | ||
|
59e7ba5290 | ||
|
83539d5df3 | ||
|
9e831ecd6e | ||
|
0d9c1cdb18 | ||
|
bc4cb450a3 |
@@ -83,23 +83,29 @@ export const EachTrainInfoCore = ({
|
|||||||
const [haveThrough, setHaveThrough] = useState(false);
|
const [haveThrough, setHaveThrough] = useState(false);
|
||||||
|
|
||||||
// 使用例
|
// 使用例
|
||||||
const stopStationIDList = trainDataWidhThrough.map((i) => {
|
const [stopStationIDList, setStopStationList] = useState([]);
|
||||||
const [station, se, time] = i.split(",");
|
useEffect(() => {
|
||||||
const Stations = stationList.map((a) =>
|
const x = trainDataWidhThrough.map((i) => {
|
||||||
a.filter((d) => d.StationName == station)
|
const [station, se, time] = i.split(",");
|
||||||
);
|
const Stations = stationList.map((a) =>
|
||||||
const StationNumbers =
|
a.filter((d) => d.StationName == station)
|
||||||
Stations &&
|
);
|
||||||
Stations.reduce((newArray, e) => {
|
const StationNumbers =
|
||||||
return newArray.concat(e);
|
Stations &&
|
||||||
}, []).map((d) => d.StationNumber);
|
Stations.reduce((newArray, e) => {
|
||||||
return StationNumbers;
|
return newArray.concat(e);
|
||||||
});
|
}, []).map((d) => d.StationNumber);
|
||||||
|
return StationNumbers;
|
||||||
|
});
|
||||||
|
setStopStationList(x);
|
||||||
|
}, [trainDataWidhThrough]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const isCancel = [];
|
const isCancel = [];
|
||||||
const stopStationList = trainData.map((i,index,array) => {
|
const stopStationList = trainData.map((i, index, array) => {
|
||||||
const [station, se, time] = i.split(",");
|
const [station, se, time] = i.split(",");
|
||||||
const [nextStation, nextSe, nextTime] = array[index+1]?.split(",") || [];
|
const [nextStation, nextSe, nextTime] =
|
||||||
|
array[index + 1]?.split(",") || [];
|
||||||
isCancel.push(se.includes("休") && nextSe.includes("休"));
|
isCancel.push(se.includes("休") && nextSe.includes("休"));
|
||||||
if (se == "通編") setHaveThrough(true);
|
if (se == "通編") setHaveThrough(true);
|
||||||
return stationList.map((a) => a.filter((d) => d.StationName == station));
|
return stationList.map((a) => a.filter((d) => d.StationName == station));
|
||||||
@@ -131,8 +137,9 @@ export const EachTrainInfoCore = ({
|
|||||||
d.StationNumber > baseStationNumberFirst &&
|
d.StationNumber > baseStationNumberFirst &&
|
||||||
d.StationNumber < baseStationNumberSecond
|
d.StationNumber < baseStationNumberSecond
|
||||||
) {
|
) {
|
||||||
|
allThroughStation.push(
|
||||||
allThroughStation.push(`${d.Station_JP},${isCancel[index] ? "通休編" : "通過"},`);
|
`${d.Station_JP},${isCancel[index] ? "通休編" : "通過"},`
|
||||||
|
);
|
||||||
setHaveThrough(true);
|
setHaveThrough(true);
|
||||||
reverse = false;
|
reverse = false;
|
||||||
} else {
|
} else {
|
||||||
@@ -140,7 +147,9 @@ export const EachTrainInfoCore = ({
|
|||||||
d.StationNumber < baseStationNumberFirst &&
|
d.StationNumber < baseStationNumberFirst &&
|
||||||
d.StationNumber > baseStationNumberSecond
|
d.StationNumber > baseStationNumberSecond
|
||||||
) {
|
) {
|
||||||
allThroughStation.push(`${d.Station_JP},${isCancel[index] ? "通休編" : "通過"},`);
|
allThroughStation.push(
|
||||||
|
`${d.Station_JP},${isCancel[index] ? "通休編" : "通過"},`
|
||||||
|
);
|
||||||
setHaveThrough(true);
|
setHaveThrough(true);
|
||||||
reverse = true;
|
reverse = true;
|
||||||
}
|
}
|
||||||
@@ -252,6 +261,7 @@ export const EachTrainInfoCore = ({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const position = getPosition(currentTrainData);
|
const position = getPosition(currentTrainData);
|
||||||
|
if (stopStationIDList.length == 0) return;
|
||||||
if (position) {
|
if (position) {
|
||||||
if (position.length > 1) {
|
if (position.length > 1) {
|
||||||
if (position[0] == "-Iyo") {
|
if (position[0] == "-Iyo") {
|
||||||
@@ -259,8 +269,7 @@ export const EachTrainInfoCore = ({
|
|||||||
stopStationIDList[
|
stopStationIDList[
|
||||||
stopStationIDList.findIndex((d) => d.includes("U14")) - 1
|
stopStationIDList.findIndex((d) => d.includes("U14")) - 1
|
||||||
][0];
|
][0];
|
||||||
}
|
} else if (position[0] == "+Iyo") {
|
||||||
else if (position[0] == "+Iyo") {
|
|
||||||
position[0] =
|
position[0] =
|
||||||
stopStationIDList[
|
stopStationIDList[
|
||||||
stopStationIDList.findIndex((d) => d.includes("U14")) + 1
|
stopStationIDList.findIndex((d) => d.includes("U14")) + 1
|
||||||
@@ -271,7 +280,7 @@ export const EachTrainInfoCore = ({
|
|||||||
stopStationIDList[
|
stopStationIDList[
|
||||||
stopStationIDList.findIndex((d) => d.includes("U14")) + 1
|
stopStationIDList.findIndex((d) => d.includes("U14")) + 1
|
||||||
][0];
|
][0];
|
||||||
}else if (position[1] == "-Iyo") {
|
} else if (position[1] == "-Iyo") {
|
||||||
position[1] =
|
position[1] =
|
||||||
stopStationIDList[
|
stopStationIDList[
|
||||||
stopStationIDList.findIndex((d) => d.includes("U14")) - 1
|
stopStationIDList.findIndex((d) => d.includes("U14")) - 1
|
||||||
@@ -281,7 +290,7 @@ export const EachTrainInfoCore = ({
|
|||||||
|
|
||||||
setCurrentPosition(position);
|
setCurrentPosition(position);
|
||||||
}
|
}
|
||||||
}, [currentTrainData]);
|
}, [currentTrainData,stopStationIDList]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
//列車現在地アイコン表示スイッチ
|
//列車現在地アイコン表示スイッチ
|
||||||
@@ -294,7 +303,7 @@ export const EachTrainInfoCore = ({
|
|||||||
const customTrainType = getTrainType({
|
const customTrainType = getTrainType({
|
||||||
type: customTrainDataDetector(data.trainNum, allCustomTrainData).type,
|
type: customTrainDataDetector(data.trainNum, allCustomTrainData).type,
|
||||||
});
|
});
|
||||||
|
|
||||||
const openTrainInfo = (d) => {
|
const openTrainInfo = (d) => {
|
||||||
const train = customTrainDataDetector(d, allCustomTrainData);
|
const train = customTrainDataDetector(d, allCustomTrainData);
|
||||||
let TrainNumber = "";
|
let TrainNumber = "";
|
||||||
@@ -365,9 +374,7 @@ export const EachTrainInfoCore = ({
|
|||||||
style: {
|
style: {
|
||||||
maxHeight: isLandscape ? height - 94 : (height / 100) * 70,
|
maxHeight: isLandscape ? height - 94 : (height / 100) * 70,
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
customTrainType.data === "notService"
|
customTrainType.data === "notService" ? "#777777ff" : "white",
|
||||||
? "#777777ff"
|
|
||||||
: "white",
|
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
shortHeader={
|
shortHeader={
|
||||||
|
@@ -34,8 +34,13 @@ export const FixedTrain: FC<props> = ({
|
|||||||
displaySize,
|
displaySize,
|
||||||
setDisplaySize,
|
setDisplaySize,
|
||||||
}) => {
|
}) => {
|
||||||
const {fixedPosition, setFixedPosition, currentTrain, getCurrentStationData, getPosition } =
|
const {
|
||||||
useCurrentTrain();
|
fixedPosition,
|
||||||
|
setFixedPosition,
|
||||||
|
currentTrain,
|
||||||
|
getCurrentStationData,
|
||||||
|
getPosition,
|
||||||
|
} = useCurrentTrain();
|
||||||
|
|
||||||
const { mapSwitch } = useTrainMenu();
|
const { mapSwitch } = useTrainMenu();
|
||||||
const { allCustomTrainData, allTrainDiagram } = useAllTrainDiagram();
|
const { allCustomTrainData, allTrainDiagram } = useAllTrainDiagram();
|
||||||
@@ -53,8 +58,7 @@ export const FixedTrain: FC<props> = ({
|
|||||||
const stationData = getCurrentStationData(trainID);
|
const stationData = getCurrentStationData(trainID);
|
||||||
if (stationData) {
|
if (stationData) {
|
||||||
setTrain(stationData);
|
setTrain(stationData);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
alert("追跡していた列車が消えました。追跡を終了します。");
|
alert("追跡していた列車が消えました。追跡を終了します。");
|
||||||
setFixedPosition({ type: null, value: null });
|
setFixedPosition({ type: null, value: null });
|
||||||
}
|
}
|
||||||
@@ -133,22 +137,27 @@ export const FixedTrain: FC<props> = ({
|
|||||||
});
|
});
|
||||||
setTrainDataWithThrough(mainArray);
|
setTrainDataWithThrough(mainArray);
|
||||||
}, [allTrainDiagram, stationList, trainID]);
|
}, [allTrainDiagram, stationList, trainID]);
|
||||||
const stopStationIDList = trainDataWidhThrough.map((i) => {
|
const [stopStationIDList, setStopStationList] = useState([]);
|
||||||
const [station, se, time] = i.split(",");
|
useEffect(() => {
|
||||||
const Stations = stationList.map((a) =>
|
const x = trainDataWidhThrough.map((i) => {
|
||||||
a.filter((d) => d.StationName == station)
|
const [station, se, time] = i.split(",");
|
||||||
);
|
const Stations = stationList.map((a) =>
|
||||||
const StationNumbers =
|
a.filter((d) => d.StationName == station)
|
||||||
Stations &&
|
);
|
||||||
Stations.reduce((newArray, e) => {
|
const StationNumbers =
|
||||||
return newArray.concat(e);
|
Stations &&
|
||||||
}, []).map((d) => d.StationNumber);
|
Stations.reduce((newArray, e) => {
|
||||||
return StationNumbers;
|
return newArray.concat(e);
|
||||||
});
|
}, []).map((d) => d.StationNumber);
|
||||||
|
return StationNumbers;
|
||||||
|
});
|
||||||
|
setStopStationList(x);
|
||||||
|
}, [trainDataWidhThrough]);
|
||||||
const [currentPosition, setCurrentPosition] = useState<string[]>([]);
|
const [currentPosition, setCurrentPosition] = useState<string[]>([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let position = getPosition(train);
|
let position = getPosition(train);
|
||||||
|
if (stopStationIDList.length == 0) return;
|
||||||
if (position) {
|
if (position) {
|
||||||
if (position.length > 1) {
|
if (position.length > 1) {
|
||||||
if (position[0] == "-Iyo") {
|
if (position[0] == "-Iyo") {
|
||||||
@@ -177,7 +186,7 @@ export const FixedTrain: FC<props> = ({
|
|||||||
|
|
||||||
setCurrentPosition(position);
|
setCurrentPosition(position);
|
||||||
}
|
}
|
||||||
}, [train]);
|
}, [train,stopStationIDList]);
|
||||||
|
|
||||||
const [nextStationData, setNextStationData] = useState<StationProps[]>([]);
|
const [nextStationData, setNextStationData] = useState<StationProps[]>([]);
|
||||||
const [untilStationData, setUntilStationData] = useState<StationProps[]>([]);
|
const [untilStationData, setUntilStationData] = useState<StationProps[]>([]);
|
||||||
|
@@ -31,10 +31,17 @@ export const findReversalPoints = (array, stopStationIDList) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
} else if (array[0] == "U15" && array[1] == "U14") {
|
||||||
|
|
||||||
|
return d[0] == "U13" ? true : false;
|
||||||
|
} else if (array[0] == "S17" && array[1] == "U14") {
|
||||||
|
|
||||||
|
return d[0] == "U14" ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let returndata = false;
|
let returndata = false;
|
||||||
d.forEach((x) => {
|
d.forEach((x) => {
|
||||||
|
console.log(array, x, d);
|
||||||
if (array[0] < x && x < array[1]) {
|
if (array[0] < x && x < array[1]) {
|
||||||
returndata = true;
|
returndata = true;
|
||||||
} else if (array[0] < x && x == array[1]) {
|
} else if (array[0] < x && x == array[1]) {
|
||||||
|
@@ -112,7 +112,7 @@ export const CurrentTrainProvider: FC<props> = ({ children }) => {
|
|||||||
currentTrainData: trainDataType
|
currentTrainData: trainDataType
|
||||||
) => string[] | undefined;
|
) => string[] | undefined;
|
||||||
const getPosition: getPositionFuncType = (currentTrainData) => {
|
const getPosition: getPositionFuncType = (currentTrainData) => {
|
||||||
//currentTrainData.Pos = "鴨川~端岡"; //test
|
//currentTrainData = {Pos:"伊予若宮~伊予大洲"}; //test
|
||||||
if (!currentTrainData) return;
|
if (!currentTrainData) return;
|
||||||
if (!currentTrainData?.Pos) return;
|
if (!currentTrainData?.Pos) return;
|
||||||
if (currentTrainData?.Pos.match("~")) {
|
if (currentTrainData?.Pos.match("~")) {
|
||||||
|
@@ -127,7 +127,8 @@ export const StationListProvider: FC<Props> = ({ children }) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (bootStationList[0].line === undefined) return "";
|
console.log(bootStationList[0]);
|
||||||
|
if (bootStationList[0] === undefined) return "";
|
||||||
return `MoveDisplayStation('${bootStationList[0].line}_${bootStationList[0].station.MyStation}_${bootStationList[0].station.Station_JP}');document.getElementById("disp").insertAdjacentHTML("afterbegin", "<div />");setReload();`;
|
return `MoveDisplayStation('${bootStationList[0].line}_${bootStationList[0].station.MyStation}_${bootStationList[0].station.Station_JP}');document.getElementById("disp").insertAdjacentHTML("afterbegin", "<div />");setReload();`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user