Pomax / are-we-flying

Writing auto-pilots in JavaScript for MSFS
40 stars 3 forks source link

run ALOS as XYZ tile server #1

Open Pomax opened 1 year ago

Pomax commented 1 year ago

It has all the elevation information already anyway, should be able to make this an XYZ tile source for Leaflet to tap into.

Optimizations:

Pomax commented 1 year ago

working on this in https://github.com/Pomax/are-we-flying/tree/alos-server

Pomax commented 1 year ago

MSFS has no way for you to ask it for elevation other than by first placing a thing there, and then asking for the thing's elevation, which is a really annoying way of getting elevation data. So using external data (and it doesn't have to be ALOS, any DEM source will technically work, I just used ALOS because it's 30m resolution so you have a lot of freedom in what you do with that) that you run out-of-game will be both less work, and run faster.

Pomax commented 1 year ago

My initial attempt used the open-elevation API, so you can totally do this using a server. In order to serve up XYZ tiles you kinda need one anyway since leaflet needs a URL it request the tile PNGs from, so adding an extra route (or more) for getting elevation at one or more lat/long coords is pretty trivial. E.g. https://github.com/Pomax/are-we-flying/blob/main/src/elevation/alos-server.js

Pomax commented 1 year ago

That said, ALOS is 450GB, but you could also use the SRTM data (which is 20GBish), and you can always convert the horribly inefficient GeoTIFF files into monochrome PNG instead, which gives you much better compression. What I'm doing atm is converting the ALOS data from 3600x3600 GeoTIFF to 360x360 PNG (which makes it 300m resolution rather than 30m, but it uses a "preserve highest altitude" scaling so for the purposes of this work that's fine) and that turns it into ~1.5GB which is incredibly reasonable for full-planet coverage.

Pomax commented 1 year ago

You need elevation data if you're going to serve elevation data =)

Pomax commented 1 year ago

it doesn't technically need to be a plane, you could just spawn a ball or ground crew or something else small and move it around, but that's still way more work than it should have to be. I've seen some folks work directly with MSFS's own DEM data (so, out-of-game but tapping into the game's CGL files), but I figured I have good internet, and I have plenty of disk space, might as well dive into 3rd party DEM

Pomax commented 1 year ago

ah, yeah fair.

Pomax commented 1 year ago

possibly overkill, but always good to add to a book-sized tutorial: adding isolines to XYZ tiles by using something like http://paulbourke.net/papers/conrec

Pomax commented 1 year ago

current hillshading experiment: https://glitch.com/edit/#!/testing-hill-shading

Pomax commented 1 year ago

Tiling works, but this palette is way too dark.

photo_2023-07-08_14-31-56

Pomax commented 1 year ago

Compare to gterrain:

image