Skip to content
This repository has been archived by the owner on Jul 19, 2023. It is now read-only.

Cannot retrieve any tags with Annotator() #66

Open
JonasHeidelberg opened this issue Dec 30, 2021 · 2 comments
Open

Cannot retrieve any tags with Annotator() #66

JonasHeidelberg opened this issue Dec 30, 2021 · 2 comments

Comments

@JonasHeidelberg
Copy link

I am trying to get route-annotator to work for retrieving tags for an OSRM route, as advertised by @danpat. I am starting with the code example from README.md, with fixes as proposed by @StephanGeorg. However, I always only get back a way ID, no further tags.

For example, when using the test/data/monaco.extract.osm file, I try to retrieve this information, using the nodes as starting point:

 <way id="4227277" visible="true" version="13" changeset="49895491" timestamp="2017-06-28T15:54:59Z" user="ika-chan!" uid="4763179">
  <nd ref="1918966551"/>
  <nd ref="1079045459"/>
  <nd ref="4940692951"/>
  <nd ref="2109529537"/>
  <tag k="highway" v="primary"/>
  <tag k="lanes" v="2"/>
  <tag k="lit" v="yes"/>
  <tag k="maxspeed" v="50"/>
  <tag k="name" v="Rue de la Colle"/>
  <tag k="oneway" v="yes"/>
  <tag k="sidewalk" v="both"/>
  <tag k="smoothness" v="excellent"/>
  <tag k="surface" v="asphalt"/>
  <tag k="turn:lanes" v="left|through"/>
 </way>

I start node.js manually and type:

var taglookup = new (require('./index')).Annotator({ coordinates: true });
global.myWayIDs = 'n/a yet'
global.mytags = 'n/a yet'
taglookup.loadOSMExtract('test/data/monaco.extract.osm', (err) => {
  console.log('loadOSMExtract done');
  if (err) console.log(err);
  console.log('Success :-)');
});

Once I see the Success message, I launch this code (with the 4 nodes from above):

var nodes = [1918966551, 1079045459, 4940692951, 2109529537];
taglookup.annotateRouteFromNodeIds(nodes, (err, wayIds) => {
  console.log('annotateRouteFromNodeIds done');
  if (err) console.log(err);
  global.myWayIDs = wayIds;
  console.log('Success :-)');
  console.log(wayIds);
});

The wayIds shown are [ 4, 4, 4 ], instead of [4227277] or maybe [4227277, 4227277, 4227277] which I would have expected. I plow ahead nonetheless and try to retrieve/show the tags:

taglookup.getAllTagsForWayId(myWayIDs[0], (err, tags) => {
  if (err) throw err;
  console.log(tags);
  mytags = tags
});

which gives me a mere
{ _way_id: '4227277' }

I am a bit lost here... what am I doing wrong? I would have expected something like
{highway:'primary', lanes:2, lit: 'yes', maxspeed:50?

@JonasHeidelberg
Copy link
Author

It occured to me that I at least get from the Nodes to the way id, so I can use the way id (returned in tags, not in wayIds!) and call the overpass API:
https://lz4.overpass-api.de/api/interpreter?data=[out:json];way(4227277);out;
returns (among other things)
"tags": {
"highway": "primary",
"lanes": "2",
"lit": "yes",
"maxspeed": "50",
"name": "Rue de la Colle",
"oneway": "yes",
"sidewalk": "left",
"smoothness": "excellent",
"surface": "asphalt",
"turn:lanes": "left|through"
}

i.e. exactly what I would have expected from the call to getAllTagsForWayId.
--> I will try this as a workaround for now, but I am still puzzled.

@StephanGeorg
Copy link

Hey @JonasHeidelberg. Yes, this was also my solution, not with Overpass but to query osm_id in a OSM DB. But honestly I stopped my investigation b/c of #64. If you want we can share some experiences about this: https://twitter.com/StephanGeorg

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants