-
Notifications
You must be signed in to change notification settings - Fork 12
Refactorings and small improvments #61
base: develop
Are you sure you want to change the base?
Changes from all commits
13a1b76
deec3b3
90ec6d0
f6fcbd8
3696ee8
ce026dc
44fff15
319b0fb
0ecf2ff
ccfc0e9
c59dd22
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#your api key | ||
DBDeveloperAuthorization= | ||
#enable routing | ||
experimental=true |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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> |
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; |
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; |
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; |
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; |
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; |
This file was deleted.
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; |
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; |
This file was deleted.
There was a problem hiding this comment.
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