[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Maposmatic-dev] [PATCH 02/22] coords: add BoundingBox::as_javascript()
From: |
Thomas Petazzoni |
Subject: |
[Maposmatic-dev] [PATCH 02/22] coords: add BoundingBox::as_javascript() method |
Date: |
Fri, 30 Mar 2012 13:00:19 +0200 |
This method returns a string containing a bit of Javascript code that
is useful to render the Bounding Box with the Leaflet Javascript
code. It allows to quickly have a graphical representation of multiple
bounding boxes on a slippy map. This is very useful to understand if
the computations done on bounding boxes are correct.
Signed-off-by: Thomas Petazzoni <address@hidden>
---
ocitysmap2/coords.py | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/ocitysmap2/coords.py b/ocitysmap2/coords.py
index 1159956..cad307f 100644
--- a/ocitysmap2/coords.py
+++ b/ocitysmap2/coords.py
@@ -155,6 +155,20 @@ class BoundingBox:
return (int(math.ceil(pix_y)), int(math.ceil(pix_x)))
+ def as_javascript(self, name=None, color=None):
+ if name:
+ name_str = ", \"%s\"" % name
+ else:
+ name_str = ""
+
+ if color:
+ color_str = ", { color: \"%s\" }" % color
+ else:
+ color_str = ""
+
+ return 'BoundingBox(%f,%f,%f,%f%s%s)' % \
+ (self._lat1, self._long1, self._lat2, self._long2,
+ name_str, color_str)
if __name__ == "__main__":
wkt = 'POINT(2.0333 48.7062132250362)'
--
1.7.4.1
- [Maposmatic-dev] Implementation of a multi-page renderer, Thomas Petazzoni, 2012/03/30
- [Maposmatic-dev] [PATCH 01/22] Initial version of a multi-page renderer, Thomas Petazzoni, 2012/03/30
- [Maposmatic-dev] [PATCH 03/22] multi-page: add a shape file that greys out the overlayed area between pages, Thomas Petazzoni, 2012/03/30
- [Maposmatic-dev] [PATCH 06/22] multi-page: add grid and grid labels, Thomas Petazzoni, 2012/03/30
- [Maposmatic-dev] [PATCH 05/22] multi-page: differentiate overlap margin and grayed margin, Thomas Petazzoni, 2012/03/30
- [Maposmatic-dev] [PATCH 04/22] multi-page: show page number at the bottom of each page, Thomas Petazzoni, 2012/03/30
- [Maposmatic-dev] [PATCH 07/22] indexlib: add page_number to IndexItem, Thomas Petazzoni, 2012/03/30
- [Maposmatic-dev] [PATCH 02/22] coords: add BoundingBox::as_javascript() method,
Thomas Petazzoni <=
- [Maposmatic-dev] [PATCH 08/22] indexlib: do not raise exception when index is empty, Thomas Petazzoni, 2012/03/30
- [Maposmatic-dev] [PATCH 09/22] indexlib: villages section is not of street type, Thomas Petazzoni, 2012/03/30
- [Maposmatic-dev] [PATCH 10/22] renderers: pass the db connection to the Renderer class constructor, Thomas Petazzoni, 2012/03/30
- [Maposmatic-dev] [PATCH 12/22] indexlib: render page number as part of the street/amenity location, Thomas Petazzoni, 2012/03/30
- [Maposmatic-dev] [PATCH 15/22] indexlib: properly differentiate the page_number=None and page_number=0 cases, Thomas Petazzoni, 2012/03/30
- [Maposmatic-dev] [PATCH 13/22] multi-page: add in dex rendering with a new MultiPageStreetIndexRenderer cl ass, Thomas Petazzoni, 2012/03/30
- [Maposmatic-dev] [PATCH 11/22] multi-page: prepare data for index generation, Thomas Petazzoni, 2012/03/30
- [Maposmatic-dev] [PATCH 14/22] multi-page: remove multiple debugging outputs, Thomas Petazzoni, 2012/03/30
- [Maposmatic-dev] [PATCH 18/22] indexlib: add min_drawing_width() method, Thomas Petazzoni, 2012/03/30
- [Maposmatic-dev] [PATCH 19/22] MultiPageStreetIndexRenderer: remove debugging background rectangle, Thomas Petazzoni, 2012/03/30