Skip to content
This repository has been archived by the owner on Feb 18, 2022. It is now read-only.

Refactorings and small improvments #61

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env.default
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#your api key
DBDeveloperAuthorization=
#enable routing
experimental=true
19 changes: 19 additions & 0 deletions .idea/$PRODUCT_WORKSPACE_FILE$

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

116 changes: 116 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions 1BahnQL.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if this file is needed. looks to me like an config file

<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
5 changes: 3 additions & 2 deletions Routing/Route.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const RoutePart = require("./RoutePart.js");

class Route {

constructor(data) {
this.parts = data.parts.map(element => new RoutePart(element))
this.parts = data.legs.map(element => new RoutePart(element));
}

}

module.exports = Route
module.exports = Route;
17 changes: 17 additions & 0 deletions Routing/RouteLine.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class RouteLine {

constructor(payload) {
this.type = payload.type;
this.id = payload.id;
this.fahrtNr = payload.fahrtNr;
this.name = payload.name;
this.public = payload.public;
this.adminCode = payload.adminCode;
this.mode = payload.mode;
this.product = payload.product;
this.additionalName = payload.additionalName;
}

}

module.exports = RouteLine;
12 changes: 12 additions & 0 deletions Routing/RouteLocation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class RouteLocation {

constructor(payload) {
this.type = payload.type;
this.id = payload.id;
this.latitude = payload.latitude;
this.longitude = payload.longitude;
}

}

module.exports = RouteLocation;
33 changes: 20 additions & 13 deletions Routing/RoutePart.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
const VehicleProduct = require("./VehicleProduct.js");
const RouteStop = require("./RouteStop.js");
const RouteLine = require("./RouteLine.js");

class RoutePart {
constructor(route) {
this.delay = route.delay || 0;
this.direction = route.direction;
this.start = route.start;
this.end = route.end;
if(route.line) {
this.product = new VehicleProduct(route.line);
}
this.fromEvaId = route.origin.id;
this.toEvaId = route.destination.id;
this.arrivingPlatformNumber = route.arrivalPlatform;
this.departingPlatformNumber = route.departurePlatform;

constructor(payload) {
this.origin = new RouteStop(payload.origin);
this.destination = new RouteStop(payload.destination);
this.arrival = payload.arrival;
this.plannedArrival = payload.plannedArrival;
this.arrivalDelay = payload.arrivalDelay;
this.departure = payload.departure;
this.plannedDeparture = payload.plannedDeparture;
this.reachble = payload.reachble;
this.tripId = payload.tripId;
this.line = (payload.line) ? new RouteLine(payload.line) : null;
this.direction = payload.direction;
this.arrivalPlatform = payload.arrivalPlatform;
this.plannedArrivalPlatform = payload.plannedArrivalPlatform;
this.departurePlatform = payload.departurePlatform;
this.plannedDeparturePlatform = payload.plannedDeparturePlatform;
}

}

module.exports = RoutePart;
18 changes: 18 additions & 0 deletions Routing/RouteProducts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class RouteProducts {

constructor(payload) {
this.nationalExpress = payload.nationalExpress;
this.national = payload.national;
this.regionalExp = payload.regionalExp;
this.regional = payload.regional;
this.suburban = payload.suburban;
this.bus = payload.bus;
this.ferry = payload.ferry;
this.subway = payload.subway;
this.tram = payload.tram;
this.taxi = payload.taxi;
}

}

module.exports = RouteProducts;
39 changes: 0 additions & 39 deletions Routing/RouteRelationships.js

This file was deleted.

16 changes: 16 additions & 0 deletions Routing/RouteStop.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const RouteLocation = require("./RouteLocation.js");
const RouteProducts = require("./RouteProducts.js");

class RouteStop {

constructor(payload) {
this.type = payload.type;
this.id = payload.id;
this.name = payload.name;
this.location = new RouteLocation(payload.location);
this.products = new RouteProducts(payload.products);
}

}

module.exports = RouteStop;
26 changes: 16 additions & 10 deletions Routing/RoutingService.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
const hafas = require('db-hafas')
const Route = require("./Route.js")
const Route = require("./Route.js");
const createHafas = require('db-hafas');
const hafas = createHafas('routing-service');

class RoutingService {

constructor() {
this.relationships;
routes(from, to, departure, arrival) {
let opt = {
results: 10,
};
if(departure) {
opt.departure = new Date(departure);
}
if(arrival) {
opt.arrival = new Date(arrival);
}
return hafas.journeys(from + "", to + "", opt)
.then(result => result.journeys.map(element => new Route(element)));
}

routes(from, to) {
const self = this
return hafas.journeys(from + "", to + "")
.then(result => result.map(element => self.relationships.resolve(new Route(element))))
}
}

module.exports = RoutingService
module.exports = RoutingService;
10 changes: 0 additions & 10 deletions Routing/VehicleProduct.js

This file was deleted.

Loading