import { Helpers } from "./Helpers"; import { DEBUG } from "./main"; export default class Building { public Footprint: GeoJSON.Feature | null; public Name: string; public Id: number; public RefPoint: Helpers.Coordinates.Utm; public RotationDegree: number; constructor(Raw: { id: number; designation: string; areaId: number; refPoint: { lat: number; lon: number; }; street: string; number: string; path: { lat: number; lon: number; }[]; pathRelative: { lat: number; lon: number; }[]; rotationDegree: number; }) { try { let footprintCoords = [ Raw.path.map(p => [ Helpers.Calculations.RadToDeg(p.lon), Helpers.Calculations.RadToDeg(p.lat) ]) ]; footprintCoords[0].push([ Helpers.Calculations.RadToDeg(Raw.path[0].lon), Helpers.Calculations.RadToDeg(Raw.path[0].lat) ]); // Last point == first point this.Footprint = { type: "Feature", properties: { name: Raw.designation }, geometry: { type: "Polygon", coordinates: footprintCoords } }; } catch { this.Footprint = null; } this.RefPoint = new Helpers.Coordinates.LatLon( Helpers.Calculations.RadToDeg(Raw.refPoint.lat), Helpers.Calculations.RadToDeg(Raw.refPoint.lon) ).ToUtm(); this.Name = Raw.designation; this.Id = Raw.id; this.RotationDegree = Raw.rotationDegree; if (DEBUG) console.log(`new Building() with Id = ${this.Id}`); } }