-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(#9): ✨ Made the text clearer, added a box for elevation target
The text was blurry before, but should now be clear. Also added the showing of elevation for a target point
- Loading branch information
Showing
5 changed files
with
104 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
|
|
||
| #posCanvas { | ||
| position: absolute; | ||
| left: 10px; | ||
| bottom: 10px; | ||
| width: 300px; | ||
| height: 50px; | ||
| pointer-events: none; | ||
| background-color: #19282C; | ||
| z-index: 10; | ||
| border-radius: 5px; | ||
| } | ||
|
|
||
| #elevationCanvas { | ||
| position: absolute; | ||
| right: 100px; | ||
| top: 15px; | ||
| width: 300px; | ||
| height: 50px; | ||
| pointer-events: none; | ||
| background-color: #19282C; | ||
| z-index: 10; | ||
| border-radius: 5px; | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| // EPSG:32633 (WGS84 / UTM zone 33N) to WGS84 (lon/lat) | ||
| const utm33 = "+proj=utm +zone=33 +datum=WGS84 +units=m +no_defs"; //UTM zone 33N | ||
| const wgs84 = "+proj=longlat +datum=WGS84 +no_defs"; //WGS84 is the current standard for GPS coordinates | ||
|
|
||
| const posCanvas = document.getElementById('posCanvas'); | ||
| let posCtx = posCanvas.getContext('2d'); | ||
|
|
||
| const elevationCanvas = document.getElementById('elevationCanvas'); | ||
| let elevationCtx = elevationCanvas.getContext('2d'); | ||
|
|
||
|
|
||
| function resizeCanvas(canvas) { | ||
| const dpr = window.devicePixelRatio || 1; | ||
| const ctx = canvas.getContext('2d'); | ||
|
|
||
| // Set canvas internal size | ||
| canvas.width = canvas.clientWidth * dpr; | ||
| canvas.height = canvas.clientHeight * dpr; | ||
|
|
||
| // Scale context so drawing uses CSS pixels | ||
| ctx.setTransform(dpr, 0, 0, dpr, 0, 0); | ||
| return ctx; | ||
| } | ||
|
|
||
| function updateCameraOverlay() { | ||
| const cam = window.viewer.scene.view.position; | ||
| const [lon, lat] = proj4(utm33, wgs84, [cam.x, cam.y]); // Conversion using proj4js library | ||
|
|
||
| const centerX = posCanvas.clientWidth / 2; | ||
| const centerY = posCanvas.clientHeight / 2; | ||
|
|
||
| posCtx.clearRect(0, 0, posCanvas.width, posCanvas.height); | ||
| posCtx.fillStyle = '#cccccc'; | ||
| posCtx.font = '20px Arial'; | ||
| posCtx.textAlign = "center"; | ||
| posCtx.textBaseline = "middle"; | ||
| posCtx.fillText(`lat = ${lat.toFixed(2)}˚ lon = ${lon.toFixed(2)}˚`, centerX, centerY); | ||
| } | ||
|
|
||
|
|
||
| function targetElevation() { | ||
| const pivot = window.viewer.scene.view.getPivot(); | ||
| const mode = window.viewer.getControls(); | ||
|
|
||
| const centerX = elevationCanvas.clientWidth / 2; | ||
| const centerY = elevationCanvas.clientHeight / 2; | ||
|
|
||
| if (mode === window.viewer.orbitControls) { | ||
| elevationCanvas.style.display = 'inline'; | ||
| elevationCtx.clearRect(0, 0, elevationCanvas.width, elevationCanvas.height); | ||
| elevationCtx.fillStyle = '#cccccc'; | ||
| elevationCtx.font = '20px Arial'; | ||
| elevationCtx.textAlign = "center"; | ||
| elevationCtx.textBaseline = "middle"; | ||
| elevationCtx.fillText(`Target elevation = ${pivot.z.toFixed(2)}m`, centerX, centerY); | ||
| } | ||
| else{ | ||
| elevationCanvas.style.display = 'none'; | ||
| } | ||
| } | ||
|
|
||
|
|
||
| viewer.addEventListener("update", targetElevation); | ||
| viewer.addEventListener("update", updateCameraOverlay); | ||
|
|
||
| posCtx = resizeCanvas(posCanvas); | ||
| elevationCtx = resizeCanvas(elevationCanvas); | ||
|
|
||
| window.addEventListener('resize', () => { | ||
| posCtx = resizeCanvas(posCanvas); | ||
| elevationCtx = resizeCanvas(elevationCanvas); | ||
| }); | ||
|
|
||
|
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1 @@ | ||
| // EPSG:32633 (WGS84 / UTM zone 33N) → WGS84 (lon/lat) | ||
| const utm33 = "+proj=utm +zone=33 +datum=WGS84 +units=m +no_defs"; //UTM zone 33N | ||
| const wgs84 = "+proj=longlat +datum=WGS84 +no_defs"; //Current standard for GPS coordinates | ||
|
|
||
| const posCanvas = document.getElementById('camera-pos'); | ||
| const context = posCanvas.getContext('2d'); | ||
|
|
||
| function updateCameraOverlay() { | ||
| const cam = window.viewer.scene.view.position; | ||
| const [lon, lat] = proj4(utm33, wgs84, [cam.x, cam.y]); // Conversion using proj4js library | ||
|
|
||
| context.clearRect(0, 0, posCanvas.width, posCanvas.height); | ||
| context.fillStyle = 'white'; | ||
| context.font = '20px Times New Roman'; | ||
| context.fillText(`lat=${lat.toFixed(2)}˚ lon=${lon.toFixed(2)}˚`, 10, 40); | ||
| } | ||
| viewer.addEventListener("update", updateCameraOverlay); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +0,0 @@ | ||
|
|
||
| #camera-pos { | ||
| position: absolute; | ||
| left: 10px; | ||
| bottom: 10px; | ||
| width: 300px; | ||
| height: 60px; | ||
| pointer-events: none; | ||
| z-index: 10; | ||
| } | ||