itinero / idp

Itinero data processor.
12 stars 10 forks source link

Question: adding custom tag #1

Open alecava58 opened 7 years ago

alecava58 commented 7 years ago

Looking at IDP I'd need to add a custom tag if the nodes referenced by a way is inside an area. My idea was to create a filter like AddWayId but I don't know how to get the coordinates of the nodes contained in the Nodes collection of the Way.

Could you help me doing this. Thanks static OsmSharp.OsmGeo EventsFilter_AddWayId(OsmSharp.OsmGeo osmGeo, object param) { if (osmGeo.Type == OsmSharp.OsmGeoType.Way) { var w = (OsmSharp.Way)osmGeo; foreach(var node in w.Nodes) { //var lat = ?? how to get latitude of node } osmGeo.Tags.Add("way_id", osmGeo.Id.ToString()); } return osmGeo; }

xivk commented 7 years ago

This is why Itinero does 2 passes over the OSM-data. This is what happens in each pass:

  1. Checks way tags and if usefull adds the node id's to a large set.
  2. Saves the node coordinates that are in the set from pass 1.

This is the only way to get all the node coordinates. Itinero already does so you should be able to reuse the way I have done this.... have a look at the code processing the OSM data in Itinero.