aardgoose / CaveView.js

Web native 3d cave survey viewer
https://aardgoose.github.io/CaveView.js/
MIT License
44 stars 11 forks source link

Calculation of Depth From Surface wrong since 2.1.0 #50

Open Tapter opened 2 years ago

Tapter commented 2 years ago

Hi I have a project which I recently updated from 2.0.2 to the latest version. However, I noticed that the display of the 'depth from surface' was wrong ever since then. I'm using EPSG:2056 for everything. The lox model also contains the surface and DEM (all in EPSG:2056). The displayed coordinates and height are correct, but the depth from surface changed:

See the two versions and compare the depth of the (only) entrance: Version 2.0.2: https://3d.bergwerke.ch/caveview-2.0.2/ entrance has depth from surface: 3m (which is close enough) Console writes: "Adjustmenting terrain height by: 5.377297944445161 sd: 0"

Version 2.1.0 (and every later version): https://3d.bergwerke.ch/caveview-2.1.0/ entrance has depth from surface: -19m Console writes: "Adjustmenting terrain height by: 27.624488137881315 sd: 0"

I'm not even sure why the terrain height should be adjusted at all ??

In the DEM, this point has a height of 2423m. The point in the model has a Z height of 2426m - so the 3m from 2.0.2 would be accurate

Thus so far I'm stuck with 2.0.2. Is this a general issue or might it be related with the release notes entry "Grid based on survey original coordinate reference system (CRS) (approximate when using external terrain)." ? Or do I have to specify the CRS somewhere in the JS?

Tapter commented 1 year ago

Any help on how to debug this? Or is there any configuration concerning this?

aardgoose commented 1 year ago

Hi, Sorry about the delay. Have you tried the latest version, 2.6? I have fixed various height related bugs recently. Can you send me an example .lox file if the latest version doesn't work correctly.

Regarding the datum adjustment: using a cave model with a different CRS than the DEM CRS can cause problems because the library used to convert between CRS doesn't handle heights. The adjustment is a crude attempt to correct for this by fitting the DEM to the surface stations of the model.

Tapter commented 1 year ago

Hi aardgoose Thanks for your reply. v2.6 seems to be better again, but it still appears to be wrong.

Here's an example lox: http://3d.bergwerke.ch/buffalora/surveys/buffalora-caveview-issue50.lox I've specially crafted it so that it only has one fixed point which I measured using RTK GPS to an accuracy below 10cm. I'm using EPSG:2056 for all specified coordinates (fix points, overlay and DEM). The entrance (point buffalora.1) has the exact height 2422.572. I've manually verified that the DEM model also results in 2422.02 for that point (those all are not GPS/WGS84 heights but geoid/orthometric heights). However, caveview 2.6 shows me "Depth from Surface: -3m, adjusted depth: 11m".

There are also a few surface shots which - however - I don't trust. If you say those are also taken into account, I'd probably better remove them if they skew the depth calculation. What I wished for would be, that cavejs would not do any height calculation/correction at all since the DEM and the fix stations match very exactly and don't need any adjustment. But I don't see how it determines those -3m since those fix coords are exactly on the ground and this is also reflected by the DEM ? Is this because internally everything is reprojected to another CRS or something or because it does some calculations using the surface shots?

Tell me if you need more data, I can also provide you the .th files with the DEM etc if needed Thanks Matt

aardgoose commented 1 year ago

Thanks for the test file. I will check shortly, and see if I can see what is going on.

aardgoose commented 1 year ago

Hi,

The point you indicate is shown against the overlap map image on the 2420m contour in CaveView and the Therion Loch viewer, and in both viewers that station is shown above the land surface, which would agree with the -3m error with rounding. Is it possible that there is an incorrect offset applied to the DEM in the model file?

Tapter commented 1 year ago

@aardgoose: Hi Thanks for the reply and sorry it took so long to look closer into it. Well, I could live with -3m probably, although in reality it would be closer to -0.5m. I've verified again, that in the DEM, the height at those coordinates is 2422m (see https://3d.bergwerke.ch/buffalora/surveys/buffalora-dem.asc). I used this DEM 1:1 in the therion definition ("grid 2814633 1168309 1 1 1215 755" followed by the raw data in that file) - I'm not sure where else an offset could come from? Aven also shows the correct height given the .3d file generated in the same run.

What remains is maybe the result of some lossy transformations from EPSG:2056 to WGS84 (or whatever caveview uses internally) ? And what I don't understand at all is, how this 'adjustment' is calculated? Is 'Depth from Surface' calculated using the fixed station(s) vs the DEM ? How is this 'adjustment' calculated? Maybe there could just be a manual adjustment override for those who don't wish to have anything 'automatically' adjusted because they know, that their values are already correct enough? Thanks Matt