[OSM-dev] Limitation on downloading ways via /map API Call

Christopher Schmidt crschmidt at crschmidt.net
Sun Jul 9 17:19:06 BST 2006


On Sun, Jul 09, 2006 at 12:12:50PM -0400, Christopher Schmidt wrote:
> http://svn.openstreetmap.org/www.openstreetmap.org/ruby/api/osm/dao.rb
> is the code as it stands. If persistent connections were to be enabled,
> such that each new MySQL query didn't create a new database handle, then
> the patch attached to this email would correct the current
> segments-in-ways limitation. However, as it stands, creating a new
> database handle for every query is slowing everything down to much to
> the extent that this patch should not be applied.

Previous patch was bad. New patch is fixed. Although it still shouldn't
be applied.

-- 
Christopher Schmidt
Web Developer
-------------- next part --------------
Index: www.openstreetmap.org/ruby/api/osm/dao.rb
===================================================================
--- www.openstreetmap.org/ruby/api/osm/dao.rb	(revision 1152)
+++ www.openstreetmap.org/ruby/api/osm/dao.rb	(working copy)
@@ -1099,16 +1099,12 @@
 
       id_list = segment_ids.join(',')
 
+      ress = call_sql { "select id from current_way_segments where segment_id in (#{id_list}) group by id" }
 
-      ress = call_sql { "select d.id,d.segs,d.tags,current_ways.timestamp,current_ways.visible from (select c.id, segs, group_concat(k , concat('===', v) SEPARATOR '|||') as tags from (select id, group_concat(segment_id order by sequence_id) as segs from (select a.id, segment_id, sequence_id from (select id from current_way_segments where segment_id in (#{id_list}) group by id) as a, current_way_segments where a.id = current_way_segments.id) as b group by id) as c, current_way_tags where c.id = current_way_tags.id group by id) as d, current_ways where current_ways.id = d.id;" }
-
       multis = []
 
       ress.each_hash do |row|
-        tags = row['tags'].split('|||').collect {|x| x.split('===')}
-        segs = row['segs'].split(',').collect {|x| x}
-        visible = row['visible'] == '1'
-        multis << Street.new(row['id'].to_i, tags, segs, visible, row['timestamp'])
+        multis << get_multi(row['id'].to_i)
       end
 
       return multis


More information about the dev mailing list