missing projection alert

Russell Nelson nelson at crynwr.com
Tue Dec 28 21:25:09 CET 2004


I propose two patches here.

The first patch (legend.py) uses the map legend to let you know that
you have no map, or if you have a map, that the map has no projection.
Unfortunately, the code doesn't work for me because of some
wxGTK/wxGTK2/pango problem on FC2 that causes Text Extents to blow up
into the thousands of pixels.  The code is in theory correct (haha),
and it would be nice if somebody could try it to see if it's helpful
to them.  Clearly, a subroutine is called for here, but I want to
submit a succinct patch to find out if anybody else finds the code
worthwhile.

I have more confidence that the second patch (mainwindow.py) is
correct.  If you have a layer whose LatLonBoundingBox returns values
which are not legitimate latitude or longitudes, the status bar gets a
message asking you to correct the projection.  If you load a UTM map,
you'll get this message.


Index: Thuban/UI/legend.py
===================================================================
RCS file: /thubanrepository/thuban/Thuban/UI/legend.py,v
retrieving revision 1.37
diff -u -r1.37 legend.py
--- Thuban/UI/legend.py	18 Apr 2004 20:37:45 -0000	1.37
+++ Thuban/UI/legend.py	28 Dec 2004 20:11:45 -0000
@@ -739,8 +739,18 @@
         dc.SelectObject(bmp)
         dc.Clear()
 
-        if self.canvas.map is not None \
-            and self.canvas.map.projection is not None:
+
+        if self.canvas.map is None:
+            text = _("No map")
+            l2width, l2height = dc.GetTextExtent(text)
+            dc.SetTextForeground(wxBLACK)
+            dc.DrawText(text, (self.width - l2width)/2, (self.height - l2height)/2)
+        elif self.canvas.map.projection is None:
+            text = _("No map projection")
+            l2width, l2height = dc.GetTextExtent(text)
+            dc.SetTextForeground(wxBLACK)
+            dc.DrawText(text, (self.width - l2width)/2, (self.height - l2height)/2)
+        else:
 
             # if we are using a projection with geographics coordinates
             # we need to change the scale value based on where we are








Index: Thuban/UI/mainwindow.py
===================================================================
RCS file: /thubanrepository/thuban/Thuban/UI/mainwindow.py,v
retrieving revision 1.135
diff -u -r1.135 mainwindow.py
--- Thuban/UI/mainwindow.py	1 Oct 2004 18:22:32 -0000	1.135
+++ Thuban/UI/mainwindow.py	28 Dec 2004 20:11:45 -0000
@@ -340,6 +340,19 @@
             text = "(%10.10g, %10.10g)" % pos
         else:
             text = ""
+            map = self.canvas.Map()
+            for layer in map.layers:
+                bbox = layer.LatLongBoundingBox()
+                if bbox:
+                    left, bottom, right, top = bbox
+                    if not (-180 < left < 180 and
+                        -180 < right < 180 and
+                        -90 < top < 90 and
+                        -90 < bottom < 90):
+                        text = ("Select "+layer.title+" and pick a " +
+                            "projection using Layer/Projection...")
+                        break
+
         self.set_position_text(text)
 
     def set_position_text(self, text):




More information about the Thuban-devel mailing list

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