Skip to content

56-display-lat-lon-and-elevation-in-2d-profile-measurement #57

Merged

Conversation

gautegf
Copy link
Member

@gautegf gautegf commented Nov 2, 2025

Issue number

Closes #56

Description

Because of the change of coordinate system the z coordinate no longer represents the elevation of a point. Instead of displaying x,y,z it now displays lat, lon, and elevation which is more useful to the user. Also removed some of the attributes which are 0 and cluttering the space

Testing steps

  • Create a profile measurement, and open the 2D profile. Check if the y-axis displays correct depth values. Also hover points to see if the info box shows lat, lan, and elevation, and check if the values look correct.

  • Try to hover a lot of points going back and forth across the 2D profile, and see if the info window stays persistent. I have seen a bug before where it sometimes reverts to the x, y, z view, but I think that is fixed. If this happens, try restarting the dev environment.

… x,y,z

Because of the change of coordinate system the z coordinate no longer represents the elevation of a point. Instead of displaying x,y,z it now displays lat, lon, and elevation which is more useful to the user. Also removed some of the attributes which are 0 and cluttering the space
@gautegf gautegf self-assigned this Nov 2, 2025
@gautegf gautegf linked an issue Nov 2, 2025 that may be closed by this pull request
@coderabbit
Copy link

coderabbit bot commented Nov 2, 2025

Walkthrough

A new 2D profile override module is added to customize Potree's profile visualization. It includes CSS styling to fix clipping and improve label readability, a JavaScript module that patches profile behavior to derive elevation from ECEF coordinates and modify the selection panel display, and integrates this into the main viewer initialization.

Changes

Cohort / File(s) Summary
Profile Override CSS
index.html, src/2DProfileOverride/2DProfileOverride.css
Adds stylesheet link to HTML head; introduces CSS rules to prevent SVG content clipping with overflow: visible and improves axis label visibility with stroke styling
Profile Override Module
src/2DProfileOverride/2DProfileOverride.js
New module that patches ProfileWindow.addPoints to extract elevation from ECEF coordinates, sets up MutationObserver to override the selection info panel display with lon/lat/elevation, includes patching retry logic with timeout, and handles errors gracefully
Viewer Integration
src/potreeViewer.js
Imports init2DProfileOverride and invokes it during viewer initialization after compass setup to activate the profile override behavior

Sequence Diagram

sequenceDiagram
    participant Viewer as Potree Viewer
    participant Init as init2DProfileOverride
    participant Potree as ProfileWindow
    participant DOM as DOM / MutationObserver
    
    Viewer->>Init: init2DProfileOverride(viewer)
    activate Init
    Init->>Init: Attempt to patch ProfileWindow.addPoints
    alt Patch Available
        Init->>Potree: Override addPoints with ECEF extraction
    else Patch Not Available
        Init->>Init: Poll with retry (up to timeout)
        Init->>Potree: Override addPoints when available
    end
    Init->>DOM: Setup MutationObserver for selection panel
    deactivate Init
    
    Viewer->>Potree: User selects point in profile
    Potree->>DOM: Render selection info panel
    DOM->>Init: Observer detects new panel
    Init->>DOM: Modify rows to display lon/lat/elevation<br/>Remove extraneous fields
    DOM-->>Viewer: Updated panel displayed
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Areas requiring extra attention:

  • The patching mechanism in 2DProfileOverride.js that overrides Potree's internal ProfileWindow.addPoints method—ensure ECEF-to-elevation conversion logic is correct and doesn't break on edge cases
  • MutationObserver implementation for DOM manipulation; verify that row indexing and field removal is robust across different Potree versions
  • Retry/polling logic with timeout to handle cases where Potree hasn't fully initialized; check that timeout value is appropriate
  • Error handling and fallback behavior when patching fails

Poem

🐰 The profiles grow taller, so clear and so bright,
With lon, lat, and height shining into the night!
No clipping, no chaos, just labels so clean,
The finest of overrides ever seen! ✨


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Free

📥 Commits

Reviewing files that changed from the base of the PR and between 923d8d6 and 4e0b45e.

📒 Files selected for processing (4)
  • index.html (1 hunks)
  • src/2DProfileOverride/2DProfileOverride.css (1 hunks)
  • src/2DProfileOverride/2DProfileOverride.js (1 hunks)
  • src/potreeViewer.js (2 hunks)

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands and usage tips.

@gautegf gautegf changed the title fix(#56): 🐛 2D profile measurement shows lat,lon,elevation 56-display-latlon-and-elevation-in-2d-profile-measurement Nov 2, 2025
@gautegf gautegf changed the title 56-display-latlon-and-elevation-in-2d-profile-measurement 56-display-lat,lon-and-elevation-in-2d-profile-measurement Nov 2, 2025
@gautegf gautegf changed the title 56-display-lat,lon-and-elevation-in-2d-profile-measurement 56-display-lat-lon-and-elevation-in-2d-profile-measurement Nov 2, 2025
Copy link
Member

@tobiaobr tobiaobr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The functionality works as described. Did not encounter the bug described. Tried making several height profiles to check if this would agitate the bug, it did not.

As for the code itself, it looks good to me. Though, i am not experienced in the potree logic, so i might have overlooked noticeable improvements, inefficiencies or faults. The js logic looks good.

Copy link
Member

@mariewah mariewah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :D
Did not see any bug, lat, long, elev responsive, code looks clean, comments are nice!

@gautegf gautegf merged commit c138179 into dev Nov 2, 2025
2 checks passed
@gautegf gautegf deleted the 56-display-latlon-and-elevation-in-2d-profile-measurement branch November 2, 2025 20:31
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Display lat,lon and elevation in 2D profile measurement
3 participants