This repository has been archived by the owner on Feb 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
FlinksterParkingArea.js
49 lines (45 loc) · 1.93 KB
/
FlinksterParkingArea.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const access = require('safe-access');
const Location = require('./Location');
const MailAddress = require('./mailAddress');
class FlinksterParkingArea {
constructor(parkingArea) {
this.id = parkingArea.uid;
this.url = parkingArea.href;
this.name = parkingArea.name;
this.address = new MailAddress(parkingArea.address.city, parkingArea.address.zip, `${parkingArea.address.street} ${parkingArea.address.number}`);
this.address.district = parkingArea.address.district;
this.address.isoCountryCode = parkingArea.address.isoCountryCode;
this.parkingDescription = access(parkingArea, 'attributes.parking');
this.accessDescription = access(parkingArea, '.attributes.access');
this.locationDescription = access(parkingArea, '.attributes.locationnote');
this.publicTransport = access(parkingArea, '.attributes.publictransportation');
this.provider = new FlinksterAreaProvider(parkingArea.provider, parkingArea.providerAreaId, parkingArea.providerNetworkIds);
this.type = parkingArea.type;
if (parkingArea.geometry.position.type == 'Point') {
this.position = new Location(parkingArea.geometry.position.coordinates[0], parkingArea.geometry.position.coordinates[1]);
} else if (parkingArea.geometry.position.type == 'MultiPolygon') {
this.position = new Location(parkingArea.geometry.centroid.coordinates[0], parkingArea.geometry.centroid.coordinates[1]);
this.GeoJSON = {
type: 'FeatureCollection',
features: [{
type: 'Feature',
properties: {
name: parkingArea.name,
},
geometry: {
type: 'MultiPolygon',
coordinates: parkingArea.geometry.position.coordinates,
},
}],
};
}
}
}
class FlinksterAreaProvider {
constructor(provider, areaId, networkIds) {
this.url = provider.href;
this.areaId = areaId;
this.networkIds = networkIds;
}
}
module.exports = FlinksterParkingArea;