Switching to OpenMapTiles and Fixing Small Bugs#155
Conversation
|
Yeah OpenFreeMap is probably the way to go for now. But the endpoint can be changed as needed since OpenMapTiles is an open standard. |
jaller94
left a comment
There was a problem hiding this comment.
Looks good. It's updating the map and fixes a handful of issues correctly.
I'm not sure about the increased search area for elements. How does this make sure that we'll find all relevant points? I think it will still miss many. It might affect performance, but while testing it the performance seemed unchanged.
ecda55a
Self-hosting the tiles from Open is possible and legal. The single-person project offers new world files every week.
The adaptions to the styles are a bit too much for me to review by reading them. Opening the application shows that the style looks great and mostly unchanged to the current version on main.
A comment about something potentially breaking support on Windows seems unrelated. This PR does not touch anything related to the dependencies, launch or terminal output.
|
I looked into commit On Windows, running #!/usr/bin/env node
'use strict';
require('../main.js');and change |
|
@ionmeo Thank a lot for looking into this. Based on the writing style of the PR description, I assume that you've used an LLM. While that's probably ok, could you please disclose whether you used an AI assistant and which one? |
|
After writing the draft pull request, I used Claude to rephrase some of the sentences, so some parts might seem like AI-generated. I took help from Claude for some of the bug fixes, most notably commit |
This description follows a
[problem] => [commit link]format where each problem's description followed by the commit that resolves it.Runtime Error
After cloning the repo, when you run
npm installfollowed bynode main.js, you will encounter:To fix it, we need to always return the buffer in the
_getHTTPmethod ofTileSource.js.commit
1736dac: fixed undefined slice error at runtimeRemote Tile Source Issues
After fixing the initial runtime error, running
node main.jsreveals rendering bugs at certain zoom levels.These issues stem from problems with files hosted on
mapscii.merather than the codebase itself. You can verify this by using a local .mbtiles file. As osm2vectortiles was archived a while ago, you can only download such.mbtilesfrom Wayback Machine.Planet from z0 to z5 (20MB)
Planet from z0 to z8 (411MB)
However, when running
You will encounter
Error: no TileSource defined. To fix the issue, we need to make theinitmethod inTileSource.jsand_initTileSourcemethod inMapscii.jsasynchronous.commit
ea69053: fixed no tilesource defined error when using local mbtiles fileZoom Level Crashes
When using the .mbtiles files linked above, if you keep on zooming, the program crashes with
Tile does not existerror as the file only supports zooming upto a certain point.commit
5a1d9b0: prevent zooming beyond max zoom level in local mbtiles fileMigrating to OpenMapTiles
The main three changes are:
Layer Name Updates
_generateDrawOrderfunction inRenderer.jslayersarray inconfig.js.Change tile source
config.jsandTileSource.spec.jsUnimplemented type: 4error.https://tiles.openfreemap.org/planet/map/but themappart is a wildcard.Update styles in
dark.jsonCommit
ea03d52: migrate to OpenMapTilesFilter Interpreting Issue
At this point, when you zoom in, you will see color of the
roadlayer has changed from yellow to pink.To find the reason, we need to go back to commit
5a1d9b0i.e. the codebase before migrating to OpenMapTiles. Now, take a look at the first two instances of"source-layer": "road"in the olddark.json.{ "type": "line", "id": "tunnel_path_pedestrian", "paint": { "line-color": "@tunnel_path_pedestrian" }, "source-layer": "road", "filter": [ "all", ["==", "$type", "LineString"], [ "all", ["==", "structure", "tunnel"], ["in", "class", "path", "pedestrian"] ] ] }, { "type": "line", "id": "tunnel_motorway_link", "paint": { "line-color": "@tunnel_motorway_link" }, "source-layer": "road", "filter": [ "all", ["==", "structure", "tunnel"], ["==", "class", "motorway_link"] ] }If you change the value of
@tunnel_path_pedestrian, you won't notice a change in the map. However, if you change value of@tunnel_motorway_link, you will see a change in the color of all roads. This is problematic because the filter should color aroadonly if it's atunneland amotorway_linkbut it seems like it is coloring all the roads.However, in the new version, when you modify the value of
@tunnel_path, it is changing color of everything intransportationlayer. This is most likely because the filter does not have double nesting anymore, implying an issue with interpretation of double nesting inside a filter. Fortunately, we do not have to fix it right now because we can write the same filter condition without using double nesting due to filter conditions being essentially just AND logic,{ "type": "line", "id": "tunnel_path", "paint": { "line-color": "@tunnel_path" }, "source-layer": "transportation", "filter": [ "all", ["==", "$type", "LineString"], ["==", "brunnel", "tunnel"], ["==", "class", "path"] ] }, { "type": "line", "id": "tunnel_motorway_ramp", "paint": { "line-color": "@tunnel_motorway_ramp" }, "source-layer": "transportation", "filter": [ "all", ["==", "brunnel", "tunnel"], ["==", "class", "motorway"], ["==", "ramp", 1] ] }However, we do have to fix the issue of all transportation paths being colored with the first instance of layer
transportation, regardless of the filter condition. This issue stems from handling of the 'all' keyword inStyler.js.As the styles are now rendering properly, we can proceed to fix some issues with styling. As the map becomes cluttered with country names and boundaries at early zoom levels, I added some zoom limits via
minzoomindark.json. Additionally, I changed@admin_level_2from#fffto#aacto reduce eye strain.commit
1015ecd: fixed handling of filter keyword 'all' and updated stylesPolygon Rendering
There are still some rendering issues like blacked out areas where there is supposed to be ocean, and a huge water block appearing across Europe. To fix these issues, you have to modify the polygon rendering in
Canvas.js. In the new version, we first separate between outer and inner rings and then use point-in-polygon to figure out which inner ring belongs to which outer ring.commit
d85535e: fixed water appearing over land and areas with missing waterWater Block Blackouts
Now, another issue you will notice is when zoomed in a bit, certain water blocks black out. You need to increase the range in
_getTileFeaturesfunction inRenderer.jsto fix the issue.commit
ecda55a: fixed empty blocks at some zoom levelsAdapt bright.json
Finally, I just converted
bright.jsonto be compatible with OpenMapTiles.commit
588ec3c: adapted bright.json for OpenMapTiles