1 class ApiController < ApplicationController
5 unless bbox and bbox.count(',') == 3
6 render :nothing => true, :status => 400
10 bbox = bbox.split(',')
12 min_lat = bbox[0].to_f
13 min_lon = bbox[1].to_f
14 max_lat = bbox[2].to_f
15 max_lon = bbox[3].to_f
17 nodes = Node.find(:all, :conditions => ['latitude > ? AND longitude > ? AND latitude < ? AND longitude < ? AND visible = 1', min_lat, min_lon, max_lat, max_lon])
19 node_ids = "(#{nodes.collect {|node| node.id }})"
21 segments = Segment.find(:all, :condtions => ['node_a in ? or node_b in ?', node_ids, node_ids])
22 render :text => node_ids.join(',')
25 doc = XML::Document.new
26 doc.encoding = 'UTF-8'
27 root = XML::Node.new 'osm'
28 root['version'] = '0.4'
29 root['generator'] = 'OpenStreetMap server'
32 render :text => doc.to_s
34 #el1 = XML::Node.new 'node'
35 #el1['id'] = self.id.to_s
36 #el1['lat'] = self.latitude.to_s
37 #el1['lon'] = self.longitude.to_s
38 #Node.split_tags(el1, self.tags)
39 #el1['visible'] = self.visible.to_s
40 #el1['timestamp'] = self.timestamp.xmlschema