通過駅情報を追加
This commit is contained in:
parent
c224025c52
commit
86655f5632
@ -1,5 +1,5 @@
|
||||
export default [
|
||||
{"Station_JP" : "徳島", "Station_EN" : "Tokushima", "MyStation" : "0", "StationNumber" : "T00", "DispNum" : "3", "StationTimeTable" : "http://www.jr-shikoku.co.jp/01_trainbus/jikoku/pdf/tokushima.pdf", "StationMap":"https://www.google.co.jp/maps/place/34.074642,134.550764", "JrHpUrl" : "http://www.jr-shikoku.co.jp/01_trainbus/kakueki/tokushima/"},
|
||||
{"Station_JP" : "徳島", "Station_EN" : "Tokushima", "MyStation" : "0", "StationNumber" : "B00", "DispNum" : "3", "StationTimeTable" : "http://www.jr-shikoku.co.jp/01_trainbus/jikoku/pdf/tokushima.pdf", "StationMap":"https://www.google.co.jp/maps/place/34.074642,134.550764", "JrHpUrl" : "http://www.jr-shikoku.co.jp/01_trainbus/kakueki/tokushima/"},
|
||||
{"Station_JP" : "佐古", "Station_EN" : "Sako", "MyStation" : "0", "StationNumber" : "B01", "DispNum" : "2", "StationTimeTable" : "http://www.jr-shikoku.co.jp/01_trainbus/jikoku/pdf/sako.pdf", "StationMap":"https://www.google.co.jp/maps/place/34.080616,134.538576", "JrHpUrl" : ""},
|
||||
{"Station_JP" : "蔵本", "Station_EN" : "Kuramoto", "MyStation" : "1", "StationNumber" : "B02", "DispNum" : "2", "StationTimeTable" : "http://www.jr-shikoku.co.jp/01_trainbus/jikoku/pdf/kuramoto.pdf", "StationMap":"https://www.google.co.jp/maps/place/34.079332,134.518705", "JrHpUrl" : ""},
|
||||
{"Station_JP" : "府中", "Station_EN" : "Kō", "MyStation" : "2", "StationNumber" : "B04", "DispNum" : "2", "StationTimeTable" : "http://www.jr-shikoku.co.jp/01_trainbus/jikoku/pdf/ko.pdf", "StationMap":"https://www.google.co.jp/maps/place/34.074134,134.482939", "JrHpUrl" : ""},
|
||||
|
@ -43,7 +43,7 @@ export const EachStopList = ({
|
||||
.set("hour", parseInt(time.split(":")[0]))
|
||||
.set("minute", parseInt(time.split(":")[1]))
|
||||
.add(isNaN(currentTrainData?.delay) ? 0 : currentTrainData.delay, "minute");
|
||||
const timeString = dates.format("HH:mm").split(":");
|
||||
const timeString = se == "通過"? "" :dates.format("HH:mm").split(":");
|
||||
|
||||
return (
|
||||
<TouchableWithoutFeedback
|
||||
|
@ -11,7 +11,7 @@ import {
|
||||
import { SheetManager } from "react-native-actions-sheet";
|
||||
import { AS } from "../../storageControl";
|
||||
import trainList from "../../assets/originData/trainList";
|
||||
import { lineList } from "../../lib/getStationList";
|
||||
import { lineList, lineListPair } from "../../lib/getStationList";
|
||||
import { useCurrentTrain } from "../../stateBox/useCurrentTrain";
|
||||
import { checkDuplicateTrainData } from "../../lib/checkDuplicateTrainData";
|
||||
import { getTrainType } from "../../lib/getTrainType";
|
||||
@ -34,6 +34,7 @@ import { ShowSpecialTrain } from "./EachTrainInfo/ShowSpecialTrain";
|
||||
import { useTrainMenu } from "../../stateBox/useTrainMenu";
|
||||
import { HeaderText } from "./EachTrainInfoCore/HeaderText";
|
||||
import { useStationList } from "../../stateBox/useStationList";
|
||||
import { stationIDPair } from "../../lib/getStationList2";
|
||||
|
||||
export const EachTrainInfoCore = ({
|
||||
actionSheetRef,
|
||||
@ -80,6 +81,7 @@ export const EachTrainInfoCore = ({
|
||||
const [trainPositionSwitch, setTrainPositionSwitch] = useState("false");
|
||||
const [currentPosition, setCurrentPosition] = useState([]);
|
||||
const [trainData, setTrainData] = useState([]);
|
||||
const [trainDataWidhThrough, setTrainDataWithThrough] = useState([]);
|
||||
|
||||
const stationList =
|
||||
originalStationList &&
|
||||
@ -103,8 +105,71 @@ export const EachTrainInfoCore = ({
|
||||
}, [])
|
||||
.filter((d) => d.StationNumber)
|
||||
.map((d) => d.StationNumber);
|
||||
return StationNumbers[0];
|
||||
return StationNumbers;
|
||||
});
|
||||
useEffect(() => {
|
||||
const stopStationList = trainData.map((i) => {
|
||||
const [station, se, time] = i.split(",");
|
||||
return stationList.map((a) => a.filter((d) => d.StationName == station));
|
||||
});
|
||||
const allThroughStationList = stopStationList.map((i, index, array) => {
|
||||
let allThroughStation = [];
|
||||
if (index == array.length - 1) return;
|
||||
|
||||
const firstItem = array[index];
|
||||
const secondItem = array[index + 1];
|
||||
let betweenStationLine = "";
|
||||
let baseStationNumberFirst = "";
|
||||
let baseStationNumberSecond = "";
|
||||
Object.keys(stationIDPair).forEach((d, index2, array) => {
|
||||
if (!d) return;
|
||||
const haveFirst = firstItem[index2];
|
||||
const haveSecond = secondItem[index2];
|
||||
if (haveFirst.length && haveSecond.length) {
|
||||
betweenStationLine = d;
|
||||
baseStationNumberFirst = haveFirst[0].StationNumber;
|
||||
baseStationNumberSecond = haveSecond[0].StationNumber;
|
||||
}
|
||||
});
|
||||
if (!betweenStationLine) return;
|
||||
let reverse = false;
|
||||
originalStationList[
|
||||
lineListPair[stationIDPair[betweenStationLine]]
|
||||
].forEach((d) => {
|
||||
console.log(d.StationNumber, baseStationNumberFirst, baseStationNumberSecond);
|
||||
if (
|
||||
d.StationNumber > baseStationNumberFirst &&
|
||||
d.StationNumber < baseStationNumberSecond
|
||||
) {
|
||||
console.log(d.Station_JP);
|
||||
allThroughStation.push(`${d.Station_JP},通過,`);
|
||||
reverse = false;
|
||||
} else {
|
||||
if (
|
||||
d.StationNumber < baseStationNumberFirst &&
|
||||
d.StationNumber > baseStationNumberSecond
|
||||
) {
|
||||
console.log(d.Station_JP);
|
||||
allThroughStation.push(`${d.Station_JP},通過,`);
|
||||
reverse = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
if (reverse) allThroughStation.reverse();
|
||||
return allThroughStation;
|
||||
});
|
||||
let mainArray = [...trainData];
|
||||
let indexs = 0;
|
||||
trainData.forEach((d, index, array) => {
|
||||
indexs = indexs+1;
|
||||
if(!allThroughStationList[index]) return;
|
||||
if(allThroughStationList[index].length == 0) return;
|
||||
mainArray.splice(indexs, 0, ...allThroughStationList[index]);
|
||||
indexs = indexs+allThroughStationList[index].length;
|
||||
});
|
||||
setTrainDataWithThrough(mainArray);
|
||||
}, [trainData]);
|
||||
|
||||
const points =
|
||||
trainPositionSwitch == "true"
|
||||
? findReversalPoints(currentPosition, stopStationIDList)
|
||||
@ -360,18 +425,18 @@ export const EachTrainInfoCore = ({
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
{trainData.map((i, index) =>
|
||||
{trainDataWidhThrough.map((i, index) =>
|
||||
i.split(",")[1] == "提" ? (
|
||||
<DataFromButton i={i} />
|
||||
) : (
|
||||
<EachStopList
|
||||
i={i}
|
||||
index={index}
|
||||
stationList={stationList}
|
||||
points={points}
|
||||
currentTrainData={currentTrainData}
|
||||
openStationACFromEachTrainInfo={openStationACFromEachTrainInfo}
|
||||
/>
|
||||
<EachStopList
|
||||
i={i}
|
||||
index={index}
|
||||
stationList={stationList}
|
||||
points={points}
|
||||
currentTrainData={currentTrainData}
|
||||
openStationACFromEachTrainInfo={openStationACFromEachTrainInfo}
|
||||
/>
|
||||
)
|
||||
)}
|
||||
{tailStation.length != 0 &&
|
||||
|
@ -20,11 +20,11 @@ export const findReversalPoints = (array, stopStationIDList) => {
|
||||
const stopStationIDListNumber = stopStationIDList.map((d) => {
|
||||
if (!d) return { line: [], ID: [] };
|
||||
return {
|
||||
line: d
|
||||
line: d[0]
|
||||
.split("")
|
||||
.filter((s) => "A" < s && s < "Z")
|
||||
.join(""),
|
||||
ID: d
|
||||
ID: d[0]
|
||||
.split("")
|
||||
.filter((s) => "0" <= s && s <= "9")
|
||||
.join(""),
|
||||
|
Loading…
Reference in New Issue
Block a user