Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bathymetry not displayed #1871

Open
vladimir-rybalko opened this issue Jul 13, 2022 · 20 comments
Open

Bathymetry not displayed #1871

vladimir-rybalko opened this issue Jul 13, 2022 · 20 comments
Assignees
Labels
Milestone

Comments

@vladimir-rybalko
Copy link

vladimir-rybalko commented Jul 13, 2022

Hello!
I'm trying to display bathymetry and need a negative altitude value for that.

What am I trying to do?

  1. Deployed the Geoserver and the DDS/BIL(World Wind Data Formats) Extension plugin to generate bil tiles.
  2. Wrote a proxy for converting wms to wmts.
  3. Described the wmts source
const wmtsSource = new itowns.WMTSSource({
  tileMatrixSet: 'WGS84',
  crs: "EPSG:4326",
  url: `http://195.58.46.152:9090/tiles/${model.name}/%TILEMATRIX/%ROW/%COL`,
  format: "image/x-bil;bits=32",
  name: "Elevation",
  tileMatrixSetLimits: {
    "0": {
      "minTileRow": 0,
      "maxTileRow": 0,
      "minTileCol": 0,
      "maxTileCol": 1
    },
    "1": {
      "minTileRow": 0,
      "maxTileRow": 1,
      "minTileCol": 0,
      "maxTileCol": 4
    },
    "2": {
      "minTileRow": 0,
      "maxTileRow": 3,
      "minTileCol": 0,
      "maxTileCol": 7
    },
    "3": {
      "minTileRow": 0,
      "maxTileRow": 7,
      "minTileCol": 0,
      "maxTileCol": 15
    },
    "4": {
      "minTileRow": 0,
      "maxTileRow": 15,
      "minTileCol": 0,
      "maxTileCol": 31
    },
    "5": {
      "minTileRow": 1,
      "maxTileRow": 31,
      "minTileCol": 0,
      "maxTileCol": 63
    },
    "6": {
      "minTileRow": 2,
      "maxTileRow": 63,
      "minTileCol": 0,
      "maxTileCol": 128
    },
    "7": {
      "minTileRow": 4,
      "maxTileRow": 127,
      "minTileCol": 0,
      "maxTileCol": 255
    },
    "8": {
      "minTileRow": 9,
      "maxTileRow": 255,
      "minTileCol": 0,
      "maxTileCol": 512
    },
    "9": {
      "minTileRow": 18,
      "maxTileRow": 511,
      "minTileCol": 0,
      "maxTileCol": 1023
    },
    "10": {
      "minTileRow": 36,
      "maxTileRow": 1023,
      "minTileCol": 0,
      "maxTileCol": 2048
    },
    "11": {
      "minTileRow": 72,
      "maxTileRow": 2047,
      "minTileCol": 0,
      "maxTileCol": 4095
    },
    "12": {
      "minTileRow": 145,
      "maxTileRow": 4095,
      "minTileCol": 0,
      "maxTileCol": 8191
    },
    "13": {
      "minTileRow": 291,
      "maxTileRow": 8191,
      "minTileCol": 0,
      "maxTileCol": 16383
    },
    "14": {
      "minTileRow": 582,
      "maxTileRow": 16383,
      "minTileCol": 0,
      "maxTileCol": 32767
    },
    "15": {
      "minTileRow": 1165,
      "maxTileRow": 32767,
      "minTileCol": 0,
      "maxTileCol": 65535
    },
    "16": {
      "minTileRow": 2330,
      "maxTileRow": 65535,
      "minTileCol": 0,
      "maxTileCol": 131071
    },
    "17": {
      "minTileRow": 4660,
      "maxTileRow": 131071,
      "minTileCol": 0,
      "maxTileCol": 262143
    }
  }
});

const elevationLayer = new itowns.ElevationLayer('elevation-layer', {
  source: wmtsSource,
  noDataValue : -99999
});
itownsViewer.addLayer(elevationLayer);

What do I get?
Terrain is applied but there are no negative values and my bathymetry is not displayed.
image

@mgermerie
Copy link
Contributor

Hi,

Thanks for your feedback !

I don't have elevation data with negative altitude values at my disposal. Would you by any chance be able to grant me access to your WMTS stream so I can test displaying a negative altitudes elevation layer and see what seams to be the issue with iTowns ?

@mgermerie
Copy link
Contributor

@gchoqueux found out something : he applied an offset a DEM we have so that it contains negative values, and succeeded in displaying those value in an ElevationLayer. To do so, he had to specify a zmin property in the ElevationLayer.

Could you try implementing ElevationLayer as following in your example ?

const elevationLayer = new itowns.ElevationLayer('elevation-layer', {
    source: wmtsSource,
    noDataValue : -99999,
    zmin: -10000  // Or any large negative value
});

The zmin and zmax properties are not documented. Each elevation value that is not between zmin and zmax is overridden to 0. Documentation should be added on those properties, and a clamp should probably be applied to the values outside of [zmin, zmax] interval (instead of being set to 0).

@vladimir-rybalko
Copy link
Author

@gchoqueux found out something : he applied an offset a DEM we have so that it contains negative values, and succeeded in displaying those value in an ElevationLayer. To do so, he had to specify a zmin property in the ElevationLayer.

Could you try implementing ElevationLayer as following in your example ?

const elevationLayer = new itowns.ElevationLayer('elevation-layer', {
    source: wmtsSource,
    noDataValue : -99999,
    zmin: -10000  // Or any large negative value
});

The zmin and zmax properties are not documented. Each elevation value that is not between zmin and zmax is overridden to 0. Documentation should be added on those properties, and a clamp should probably be applied to the values outside of [zmin, zmax] interval (instead of being set to 0).

@mgermerie, thanks for your reply!
I tried your solution in my code, but the result is disappointing.
If I set a value zmin=-10_000, then I get problems with the map where there is no data for the relief.
I create exmple with my data and set zmin value -50, but i have cracking tiles
image
If I overlay data, such as biometrics, I get the overlap problem I described earlier.

@vladimir-rybalko
Copy link
Author

@mgermerie, there is some progress in the issue?

@mgermerie
Copy link
Contributor

@mgermerie, there is some progress in the issue?

Hi ! I could not yet figure out what's causing the glitches on your example. I'm working on it at the moment and will let you know as soon as I find something out.

@etienleigh
Copy link

@mgermerie, there is some progress in the issue?

Hi ! I could not yet figure out what's causing the glitches on your example. I'm working on it at the moment and will let you know as soon as I find something out.

@gchoqueux

You guys still soldiering on.
Ill put together a server with whatever i have on this stuff soon and post it here if it helps cool. FYI i decided to work with cesium which didnt have this negative elevation issue. I still prefer ITowns for a hell of a lot of other things - so yeah - i really hope you guys can fix this issue seeing as i was not the only dude to have it.

@etienleigh
Copy link

PS unrelated - but kinda related - .bil is heavyy - does ITowns support RGBA PNG tiles for elevation ? Thats so much lighter.

@alexLuky
Copy link

alexLuky commented Aug 26, 2022

PS unrelated - but kinda related - .bil is heavyy - does ITowns support RGBA PNG tiles for elevation ? Thats so much lighter.

@etienleigh
Hi, please take a look here. Maybe you faced the same issue previosly. This struggle looks hopeless... Do you have any working variants for rendering multiple b3dms and the tileset.json tree from obj/gltf model for itowns?

@jailln
Copy link
Contributor

jailln commented Oct 14, 2022

PS unrelated - but kinda related - .bil is heavyy - does ITowns support RGBA PNG tiles for elevation ? Thats so much lighter.

Nearly but not yet, it is planned, see #1463

@jailln
Copy link
Contributor

jailln commented Oct 14, 2022

@mgermerie, there is some progress in the issue?

Hi ! I could not yet figure out what's causing the glitches on your example. I'm working on it at the moment and will let you know as soon as I find something out.

@gchoqueux

You guys still soldiering on. Ill put together a server with whatever i have on this stuff soon and post it here if it helps cool. FYI i decided to work with cesium which didnt have this negative elevation issue. I still prefer ITowns for a hell of a lot of other things - so yeah - i really hope you guys can fix this issue seeing as i was not the only dude to have it.

@etienleigh did you manage to put a server on with your data? We will continue looking at it

@jailln
Copy link
Contributor

jailln commented Oct 14, 2022

PS unrelated - but kinda related - .bil is heavyy - does ITowns support RGBA PNG tiles for elevation ? Thats so much lighter.

@etienleigh Hi, please take a look here. Maybe you faced the same issue previosly. This struggle looks hopeless... Do you have any working variants for rendering multiple b3dms and the tileset.json tree from obj/gltf model for itowns?

It is not related to 3d tiles rendering but we will take a look at your issue (#1859 )

@vladimir-rybalko
Copy link
Author

PS unrelated - but kinda related - .bil is heavyy - does ITowns support RGBA PNG tiles for elevation ? Thats so much lighter.

Nearly but not yet, it is planned, see #1463

When is this feature planned or should I look for a workaround?

@jailln
Copy link
Contributor

jailln commented Oct 19, 2022

We don't have a date to provide yet sorry but we will try to prioritize it and to let you know.

Instead of a workaround we can help you implement it in itowns if you are keen to do it, some of the code needed to it is already in itowns, it is just not used and therefore it shouldn't be much work to do it. If you're interested, let me know how we can help you to jump into it (more doc on the current architecture? a short meeting to explain you the general ideas and where to look? etc.)

@mgermerie mgermerie added this to the 2.xx.x milestone Oct 20, 2022
@vladimir-rybalko
Copy link
Author

We don't have a date to provide yet sorry but we will try to prioritize it and to let you know.

Instead of a workaround we can help you implement it in itowns if you are keen to do it, some of the code needed to it is already in itowns, it is just not used and therefore it shouldn't be much work to do it. If you're interested, let me know how we can help you to jump into it (more doc on the current architecture? a short meeting to explain you the general ideas and where to look? etc.)

Our team is interested in implementing this functionality and improving itowns. We are willing to discuss receiving instructions on this matter. To contact directly, you can use my email in the github profile.

@alienatorZ
Copy link

Has there been any progress on the culling issues for negative elevations? Are there any workarounds?
Thanks!

@jailln
Copy link
Contributor

jailln commented Nov 2, 2022

We don't have a date to provide yet sorry but we will try to prioritize it and to let you know.
Instead of a workaround we can help you implement it in itowns if you are keen to do it, some of the code needed to it is already in itowns, it is just not used and therefore it shouldn't be much work to do it. If you're interested, let me know how we can help you to jump into it (more doc on the current architecture? a short meeting to explain you the general ideas and where to look? etc.)

Our team is interested in implementing this functionality and improving itowns. We are willing to discuss receiving instructions on this matter. To contact directly, you can use my email in the github profile.

I contacted you by email, let's continue this discussion on this matter on the dedicated issue: #1463

Has there been any progress on the culling issues for negative elevations? Are there any workarounds?
Thanks!

Not yet but @mgermerie which is on leave this week will let you know when he gets back and takes a look at it

@mgermerie
Copy link
Contributor

Hi ! There seams to be an issue with the server providing elevation data in your example. I get 503 error for the requests. Would you have a way to remedying this issue or provide an alternate url ?
Thanks in advance.

@vladimir-rybalko
Copy link
Author

Hi ! There seams to be an issue with the server providing elevation data in your example. I get 503 error for the requests. Would you have a way to remedying this issue or provide an alternate url ? Thanks in advance.

Hello! I have corrected the address to get the height data in my example. An example can be found here.

@mgermerie
Copy link
Contributor

mgermerie commented Nov 8, 2022

Thanks for the data.

I set up an example here. When clicking while holding down p key, the altitude red in data from the WMTS stream is logged in console. This uses iTowns DEMUtils module to read directly in the image fetched from the WMTS server.

Using this to check the values on the "cracking" tiles (those which do not display negative elevation), I found out that the value is -9999. On the screenshot bellow, you can see the value red for the orange tile in the console.
Note that should you set the noDataValue parameter of the ElevationLayer to -9999 instead of the previous -99999, the DEMUtils elevation reading method would return undefined, as it is its intended behavior.

Capture d’écran du 2022-11-08 14-22-08

Therefore I would suggest that the cracking tiles are caused by the lack of elevation data in the WMTS server for the tiles' zoom level and coordinates. In the example of the screenshot, it seams that there is no data for the orange tile, whose TMS coordinates are { zoom: 17, row: 21192, col: 152293 }

I also encountered problems with tiles outside the area with negative elevation values : they all had an elevation value of 32768. Should I assume that the data set has two different values for no data (32768 and -9999) ? If so, iTowns does not support elevation data set with multiple no data values.

That being said, even if there was no issue with elevation data, iTowns still need some fixing to support negative elevation data. It has to do with tiles' bounding boxes that are not well positioned in altitude. I will open a separate issue on bounding boxes positioning, to keep this one clear.

EDIT : I created the issue #1945

@vladimir-rybalko
Copy link
Author

vladimir-rybalko commented Nov 10, 2022

Hi, Madec!
Thanks for your work. In my data, there was indeed a problem with the fact that the value no data was different from -9999.
I fixed the issue with the values in my data. I noticed this feature: tiles that have pixels with values and no data values - the dataset border break when the scene is rotated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants