- if !create and pt['id'] != '0'
- way.id = pt['id'].to_i
- end
-
- way.version = pt['version']
- raise OSM::APIBadXMLError.new("node", pt, "Changeset is required") if pt['changeset'].nil?
- way.changeset_id = pt['changeset']
-
- # This next section isn't required for the create, update, or delete of ways
- if create
- way.timestamp = Time.now.getutc
- way.visible = true
- else
- if pt['timestamp']
- way.timestamp = Time.parse(pt['timestamp'])
- end
- # if visible isn't present then it defaults to true
- way.visible = (pt['visible'] or true)
+ fail OSM::APIBadXMLError.new("way", pt, "Version is required when updating") unless create || !pt["version"].nil?
+ way.version = pt["version"]
+ fail OSM::APIBadXMLError.new("way", pt, "Changeset id is missing") if pt["changeset"].nil?
+ way.changeset_id = pt["changeset"]
+
+ unless create
+ fail OSM::APIBadXMLError.new("way", pt, "ID is required when updating") if pt["id"].nil?
+ way.id = pt["id"].to_i
+ # .to_i will return 0 if there is no number that can be parsed.
+ # We want to make sure that there is no id with zero anyway
+ fail OSM::APIBadUserInput.new("ID of way cannot be zero when updating.") if way.id == 0