NASA-AMMOS / LithoSphere

A Tiled 3D Planetary Web-Based GIS JavaScript Library
Other
24 stars 10 forks source link

What is the meaning of `resunitsperpixel` and `reszoomlevel`? #19

Closed tcannon686 closed 2 years ago

tcannon686 commented 2 years ago

I am trying to use LithoSphere with a stereographic projection on the moon. I am having a little trouble understanding what value should go in resunitsperpixel and reszoomlevel though. I tried setting resunitsperpixel equal to the pixel_size value retrieved from gdalinfo, but that didn't seem to work. Also should resunitsperpixel be the same value used for pixel_size in the gdal2customtiles.py script?

Any help on this would be greatly appreciated. Thanks!

tariqksoliman commented 2 years ago

Hi! First off it looks like resunitsperpixel and reszoomlevel are only for WMS tilesets (which would be generated in a map server and not with gdal2customtiles.py). They should not have any effect if you're using a tileset from gdal2customtiles.py (I might be wrong).

They are essentially tileset specific resolution scalars.

For example:

resunitsperpixel = 1000
reszoomlevel = 0

means that:

Both these options are an abbreviated way representing the "units-per-pixel" and "order" attributes in the TileSets section of the tileset's tilemapresource.xml (which should be generated too when using gdal2customtiles.py)

example:

      <TileSets profile="mercator">
        <TileSet href="8" units-per-pixel="611.49622617187504" order="8"/>
        <TileSet href="9" units-per-pixel="305.74811308593752" order="9"/>
        <TileSet href="10" units-per-pixel="152.87405654296876" order="10"/>
        <TileSet href="11" units-per-pixel="76.43702827148438" order="11"/>
        <TileSet href="12" units-per-pixel="38.21851413574219" order="12"/>
      </TileSets>

Hope this help some.

tcannon686 commented 2 years ago

Hi Tariq,

Thank you for your response! It looks like resunitsperpixel and reszoomlevel fields are used for TMS currently.

Setting them to the values returned from gdal2customtiles.py worked if I did not change the majorRadius of lithosphere, but when I changed majorRadius to the radius of the moon, the tiles were the wrong size.

I looked through the lithosphere source code and found these lines of code. I saw that depending on the planet radius, a number is being added to the reszoomlevel, which is based on the surface area of the planet relative to the surface area of mars.

If I undo these lines by calculating the value that is added to reszoomlevel and subtracting it from reszoomlevel, things seem to work correctly.

I'm not sure I understand why adding that number is necessary. Do you know why it is needed?

tariqksoliman commented 2 years ago

Yeah, I'll need to investigate that further. 3396190 is the radius of Mars (which shouldn't be hardcoded). But I'm not sure why it's incrementing reszoomlevel by the ratio of surface areas.

but when I changed majorRadius to the radius of the moon, the tiles were the wrong size

And "wrong size" as in they were 4x too small?

tcannon686 commented 2 years ago

And "wrong size" as in they were 4x too small?

They were 16 times to large. Dividing the resunitsperpixel by 16 had the same effect as subtracting 4 from the reszoomlevel.

It looks like in exampleProj.html the majorRadius is set in LithoSphere, but the radius is not set in the projection itself. Maybe the surface area code is there to account for this?

tariqksoliman commented 2 years ago

Just put the fix in to remove it and it'll be in the next release. Thanks for finding this too! It was absolutely a wrong thing to have in there.

tcannon686 commented 2 years ago

Thanks for the fix!