[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Maposmatic-dev] [PATCH] Adding bounding box coords (SRS 4002)
From: |
Pierre Mauduit |
Subject: |
[Maposmatic-dev] [PATCH] Adding bounding box coords (SRS 4002) |
Date: |
Thu, 5 Aug 2010 19:47:49 +0200 |
Adding to nominatim results the bounding box coordinates, in order to
check if the size is correct.
---
www/maposmatic/nominatim.py | 21 +++++++++++++++++----
1 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/www/maposmatic/nominatim.py b/www/maposmatic/nominatim.py
index f4f8726..eeeb5f1 100644
--- a/www/maposmatic/nominatim.py
+++ b/www/maposmatic/nominatim.py
@@ -32,7 +32,7 @@ Simple API to query http://nominatim.openstreetmap.org
Most of the credits should go to gthe Nominatim team.
"""
-
+from ocitysmap import coords
import www.settings
import psycopg2
from urllib import urlencode
@@ -194,17 +194,30 @@ def _retrieve_missing_data_from_GIS(entries):
for table_name in ("polygon", "line"):
# Lookup the polygon/line table for both osm_id and
# the opposite of osm_id
- cursor.execute("""select osm_id, admin_level, way_area
+ cursor.execute("""select osm_id, admin_level, way_area,
+ st_astext(st_envelope(st_transform(way,
+ 4002))) AS bbox
from planet_osm_%s
where osm_id = -%s""" \
% (table_name,entry["osm_id"]))
result = tuple(set(cursor.fetchall()))
if len(result) == 1:
- osm_id, admin_level, way_area = result[0]
+ osm_id, admin_level, way_area, bboxtxt = result[0]
+
+ bbox = coords.BoundingBox.parse_wkt(bboxtxt)
+
+ # Convert the floats to string, since it has
+ # to be rendered correctly by the JSON encoder
+ minx = str(bbox.get_top_left()[1])
+ miny = str(bbox.get_bottom_right()[0])
+ maxy = str(bbox.get_top_left()[0])
+ maxx = str(bbox.get_bottom_right()[1])
+
entry["ocitysmap_params"] \
= dict(table=table_name, id=osm_id,
admin_level=admin_level,
- way_area=way_area)
+ way_area=way_area, minx=minx, miny=miny,
+ maxx=maxx, maxy=maxy)
# Make these first in list, priviledging level 8
entry_rank = (ADMIN_LEVEL_RANKS.get(admin_level,9),
-way_area)
--
1.7.1