# Main AMF handlers: process the raw AMF string (using AMF library) and
# calls each action (private method) accordingly.
# Main AMF handlers: process the raw AMF string (using AMF library) and
# calls each action (private method) accordingly.
when 'getpresets'; results[index]=AMF.putdata(index,getpresets())
when 'whichways'; results[index]=AMF.putdata(index,whichways(*args))
when 'whichways_deleted'; results[index]=AMF.putdata(index,whichways_deleted(*args))
when 'getpresets'; results[index]=AMF.putdata(index,getpresets())
when 'whichways'; results[index]=AMF.putdata(index,whichways(*args))
when 'whichways_deleted'; results[index]=AMF.putdata(index,whichways_deleted(*args))
when 'getrelation'; results[index]=AMF.putdata(index,getrelation(args[0].to_i))
when 'getway_old'; results[index]=AMF.putdata(index,getway_old(args[0].to_i,args[1]))
when 'getway_history'; results[index]=AMF.putdata(index,getway_history(args[0].to_i))
when 'getrelation'; results[index]=AMF.putdata(index,getrelation(args[0].to_i))
when 'getway_old'; results[index]=AMF.putdata(index,getway_old(args[0].to_i,args[1]))
when 'getway_history'; results[index]=AMF.putdata(index,getway_history(args[0].to_i))
[0, ways, points, relations]
rescue Exception => err
[0, ways, points, relations]
rescue Exception => err
begin
check_boundaries(xmin, ymin, xmax, ymax)
rescue Exception => err
begin
check_boundaries(xmin, ymin, xmax, ymax)
rescue Exception => err
end
nodes_in_area = Node.find_by_area(ymin, xmin, ymax, xmax, :conditions => ["current_ways.visible = ?", false], :include => :ways_via_history)
end
nodes_in_area = Node.find_by_area(ymin, xmin, ymax, xmax, :conditions => ["current_ways.visible = ?", false], :include => :ways_via_history)
[wayid, points, tags, version]
end
[wayid, points, tags, version]
end
# Get an old version of a way, and all constituent nodes.
#
# For undelete (version<0), always uses the most recent version of each node,
# Get an old version of a way, and all constituent nodes.
#
# For undelete (version<0), always uses the most recent version of each node,
if searchterm.to_i>0 then
rel = Relation.find(searchterm.to_i)
if rel and rel.visible then
if searchterm.to_i>0 then
rel = Relation.find(searchterm.to_i)
if rel and rel.visible then
- rels.push([rel.id, rel.tags, rel.members])
+ rels.push([rel.id, rel.tags, rel.members, rel.version])
end
else
RelationTag.find(:all, :limit => 11, :conditions => ["match(v) against (?)", searchterm] ).each do |t|
if t.relation.visible then
end
else
RelationTag.find(:all, :limit => 11, :conditions => ["match(v) against (?)", searchterm] ).each do |t|
if t.relation.visible then
- rels.push([t.relation.id, t.relation.tags, t.relation.members])
+ rels.push([t.relation.id, t.relation.tags, t.relation.members, t.relation.version])
def putrelation(renumberednodes, renumberedways, usertoken, changeset_id, version, relid, tags, members, visible) #:doc:
user = getuser(usertoken)
def putrelation(renumberednodes, renumberedways, usertoken, changeset_id, version, relid, tags, members, visible) #:doc:
user = getuser(usertoken)
return [0, relid, new_relation.id, new_relation.version]
else
return [0, relid, new_relation.id, new_relation.version]
else
- return [0, relid, relation.id, relation.version]
+ return [0, relid, relid, relation.version]
end
rescue OSM::APIChangesetAlreadyClosedError => ex
return [-1, "The changeset #{ex.changeset.id} was closed at #{ex.changeset.closed_at}."]
end
rescue OSM::APIChangesetAlreadyClosedError => ex
return [-1, "The changeset #{ex.changeset.id} was closed at #{ex.changeset.closed_at}."]
# Really need to check to see whether this is a server load issue, and the
# last version was in the same changeset, or belongs to the same user, then
# we can return something different
# Really need to check to see whether this is a server load issue, and the
# last version was in the same changeset, or belongs to the same user, then
# we can return something different
- return [-3, "Sorry, someone else has changed this relation since you started editing. Please click the 'Edit' tab to reload the area."]
+ return [-3, "Sorry, someone else has changed this relation since you started editing. Please click the 'Edit' tab to reload the area. The server said: #{ex}"]
rescue OSM::APIAlreadyDeletedError => ex
return [-1, "The relation has already been deleted."]
rescue OSM::APIError => ex
# Some error that we don't specifically catch
rescue OSM::APIAlreadyDeletedError => ex
return [-1, "The relation has already been deleted."]
rescue OSM::APIError => ex
# Some error that we don't specifically catch
- deleteitemrelations(user, changeset_id, id, 'node', node.version)
+ deleteitemrelations(user, changeset_id, id, 'Node', node.version)
# Really need to check to see whether this is a server load issue, and the
# last version was in the same changeset, or belongs to the same user, then
# we can return something different
# Really need to check to see whether this is a server load issue, and the
# last version was in the same changeset, or belongs to the same user, then
# we can return something different
- return [-3, "Sorry, someone else has changed this way since you started editing. Please click the 'Edit' tab to reload the area."]
+ return [-3, "Sorry, someone else has changed this way since you started editing. Click the 'Edit' tab to reload the area. The server said: #{ex}"]
rescue OSM::APITooManyWayNodesError => ex
return [-1, "You have tried to upload a really long way with #{ex.provided} points: only #{ex.max} are allowed."]
rescue OSM::APIAlreadyDeletedError => ex
return [-1, "The point has already been deleted."]
rescue OSM::APIError => ex
# Some error that we don't specifically catch
rescue OSM::APITooManyWayNodesError => ex
return [-1, "You have tried to upload a really long way with #{ex.provided} points: only #{ex.max} are allowed."]
rescue OSM::APIAlreadyDeletedError => ex
return [-1, "The point has already been deleted."]
rescue OSM::APIError => ex
# Some error that we don't specifically catch
# Really need to check to see whether this is a server load issue, and the
# last version was in the same changeset, or belongs to the same user, then
# we can return something different
# Really need to check to see whether this is a server load issue, and the
# last version was in the same changeset, or belongs to the same user, then
# we can return something different
- return [-3, "Sorry, someone else has changed this point since you started editing. Please click the 'Edit' tab to reload the area."]
+ return [-3, "Sorry, someone else has changed this point since you started editing. Please click the 'Edit' tab to reload the area. The server said: #{ex}"]
rescue OSM::APIAlreadyDeletedError => ex
return [-1, "The point has already been deleted"]
rescue OSM::APIError => ex
# Some error that we don't specifically catch
rescue OSM::APIAlreadyDeletedError => ex
return [-1, "The point has already been deleted"]
rescue OSM::APIError => ex
# Some error that we don't specifically catch
- # Returns array of id, long, lat, hash of tags, version.
+ # Returns array of id, long, lat, hash of tags, (current) version.
n = OldNode.find(id, :conditions=>['timestamp=?',DateTime.strptime(timestamp, "%d %b %Y, %H:%M:%S")])
end
if n
n = OldNode.find(id, :conditions=>['timestamp=?',DateTime.strptime(timestamp, "%d %b %Y, %H:%M:%S")])
end
if n
- return [n.id, n.lon, n.lat, n.tags, n.version]
+ return [n.id, n.lon, n.lat, n.tags, v]
else
return [nil, nil, nil, {}, nil]
end
else
return [nil, nil, nil, {}, nil]
end
delete_way = Way.new
delete_way.version = way_version
delete_way.changeset_id = changeset_id
old_way.delete_with_history!(delete_way, user)
delete_way = Way.new
delete_way.version = way_version
delete_way.changeset_id = changeset_id
old_way.delete_with_history!(delete_way, user)
- deleteitemrelations(user, changeset_id, node_id, 'node', node.version)
+ deleteitemrelations(user, changeset_id, node_id, 'Node', node.version)
delete_node.version = node.version
end
node.delete_with_history!(delete_node, user)
delete_node.version = node.version
end
node.delete_with_history!(delete_node, user)
return [-1, "The way has already been deleted."]
rescue OSM::APIError => ex
# Some error that we don't specifically catch
return [-1, "The way has already been deleted."]
rescue OSM::APIError => ex
# Some error that we don't specifically catch
def deleteitemrelations(user, changeset_id, objid, type, version) #:doc:
relations = RelationMember.find(:all,
def deleteitemrelations(user, changeset_id, objid, type, version) #:doc:
relations = RelationMember.find(:all,
- :conditions => ['member_type = ? and member_id = ?', type, objid],
+ :conditions => ['member_type = ? and member_id = ?', type.classify, objid],
SELECT DISTINCT cr.id AS relid,cr.version AS version
FROM current_relations cr
INNER JOIN current_relation_members crm ON crm.id=cr.id
SELECT DISTINCT cr.id AS relid,cr.version AS version
FROM current_relations cr
INNER JOIN current_relation_members crm ON crm.id=cr.id
WHERE #{OSM.sql_for_area(ymin, xmin, ymax, xmax, "cn.")}
EOF
unless way_ids.empty?
WHERE #{OSM.sql_for_area(ymin, xmin, ymax, xmax, "cn.")}
EOF
unless way_ids.empty?
SELECT DISTINCT cr.id AS relid,cr.version AS version
FROM current_relations cr
INNER JOIN current_relation_members crm ON crm.id=cr.id
SELECT DISTINCT cr.id AS relid,cr.version AS version
FROM current_relations cr
INNER JOIN current_relation_members crm ON crm.id=cr.id
- SELECT latitude*0.0000001 AS lat,longitude*0.0000001 AS lon,current_nodes.id
+ SELECT latitude*0.0000001 AS lat,longitude*0.0000001 AS lon,current_nodes.id,current_nodes.version
FROM current_way_nodes,current_nodes
WHERE current_way_nodes.id=#{wayid.to_i}
AND current_way_nodes.node_id=current_nodes.id
FROM current_way_nodes,current_nodes
WHERE current_way_nodes.id=#{wayid.to_i}
AND current_way_nodes.node_id=current_nodes.id
- points << [row['lon'].to_f,row['lat'].to_f,row['id'].to_i,nodetags]
+ points << [row['lon'].to_f,row['lat'].to_f,row['id'].to_i,nodetags,row['version'].to_i]