OpenStreetMap Forum

The Free Wiki World Map

You are not logged in.

#1 2018-04-05 00:09:48

user_7984
New Member
Registered: 2018-04-04
Posts: 1

How to programmatically combine ways with identical tags

I've got an .osm file that is the result of a conversion from shape files and I would like to know how to programmatically combine ways with identical tags and common nodes. I can combine ways in JOSM but since I have 1,411 roads split into many more ways, I thought it would save tons of time to combine them programmatically.

Offline

#2 2018-04-05 12:35:19

MikeN
Member
Registered: 2009-09-03
Posts: 294

Re: How to programmatically combine ways with identical tags

Offline

#3 2018-07-04 07:24:44

Martin Borsje
Moderator
From: Puth
Registered: 2011-10-22
Posts: 1,336

Re: How to programmatically combine ways with identical tags

Be careful not combining 'identical' ways that are not identical in being part of (different) route relations!

Last edited by Martin Borsje (2018-07-04 07:25:20)

Offline

#4 2018-07-09 15:41:53

Andreas Binder
Member
Registered: 2010-06-26
Posts: 354

Re: How to programmatically combine ways with identical tags

Be warned to use OsmGlommer!

See the source code https://svn.openstreetmap.org/applicati … r/Form1.cs and you will see, that the word "relation" is not mentioned once. This means that OsmGlommer does not know what an relation is.

I have tested OsmGlommer and the result was very, very bad for relations. The relation is just wrong afterwards or the relation has members which OsmGlommers deleted by joining ways. Josm denies to open such an corrupt osm-file.

Use this example file for input, if you want see the trash

<osm version='0.6' generator='JOSM'>
  <node id='-39203' action='modify' lat='47.71264102887' lon='12.86052412842' />
  <node id='-39205' action='modify' lat='47.71480874974' lon='12.88694301948' />
  <node id='-39207' action='modify' lat='47.7156221727' lon='12.91295392568' />
  <node id='-39209' action='modify' lat='47.70315060092' lon='12.8851379672' />
  <node id='-39211' action='modify' lat='47.71442440273' lon='12.87498210172' />
  <node id='-39269' action='modify' lat='47.71430163177' lon='12.88106444479' />
  <node id='-39287' action='modify' lat='47.71389239317' lon='12.8676224666' />
  <node id='-39353' action='modify' lat='47.71503825316' lon='12.90064958947' />
  <node id='-39369' action='modify' lat='47.70934962886' lon='12.88593031924' />
  <way id='-39213' action='modify'>
    <nd ref='-39203' />
    <nd ref='-39287' />
    <nd ref='-39211' />
    <tag k='highway' v='path' />
    <tag k='name' v='Test' />
  </way>
  <way id='-39215' action='modify'>
    <nd ref='-39205' />
    <nd ref='-39353' />
    <nd ref='-39207' />
    <tag k='highway' v='path' />
    <tag k='name' v='Test' />
  </way>
  <way id='-39217' action='modify'>
    <nd ref='-39209' />
    <nd ref='-39369' />
    <nd ref='-39205' />
    <tag k='highway' v='path' />
  </way>
  <way id='-39219' action='modify'>
    <nd ref='-39211' />
    <nd ref='-39269' />
    <nd ref='-39205' />
    <tag k='highway' v='path' />
    <tag k='name' v='Test' />
  </way>
  <relation id='-39221' action='modify'>
    <member type='way' ref='-39217' role='' />
    <member type='way' ref='-39215' role='' />
    <tag k='network' v='lwn' />
    <tag k='route' v='hiking' />
    <tag k='type' v='route' />
  </relation>
</osm>

Last edited by Andreas Binder (2018-07-13 19:18:09)

Offline

Board footer

Powered by FluxBB