json.bounds do
- json.minlat format("%.7f", @bounds.min_lat)
- json.minlon format("%.7f", @bounds.min_lon)
- json.maxlat format("%.7f", @bounds.max_lat)
- json.maxlon format("%.7f", @bounds.max_lon)
+ json.minlat GeoRecord::Coord.new(@bounds.min_lat)
+ json.minlon GeoRecord::Coord.new(@bounds.min_lon)
+ json.maxlat GeoRecord::Coord.new(@bounds.max_lat)
+ json.maxlon GeoRecord::Coord.new(@bounds.max_lon)
end
json.type "node"
json.id node.id
if node.visible
- json.lat format("%.7f", node.lat.to_f)
- json.lon format("%.7f", node.lon.to_f)
+ json.lat GeoRecord::Coord.new(node.lat)
+ json.lon GeoRecord::Coord.new(node.lon)
end
json.timestamp node.timestamp.xmlschema
json.version node.version
json.type "node"
json.id old_node.node_id
if old_node.visible
- json.lat format("%.7f", old_node.lat.to_f)
- json.lon format("%.7f", old_node.lon.to_f)
+ json.lat GeoRecord::Coord.new(old_node.lat)
+ json.lon GeoRecord::Coord.new(old_node.lon)
end
json.timestamp old_node.timestamp.xmlschema
json.version old_node.version
assert_equal Settings.api_version, js["version"]
assert_equal Settings.generator, js["generator"]
- assert_equal "#{format('%.7f', minlon)}", js["bounds"]["minlon"]
- assert_equal "#{format('%.7f', minlat)}", js["bounds"]["minlat"]
- assert_equal "#{format('%.7f', maxlon)}", js["bounds"]["maxlon"]
- assert_equal "#{format('%.7f', maxlat)}", js["bounds"]["maxlat"]
+ assert_equal GeoRecord::Coord.new(minlon), js["bounds"]["minlon"]
+ assert_equal GeoRecord::Coord.new(minlat), js["bounds"]["minlat"]
+ assert_equal GeoRecord::Coord.new(maxlon), js["bounds"]["maxlon"]
+ assert_equal GeoRecord::Coord.new(maxlat), js["bounds"]["maxlat"]
result_nodes = js["elements"].select { |a| a["type"] == "node" }
.select { |a| a["id"] == node.id }
- .select { |a| a["lat"] == "#{format('%.7f', node.lat)}" }
- .select { |a| a["lon"] == "#{format('%.7f', node.lon)}" }
+ .select { |a| a["lat"] == GeoRecord::Coord.new(node.lat) }
+ .select { |a| a["lon"] == GeoRecord::Coord.new(node.lon) }
.select { |a| a["version"] == node.version }
.select { |a| a["changeset"] == node.changeset_id }
.select { |a| a["timestamp"] == node.timestamp.xmlschema }