UNPKG

@golemio/parkings

Version:
81 lines 3.99 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.TskParkingSectionTransformation = void 0; const SourceEnum_1 = require("../../helpers/constants/SourceEnum"); const AbstractTransformation_1 = require("@golemio/core/dist/helpers/transformation/AbstractTransformation"); const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe"); const wkt_1 = require("@terraformer/wkt"); const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors"); const GeodataHelper_1 = require("../helpers/GeodataHelper"); const helpers_1 = require("@golemio/core/dist/helpers"); let TskParkingSectionTransformation = exports.TskParkingSectionTransformation = class TskParkingSectionTransformation extends AbstractTransformation_1.AbstractTransformation { constructor(transformationDate) { super(); this.transformationDate = transformationDate; this.name = "TskParkingSectionTransformation"; this.transformInternal = (section) => { const location = (0, wkt_1.wktToGeoJSON)(section.borderWKT); const valid_from = helpers_1.DateTime.fromISO(section.activeFrom, { timeZone: "Europe/Prague" }).toISOString(); return { id: "tsk2-" + section.sectionCode, source: SourceEnum_1.SourceEnum.TSK_V2, source_id: section.idSection, data_provider: "www.tsk-praha.cz", location, name: section.sectionCode, total_spot_number: section.projectedCapacity, category: this.getSectionCat(section.sectionCat), valid_from, parking_type: "on_street", zone_type: "zone", date_modified: this.transformationDate.toISOString(), centroid: (0, GeodataHelper_1.getPointOnFeature)(location), parking_policy: "zone", active: true, }; }; this.transformParkingTariffsRelation = (sections) => { const parkingTariffsIdPairs = []; for (const section of sections) { if (section.idTariff) { parkingTariffsIdPairs.push({ parking_id: "tsk2-" + section.sectionCode, tariff_id: section.idTariff, source: SourceEnum_1.SourceEnum.TSK_V2, }); } } return parkingTariffsIdPairs; }; } getSectionCat(catNo) { switch (catNo) { case 1: return "blue"; case 2: return "violet"; case 3: return "orange"; case 6: return "other"; case 7: return "other"; default: throw new golemio_errors_1.GeneralError(`Unknown section category ${catNo} in TSK parking zones.`); } } }; exports.TskParkingSectionTransformation = TskParkingSectionTransformation = __decorate([ (0, tsyringe_1.injectable)(), __metadata("design:paramtypes", [Date]) ], TskParkingSectionTransformation); //# sourceMappingURL=TskParkingSectionTransformation.js.map