[Thuban-devel] scaling

Russell Nelson nelson at crynwr.com
Tue Jan 11 06:26:45 CET 2005


Jan-Oliver Wagner writes:
 > I must admit that I'd need to see the patch to better judge whether
 > it is a good idea to add this to Thuban core. The reason is that
 > I do not yet fully understand the consequences of such a change
 > and playing with it helps me to get a better impression.

This is the diff I'd like to check in.

diff -u -r1.60 layer.py
--- Thuban/Model/layer.py	20 Sep 2004 08:13:00 -0000	1.60
+++ Thuban/Model/layer.py	11 Jan 2005 05:21:41 -0000
@@ -71,6 +71,10 @@
         self.projection = projection
         self.changed(LAYER_PROJECTION_CHANGED, self)
 
+    def AdjustScale(self, scale):
+        """Adjust the map's scaling to a preferred scale."""
+        return scale
+
 class Layer(BaseLayer):
 
     """Represent the information of one geodata file (currently a shapefile)
diff -u -r1.18 map.py
--- Thuban/Model/map.py	10 Jul 2003 14:53:15 -0000	1.18
+++ Thuban/Model/map.py	11 Jan 2005 05:21:41 -0000
@@ -170,6 +170,13 @@
             self.changed(MAP_LAYERS_CHANGED, self)
             self.changed(MAP_STACKING_CHANGED, self)
 
+    def AdjustScale(self, scale):
+        """Adjust the scale of the map as requested by any layer."""
+
+        for layer in self.layers:
+            scale = layer.AdjustScale(scale)
+        return scale
+
     def BoundingBox(self):
         """Return the bounding box of the map in Lat/Lon coordinates.
 
diff -u -r1.19 viewport.py
--- Thuban/UI/viewport.py	18 Nov 2004 20:17:43 -0000	1.19
+++ Thuban/UI/viewport.py	11 Jan 2005 05:21:44 -0000
@@ -410,7 +410,8 @@
         elif scale < min_scale:
             scale = min_scale
 
-        self.scale = scale
+        # give the layers a chance to pick a better scale.
+        self.scale = self.map.AdjustScale(scale)
 
         # determine new offset to preserve the center
         self.offset = (wwidth/2 - scale * pcenterx,

-- 
--My blog is at angry-economist.russnelson.com  | Freedom means allowing
Crynwr sells support for free software  | PGPok | people to do things the
521 Pleasant Valley Rd. | +1 315-323-1241 cell  | majority thinks are
Potsdam, NY 13676-3213  | +1 212-202-2318 VOIP  | stupid, e.g. take drugs.




More information about the Thuban-devel mailing list

This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)