tilemaker icon indicating copy to clipboard operation
tilemaker copied to clipboard

Keep OSM feature type in the final mbtiles file

Open laem opened this issue 1 year ago • 14 comments

Hi, I found the include_ids option in the parameters, but I can't find an option to store the OSM feature type as well : node, way or relation.

It makes it very difficult to link the tiles' nodes to OSM on the final map.

I wonder if it's possible to add someting in the process-openmaptiles.lua file... Any help appreciated, thanks :)

laem avatar Aug 06 '24 09:08 laem

Exemple inspecting the mbtiles produces with the default tilemaker options with include_ids.

Sélection_230

This "Point" is in fact a way https://www.openstreetmap.org/way/64518593#map=20/47.55544/-3.13397&layers=H

laem avatar Aug 06 '24 09:08 laem

The $id is a dedicated field in the vector tiles, rather than an user-set attribute: see 4.2 in https://github.com/mapbox/vector-tile-spec/tree/master/2.1. There is no dedicated field for an "id type".

If you do want to add it as an attribute, you could certainly do that in process.lua. In node_function you'd add a line like Attribute("obj_type", "node"), in way_function you'd add Attribute("obj_type","way") and so on.

systemed avatar Aug 06 '24 10:08 systemed

Thanks for your quick answer ! I just tried this https://github.com/laem/gtfs/blob/master/tilemaker/resources/process-openmaptiles.lua#L124 without success yet, but I'm investigating.

laem avatar Aug 06 '24 11:08 laem

Mmmh maybe WritePOI needs to be modified as well.

laem avatar Aug 06 '24 11:08 laem

Awesome :)

image

laem avatar Aug 06 '24 11:08 laem

Do you think I should open a PR to add this attribute to the default process-openmaptiles.lua ? Else, the PR can be closed. Thanks again !

laem avatar Aug 06 '24 11:08 laem

Hi @systemed, what about relations that are handled by way_function, is it possible to know that a feature treated by way_function is an OSM relation ?

Tilemaker handles multipolygon relations natively. The combined geometries are processed as ways (i.e. by way_function), so if your function puts buildings in a 'buildings' layer, tilemaker will cope with this whether the building is mapped as a simple way or a multipolygon. The only difference is that they're given an artificial ID. Multipolygons are expected to have tags on the relation, not the outer way.

E.g. some schools can be ways or relations. This one is a relation, but in my tiles I want to keep track of the original OSM object, so I need to keep its original relation status.

I haven't been able to find a way to do that.

Could way_function get a parameter that tells the original status of the OSM feature ?

laem avatar Oct 24 '24 14:10 laem

I believe I found the answer. These relations are directed to way_function because they are multipolygon relations.

Tilemaker handles multipolygon relations natively. The combined geometries are processed as ways (i.e. by way_function), so if your function puts buildings in a 'buildings' layer, tilemaker will cope with this whether the building is mapped as a simple way or a multipolygon. The only difference is that they're given an artificial ID. Multipolygons are expected to have tags on the relation, not the outer way.

Hence, just testing if it's a multipolygon will tell us if it is a relation.

IsMultiPolygon(): returns true if the current object is a multipolygon.

laem avatar Apr 25 '25 13:04 laem

Mmmh, it's not working, IsMultiPolygon() does not appear to be available in process_openmaptiles.

laem avatar Apr 25 '25 13:04 laem

My bad ! It's an addition from two weeks ago, my local executable is older.

laem avatar Apr 25 '25 13:04 laem

Wonderful. Code is here : https://github.com/cartesapp/serveur/commit/51dd2a222b3d410562ee3b2e8c126010de71bd50

Image

Keeping this open in case merging to the repo's lua file is considered a good idea at some point.

laem avatar Apr 25 '25 14:04 laem

This is great - absolutely delighted you're using tilemaker for cartes.app!

systemed avatar Apr 25 '25 14:04 systemed

Thanks ! Hopefully to generate tiles for the whole europe and then the world soon. For now, we're using movisda's degree tiles to generate tiles that englobe France, and a MapLibre protocol to switch to Panoramax's planet.pmtiles.

laem avatar Apr 25 '25 16:04 laem

solved in #834 by adding a new function OsmType(). (@systemed you can close the issue, I tried but I don't have the rights to do so)

etienneJr avatar Oct 07 '25 19:10 etienneJr