From 86655f5632f30cf9ebcfc437e329f60d5c4e9b5a Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sat, 19 Oct 2024 12:08:55 +0000 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E9=81=8E=E9=A7=85=E6=83=85=E5=A0=B1?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/originData/tokushima.ts | 2 +- .../EachTrainInfo/EachStopList.js | 2 +- .../EachTrainInfoCore.js | 87 ++++++++++++++++--- .../findReversalPoints.js | 4 +- 4 files changed, 80 insertions(+), 15 deletions(-) diff --git a/assets/originData/tokushima.ts b/assets/originData/tokushima.ts index c90b303..b94015d 100644 --- a/assets/originData/tokushima.ts +++ b/assets/originData/tokushima.ts @@ -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" : ""}, diff --git a/components/ActionSheetComponents/EachTrainInfo/EachStopList.js b/components/ActionSheetComponents/EachTrainInfo/EachStopList.js index a2813b3..dbfd194 100644 --- a/components/ActionSheetComponents/EachTrainInfo/EachStopList.js +++ b/components/ActionSheetComponents/EachTrainInfo/EachStopList.js @@ -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 ( 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 = ({ )} - {trainData.map((i, index) => + {trainDataWidhThrough.map((i, index) => i.split(",")[1] == "提" ? ( ) : ( - + ) )} {tailStation.length != 0 && diff --git a/lib/eachTrainInfoCoreLib/findReversalPoints.js b/lib/eachTrainInfoCoreLib/findReversalPoints.js index 05f6f55..a7cd70e 100644 --- a/lib/eachTrainInfoCoreLib/findReversalPoints.js +++ b/lib/eachTrainInfoCoreLib/findReversalPoints.js @@ -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(""),