UNPKG

@dasch-swiss/dsp-js

Version:
66 lines 2.23 kB
import { __decorate, __metadata } from "tslib"; import { JsonObject, JsonProperty } from 'json2typescript'; import { Constants } from '../../../Constants'; import { ReadValue } from './read-value'; /** * @category Internal */ let ParseReadGeomValue = class ParseReadGeomValue extends ReadValue { constructor() { super(...arguments); this.geometryString = ''; } }; __decorate([ JsonProperty(Constants.GeometryValueAsGeometry, String), __metadata("design:type", Object) ], ParseReadGeomValue.prototype, "geometryString", void 0); ParseReadGeomValue = __decorate([ JsonObject('ReadGeomValue') ], ParseReadGeomValue); export { ParseReadGeomValue }; /** * Represents a point in a 2D-coordinate system (for geometry values). * * @category Model V2 */ export class Point2D { constructor(x, y) { this.x = x; this.y = y; } } /** * Represents a geometry value parsed from JSON. * * @category Model V2 */ export class RegionGeometry { constructor(status, lineColor, lineWidth, points, type, radius) { this.status = status; this.lineColor = lineColor; this.lineWidth = lineWidth; this.points = points; this.type = type; this.radius = radius; } } /** * @category Model V2 */ export class ReadGeomValue extends ReadValue { constructor(geometry) { super(geometry.id, geometry.type, geometry.attachedToUser, geometry.arkUrl, geometry.versionArkUrl, geometry.valueCreationDate, geometry.hasPermissions, geometry.userHasPermission, geometry.uuid, geometry.propertyLabel, geometry.propertyComment, geometry.property, 'GEOMETRY', geometry.valueHasComment); const geometryJSON = JSON.parse(geometry.geometryString); const points = []; for (const point of geometryJSON.points) { points.push(new Point2D(point.x, point.y)); } let radius; if (geometryJSON.radius) { radius = new Point2D(geometryJSON.radius.x, geometryJSON.radius.y); } this.geometry = new RegionGeometry(geometryJSON.status, geometryJSON.lineColor, geometryJSON.lineWidth, points, geometryJSON.type, radius); } } //# sourceMappingURL=read-geom-value.js.map