Merge commit 'c2c23d85fb08c2cf872b195f7f74d0de497430b9' into develop
This commit is contained in:
commit
54f3974527
@ -1,5 +1,5 @@
|
|||||||
export default [
|
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" : "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" : "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" : ""},
|
{"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" : ""},
|
||||||
|
@ -10,7 +10,9 @@ export const EachStopList = ({
|
|||||||
points,
|
points,
|
||||||
currentTrainData,
|
currentTrainData,
|
||||||
openStationACFromEachTrainInfo,
|
openStationACFromEachTrainInfo,
|
||||||
|
showThrew,
|
||||||
}) => {
|
}) => {
|
||||||
|
if (!showThrew && i.split(",")[1] == "通過") return null;
|
||||||
const [station, se, time] = i.split(","); // 阿波池田,発,6:21
|
const [station, se, time] = i.split(","); // 阿波池田,発,6:21
|
||||||
const Stations = stationList
|
const Stations = stationList
|
||||||
.map((a) => a.filter((d) => d.StationName == station))
|
.map((a) => a.filter((d) => d.StationName == station))
|
||||||
@ -43,7 +45,7 @@ export const EachStopList = ({
|
|||||||
.set("hour", parseInt(time.split(":")[0]))
|
.set("hour", parseInt(time.split(":")[0]))
|
||||||
.set("minute", parseInt(time.split(":")[1]))
|
.set("minute", parseInt(time.split(":")[1]))
|
||||||
.add(isNaN(currentTrainData?.delay) ? 0 : currentTrainData.delay, "minute");
|
.add(isNaN(currentTrainData?.delay) ? 0 : currentTrainData.delay, "minute");
|
||||||
const timeString = dates.format("HH:mm").split(":");
|
const timeString = se == "通過" ? "" : dates.format("HH:mm").split(":");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TouchableWithoutFeedback
|
<TouchableWithoutFeedback
|
||||||
@ -66,7 +68,9 @@ export const EachStopList = ({
|
|||||||
{lineIDs.map((lineID, index) => (
|
{lineIDs.map((lineID, index) => (
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: lineColorList[lineID],
|
backgroundColor: `${lineColorList[lineID]}${
|
||||||
|
se == "通過" ? "80" : ""
|
||||||
|
}`,
|
||||||
flex: 1,
|
flex: 1,
|
||||||
}}
|
}}
|
||||||
key={lineID}
|
key={lineID}
|
||||||
@ -97,9 +101,13 @@ export const EachStopList = ({
|
|||||||
flex: 1,
|
flex: 1,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Text style={{ fontSize: 20 }}>{station}</Text>
|
<Text
|
||||||
|
style={{ fontSize: 20, color: `#000${se == "通過" ? "5" : ""}` }}
|
||||||
|
>
|
||||||
|
{station}
|
||||||
|
</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 && (
|
||||||
@ -128,7 +136,7 @@ export const EachStopList = ({
|
|||||||
width: 60,
|
width: 60,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{timeString[0]}:{timeString[1]}
|
{se == "通過" ? "レ" : `${timeString[0]}:${timeString[1]}`}
|
||||||
</Text>
|
</Text>
|
||||||
<Text style={{ fontSize: 18, width: 50 }}>
|
<Text style={{ fontSize: 18, width: 50 }}>
|
||||||
{se?.replace("発", "出発").replace("着", "到着")}
|
{se?.replace("発", "出発").replace("着", "到着")}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { View, Text } from "react-native";
|
import { View, Text, LayoutAnimation, TouchableOpacity } from "react-native";
|
||||||
|
|
||||||
export const ScrollStickyContent = ({ currentTrainData }) => {
|
export const ScrollStickyContent = (props) => {
|
||||||
|
const { currentTrainData, showThrew, setShowThrew, haveThrough } = props;
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
@ -49,7 +50,32 @@ export const ScrollStickyContent = ({ currentTrainData }) => {
|
|||||||
>
|
>
|
||||||
見込
|
見込
|
||||||
</Text>
|
</Text>
|
||||||
<Text style={{ fontSize: 20, width: 50 }}></Text>
|
<TouchableOpacity
|
||||||
|
onPress={() => {
|
||||||
|
if (!haveThrough) return;
|
||||||
|
LayoutAnimation.configureNext({
|
||||||
|
duration: 200,
|
||||||
|
update: { type: "easeInEaseOut", springDamping: 0.6 },
|
||||||
|
});
|
||||||
|
setShowThrew(!showThrew);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<View style={{ flex: 1 }} />
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
fontSize: 12,
|
||||||
|
width: 50,
|
||||||
|
paddingBottom: 0,
|
||||||
|
margin: "auto",
|
||||||
|
textAlign: "center",
|
||||||
|
textAlignVertical: "center",
|
||||||
|
opacity: haveThrough ? 1 : 0,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
(通過{showThrew ? "▼" : "▶"})
|
||||||
|
</Text>
|
||||||
|
<View style={{ flex: 1 }} />
|
||||||
|
</TouchableOpacity>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
@ -11,7 +11,7 @@ import {
|
|||||||
import { SheetManager } from "react-native-actions-sheet";
|
import { SheetManager } from "react-native-actions-sheet";
|
||||||
import { AS } from "../../storageControl";
|
import { AS } from "../../storageControl";
|
||||||
import trainList from "../../assets/originData/trainList";
|
import trainList from "../../assets/originData/trainList";
|
||||||
import { lineList } from "../../lib/getStationList";
|
import { lineList, lineListPair } from "../../lib/getStationList";
|
||||||
import { useCurrentTrain } from "../../stateBox/useCurrentTrain";
|
import { useCurrentTrain } from "../../stateBox/useCurrentTrain";
|
||||||
import { checkDuplicateTrainData } from "../../lib/checkDuplicateTrainData";
|
import { checkDuplicateTrainData } from "../../lib/checkDuplicateTrainData";
|
||||||
import { getTrainType } from "../../lib/getTrainType";
|
import { getTrainType } from "../../lib/getTrainType";
|
||||||
@ -34,6 +34,7 @@ import { ShowSpecialTrain } from "./EachTrainInfo/ShowSpecialTrain";
|
|||||||
import { useTrainMenu } from "../../stateBox/useTrainMenu";
|
import { useTrainMenu } from "../../stateBox/useTrainMenu";
|
||||||
import { HeaderText } from "./EachTrainInfoCore/HeaderText";
|
import { HeaderText } from "./EachTrainInfoCore/HeaderText";
|
||||||
import { useStationList } from "../../stateBox/useStationList";
|
import { useStationList } from "../../stateBox/useStationList";
|
||||||
|
import { stationIDPair } from "../../lib/getStationList2";
|
||||||
|
|
||||||
export const EachTrainInfoCore = ({
|
export const EachTrainInfoCore = ({
|
||||||
actionSheetRef,
|
actionSheetRef,
|
||||||
@ -80,6 +81,9 @@ export const EachTrainInfoCore = ({
|
|||||||
const [trainPositionSwitch, setTrainPositionSwitch] = useState("false");
|
const [trainPositionSwitch, setTrainPositionSwitch] = useState("false");
|
||||||
const [currentPosition, setCurrentPosition] = useState([]);
|
const [currentPosition, setCurrentPosition] = useState([]);
|
||||||
const [trainData, setTrainData] = useState([]);
|
const [trainData, setTrainData] = useState([]);
|
||||||
|
const [trainDataWidhThrough, setTrainDataWithThrough] = useState([]);
|
||||||
|
const [showThrew, setShowThrew] = useState(false);
|
||||||
|
const [haveThrough, setHaveThrough] = useState(false);
|
||||||
|
|
||||||
const stationList =
|
const stationList =
|
||||||
originalStationList &&
|
originalStationList &&
|
||||||
@ -91,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)
|
||||||
@ -100,15 +104,75 @@ 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)
|
return StationNumbers;
|
||||||
.map((d) => d.StationNumber);
|
|
||||||
return StationNumbers[0];
|
|
||||||
});
|
});
|
||||||
|
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) => {
|
||||||
|
if (
|
||||||
|
d.StationNumber > baseStationNumberFirst &&
|
||||||
|
d.StationNumber < baseStationNumberSecond
|
||||||
|
) {
|
||||||
|
allThroughStation.push(`${d.Station_JP},通過,`);
|
||||||
|
setHaveThrough(true);
|
||||||
|
reverse = false;
|
||||||
|
} else {
|
||||||
|
if (
|
||||||
|
d.StationNumber < baseStationNumberFirst &&
|
||||||
|
d.StationNumber > baseStationNumberSecond
|
||||||
|
) {
|
||||||
|
allThroughStation.push(`${d.Station_JP},通過,`);
|
||||||
|
setHaveThrough(true);
|
||||||
|
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 =
|
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(":");
|
||||||
@ -193,9 +257,41 @@ export const EachTrainInfoCore = ({
|
|||||||
if (currentTrainData?.Pos.match("~")) {
|
if (currentTrainData?.Pos.match("~")) {
|
||||||
const pos = currentTrainData?.Pos.replace("(下り)", "")
|
const pos = currentTrainData?.Pos.replace("(下り)", "")
|
||||||
.replace("(上り)", "")
|
.replace("(上り)", "")
|
||||||
|
.replace("(徳島線)", "")
|
||||||
|
.replace("(高徳線)", "")
|
||||||
.split("~");
|
.split("~");
|
||||||
const direction = parseInt(currentTrainData?.Direction) || 0;
|
const direction = parseInt(currentTrainData?.Direction) || 0;
|
||||||
if (direction == 0) {
|
if (pos[0] == "児島" && pos[1] == "宇多津") {
|
||||||
|
setCurrentPosition(["M12", "Y09"]);
|
||||||
|
return;
|
||||||
|
} else if (pos[1] == "児島" && pos[0] == "宇多津") {
|
||||||
|
setCurrentPosition(["Y09", "M12"]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const currentPosID = Object.keys(originalStationList).map((key) => {
|
||||||
|
let firstStation = false;
|
||||||
|
let firstStationID = "";
|
||||||
|
let secondStation = false;
|
||||||
|
let secondStationID = "";
|
||||||
|
originalStationList[key].forEach((station) => {
|
||||||
|
if (station.Station_JP === pos[0]) {
|
||||||
|
firstStation = true;
|
||||||
|
firstStationID = station.StationNumber;
|
||||||
|
}
|
||||||
|
if (station.Station_JP === pos[1]) {
|
||||||
|
secondStation = true;
|
||||||
|
secondStationID = station.StationNumber;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (firstStation && secondStation) {
|
||||||
|
return [firstStationID, secondStationID];
|
||||||
|
} else return false;
|
||||||
|
});
|
||||||
|
const currentPos = currentPosID.filter((d) => d != false)[0];
|
||||||
|
if (currentPos) {
|
||||||
|
if (direction == 0) setCurrentPosition(currentPos.reverse());
|
||||||
|
else setCurrentPosition(currentPos);
|
||||||
|
} else if (direction == 0) {
|
||||||
setCurrentPosition([
|
setCurrentPosition([
|
||||||
getStationID(pos[1], stationList),
|
getStationID(pos[1], stationList),
|
||||||
getStationID(pos[0], stationList),
|
getStationID(pos[0], stationList),
|
||||||
@ -301,7 +397,9 @@ export const EachTrainInfoCore = ({
|
|||||||
shortHeader={<ShortHeader {...headerItem} />}
|
shortHeader={<ShortHeader {...headerItem} />}
|
||||||
longHeader={<LongHeader {...headerItem} />}
|
longHeader={<LongHeader {...headerItem} />}
|
||||||
topStickyContent={
|
topStickyContent={
|
||||||
<ScrollStickyContent currentTrainData={currentTrainData} />
|
<ScrollStickyContent
|
||||||
|
{...{ currentTrainData, showThrew, setShowThrew, haveThrough }}
|
||||||
|
/>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{headStation.length != 0 &&
|
{headStation.length != 0 &&
|
||||||
@ -360,17 +458,20 @@ export const EachTrainInfoCore = ({
|
|||||||
</Text>
|
</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
)}
|
)}
|
||||||
{trainData.map((i, index) =>
|
{trainDataWidhThrough.map((i, index) =>
|
||||||
i.split(",")[1] == "提" ? (
|
i.split(",")[1] == "提" ? (
|
||||||
<DataFromButton i={i} />
|
<DataFromButton i={i} />
|
||||||
) : (
|
) : (
|
||||||
<EachStopList
|
<EachStopList
|
||||||
i={i}
|
{...{
|
||||||
index={index}
|
i,
|
||||||
stationList={stationList}
|
index,
|
||||||
points={points}
|
stationList,
|
||||||
currentTrainData={currentTrainData}
|
points: points ? points[index] : false,
|
||||||
openStationACFromEachTrainInfo={openStationACFromEachTrainInfo}
|
currentTrainData,
|
||||||
|
openStationACFromEachTrainInfo,
|
||||||
|
showThrew,
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
|
@ -141,7 +141,7 @@ export const EachData: FC<Props> = (props) => {
|
|||||||
<Description
|
<Description
|
||||||
info={`${
|
info={`${
|
||||||
trainIDSwitch
|
trainIDSwitch
|
||||||
? currentTrainData?.PosNum
|
? currentTrainData?.PosNum+currentTrainData?.Line
|
||||||
: trainPositionText(currentTrainData)
|
: trainPositionText(currentTrainData)
|
||||||
} ${platformNumber ? platformNumber + "番線" : ""}`}
|
} ${platformNumber ? platformNumber + "番線" : ""}`}
|
||||||
onLongClick={() => {
|
onLongClick={() => {
|
||||||
|
@ -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
|
|
||||||
.split("")
|
|
||||||
.filter((s) => "A" < s && s < "Z")
|
|
||||||
.join(""),
|
|
||||||
ID: d
|
|
||||||
.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 (d[0] < array[0] && d[0] > array[1]) {
|
||||||
if (index1 > index2) {
|
return true;
|
||||||
if (index2 + 1 == index1) return [index1];
|
} else if (d[0] < array[1] && d[0] > array[0]) {
|
||||||
else {
|
return true;
|
||||||
const returnArray = [];
|
}else if (d[0] < array[0] && d[0] == array[1]) {
|
||||||
for (let i = index2 + 1; i <= index1; i++) {
|
return true;
|
||||||
returnArray.push(i);
|
} else if (d[0] == array[1] && d[0] > array[0]) {
|
||||||
}
|
return true;
|
||||||
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];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 通過駅の場合
|
return false;
|
||||||
}
|
});
|
||||||
|
return allThroughStation;
|
||||||
return [];
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
Loading…
Reference in New Issue
Block a user