jrshikoku/lib/eachTrainInfoCoreLib/getStationData.js

28 lines
808 B
JavaScript

// 駅名から駅情報を取得する
//stationName: 駅名
//stationList: 駅情報リスト
export const getStationID = (stationName, stationList) => {
const Stations = stationList.map((a) =>
a.filter((d) => d.StationName == stationName)
);
const Station =
Stations &&
Stations.reduce((newArray, e) => {
return newArray.concat(e);
}, []);
if (!Station[0]) return [];
return Station.map((d) => d.StationNumber)[0];
};
export const getStationName = (stationId, stationList) => {
const Stations = stationList.map((a) =>
a.filter((d) => d.StationNumber == stationId)
);
const Station =
Stations &&
Stations.reduce((newArray, e) => {
return newArray.concat(e);
}, []);
if (!Station[0]) return [];
return Station.map((d) => d.StaitonName)[0];
};