protomaps / PMTiles

Cloud-optimized + compressed single-file tile archives for vector and raster maps
https://protomaps.com/docs/pmtiles/
BSD 3-Clause "New" or "Revised" License
2.12k stars 125 forks source link

MaplibreGL broken river rendering #463

Closed MightyPork closed 2 months ago

MightyPork commented 2 months ago

I opened the issue here https://github.com/maplibre/maplibre-gl-js/issues/4763 but maybe it is a bug in this repo instead. More details are in the other issue.

Screenshot_20240925_123854

the map file was grabbed today using this command:

pmtiles extract https://build.protomaps.com/20240924.pmtiles my_area.pmtiles --bbox=14.566343,50.150491,14.761007,50.243677

I get the same broken rendering with your example html file, completely unchanged outside of editing the source link and coordinates.

This bug does not reproduce with the example file https://pmtiles.io/protomaps(vector)ODbL_firenze.pmtiles

my pmtiles command line tool is installed from AUR, version 1.20.0

bdon commented 2 months ago

Hi, which example HTML file are you using?

The issue is definitely in here, I am merging in the breaking 4.0 major version changes and some layers have mixed geometry types so we need to add geometry filters to the styles.

MightyPork commented 2 months ago

this one https://github.com/protomaps/PMTiles/blob/main/js/examples/maplibre.html

you can also see it live on my test page, it's all static files on apache and some CDN for assets

https://bits.ondrovo.com/osm/

bdon commented 2 months ago

you need to modify the water rule to have a filter on geometry type:

id: "water",
type: "fill",
filter: ["==", ["geometry-type"], "Polygon"],

I will work on updating the examples

MightyPork commented 2 months ago

So basically the tiles contain closed lines (polygons) as well as open lines and the bug was that it closed the open lines using the fill style?

MightyPork commented 2 months ago

the fix works perfectly :+1:

bdon commented 2 months ago

yes, exactly. This has to do with the Basemaps repo which generates the 20240924.pmtiles in the public bucket, I'm making a new major revision of the tileset which changes the layers around. So examples written against the previous revision (v3) may be affected, thanks for working through this and let me know if you encounter similar issues.

MightyPork commented 2 months ago

hmmm, I added (guessed) more styles using the reference at https://maplibre.org/maplibre-style-spec/ and now I also see little streams and possibly other features. These completely disappeared with adding the filter for fill.

Screenshot_20240925_161230

[
      {
                        "id": "water2",
                        "source": "selfhosted",
                        "source-layer": "water",
                        "type": "line",
                        "filter": ["==", ["geometry-type"], "LineString"],
                        "paint": {
                            "line-color": "#80b1d3",
                        },
                    },
                    {
                        "id": "water3",
                        "source": "selfhosted",
                        "source-layer": "water",
                        "type": "line",
                        "filter": ["==", ["geometry-type"], "MultiLineString"],
                        "paint": {
                            "line-color": "#80b1d3",
                        },
                    },
                    {
                        "id": "water4",
                        "source": "selfhosted",
                        "source-layer": "water",
                        "type": "fill",
                        "filter": ["==", ["geometry-type"], "MultiPolygon"],
                        "paint": {
                            "fill-color": "#80b1d3",
                        },
                    },
]

Is there a good-to-use-as-is style compatible with the v4 format I could use instead of trying to make my own?

bdon commented 2 months ago

Should be fixed by https://github.com/protomaps/PMTiles/pull/464

the new style for v4 is not on NPM yet but you can either copy-paste it from maps.protomaps.com Get Style JSON or you can check out http://github.com/protomaps/basemaps repo and run npm run generate-styles in the styles/ directory. For V4 the serialized JSON style has a version per chosen language (en, de etc) in dist/styles

MightyPork commented 2 months ago

If I want the map to use local names (I'm making maps for Czech Republic, so e.g. Labe instead of Elbe)... I will have to generate my own planet file first, or the language in styles somehow does this? Or it just changes what font is used?

bdon commented 2 months ago

If you run generate-styles there should be a file like dist/light/cs.json which is the Czech localized version of the style. The planet tileset is the same for all languages.