Advertisement
Guest User

Untitled

a guest
Oct 19th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. import osmapi
  2.  
  3. # Connect to OSM
  4. api = osmapi.OsmApi(username="osm-user", password="***")
  5.  
  6. # Create a new changeset
  7. api.ChangesetCreate({u"comment": u"updating abandoned roads"})
  8.  
  9. # Read File with way id and highway dates
  10. with open("East_Complex_Attributes.txt", "r") as f:
  11. for row in f:
  12. # Extract values for row
  13. values = row.split(",")
  14. nid = int(values[0].strip())
  15. time1 = values[1].strip()
  16. time2 = values[2].strip()
  17.  
  18. print nid
  19.  
  20. way = api.WayGet(nid)
  21.  
  22. # If Way exists
  23. if way is not None:
  24. print way
  25.  
  26. # Remove timestamp tag for later update
  27. way.pop(u'timestamp')
  28.  
  29. # Add highway dates
  30. way[u"tag"][u"highway:{}".format(time1)] = u"track"
  31. if len(time2):
  32. way[u"tag"][u"highway:{}".format(time2)] = u"track"
  33.  
  34. # Update Way
  35. api.WayUpdate(way)
  36.  
  37. # If way doesn't exist
  38. else:
  39. print "skip"
  40.  
  41. # Close Changeset
  42. api.ChangesetClose()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement