@golemio/parkings
Version:
Golemio Parkings Module
37 lines • 1.57 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TskFeatureMapper = exports.ParkingTypeEnum = void 0;
const output_gateway_1 = require("@golemio/core/dist/output-gateway");
var ParkingTypeEnum;
(function (ParkingTypeEnum) {
ParkingTypeEnum["ParkAndRide"] = "park_and_ride";
ParkingTypeEnum["ParkPaidPrivate"] = "park_paid_private";
})(ParkingTypeEnum || (exports.ParkingTypeEnum = ParkingTypeEnum = {}));
class TskFeatureMapper {
static formatOutput(record) {
const { parking_type, id, last_updated, payment_link, ...rest } = record.get({ plain: true });
return (0, output_gateway_1.buildGeojsonFeatureType)("centroid", {
parking_type: this.createParkingTypeObject(parking_type),
id: Number.isNaN(parseInt(id)) ? id : parseInt(id),
last_updated: last_updated ? new Date(last_updated).getTime() : null,
...rest,
...this.getPaymentAttributes(payment_link),
});
}
static createParkingTypeObject(parkingType) {
return parkingType === ParkingTypeEnum.ParkAndRide
? { description: "P+R parkoviště", id: 1 }
: { description: "placené parkoviště", id: 2 };
}
static getPaymentAttributes(paymentLink) {
if (!paymentLink) {
return {};
}
return {
payment_link: paymentLink,
payment_shortname: paymentLink.split("?shortname=").pop(),
};
}
}
exports.TskFeatureMapper = TskFeatureMapper;
//# sourceMappingURL=TskFeatureMapper.js.map