Fix compatible paper size calculation

The compatible paper size calculation in the PlainRenderer was not
properly using the returned result of BoundingBox.spheric_size(): the
width and height were switched, resulting in wrong chosen paper
orientations and sizes.

Signed-off-by: Maxime Petazzoni <maxime.petazzoni@bulix.org>
stable
Maxime Petazzoni 2010-08-08 09:35:33 +02:00
rodzic 3f5dce84cd
commit 118f0a4210
3 zmienionych plików z 7 dodań i 7 usunięć

Wyświetl plik

@ -100,7 +100,7 @@ class BoundingBox:
radius_lat * math.radians(delta_long))
def get_pixel_size_for_zoom_factor(self, zoom):
"""Return the size in pixels (tuple width,height) needed to
"""Return the size in pixels (tuple height,width) needed to
render the bounding box at the given zoom factor."""
delta_long = abs(self._long1 - self._long2)
# 2^zoom tiles (1 tile = 256 pix) for the whole earth
@ -115,4 +115,4 @@ class BoundingBox:
pix_y = (yplan(self._lat1) - yplan(self._lat2)) \
* (2 ** (zoom + 7)) / yplan(85)
return (int(math.ceil(pix_x)), int(math.ceil(pix_y)))
return (int(math.ceil(pix_y)), int(math.ceil(pix_x)))

Wyświetl plik

@ -65,7 +65,7 @@ class MapCanvas:
off_x+width, off_y+height)
self._geo_bbox = self._inverse_envelope(envelope)
g_width, g_height = self._geo_bbox.get_pixel_size_for_zoom_factor(
g_height, g_width = self._geo_bbox.get_pixel_size_for_zoom_factor(
stylesheet.zoom_level)
l.debug('Corrected bounding box from %s to %s, ratio: %.2f.' %

Wyświetl plik

@ -92,7 +92,7 @@ class Renderer:
# The DEFAULT_KM_IN_MM represents the minimum acceptable size in milimeters
# on the rendered map of a kilometer
DEFAULT_KM_IN_MM = 80
DEFAULT_KM_IN_MM = 100
def __init__(self, rc, tmpdir):
self.rc = rc
@ -440,9 +440,9 @@ class PlainRenderer(Renderer):
capable).
"""
geo_width_m, geo_height_m = bounding_box.spheric_sizes()
paper_width_mm = geo_width_m/1000.0 * resolution_km_in_mm
paper_height_mm = geo_height_m/1000.0 * resolution_km_in_mm
geo_height_m, geo_width_m = bounding_box.spheric_sizes()
paper_width_mm = int(geo_width_m/1000.0 * resolution_km_in_mm)
paper_height_mm = int(geo_height_m/1000.0 * resolution_km_in_mm)
l.debug('Map represents %dx%dm, needs at least %.1fx%.1fcm '
'on paper.' % (geo_width_m, geo_height_m,