systemed / tilemaker

Make OpenStreetMap vector tiles without the stack
https://tilemaker.org/
Other
1.42k stars 228 forks source link

Missing Icons #617

Closed StephenAtty closed 6 months ago

StephenAtty commented 8 months ago

mbtiles created by tilemaker seem to be missing a lot of the icons.

Should look like

image

but lt looks like this

image

There are no errors in the browser console log so that suggests that the data just isn't there. I'm not getting any errors when running tilemaker either.

I suspect I've just missed something somewhere.

systemed commented 8 months ago

This is what I get when running tilemaker with the bundled demo server and version of OSM Bright:

Screenshot 2023-12-15 at 09 03 06

Just guessing, but one possible cause is that the OpenMapTiles schema, exasperatingly, has no clarity about how names are meant to be encoded (https://github.com/openmaptiles/openmaptiles/issues/930). I wonder if the version of the style you're using expects names to be in a different field from the one that tilemaker's processing script is writing. You can adjust this fairly easily in the first few lines of resources/process-openmaptiles.lua.

If you want to compare what's in the tilemaker-created tiles vs your existing tiles, you could use the inspect plugin, or vt2geojson.

StephenAtty commented 8 months ago

We're using bright. I'll see if I can get inspect plugin to work - it seems to be throwing an error at the moment. I've tried setting the language to en rather than nil but it seems to have made no difference

systemed commented 8 months ago

I think the most likely change would be changing name:latin to either name or name_en. If you can point at the exact version of the OSM Bright stylesheet you're using I can take a look.

StephenAtty commented 8 months ago

its version 8

https://maps.tty.org.uk/bright_uk-style.json

systemed commented 8 months ago

Ah, I think I can see. It is the stupid OpenMapTiles name issue again.

Have a look at line 3603 in the style.json. The stylesheet contains the filter

    [ "has", "name" ]

several times, i.e. "only show if the name attribute is set".

Which is fine, but it then goes on a few lines later to say

    "text-field": "{name:latin}\n{name:nonlatin}",

i.e. "render a text label using the 'name:latin' attribute". So it looks for the name attribute, but renders the name:latin attribute. Sigh.

Easiest way to fix this would be to adjust tilemaker's Lua script (resources/process-openmaptiles.lua) so after this in line 687:

obj:Attribute(preferred_language_attribute, iname)

you add

obj:Attribute("name", iname)

then regenerate. That'll make sure it's set for both name:latin (which is preferred_language_attribute from the top of the file) and name.

StephenAtty commented 8 months ago

That's brought them back but places have different rank values.

So in my live maps

https://tiles2.tty.org.uk/index.html#16/51.906003/-2.04701

Clyde Crescent Play area has a rank of 21, in the new maps it is 25 Cheltenham Cemetery and Crem has a rank of 5, in the new maps it is 25 Bouncers Lane Cemetery has a rank of 2. It doesn't seem to be in the new maps.

Bus Stops just dont seem to be there at all

So I think this is down to the node_keys and the poiClasses and poiClassRanks

systemed commented 8 months ago

Yes, it isn't a like-for-like emulation of OpenMapTiles' rank values - OpenMapTiles has some fairly complex SQL operations to generate these, and they obviously aren't available to tilemaker as it isn't a SQL-based environment.

The Lua script has a GetPOIRank function which you can tweak - as you've seen this uses poiClassRanks as a lookup.

StephenAtty commented 8 months ago

So how do I add things like bus stops. I assume I have to look at the existing map.So a bus stop is a class of "bus" and a subclass of "bus_stop" Similarly for railway stations which seem to be class ='railway" and a subclass of "station"

systemed commented 8 months ago

Ah, sorry, you need to add the extra name code near L693 of the Lua as well. So it reads

if preferred_language and obj:Holds("name:"..preferred_language) then
    iname = obj:Find("name:"..preferred_language)
    obj:Attribute(preferred_language_attribute, iname)
    obj:Attribute("name", iname)                        -- <=== insert this line
    if iname~=name and default_language_attribute then
        obj:Attribute(default_language_attribute, name)
    else main_written = iname end
else
    obj:Attribute(preferred_language_attribute, name)
    obj:Attribute("name", name)                         -- <=== insert this line
end

I've highlighted the two lines to add. Just tested it and that works fine.

StephenAtty commented 8 months ago

That looks like its fixed it.

StephenAtty commented 7 months ago

This is back in version 3. Making the same code changes

so

if preferred_language and Holds("name:"..preferred_language) then iname = Find("name:"..preferred_language) Attribute(preferred_language_attribute, iname) Attribute("name", iname) if iname~=name and default_language_attribute then Attribute(default_language_attribute, name) else main_written = iname end else Attribute(preferred_language_attribute, name) Attribute("name", name) end

Has not worked.

systemed commented 7 months ago

Works fine for me. With the two lines added (Attribute rather than obj:Attribute), and a GB extract generated:

galibier:vt richard$ vt2geojson http://peyresourde.local:8080/14/8124/5421.pbf
{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [
          -1.4823925495147705,
          51.87269552179052
        ]
      },
      "properties": {
        "class": "town",
        "rank": 10,
        "name": "Charlbury",
        "name:latin": "Charlbury",
        "vt_layer": "place"
      }

i.e. the "name" tag is generated correctly as well as the standard name:latin one.

StephenAtty commented 7 months ago

It seems that my laptop has some rather aggressive caching. I had to stop my test server stack (running on the laptop), purge the cache in Firefox, restart Firefox and then restart the server stack and it found them!