WorldWindEarth / worldwindjs

WorldWindJS is a community maintained fork of the WebWorldWind virtual globe SDK from NASA - an interactive 3D globe library featuring maps, imagery and terrain plus 2D map projections.
https://worldwind.earth/worldwindjs/
38 stars 9 forks source link

Scale CoordinatesDisplayLayer latitude/longitude digits based on eye … #62

Open lowswaplab opened 3 years ago

lowswaplab commented 3 years ago

Description of the Change

Scale latitude/longitude decimal places based on eye altitude. For example, if zoomed in really close, show latitude/longitude with 6 decimal places. If zoomed way out, only show 1 or 2 decimal places.

Why Should This Be In Core?

To improve display and accuracy of latitude/longitude display.

Benefits

Better display.

Potential Drawbacks

None.

Applicable Issues

None. But there are a few of hardcoded values in CoordinatesDisplayLayer that need to be taken care of (that were there prior to this PR). These hardcoded values appear to assume character width and other values.

lowswaplab commented 3 years ago

Oh wait, do not accept this PR yet. It looks like eye altitude is based on Mean Sea Level (or geoid height or something similar). For example, if you zoom in as far as you can on the Alps, eye altitude is set to 2km. Not 0m as I expected. Instead of using eye altitude alone, I need to calculate height above ground: eye altitude - terrain altitude.

ComBatVision commented 3 years ago

Why do you not using lookAt.range instead of eye.altitude?

LookAt.range is a distance to surface (including terrain elevation) of point in screen center.

lowswaplab commented 3 years ago

Done

ComBatVision commented 3 years ago

I have compared this feature with Java and Android code bases. They use constant amount of decimal places, e.g. 4 or 6.

Why do we need this dynamic decimal places? Can we simply replace 2 with 6 for all case?

lowswaplab commented 3 years ago

I did this because having 6 decimal places doesn't make sense when a pixel is only a decimal place or two wide...