[OSM-dev] [OSM-talk] Bounding box

Richard Fairhurst richard at systemeD.net
Mon Feb 5 17:46:10 GMT 2007


Robert Hart wrote:

> How difficult would it be to make the API return only complete ways? I
> assume that would require multiple DB queries

SELECT n1.latitude AS lat1,n1.longitude AS long1,n1.id AS id1,n1.tags  
as tags1,
        n2.latitude AS lat2,n2.longitude AS long2,n2.id AS id2,n2.tags  
as tags2,
        segment_id
   FROM current_way_segments,current_segments,
        current_nodes AS n1,current_nodes AS n2
  WHERE current_way_segments.id=?
    AND segment_id=current_segments.id
    AND n1.id=node_a and n2.id=node_b
  ORDER BY sequence_id

is how Potlatch does it. I'm no SQL guru; no doubt it could be  
optimised further [1].

Note that this doesn't get segment or way tags; Potlatch uses a second  
query to get way tags.

cheers
Richard

[1] If anyone wants to download the Potlatch source (see wiki) and  
sanity-check/optimise the various bits of SQL in rubyamf.cgi, that  
would be extremely helpful!





More information about the dev mailing list