umap
umap copied to clipboard
import relations with remote data
Hello I'm trying to use uMap to display relations belonging to a node network.
- When I make an Overpass query, exported in json then reread in uMap everything goes well : I have the path of the relations on the map and the table of the tags of the relation in which I can choose what I want to display (name, length, elevation ...).
- When I try to do the same thing (with the same request compacted by overpass) using remote data to have an automatic real time import , I get the path of the relations on the map but no tag in the table, not even the name, they are all called with the name of the layer. Am I missing something or is it just not possible?
My overpass query : [out:json][timeout:50]; ( relation [ "network:type"="node_network" ] (44.7333816459144,4.368524551391602,44.755144990108455,4.406290054321289);); out geom;
Thanks
No comments for two years but now I can answer this question myself.
After developing a small Leaflet application to do almost the same thing, I realized what the problem was. When you tell overpass-turbo to export the result in geojson format, you get a real geojson object, correctly processed by uMap. But when you make a direct call to the Overpass API, the result is also a Json object but in OSM format. The data content is the same but the keys are different and in the case of a relation, uMap does not decode the properties. (In the case of simple nodes this seems to work. Why?) However, there is an osmtogeojson library to do the job. It is used by overpass-turbo. Why not in uMap? With a simple line of code geojsonobject = osmtogeojson(osm_data); the result could be sent to the pipe which processes geojson imports which does the job very well.
So I'm going to turn my question into a suggestion for improvement. Could this be done in uMap in the near future or am I still missing something?
A simple example of a uMap to illustrate https://umap.openstreetmap.fr/fr/map/import-relation_1070763
uMap already uses osmtogeojson:
https://github.com/umap-project/umap/blob/master/umap/static/umap/js/umap.layer.js#L989
So if it does not correctly handles relations, it may either be that we need to pass some option or do something more, or that the overpass query itself should be refined to include more data or metadata.
Concerning the query, I insist, in the umap example shown the query is exactly the same. The geojson layer (in blue) is made by loading a file exported from overpass-turbo. The table shows all the keys. The import layer is made with the same query in remote data. The table is empty and the relation is split in ways. I will have a look to the code to check if I can find something.
Here is a very simple example of what I would expect to get with uMap when the query returns a relation. https://pbalyx.github.io/tests/overpass_test/overpass_test.html Always with exactly the same query than in the uMap example I gave above. When I click on the route, I can get the name and the tags content, not only the name of the uMap layer. Source code is in https://github.com/pbalyx/tests/ ->folder overpass_test.
Still no hope of solving this problem? It would be nice though, in conjunction with the current development of a simple Overpass importer for uMap. A very simple query with this importer, "route=hiking" gives all the hiking trails in the map area. Unfortunately when we click on a route, we only have the name of the layer and not the name of the route and we cannot access the details of the relation.
I took a look at the code (umap.layers) to understand differences with my simple code above but I'm not very comfortable with modern Javascript. It seems to me that the output of osmtogeojson is processed afterwards in a recursive procedure geojsonToFeatures which decomposes each element into sub-elements. So the route relation is decomposed in ways and the name and tags of the relation are lost. Would it be possible to remove this step or at least to leave it optional if it is useful for other type of relation ?
This issue has been closed as fixed however, one day after, I don't see any change. In the example already shown https://umap.openstreetmap.fr/fr/map/import-relation_1070763 the red route, imported through remote data, has no name and is split in ways, the blue one, imported from a geojson file has the correct behaviour with name, tags and a single line geometry.
You have to wait for the next release and deployment.