Add: Json files for nearby busstops and a component for accessing said json files
This commit is contained in:
parent
68b6e4e836
commit
d304b250a2
36
src/APIexamples/locationuser1.json
Normal file
36
src/APIexamples/locationuser1.json
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"LocationList": {
|
||||||
|
"noNamespaceSchemaLocation": "http://api.vasttrafik.se/v1/hafasRestLocation.xsd",
|
||||||
|
"servertime": "16:48",
|
||||||
|
"serverdate": "2020-12-09",
|
||||||
|
"StopLocation": [
|
||||||
|
{
|
||||||
|
"name": "Bollestadsvägen, Kungälv",
|
||||||
|
"id": "9022014014754001",
|
||||||
|
"lat": "57.888940",
|
||||||
|
"lon": "11.885663",
|
||||||
|
"track": "A"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Bollestadsvägen, Kungälv",
|
||||||
|
"id": "9021014014754000",
|
||||||
|
"lat": "57.889030",
|
||||||
|
"lon": "11.885708"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Bollestadsvägen, Kungälv",
|
||||||
|
"id": "9022014014754002",
|
||||||
|
"lat": "57.889111",
|
||||||
|
"lon": "11.885753",
|
||||||
|
"track": "B"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Bredsten, Kungälv",
|
||||||
|
"id": "9022014014753002",
|
||||||
|
"lat": "57.886450",
|
||||||
|
"lon": "11.889529",
|
||||||
|
"track": "B"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
36
src/APIexamples/locationuser2.json
Normal file
36
src/APIexamples/locationuser2.json
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"LocationList": {
|
||||||
|
"noNamespaceSchemaLocation": "http://api.vasttrafik.se/v1/hafasRestLocation.xsd",
|
||||||
|
"servertime": "16:47",
|
||||||
|
"serverdate": "2020-12-09",
|
||||||
|
"StopLocation": [
|
||||||
|
{
|
||||||
|
"name": "Ekelöv västra, Kungälv",
|
||||||
|
"id": "9022014014020001",
|
||||||
|
"lat": "57.892527",
|
||||||
|
"lon": "11.865321",
|
||||||
|
"track": "A"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Ekelöv västra, Kungälv",
|
||||||
|
"id": "9021014014020000",
|
||||||
|
"lat": "57.892608",
|
||||||
|
"lon": "11.865312"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Ekelöv västra, Kungälv",
|
||||||
|
"id": "9022014014020002",
|
||||||
|
"lat": "57.892689",
|
||||||
|
"lon": "11.865285",
|
||||||
|
"track": "B"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Ekelöv östra, Kungälv",
|
||||||
|
"id": "9022014014021002",
|
||||||
|
"lat": "57.892994",
|
||||||
|
"lon": "11.873923",
|
||||||
|
"track": "B"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
36
src/APIexamples/locationuser3.json
Normal file
36
src/APIexamples/locationuser3.json
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"LocationList": {
|
||||||
|
"noNamespaceSchemaLocation": "http://api.vasttrafik.se/v1/hafasRestLocation.xsd",
|
||||||
|
"servertime": "16:45",
|
||||||
|
"serverdate": "2020-12-09",
|
||||||
|
"StopLocation": [
|
||||||
|
{
|
||||||
|
"name": "Guddeby, Kungälv",
|
||||||
|
"id": "9022014014751001",
|
||||||
|
"lat": "57.874665",
|
||||||
|
"lon": "11.903884",
|
||||||
|
"track": "A"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Guddeby, Kungälv",
|
||||||
|
"id": "9021014014751000",
|
||||||
|
"lat": "57.874710",
|
||||||
|
"lon": "11.903929"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Guddeby, Kungälv",
|
||||||
|
"id": "9022014014751002",
|
||||||
|
"lat": "57.874746",
|
||||||
|
"lon": "11.903965",
|
||||||
|
"track": "B"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Stället, Kungälv",
|
||||||
|
"id": "9022014014744001",
|
||||||
|
"lat": "57.869784",
|
||||||
|
"lon": "11.904172",
|
||||||
|
"track": "A"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
35
src/APIexamples/locationuser4.json
Normal file
35
src/APIexamples/locationuser4.json
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"LocationList": {
|
||||||
|
"noNamespaceSchemaLocation": "http://api.vasttrafik.se/v1/hafasRestLocation.xsd",
|
||||||
|
"servertime": "16:44",
|
||||||
|
"serverdate": "2020-12-09",
|
||||||
|
"StopLocation": [
|
||||||
|
{
|
||||||
|
"name": "Skrämmenborg, Kungälv",
|
||||||
|
"id": "9021014014225000",
|
||||||
|
"lat": "57.863528",
|
||||||
|
"lon": "11.867406"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Skrämmenborg, Kungälv",
|
||||||
|
"id": "9022014014225001",
|
||||||
|
"lat": "57.863528",
|
||||||
|
"lon": "11.867406",
|
||||||
|
"track": "A"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Kuröd, Kungälv",
|
||||||
|
"id": "9022014014762002",
|
||||||
|
"lat": "57.856966",
|
||||||
|
"lon": "11.863774",
|
||||||
|
"track": "B"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Kuröd, Kungälv",
|
||||||
|
"id": "9021014014762000",
|
||||||
|
"lat": "57.856831",
|
||||||
|
"lon": "11.864260"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
import User from './classes/User.js';
|
import User from './classes/User.js';
|
||||||
import Disruption from './classes/Disruption.js'
|
import Disruption from './classes/Disruption.js'
|
||||||
import Coordinates from "./classes/Coordinates.js";
|
import Coordinates from './classes/Coordinates.js';
|
||||||
|
import Stop from './classes/Stop.js'
|
||||||
|
|
||||||
let globalData = {
|
let globalData = {
|
||||||
user: new User(
|
user: new User(
|
||||||
@ -10,6 +11,8 @@ let globalData = {
|
|||||||
"9022014014020001"
|
"9022014014020001"
|
||||||
),
|
),
|
||||||
disruption: new Disruption(
|
disruption: new Disruption(
|
||||||
|
),
|
||||||
|
stop: new Stop(
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -7,8 +7,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
class Stop {
|
class Stop {
|
||||||
constructor(name, locations, departures) {
|
constructor(name, id, lat, lon, locations, departures) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
this.id = id;
|
||||||
|
this.lat = lat;
|
||||||
|
this.lon = lon;
|
||||||
this.locations = locations;
|
this.locations = locations;
|
||||||
this.departures = departures;
|
this.departures = departures;
|
||||||
}
|
}
|
||||||
|
41
src/components/FindStops.js
Normal file
41
src/components/FindStops.js
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
|
||||||
|
import globData from '../GlobalData.js';
|
||||||
|
|
||||||
|
import locationuser1 from '../APIexamples/locationuser1.json'
|
||||||
|
import locationuser2 from '../APIexamples/locationuser2.json'
|
||||||
|
import locationuser3 from '../APIexamples/locationuser3.json'
|
||||||
|
import locationuser4 from '../APIexamples/locationuser4.json'
|
||||||
|
|
||||||
|
import Button from './Button.js';
|
||||||
|
import disruptIcon from '../img/flash.svg';
|
||||||
|
|
||||||
|
class FindStops extends Button {
|
||||||
|
state = {
|
||||||
|
locations : ""
|
||||||
|
}
|
||||||
|
findStops = () => {
|
||||||
|
if(globData.user.deviceId === "1"){
|
||||||
|
this.state.locations = locationuser1.StopLocation
|
||||||
|
}else if (globData.user.deviceId === "2"){
|
||||||
|
this.state.locations = locationuser2.StopLocation
|
||||||
|
}else if (globData.user.deviceId === "3"){
|
||||||
|
this.state.locations = locationuser3.StopLocation
|
||||||
|
}else if (globData.user.deviceId === "4"){
|
||||||
|
this.state.locations = locationuser4.StopLocation
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Button onClick={[this.findStops]} className="disruptBtn">
|
||||||
|
<img src={disruptIcon} alt="" />
|
||||||
|
<span>Select nearby stops</span>
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export default FindStops;
|
0
src/components/StopSelector.js
Normal file
0
src/components/StopSelector.js
Normal file
Loading…
Reference in New Issue
Block a user