From 1cec716b20ee775da1bf472de46bd60bc1eeeeda Mon Sep 17 00:00:00 2001 From: Matthias Betz <matthias.betz@hft-stuttgart.de> Date: Mon, 2 Jun 2025 15:42:46 +0200 Subject: [PATCH] convert saving position to wgs84 --- src/index.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index e97d32c..fe3ba4f 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,5 @@ import { ToolboxType, WindowSlot, NotificationType } from '@vcmap/ui'; -import { Cesium3DTileStyle, Math as CMath, Cartesian3, ConstantProperty, Transforms, HeadingPitchRoll, Cesium3DTileset, Matrix4 } from '@vcmap-cesium/engine'; +import { Cesium3DTileStyle, Math as CMath, Ellipsoid, Cartesian3, ConstantProperty, Transforms, HeadingPitchRoll, Cesium3DTileset, Matrix4 } from '@vcmap-cesium/engine'; import { AbstractInteraction, EventType } from '@vcmap/core'; import { name, version, mapVersion } from '../package.json'; import BIMOptions, { bimOptionsId } from './upload.vue'; @@ -90,9 +90,13 @@ function saveObjects() { if (tempRoll !== undefined) { heading = tempRoll.heading; } + const ellipPos = Ellipsoid.WGS84.cartesianToCartographic(m.model.position.getValue()); + const wgs84X = CMath.toDegrees(ellipPos.longitude); + const wgs84Y = CMath.toDegrees(ellipPos.latitude); + const height = ellipPos.height; outputArray.push({ name: m.name, - position: m.model.position.getValue(), + position: [wgs84X, wgs84Y, height], heading: heading, scale: m.model.model.scale.getValue(), }); @@ -314,10 +318,11 @@ export default function smartVillagesPlugin(config, baseUrl) { // abort return; } + const cartPos = Cartesian3.fromDegrees(loadingObject.position[0], loadingObject.position[1], loadingObject.position[2]); // Add the model to the viewer model = vcMap.getEntities().add({ name: loadingObject.name, - position: loadingObject.position, + position: cartPos, model: { uri: objectUrl, scale: loadingObject.scale, -- GitLab