From 76eac8f0bc14d9bce02ca65d73cd484ef283d1a5 Mon Sep 17 00:00:00 2001 From: David MENTRE Date: Wed, 6 Jan 2010 20:02:09 +0100 Subject: [PATCH ocitysmap] Include localities into street index --- ocitysmap/street_index.py | 29 ++++++++++++++++++++++++++--- 1 files changed, 26 insertions(+), 3 deletions(-) diff --git a/ocitysmap/street_index.py b/ocitysmap/street_index.py index 4aa642f..d73cc90 100644 --- a/ocitysmap/street_index.py +++ b/ocitysmap/street_index.py @@ -597,10 +597,33 @@ class OCitySMap: (self._map_areas_table_name, pgdb.escape_string(city.encode('utf-8')))) - sl = cursor.fetchall() + street_list = cursor.fetchall() + LOG.debug("Got %d streets." % len(street_list)) + + cursor.execute("""select name, textcat_all(x || ',' || y || ';') + from (select distinct name, x, y + from planet_osm_point + join %s + on st_intersects(way, st_transform(geom, 900913)) + left join cities_area_by_name on city='%s' + where trim(name) != '' and place = 'locality' + and case when cities_area_by_name.area is null + then + true + else + st_intersects(way, cities_area_by_name.area) + end) + as foo + group by name + order by name;""" % \ + (self._map_areas_table_name, + pgdb.escape_string(city.encode('utf-8')))) - LOG.debug("Got %d streets." % len(sl)) - return self.humanize_street_list(sl) + locality_list = cursor.fetchall() + LOG.debug("Got %d localities." % len(locality_list)) + + street_list.extend(locality_list) + return self.humanize_street_list(street_list) def get_streets_by_osmid(self, db, osmid): -- 1.6.0.4