UNPKG

@golemio/parkings

Version:
44 lines 2.46 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; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.ParkingMachinesDtoTransformation = void 0; const AbstractTransformation_1 = require("@golemio/core/dist/helpers/transformation/AbstractTransformation"); const Geo_1 = require("@golemio/core/dist/output-gateway/Geo"); const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors"); const tsyringe_1 = require("@golemio/core/dist/shared/tsyringe"); let ParkingMachinesDtoTransformation = exports.ParkingMachinesDtoTransformation = class ParkingMachinesDtoTransformation extends AbstractTransformation_1.AbstractTransformation { constructor() { super(...arguments); this.name = "ParkingMachinesDtoTransformation"; this.transformToFeatureCollection = (elements) => { try { return (0, Geo_1.buildGeojsonFeatureCollection)(this.transformArray(elements)); } catch (err) { throw new golemio_errors_1.GeneralError("Transformation error", this.name, err, 500); } }; this.transformInternal = (element) => { return (0, Geo_1.buildGeojsonFeature)({ id: element.id, primary_source: element.source, primary_source_id: element.sourceId, code: element.code, machine_type: element.type, valid_from: element.validFrom, tariff_id: element.parking_tariffs_relation?.tariff_id, lon: element.location.coordinates[0], lat: element.location.coordinates[1], }, "lon", "lat", true); }; } }; exports.ParkingMachinesDtoTransformation = ParkingMachinesDtoTransformation = __decorate([ (0, tsyringe_1.injectable)() ], ParkingMachinesDtoTransformation); //# sourceMappingURL=ParkingMachinesDtoTransformation.js.map