fix: georeferenced mercator tiles with correct alignment and overlap handling#131
Merged
Conversation
…entation - Change --profile=raster to --profile=mercator in gdal2tiles so tiles are proper Web Mercator tiles that MapLibre can render at correct scale - Add EPSG:4326 georeferencing to VRT (places image at equator matching armaToLatLng coordinate conversion) - Remove DstYOff flip — satellite tile Y maps directly to image row, GeoTransform handles orientation (south-up raster, GDAL reprojects) - Remove MBTiles y-flip — mercator profile outputs TMS convention, same as MBTiles (no conversion needed) - Calculate zoom levels dynamically via MercatorZoomForWorld instead of hardcoded maxZoom=6 (Altis: z10-17, Stratis: z12-16) - Use math.Round instead of math.Ceil for maxZoom to avoid oversampling (Altis: ~14K tiles/~350MB vs ~54K tiles/~1.3GB) - Add -r average resampling to reduce edge artifacts - Add minzoom/maxzoom to style.json source metadata
Arma satellite tiles have 32px overlap on all edges for in-engine texture blending. Crop to 480px effective size in the VRT SrcRect/DstRect to eliminate visible seam duplication in PMTiles output. Also upscale undersized 4×4 ocean placeholder tiles to 512×512 via nearest-neighbor before PNG encoding, so all tiles match the VRT layout. Other fixes: - Remove TMS Y-flip in MBTiles (gdal2tiles mercator already uses TMS) - Add georeferenced EPSG:4326 GeoTransform to VRT (north-up, equator) - Compute min/max zoom from world size via MercatorZoomForWorld() - Pass MinZoom/MaxZoom through Job and into map.json/style.json
…gery The satellite tile grid is sparse — Altis has 1863 tiles spanning X=2-60, Y=8-55, not the full 64×64 grid. Using (maxTile+1)*tileEffective as VRT dimensions stretched the image to fill worldSize, causing markers to misalign: 3× vertical error, 1× horizontal (14.3% vs 4.9% stretch). Fix: set VRT canvas to worldSize×worldSize (1 pixel = 1 meter). Tiles are placed at their correct pixel positions; missing ocean tiles are transparent.
Merging this branch will decrease overall coverage
Coverage by fileChanged files (no unit tests)
Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code. Changed unit test files
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cherry-picked fixes from
feat/maplibre-pmtilesfor theinternal/maptooltile generation pipeline:--profile=rasterto--profile=mercatorin gdal2tiles so tiles are proper Web Mercator tiles. Add EPSG:4326 georeferencing to VRT matching thearmaToLatLngcoordinate conversion. Calculate zoom levels dynamically viaMercatorZoomForWorld()instead of hardcodedmaxZoom=6.worldSize×worldSize(1 pixel = 1 meter) for the VRT canvas so tiles are placed at correct pixel positions, fixing marker misalignment caused by sparse tile grids stretching the image.Test plan
go test ./internal/maptool/...to verify all tests pass