DerKarlos / OSMeta

OSM "Metaverse"
Other
15 stars 2 forks source link

Magic number 814.5 #33

Closed oli-obk closed 7 months ago

oli-obk commented 7 months ago

I think that magic number is the length in meters of the tiles' sides. At least that is how we use it in the code. But how is it calculated from the zoom level?

DerKarlos commented 7 months ago

I did id a bit od: In my pos.rs was a function to calculate the position of a tile corner. tile_size = (Tile+1).corner menus Tile.corner But at last it is a constant by the size of the Earth and the number of decrees. 40'000km / 2^15 ? 40'000'000 / 32768 = 1220,7 cos(48,5 Germany Passau) = 0,66262 1220,7 0,66262 = 808,86

https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames : const EARTH_CIR_METERS = 40075016.686 metersEW = EARTH_CIR_METERS / Math.pow(2, zoom) * Math.cos(lat)

810,379258925699463

And there is the Merkartor problem: To the poles, the width should get smaller, but NOT the height. I have to discus this with Tobias. And we may need to place the tiles not on a flat ground but a sphere.

oli-obk commented 7 months ago

Getting there: now I just need to rotate the tiles and make the corners match up, but the positions are already on a sphere!

grafik

oli-obk commented 7 months ago

grafik

the tile surfaces are now in the right direction!

need to connect them and rotate them right

oli-obk commented 7 months ago

I added a function for computing tile sizes. Looks like Munich has approximately

1223m x 643m

but the glb tiles are squares and not rectangles that have half the height of their width.

Maybe my math is wrong? Can you check it?

https://github.com/DerKarlos/OSMeta/blob/ceb6bc6137f197fdfd822599efe626fb70400439/src/geopos.rs#L69-L74

i got the width/height flipped, but otherwise it seems correct?

oli-obk commented 7 months ago

waaait... does osm simply say "equator length is 40k"? no matter the real value?

DerKarlos commented 7 months ago

No, the 40k was just my fuzzy memory. Osm uses const EARTH_CIR_METERS = 40075016.686

DerKarlos commented 7 months ago

OSM uses Mercator projection (which always makes my brain dizzy). This is the correct solution, I hope:

To the poles,

Really correct tiles should have different W-E dimensions on the N-S borders too. Not with Mercator! This is only relevant near zoom 0. We only have 2D bitmaps there. Using UV values on the sphere should do it.