From cvs at intevation.de Sun Aug 1 23:28:19 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Sun, 1 Aug 2004 23:28:19 +0200 (CEST) Subject: jan: thuban/Doc/manual thuban-manual-de.xml,1.1,1.2 Message-ID: <20040801212819.3828513AB4@lists.intevation.de> Author: jan Update of /thubanrepository/thuban/Doc/manual In directory doto:/tmp/cvs-serv5999 Modified Files: thuban-manual-de.xml Log Message: (Chapter Session Management): translation completed. Index: thuban-manual-de.xml =================================================================== RCS file: /thubanrepository/thuban/Doc/manual/thuban-manual-de.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- thuban-manual-de.xml 31 Jul 2004 11:06:52 -0000 1.1 +++ thuban-manual-de.xml 1 Aug 2004 21:28:16 -0000 1.2 @@ -432,102 +432,118 @@ Die Legende kann durch Anwahl des X in der oberen rechten Ecke geschlossen werden. Um die Legenden-Ansicht wieder zu öffnen, wählen Sie - - Karte - Legende - . - The legend is also dockable, which means that it can be detached - from the main window by clicking on the small button next to the - close button. It can be attached by clicking the same button - again. - - - The status bar displays different information depending on the - current context. If the user is selecting an item from the menu - then the status bar will display a short help message indicating - what each menu item is for. If the user has a tool selected then - the position of the cursor on the map is displayed. - - - The tool bar provides quick access to the commonly needed tools. - By hovering over each button the user can see a short messages - describing what the tool does. The tools provided are Zoom In, Zoom - Out, Pan, Full Extent, Full Layer Extent, Full Shape Extent, Identify, - and Label. Each of the tools will be explained in further detail later - in the manual. - - + + Karte + Legende + . + Das Legenden-Fenster ist lösbar. Das bedeutet, dass sie vom Hauptfenster + abgelöst und dann als eigenständiges Fenster + positioniert werden kann. Dies wird durch den kleinen Schalter + neben dem X gemacht. Erneutes Anwählen des Schalters läßt das + Legenden-Fenster wieder in das Hauptfenster integrieren. + + + Die Status-Leiste zeigt verschiedene Informationen jeweils + abhängig vom Kontext. Wählt der Benutzer einen Menüpunkt + dann wird in der Status-Leiste ein Hilfetext zu dem jeweiligen + Menüpunkt angezeigt. + Ist eines der Werkzeuge aktiviert, so wird in der Status-Leiste + die Position angegeben über der der Maus-Cursor auf der Karte + steht. + + + Die Werkzeugleiste erlaubt direkten Zugriff auf häufig + benötigte Werkzeuge. + Schwebt der Maus-Zeiger über einem Knopf wird eine Kurz-Info + über das jeweilige Werkzeug gegeben. + Folgende Werzeuge stehen zur Verfügung: Hineinzoomen, + Herauszoomen, Verschieben, Zur vollen Kartenausdehnung zoomen, + Zur vollen Ebenenausdehnung zoomen, Zur vollen Auswahlausdehnung zoomen, + Identifizieren, Labels hinzufügen/entfernen. + Alle Werkzeuge werden in diesem Handbuch noch detaillierter beschrieben. + + Session Management -
Starting a New Session - - A new session can be started from - - File - New Session - . - If a session is already loaded and has been modified without - being saved a prompt will ask if the current session should - be saved. A new session consists of an empty map with no - layers and no tables. - -
+
Eine neue Session beginnen + + Eine neue Session wird gestartet über + + Datei + Neue Session + . + Falls bereits eine Session geladen ist und seit der letzten + Speicherung verändert wurde, so wird nun nachgefragt, ob + diese Session zunächst gespeichert werden soll. + Eine neue Session besteht aus einer leeren Karte + ohne Ebenen, Tabellen und Projektion. + +
-
Opening a Session - - A session can be opened from - - File - Open Session - . A dialog box will open allowing the user to browse - for a Thuban Session file. Thuban session files end with - .thuban. Selecting a file a clicking - OK will load the session into Thuban. +
Eine Session öffnen + + Eine Session kann geöffnet werden über + + Datei + Öffne Session + . + Es wird ein Dateiauswahl-Dialog geöffnet um eine + Thuban Session Datei auszuwählen. Diese Dateien enden + auf .thuban. Wird eine Datei ausgewählt und mit + OK bestätigt, so wird die entsprechende + Session in Thuban geladen. - If a session is already loaded and has been modified without - being saved a prompt will ask if the current session should - be saved. - -
+ Ist bereits eine Session geladen und seit dem letzten Speichern modifiziert + worden, so wird nachgefragt, ob zunächst die alte Session gespeichert werden + soll. +
+
-
Saving a Session - - A session can be saved from - - File - Save Session - . A dialog box will open allowing the user to browse - the file system and select a place to save the session. Thuban - sessions should be saved under a name ending in - .thuban. If the file already exists the user - will be prompted to save under a different name or overwrite the - existing file. - -
+
Eine Session speichern + + Eine Session kann gepsiechert werden über + + Datei + Session Speichern + . + Handelt es sich bei der aktuellen Session nicht um eine + neue und ungespeicherte, so wird die entsprechende Datei + mit den Daten der aktuellen Session überschrieben. + Im Falle einer neuen und noch nicht gespeicherten Session + wird ein Dateiauswahl-Dialog geöffnet um einen Namen + für die zu speicherende Session auszuwählen. + Thuban Session Dateien sollten mit der Endung + .thuban versehen werden. + Existiert bereits eine Datei mit dem gleichen Namen + wird der Benutzer gefragt ob diese überschrieben + oder ein neuer Name gewählt werden soll. + +
-
The Session Info-Tree - -
- Session Info Tree - - - - -
-
- - The session info-tree is primarily intended for developers working - with Thuban. It displays many of the internal values for the session, - map, and layers. It can be opened from - - File - Session Tree - . - -
+
Der Session Info-Baum + +
+ Session Info-Baum + + + + +
+
+ + Der Session Info-Baum ist hauptsächlich für Software-Entwickler gedacht + die an Thuban arbeiten. + Er stellt eine Reihe von internen Daten zur Session, der Karte, den + Ebenen usw. dar. Er wird geöffnet über + + Datei + Session Baum + . + +
Map Management From cvs at intevation.de Sun Aug 1 23:31:33 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Sun, 1 Aug 2004 23:31:33 +0200 (CEST) Subject: jan: thuban/Doc/manual thuban-manual.xml,1.26,1.27 Message-ID: <20040801213133.2202113AB4@lists.intevation.de> Author: jan Update of /thubanrepository/thuban/Doc/manual In directory doto:/tmp/cvs-serv6051 Modified Files: thuban-manual.xml Log Message: (Chapter Session Management): Fixed unprecise description for Save Session. Index: thuban-manual.xml =================================================================== RCS file: /thubanrepository/thuban/Doc/manual/thuban-manual.xml,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- thuban-manual.xml 31 Jul 2004 11:12:20 -0000 1.26 +++ thuban-manual.xml 1 Aug 2004 21:31:30 -0000 1.27 @@ -484,7 +484,7 @@ If a session is already loaded and has been modified without being saved a prompt will ask if the current session should be saved. A new session consists of an empty map with no - layers and no tables. + layers, no tables and no projection. @@ -511,7 +511,12 @@ File Save Session - . A dialog box will open allowing the user to browse + . + In the case the session is not a new and unsaved one, + the corresponding file is updated with the current session + data. + In the case the current session is a new one and yet unsaved + a dialog box will open allowing the user to browse the file system and select a place to save the session. Thuban sessions should be saved under a name ending in .thuban. If the file already exists the user From cvs at intevation.de Sun Aug 1 23:32:09 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Sun, 1 Aug 2004 23:32:09 +0200 (CEST) Subject: jan: thuban ChangeLog,1.677,1.678 Message-ID: <20040801213209.CC99013B16@lists.intevation.de> Author: jan Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv6075 Modified Files: ChangeLog Log Message: further work in manuals Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.677 retrieving revision 1.678 diff -u -d -r1.677 -r1.678 --- ChangeLog 31 Jul 2004 11:14:08 -0000 1.677 +++ ChangeLog 1 Aug 2004 21:32:07 -0000 1.678 @@ -1,3 +1,11 @@ +2004-08-01 Jan-Oliver Wagner + + * Doc/manual/thuban-manual-de.xml (Chapter Session Management): + translation completed. + + * Doc/manual/thuban-manual.xml (Chapter Session Management): + Fixed unprecise description for Save Session. + 2004-07-31 Jan-Oliver Wagner Started translation of Users Manual into german. From cvs at intevation.de Tue Aug 3 13:46:02 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Tue, 3 Aug 2004 13:46:02 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver mapfile.py,1.9,1.10 Message-ID: <20040803114602.80D21139C8@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver In directory doto:/tmp/cvs-serv14272 Modified Files: mapfile.py Log Message: (MF_Metadata): Added a function to remove all metadata. (MF_Layer): Added two functions to handle the group setting. Removed the extra numlayers variable, used the mapscript parameter instead. (MF_Map): Added a function to get the numlayers parameter. Added a funtion to remove all layers. (MF_Map.add_thubanlayer): Replaced the exception handling by a check if the object is an instance. Also added the annotation layer here to export, but only the layer is created in the mapfile. Index: mapfile.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mapfile.py,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- mapfile.py 28 Jul 2004 12:35:32 -0000 1.9 +++ mapfile.py 3 Aug 2004 11:46:00 -0000 1.10 @@ -42,6 +42,9 @@ from Thuban.Model.classification import ClassGroupDefault, \ ClassGroupSingleton, ClassGroupRange +from Thuban.Model.layer import RasterLayer +from Extensions.umn_mapserver.mf_import import AnnotationLayer + from mapscript import layerObj, classObj, colorObj, styleObj, rectObj, symbolObj, \ pointObj, lineObj @@ -235,6 +238,12 @@ def __init__(self, mapobj): self.mapobj = mapobj + def remove_allmetadata(self): + keylist = self.get_metadatakeys() + if keylist: + for key in keylist: + self.mapobj.removeMetaData(key) + def get_metadatakeys(self): keylist = [] try: @@ -557,6 +566,13 @@ return True #return self._mf_layer.status + def get_group(self): + return self._mf_layer.group + + def set_group(self, new_group): + self._mf_layer.group = new_group + + def set_name(self, newname): self._mf_layer.name = newname @@ -601,7 +617,7 @@ def add_thubanclass(self, tb_class, type=""): """ Add a thuban class object - """ + """ new_class = MF_Class(classObj(self._mf_layer)) # set the class name to the Label form thuban if given, # else set it to the value @@ -843,9 +859,8 @@ # Initial Layer List self._layers = [] - self._numlayers = self._mf_map.numlayers self._i = 0 - while self._i < self._numlayers: + while self._i < self._mf_map.numlayers: self._layers.append(MF_Layer(self._mf_map.getLayer(self._i))) self._i += 1 @@ -857,7 +872,6 @@ # Create Metadata self._metadata = MF_Metadata(self._mf_map) - def get_mappath(self): return self._mf_map.mappath @@ -865,7 +879,6 @@ def set_mappath(self, new_mappath): self._mf_map.mappath = new_mappath - def get_outputformat(self): return self._outputformat @@ -908,6 +921,9 @@ def get_layers(self): return self._layers + def get_numlayers(self): + return self._mf_map.numlayers + def get_projection(self): return self._projection @@ -924,10 +940,10 @@ def get_imagetype(self): return self._mf_map.imagetype - + def get_layerorder(self): # shows the order of layer as list - return self._mf_map.getLayerOrder() + return self._mf_map.getLayerOrder() def get_size(self): #returns the size @@ -995,13 +1011,15 @@ # TODO: implement relative pathnames # yet only absolute pathnames in the LayerObj are set - try: - new_layer.set_data(tb_layer.ShapeStore().FileName()) - except: + if isinstance(tb_layer, RasterLayer ): new_layer.set_data(tb_layer.GetImageFilename(), type="raster") new_layer.set_type("raster") new_layer.set_status(tb_layer.Visible()) + elif isinstance(tb_layer, AnnotationLayer): + new_layer.set_type("annotation") + new_layer.set_status(tb_layer.Visible()) else: + new_layer.set_data(tb_layer.ShapeStore().FileName()) new_layer.set_status(tb_layer.Visible()) new_layer.set_type(tb_layer.ShapeType()) @@ -1038,9 +1056,15 @@ self._layers.append(new_layer) def remove_layer(self, nr): + #remove the last layer from the layer list and not the one which + # is removed in mapscript. This must be, becaus mapscript + # set the object links anew. Don't understand really :) + self._layers.pop() self._mf_map.removeLayer(nr) - self._numlayers -= 1 - self._layers.remove(self._layers[nr]) + + def remove_all_layers(self): + for i in range (self._mf_map.numlayers,0,-1): + self.remove_layer(i-1) def save_map(self, filepath): # save the Map From cvs at intevation.de Tue Aug 3 13:56:11 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Tue, 3 Aug 2004 13:56:11 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver mf_export.py,1.6,1.7 Message-ID: <20040803115611.28FC3139C8@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver In directory doto:/tmp/cvs-serv14431 Modified Files: mf_export.py Log Message: Removed the check if a mapobj exist, because its not needed anymore. The export function is only available if a mapobj exist. Added an extra function to remove all layers. Index: mf_export.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mf_export.py,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- mf_export.py 28 Jul 2004 12:36:27 -0000 1.6 +++ mf_export.py 3 Aug 2004 11:56:08 -0000 1.7 @@ -105,11 +105,9 @@ def export_mapfile(context): - if hasattr(context.mainwindow.canvas.Map(), "extension_umn_mapobj"): - theMap = context.mainwindow.canvas.Map().extension_umn_mapobj - else: - theMap = MF_Map(mapObj("")) - context.mainwindow.canvas.Map().extension_umn_mapobj = theMap + theMap = context.mainwindow.canvas.Map().extension_umn_mapobj + + theMap.remove_all_layers() dlg = wxFileDialog(context.mainwindow, "Save file as...", ".", "", "UMN MapServer Mapfiles (*.map)|*.map|" \ @@ -137,14 +135,6 @@ # this funktion will write a commend to the generated mapfile # that shows that the file is generated by thuban write_creatorcomment(path,file) - - # remove alle added layers from the temporary mapobj - # this is necessary because the layers will add new on each save - tb_map =context.mainwindow.canvas.Map() - tb_layers = tb_map.Layers() - - for nr in range(len(tb_layers)-1, -1, -1): - theMap.remove_layer(nr) # check if an mapobj exists, to control the menuitem is available or not From cvs at intevation.de Tue Aug 3 13:56:55 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Tue, 3 Aug 2004 13:56:55 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver mf_handle.py,1.6,1.7 Message-ID: <20040803115655.B09F8139C8@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver In directory doto:/tmp/cvs-serv14461 Modified Files: mf_handle.py Log Message: Added a group option and the metadata button to the Layer dialog. The layer dialog is temporary disabled. (Metadata_CustomDataTable): Added some funktions to show the grid correct. Index: mf_handle.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mf_handle.py,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- mf_handle.py 28 Jul 2004 12:37:28 -0000 1.6 +++ mf_handle.py 3 Aug 2004 11:56:53 -0000 1.7 @@ -25,7 +25,7 @@ import os, sys # mapscript -from mapscript import mapObj +from mapscript import mapObj, layerObj # wxPython support # TODO: explicitly use from .. import @@ -331,6 +331,12 @@ # get the web object self.tb_layer = parent.current_layer() + if hasattr(self.tb_layer,"extension_umn_layerobj"): + self.umn_layer = self.tb_layer.extension_umn_layerobj + else: + newlayerobj = parent.canvas.Map().extension_umn_mapobj.create_new_layer() + self.tb_layer.extension_umn_layerobj = newlayerobj + self.umn_layer = self.tb_layer.extension_umn_layerobj # create name layer_name = wxBoxSizer(wxHORIZONTAL) @@ -339,9 +345,23 @@ layer_name.Add(wxStaticText(self, -1, self.tb_layer.Title()), 0, wxALL|wxALIGN_CENTER_VERTICAL, 4) -##~ # metadata button -##~ metadata_button = wxButton(self, ID_METADATA_CHANGE, _("Edit Metadata")) -##~ EVT_BUTTON(self, ID_METADATA_CHANGE, self.OnChangeMetadata) + # metadata button + metadata_button = wxButton(self, ID_METADATA_CHANGE, _("Edit Metadata")) + EVT_BUTTON(self, ID_METADATA_CHANGE, self.OnChangeMetadata) + + # Group + box_group = wxBoxSizer(wxHORIZONTAL) + if self.umn_layer.get_group(): + umn_layer_group = self.umn_layer.get_group() + else: + umn_layer_group = "" + box_group.Add(wxStaticText(self, -1, _("Group:")), 0, + wxALL|wxALIGN_LEFT, 4) + self.text_group = wxTextCtrl(self, -1, + str(umn_layer_group)) + self.text_group.SetSize((250,self.text_group.GetSize()[1])) + box_group.Add(self.text_group, 0, + wxALL|wxALIGN_CENTER_VERTICAL, 4) # buttons box_buttons = wxBoxSizer(wxHORIZONTAL) @@ -356,8 +376,9 @@ # compose the final dialog top = wxBoxSizer(wxVERTICAL) #top.Add(box_template, 0, wxEXPAND |wxALL, 5) - top.Add(layer_name, 0) -##~ top.Add(metadata_button, 0, wxEXPAND) + top.Add(layer_name, 0, wxEXPAND|wxALL, 5) + top.Add(box_group, 0, wxEXPAND|wxALL, 5) + top.Add(metadata_button, 0, wxEXPAND|wxALL, 5) top.Add(box_buttons, 0, wxALIGN_RIGHT) # final layout settings @@ -368,7 +389,7 @@ # set the umn_label for scalebar so the Label_Dialog can be used self.umn_metadata= self.umn_layer.get_metadata() dialog = Metadata_Dialog(self, -1, "Layer Metadata Settings", - size=wxSize(350, 200), + size=wxSize(450, 200), style = wxDEFAULT_DIALOG_STYLE ) dialog.CenterOnScreen() @@ -390,6 +411,10 @@ self.Show(False) def OnOK(self, event): + if self.text_group.GetValue() == "": + self.umn_layer.set_group(None) + else: + self.umn_layer.set_group(self.text_group.GetValue()) self.result ="OK" self.end_dialog(self.result) @@ -1057,6 +1082,9 @@ class Metadata_CustomDataTable(wxPyGridTableBase): """ + creates a custum Grid. + + copied from the wx demo. """ def __init__(self, data): wxPyGridTableBase.__init__(self) @@ -1065,7 +1093,7 @@ self.dataTypes = [wxGRID_VALUE_STRING, wxGRID_VALUE_STRING ] - + if data: self.data = data else: @@ -1076,10 +1104,7 @@ return len(self.data) + 1 def GetNumberCols(self): - if self.data[0]: - return len(self.data[0]) - else: - return None + return len(self.data[0]) def IsEmptyCell(self, row, col): try: @@ -1102,6 +1127,7 @@ self.data[row][col] = value except IndexError: # add a new row + self.data.append([''] * self.GetNumberCols()) self.SetValue(row, col, value) @@ -1112,10 +1138,36 @@ self.GetView().ProcessTableMessage(msg) + #-------------------------------------------------- + # Some optional methods + + # Called when the grid needs to display labels + def GetColLabelValue(self, col): + return self.colLabels[col] + + # Called to determine the kind of editor/renderer to use by + # default, doesn't necessarily have to be the same type used + # natively by the editor/renderer if they know how to convert. + def GetTypeName(self, row, col): + return self.dataTypes[col] + + # Called to determine how the data can be fetched and stored by the + # editor and renderer. This allows you to enforce some type-safety + # in the grid. + def CanGetValueAs(self, row, col, typeName): + colType = self.dataTypes[col].split(':')[0] + if typeName == colType: + return true + else: + return False + + def CanSetValueAs(self, row, col, typeName): + return self.CanGetValueAs(row, col, typeName) + class Metadata_TableGrid(wxGrid): def __init__(self, parent, data): - wxGrid.__init__(self, parent, -1, size=(600,400)) + wxGrid.__init__(self, parent, -1) self.table = Metadata_CustomDataTable(data) @@ -1125,9 +1177,11 @@ self.SetTable(self.table, true) self.SetRowLabelSize(0) + self.SetColMinimalWidth(0,180) + self.SetColSize(0,180) + self.SetColMinimalWidth(1,250) + self.SetColSize(1,250) self.SetMargins(0,0) - self.AutoSizeColumns(False) - EVT_GRID_CELL_LEFT_DCLICK(self, self.OnLeftDClick) def get_table(self): @@ -1204,17 +1258,14 @@ self.Show(False) def OnOK(self, event): - # added all metadatas to the mapobj - # TODO: only add ne to the old Metadata - #self.tb_map_metadata = MF_Metadata(self.tb_map.extension_umn_mapobj) - for x in range(0, self.grid.get_table().GetNumberRows()-1,1): + # added all metadatas to the mapobj, + # first remove the old ones + self.umn_metadata.remove_allmetadata() + for x in range(self.grid.get_table().GetNumberRows()-2,-1, -1): if self.grid.get_table().GetValue(x,0): self.umn_metadata.add_metadata(str(self.grid.get_table().GetValue(x,0)),\ str(self.grid.get_table().GetValue(x,1))) - else: - delkey = self.umn_metadata.get_metadatakeys()[x] - self.umn_metadata.remove_metadatabykey(delkey) - + self.result ="OK" self.end_dialog(self.result) @@ -1226,7 +1277,7 @@ def metadatasettings(context): win = Metadata_Dialog(context.mainwindow, -1, "Metadata Settings", - size=wxSize(350, 200), + size=wxSize(450, 250), style = wxDEFAULT_DIALOG_STYLE) win.CenterOnScreen() val = win.ShowModal() @@ -1273,12 +1324,6 @@ style = wxDEFAULT_DIALOG_STYLE) win.CenterOnScreen() val = win.ShowModal() - -#create a new mapfile -def create_new_mapfile(context): - theMap = MF_Map(mapObj("")) - context.mainwindow.canvas.Map().extension_umn_mapobj = theMap - # TODO: Maybe can be imported from another class # check if an mapobj exists, to control the menuitem is available or not @@ -1288,6 +1333,8 @@ def _has_umn_mapobj_and_selectedlayer(context): """Return true if a umn_mapobj exists""" + # temporary disabled + return False if context.mainwindow.has_selected_layer(): return hasattr(context.mainwindow.canvas.Map(), "extension_umn_mapobj") else: @@ -1306,17 +1353,10 @@ mapserver_menu = experimental_menu.FindOrInsertMenu("mapserver", _("&MapServer")) -# register the new command -registry.Add(Command("create_new_mapfile", _("Create new mapfile"), \ - create_new_mapfile, \ - helptext = _("Create a new empty mapscript MapObj"))) -# finally add the new entry to the extensions menu -mapserver_menu.InsertItem("create_new_mapfile", after = "import_mapfile" ) - # find the MapServer menu and add a new submenu if found mapserver_edit_menu = mapserver_menu.FindOrInsertMenu("edit_mapfile", _("&Edit mapfile"), \ - after = "create_new_mapfile") + after = "import_layer_from_mapfile") # register the new command (Map Settings Dialog) registry.Add(Command("Map Settings", _("Map"), mapsettings, From cvs at intevation.de Tue Aug 3 13:58:07 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Tue, 3 Aug 2004 13:58:07 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver mf_import.py,1.9,1.10 Message-ID: <20040803115807.24165139C8@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver In directory doto:/tmp/cvs-serv14479 Modified Files: mf_import.py Log Message: Added a Class and a function to show the Annotation layer in thuban. The layer don't do anything. Its only to show the layer. Necessary to save the layer order. Added a funtion to import only layers to thuban and not the other settings like projection or scalebar. Moved the _has_umn_mapobj function and the create_new_mapfile functions from mf_handle.py to mf_import.py. (select_layer2import): Moved the code for showing the number of layer from import_mapfile to this function. Index: mf_import.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mf_import.py,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- mf_import.py 28 Jul 2004 12:44:26 -0000 1.9 +++ mf_import.py 3 Aug 2004 11:58:05 -0000 1.10 @@ -47,7 +47,7 @@ from Thuban.Model.proj import Projection # needed to add the new menu -from Thuban.UI.mainwindow import main_menu +from Thuban.UI.mainwindow import main_menu, wxID_CANCEL from Thuban.Model.classification import ClassGroupSingleton, \ ClassGroupRange, \ @@ -67,6 +67,49 @@ # Mainpart of the Extension # # ################################### +from Thuban.Model.layer import BaseLayer +class AnnotationLayer(BaseLayer): + """ + Class to show AnnontationLayer in Thuban. + This Class is temporary and has only the task + to indicate the layer in the layerlist. + """ + def __init__(self, title, data, visible = False, projection = None): + + BaseLayer.__init__(self, title, + visible = visible, + projection = projection) + self.store = None + self.SetShapeStore(data) + + def SetShapeStore(self, store): + self.store = store + + def ShapeStore(self): + return self.store + + def ShapeType(self): + """Return the type of the shapes in the layer. + """ + return "annotation" + + def BoundingBox(self): + """Return the layer's bounding box in the intrinsic coordinate system. + + If the layer has no shapes, return None. + """ + return self.store.BoundingBox() + + def LatLongBoundingBox(self): + """Return the layer's bounding box in lat/long coordinates. + + Return None, if the layer doesn't contain any shapes. + """ + bbox = self.BoundingBox() + if bbox is not None and self.projection is not None: + bbox = self.projection.InverseBBox(bbox) + return bbox + def set_projection_to_tb(tb_con, mapobj): """ @@ -195,6 +238,45 @@ else: return (None,errorstring) +def add_annotationlayer(context, tb_map, mapobj, maplayer): + """ + add a polygonlayer to thuban + + tb_map = context.mainwindow.canvas.Map() + + mapobj = the Mapobject created from the mapfile + + maplayer = layer obj to add to thuban + """ + filepath = mapobj.get_mappath() + layertitle = maplayer.get_name() + if maplayer.get_data(): + if os.path.isabs(maplayer.get_data()): + filename = maplayer.get_data() +".shp" + else: + filename = os.path.join(filepath, mapobj.get_shapepath(), \ + maplayer.get_data()) + filename = filename + ".shp" + # Normalize the pathname by collapses + # redundant separators and up-level references + filename = os.path.normpath(filename) + else: + context.mainwindow.RunMessageBox(_('Error Loading Layer'), + _("no shp file definied, maybe used a feature obj '%s'.") % layertitle) + # try to open the layer + try: + store = context.application.Session().OpenShapefile(filename) + except IOError: + # the layer couldn't be opened + context.mainwindow.RunMessageBox(_('Open Shapepath'), + _("Can't open the file '%s'.") % filename) + else: + # added an annotation layer as empty layer to thuban + # because thuban don't supports annotation. + layertitle = maplayer.get_name() + annotationlayer = AnnotationLayer(layertitle,store) + tb_map.AddLayer(annotationlayer) + def add_rasterlayer(context, tb_map, mapobj, maplayer): """ @@ -396,21 +478,27 @@ #add the projection if exists set_projection_to_tb(layer, maplayer) - # associate the maplayer object to the layer in thuban. - layer.extension_umn_layerobj = maplayer - - #add the projection if exists - set_projection_to_tb(layer, maplayer) - + # associate a copy of the maplayer object to the layer in thuban. + # layer.extension_umn_layerobj =maplayer #add the layer into thuban tb_map.AddLayer(layer) + def select_layer2import(context, mapobj): """ shows a dialog to select the layers to import. mapobj = the Mapobject created from the mapfile """ + # Show number of Layer found in file + numlayers = len(mapobj.get_layers()) + if numlayers == 0: + context.mainwindow.RunMessageBox(_('Loading Layer'), + _("No Layer found.")) + else: + context.mainwindow.RunMessageBox(_('Loading Layer'), + _("%s Layer loaded from file.") % numlayers) + # Show a dialog to select layers to load into thuban only lst = [] selectedlayer = [] numlayers = len(mapobj.get_layers()) @@ -430,17 +518,11 @@ selectedlayer = dlg.GetValue() return selectedlayer - -def import_mapfile(context): +def import_layer_from_mapfile(context): """ - Import the mapfile from a file given by the user. After that parse - the mapfile with the mapscript parser to create all necessary objects. - - Loaded polygon layer like polygon, line or point into thuban. - Raster layer are supported also. - - context - the thuban context + Import only the layers which are selectes from a mapfile """ + # open a dialog to select the mapfile to import dlg = wxFileDialog(context.mainwindow, _("Select MapFile file"), ".", "", _("UMN MapServer Mapfiles (*.map)|*.map|") + @@ -451,10 +533,10 @@ dlg.Destroy() else: return - + # Parse mapfile mapobj = parse_mapfile(filename) - + # Show number of Layer found in file numlayers = len(mapobj.get_layers()) if numlayers == 0: @@ -469,16 +551,36 @@ selectedlayer = select_layer2import(context,mapobj) else: selectedlayer = [] + +def import_layer_from_mapfile(context): + """ + import layers from a mapfile + """ + # open a dialog to select the mapfile to import from + dlg = wxFileDialog(context.mainwindow, + _("Select MapFile file"), ".", "", + _("UMN MapServer Mapfiles (*.map)|*.map|") + + _("All Files (*.*)|*.*"), + wxOPEN|wxOVERWRITE_PROMPT) + if dlg.ShowModal() == wxID_OK: + filename = dlg.GetPath() + dlg.Destroy() + else: + return + + # Parse mapfile + mapobj = parse_mapfile(filename) + oldmapobj = context.mainwindow.canvas.Map().extension_umn_mapobj + + # shows a dialog to select layers to import + selectedlayer = select_layer2import(context,mapobj) + # counter to show the numer of layer loaded into Tuban layer_count = 0 # import settings to thuban only if one layer is selected if len(selectedlayer) != 0: # thuban map context tb_map = context.mainwindow.canvas.Map() - # set the titel and projection - tb_map.SetTitle(mapobj.get_name()) - set_projection_to_tb(tb_map,mapobj) - # Check for each Layer if it is possible to show in Thuban for layernr in selectedlayer: maplayer = mapobj.get_layers()[layernr] @@ -495,27 +597,103 @@ (maplayer.get_type() == 'point')): add_polygonlayer(context, tb_map, mapobj, maplayer) layer_count += 1 - - # remove alle layer from the mapobj, because the layer will be - # created new in export, and the unused layers are not needed - # TODO: Save the layers which are not used somewhere, to edit - # them later and export it. - for nr in range(len(mapobj.get_layers())-1, -1, -1): - mapobj.remove_layer(nr) - - # add the map object to thuban, to use it later - tb_map.extension_umn_mapobj = mapobj + + if (maplayer.get_type() == 'annotation'): + add_annotationlayer(context, tb_map, mapobj, maplayer) # show a message how many layer were loaded into thuban # if the number of layers is not null if layer_count != 0: - # get the extent from the map and set it in thuban - extentrect = mapobj.get_extent().get_rect() - # fit the new map extent to the window - context.mainwindow.canvas.FitRectToWindow(extentrect) context.mainwindow.RunMessageBox(_('Layer loaded'), _("%s Layer loaded into Thuban") % layer_count) +def import_mapfile(context): + """ + Import the mapfile from a file given by the user. After that parse + the mapfile with the mapscript parser to create all necessary objects. + + Loaded polygon layer like polygon, line or point into thuban. + Raster layer are supported also. + + context - the thuban context + """ + # create a new session befor a mapfile is imported + if context.mainwindow.save_modified_session() != wxID_CANCEL: + context.application.SetSession(mainwindow.create_empty_session()) + + # context.mainwindow.NewSession() + # open a dialog to select the mapfile to import + dlg = wxFileDialog(context.mainwindow, + _("Select MapFile file"), ".", "", + _("UMN MapServer Mapfiles (*.map)|*.map|") + + _("All Files (*.*)|*.*"), + wxOPEN|wxOVERWRITE_PROMPT) + if dlg.ShowModal() == wxID_OK: + filename = dlg.GetPath() + dlg.Destroy() + else: + return + + # Parse mapfile + mapobj = parse_mapfile(filename) + + # shows a dialog to select layers to import + selectedlayer = select_layer2import(context,mapobj) + + # counter to show the numer of layer loaded into Tuban + layer_count = 0 + # import settings to thuban only if one layer is selected + if len(selectedlayer) != 0: + # thuban map context + tb_map = context.mainwindow.canvas.Map() + # set the titel and projection + tb_map.SetTitle(mapobj.get_name()) + set_projection_to_tb(tb_map,mapobj) + + selectedlayer = list(selectedlayer) + + # Check for each Layer if it is possible to show in Thuban + for layernr in selectedlayer: + + maplayer = mapobj.get_layers()[layernr] + + #check if rasterlayer type + if maplayer.get_type() == 'raster': + add_rasterlayer(context, tb_map, mapobj, maplayer) + layer_count += 1 + + #check if polygonlayer type + if ((maplayer.get_type() == 'polygon') or + (maplayer.get_type() == 'line') or + (maplayer.get_type() == 'circle') or + (maplayer.get_type() == 'point')): + add_polygonlayer(context, tb_map, mapobj, maplayer) + layer_count += 1 + + if (maplayer.get_type() == 'annotation'): + add_annotationlayer(context, tb_map, mapobj, maplayer) + layer_count += 1 + + # remove alle layer from the mapobj, because the layer will be + # created new in export, and the unused layers are not needed + # TODO: Save the layers which are not used somewhere, to edit + # them later and export it. + ##~ for nr in range(len(mapobj.get_layers())-1, -1, -1): + ##~ mapobj.remove_layer(nr) + + # add the map object to thuban, to use it later + tb_map.extension_umn_mapobj = mapobj + + # show a message how many layer were loaded into thuban + # if the number of layers is not null + if layer_count != 0: + # get the extent from the map and set it in thuban + extentrect = mapobj.get_extent().get_rect() + # fit the new map extent to the window + context.mainwindow.canvas.FitRectToWindow(extentrect) + context.mainwindow.RunMessageBox(_('Layer loaded'), + _("%s Layer loaded into Thuban") % layer_count) + def parse_mapfile(filename): """ Parse the mapfile. @@ -531,6 +709,15 @@ return MF_Map(theMap) +# check if an mapobj exists, to control the menuitem is available or not +def _has_umn_mapobj(context): + """Return true if a umn_mapobj exists""" + return hasattr(context.mainwindow.canvas.Map(), "extension_umn_mapobj") + +#create a new mapfile +def create_new_mapfile(context): + theMap = MF_Map(mapObj("")) + context.mainwindow.canvas.Map().extension_umn_mapobj = theMap # ################################### # @@ -538,14 +725,31 @@ # # ################################### -# register the new command -registry.Add(Command("import_mapfile", _("Import mapfile"), import_mapfile, - helptext = _("Import a mapfile"))) - # find the extensions menu (create it anew if not found) experimental_menu = main_menu.FindOrInsertMenu("experimental", _("Experimenta&l")) # find the extension menu and add a new submenu if found mapserver_menu = experimental_menu.FindOrInsertMenu("mapserver", _("&MapServer")) +# register the new command +registry.Add(Command("create_new_mapfile", _("Create new mapfile"), \ + create_new_mapfile, \ + helptext = _("Create a new empty mapscript MapObj"))) # finally add the new entry to the extensions menu -mapserver_menu.InsertItem("import_mapfile") +mapserver_menu.InsertItem("create_new_mapfile") + +# register the new command +registry.Add(Command("import_mapfile", _("Import mapfile"), import_mapfile, + helptext = _("Import a mapfile"))) +# finally add the new entry to the extensions menu +mapserver_menu.InsertItem("import_mapfile", after = "create_new_mapfile" ) + +# register the new command +registry.Add(Command("import_layer_from_mapfile", _("Import layer from mapfile"), + import_layer_from_mapfile, + helptext = _("Import a layer from a mapfile"), + sensitive = _has_umn_mapobj)) +# finally add the new entry to the extensions menu +mapserver_menu.InsertItem("import_layer_from_mapfile", + after = "import_mapfile" ) + + From cvs at intevation.de Tue Aug 3 13:58:57 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Tue, 3 Aug 2004 13:58:57 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver/sample iceland.map, 1.4, 1.5 Message-ID: <20040803115857.13994139C8@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver/sample In directory doto:/tmp/cvs-serv14496 Modified Files: iceland.map Log Message: Added the group parameter to the roads and cultural layers. Also added a new Annotation Layer for the cultural points. Index: iceland.map =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/sample/iceland.map,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- iceland.map 28 Jul 2004 12:41:06 -0000 1.4 +++ iceland.map 3 Aug 2004 11:58:55 -0000 1.5 @@ -103,6 +103,7 @@ LAYER NAME "roads" DATA roads-line + GROUP infrastructure TYPE LINE STATUS ON CLASS @@ -149,6 +150,7 @@ LAYER NAME "cultural" DATA cultural_landmark-point + GROUP infrastructure TYPE POINT STATUS ON CLASSITEM 'CLPOINT_' @@ -187,5 +189,32 @@ END END +LAYER + NAME "cultural_type" + TYPE ANNOTATION + DATA cultural_landmark-point + STATUS DEFAULT + + LABELITEM "CLPTLABEL" + CLASSITEM "CLPTLABEL" + CLASS + EXPRESSION /./ + # COLOR 232 232 232 + LABEL + COLOR 0 0 0 + # SHADOWCOLOR 218 218 218 + # SHADOWSIZE 2 2 + TYPE BITMAP + SIZE Small + POSITION AUTO + BUFFER 0 + END + END + + PROJECTION + proj=latlong + ellps=clrk66 + END +END END From cvs at intevation.de Tue Aug 3 13:59:32 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Tue, 3 Aug 2004 13:59:32 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver/sample iceland.html, 1.2, 1.3 Message-ID: <20040803115932.BA930139C8@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver/sample In directory doto:/tmp/cvs-serv14509 Modified Files: iceland.html Log Message: Added the select option for the annotation layer. Index: iceland.html =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/sample/iceland.html,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- iceland.html 28 Jul 2004 12:38:15 -0000 1.2 +++ iceland.html 3 Aug 2004 11:59:30 -0000 1.3 @@ -37,6 +37,7 @@ + From cvs at intevation.de Tue Aug 3 14:00:49 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Tue, 3 Aug 2004 14:00:49 +0200 (CEST) Subject: jschuengel: thuban ChangeLog,1.678,1.679 Message-ID: <20040803120049.6E97C139C8@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv14570 Modified Files: ChangeLog Log Message: updated ChangeLog Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.678 retrieving revision 1.679 diff -u -d -r1.678 -r1.679 --- ChangeLog 1 Aug 2004 21:32:07 -0000 1.678 +++ ChangeLog 3 Aug 2004 12:00:47 -0000 1.679 @@ -1,3 +1,47 @@ +2004-08-03 Jan Schüngel + + * Extensions/umn_mapserver/mapfile.py(MF_Metadata): Added a function + to remove all metadata. + (MF_Layer): Added two functions to handle the group setting. + Removed the extra numlayers variable, used the mapscript parameter + instead. + (MF_Map): Added a function to get the numlayers parameter. + Added a funtion to remove all layers. + (MF_Map.add_thubanlayer): Replaced the exception handling by a check + if the object is an instance. Also added the annotation layer here to + export, but only the layer is created in the mapfile. + + * Extensions/umn_mapserver/mf_export.py: Removed the check if a + mapobj exist, because its not needed anymore. The export function is + only available if a mapobj exist. + Added an extra function to remove all layers. + + * Extensions/umn_mapserver/mf_handle.py: Added a group option and the + metadata button to the Layer dialog. + The layer dialog is temporary disabled. + (Metadata_CustomDataTable): Added some funktions to show the grid + correct. + + * Extensions/umn_mapserver/mf_import.py: Added a Class and a function + to show the Annotation layer in thuban. The layer don't do anything. + Its only to show the layer. Necessary to save the layer order. + Added a funtion to import only layers to thuban and not the other + settings like projection or scalebar. + Moved the _has_umn_mapobj function and the create_new_mapfile + functions from mf_handle.py to mf_import.py. + (select_layer2import): Moved the code for showing the number of layer + from import_mapfile to this function. + + * Extensions/umn_mapserver/sample/iceland.map: Added the group + parameter to the roads and cultural layers. Also added a new + Annotation Layer for the cultural points. + + * Extensions/umn_mapserver/sample/iceland.html: Added the select + option for the annotation layer. + + * Extensions/umn_mapserver/sample/index.html: Added the start + parameter for the annotation layer. + 2004-08-01 Jan-Oliver Wagner * Doc/manual/thuban-manual-de.xml (Chapter Session Management): From jan at intevation.de Wed Aug 4 09:25:25 2004 From: jan at intevation.de (Jan-Oliver Wagner) Date: Wed, 4 Aug 2004 09:25:25 +0200 Subject: [Thuban-devel] jschuengel: thuban/Extensions/umn_mapserver mapfile.py, 1.9, 1.10 In-Reply-To: <20040803114602.80D21139C8@lists.intevation.de> References: <20040803114602.80D21139C8@lists.intevation.de> Message-ID: <20040804072525.GA21691@intevation.de> Jan, On Tue, Aug 03, 2004 at 01:46:02PM +0200, cvs at intevation.de wrote: > (MF_Metadata): Added a function to remove all metadata. can you please follow the standard way to write the ChangeLog, ie. if you add a new class, then name it. The following would have been correct: (MF_Metadata.remove_allmetadata): New. This function removes all metadata. -- Jan-Oliver Wagner http://intevation.de/~jan/ Intevation GmbH http://intevation.de/ FreeGIS http://freegis.org/ From jan at intevation.de Wed Aug 4 09:27:47 2004 From: jan at intevation.de (Jan-Oliver Wagner) Date: Wed, 4 Aug 2004 09:27:47 +0200 Subject: [Thuban-devel] jschuengel: thuban/Extensions/umn_mapserver mf_export.py, 1.6, 1.7 In-Reply-To: <20040803115611.28FC3139C8@lists.intevation.de> References: <20040803115611.28FC3139C8@lists.intevation.de> Message-ID: <20040804072747.GB21691@intevation.de> Jan, On Tue, Aug 03, 2004 at 01:56:11PM +0200, cvs at intevation.de wrote: > Removed the check if a mapobj exist, because its not needed anymore. The export function is only available if a mapobj exist. Please name the functions where you applied changes. The following would have been correct: (export_mapfile): Removed the check if a mapobj exist, because its not needed anymore. The export function is only available if a mapobj exist. -- Jan-Oliver Wagner http://intevation.de/~jan/ Intevation GmbH http://intevation.de/ FreeGIS http://freegis.org/ From bh at intevation.de Wed Aug 4 19:35:12 2004 From: bh at intevation.de (Bernhard Herzog) Date: Wed, 04 Aug 2004 19:35:12 +0200 Subject: [Thuban-devel] Re: RfD: Support for layer specific resources References: <20040609153905.GJ1019@finlandia.infodrom.north.de> <20040615190159.GT1019@finlandia.infodrom.north.de> <20040713141846.GA9814@finlandia.infodrom.north.de> <20040713142901.GA13410@finlandia.infodrom.north.de> <20040713150122.GR4134@finlandia.infodrom.north.de> <20040718034419.GC4134@finlandia.infodrom.north.de> <20040727104502.GK1334@finlandia.infodrom.north.de> Message-ID: Martin Schulze writes: > Bernhard Herzog wrote: >> Yes. Only nit: Please don't use "object" as identifier in new code. >> It's a Python builtin. > > Oh, sorry. I wonder why Python didn't complain, though. Builtins aren't keywords. The builtins are simply the last scope where python looks when trying to resolve a name. Hence it's no error to use the name of a builtin as an identifier. It can be a bit confusing though, and should generally be avoided when writing code. > In order to use the new ClassMapper I'd assume that we'll need > something like the following: > > > from Thuban.Lib.classmapper import ClassMapper > > _properties_dialogs = ClassMapper() > > def add_properties_dialog(layer_class, dialog_class): > _properties_dialogs.add(layer_class, dialog_class) > > def get_properties_dialog_class(layer): > return _properties_dialogs.get(layer) I think in practice only the mainwindow code will look up the dialogs, so I'd say, the mapper should be in Thuban/UI/mainwindow.py. I'd also omit the extra functions a simple from Thuban.Lib.classmapper import ClassMapper layer_properties_dialogs = ClassMapper() should suffice. > And for Thuban.UI.classifier: > > add_properties_dialog(Layer, Classifier) > add_properties_dialog(RasterLayer, Classifier) > > > as well as for Thuban.UI.mainwindow: > > > def OpenLayerProperties(self, layer, group = None): > dialog_class = get_properties_dialog_class(layer) > > if dialog_class is not None: > name = "layer_properties" + str(id(layer)) > self.OpenOrRaiseDialog(name, dialog_class, layer, group = group) > > Right? Yes, after adapting to my suggestion above. Bernhard -- Intevation GmbH http://intevation.de/ Skencil http://sketch.sourceforge.net/ Thuban http://thuban.intevation.org/ From bh at intevation.de Wed Aug 4 20:25:24 2004 From: bh at intevation.de (Bernhard Herzog) Date: Wed, 04 Aug 2004 20:25:24 +0200 Subject: Patch for adding version info for Extensions References: <20040729124048.GA27358@intevation.de> Message-ID: Jan-Oliver Wagner writes: > I decided to have a explicit registration for the extensions. > > Let me know what you think. > > Attached is a patch (based on current CVS HEAD) and a new > file Thuban/UI/extensionregistry.py [...] > class ThubanExtensionDesc: I'd omit the Thuban prefix from that name. If ExtensionDesc is too ambigious in the code that imports this, that importing code can always use import ... as... to choose a different name. This applies to ThubanExtensionRegistry, too. > """ > A description of a Thuban Extension. > """ > > def __init__(self, name, version, authors, copyright, desc, > min_thuban_versions): > """ > Initialize a new Thuban Extension information. > > name -- The name of the Thuban Extension. > Example: 'gns2shp' > > version -- The version number of the Thuban Extension. > Example: '1.0.0' > > authors -- List of authors. > Example: [ 'Jan-Oliver Wagner' ] > > copyright -- Copyright notice. > Example: '2003, 2004 Intevation GmbH' > > desc -- Short description of the Thuban Extension. > Example: _(''' > Converts GNS (Geographical Name Service of NIMA) > to Shapefile format and displays the data. > ''') > > min_thuban_versions -- Minimum Thuban versions required to > run the extension. This is a dictionary > where the major release numbers ('X.Y') > are the keys and the minor release > number is the contents (e.g. 'Z'). > Example: { '1.0' : '0' } I asked Jan yesterday why he chose this representation. His goal was to make it possible for an extension to state that it can use e.g. 1.0.1 and later from the 1.0 branch and 1.1.2 from the 1.1 branch. That is, neither 1.0.0 nor 1.1.1 would work, but 1.0.3 and 1.1.5 would. I have two issues with this: 1. Should we support it at all? We only need this if we backport features from newer Thuban versions to an older one. Currently this would mean that we backport from cvs HEAD to the 1.0 branch. 2. Is this the right representation for the interface of ThubanExtensionDesc? I think it's too complicated. I suggest the following, using the same versions as in my example above: [(1, 0, 1), (1, 1, 2)] That, is a simple list of versions, with each version a tuple of numbers. Representing a single version as a tuple of numbers has the advantage that we don't have to parse the version numbers anymore and comparisons are done numerically. > class ThubanExtensionRegistry: > > """ > A ThubanExtensionRegistry keeps information on the registered > Thuban Extensions. > > The registry will raise a exception either when the version > required for the Extensions exceeds the version of the currently > running Thuban or if the name of a registered extension already > is used for registering another extension. > """ > > def __init__(self): > self.registry = [] > > def Add(self, ext): > self.registry.append(ext) > > def Get(self): > return self.registry I'd lose the Get method and implement some others instead which match the usage of the registry better. See below. Another thing: I think the Add method should be spelled add, that is all lowercase. The main reason is that I think we should, in the long term, adopt the more common naming styles used in python code. For Thuban this basically means not to start method names with upper case letters. For Thuban this would be a substantial change and even though it would be easy to retain the old method names for a while for backwards compatibility it's not something that should be done soon. OTOH, for small new classes such as this or the ClassMapper it wouldn't be a problem to adopt that naming scheme and, in fact, ClassMapper already uses it. > --- Extensions/gns2shp/gns2shp.py 18 May 2004 21:09:50 -0000 1.3 > +++ Extensions/gns2shp/gns2shp.py 29 Jul 2004 12:24:53 -0000 > @@ -32,8 +32,22 @@ if __name__ != '__main__': > from Thuban import _ > from Thuban.Model.layer import Layer > > +from Thuban.UI.extensionregistry import ThubanExtensionDesc, ext_registry > + > import shapelib > import dbflib > + > + > +ext_registry.Add(ThubanExtensionDesc( > + name = 'gns2shp', > + version = '1.0.0', > + authors= [ 'Jan-Oliver Wagner' ], > + copyright = '2003, 2004 Intevation GmbH', > + desc = _("Converts GNS (Geographical Name Service\n" \ > + "of NIMA) to Shapefile format and\n" \ > + "displays the data."), > + min_thuban_versions = { '1.0' : '0' })) That min_thuban_versions is wrong. 1.0.0 doesn't have the extension registry :) The same applies to the other places where you call ThubanExtensionDesc. > --- Thuban/UI/about.py 26 Mar 2004 18:15:35 -0000 1.12 > +++ Thuban/UI/about.py 29 Jul 2004 12:27:14 -0000 > @@ -70,6 +72,14 @@ class About(wxDialog): > text+= '\t%s %s\n' % (name, version) > text += '\n' > > + text += _('Extensions:\n') > + if len(ext_registry.Get()) == 0: I think we should implement either __len__ or __nonzero__ in ThubanExtensionRegistry so that you could write if ext_registry: instead. > + text += _('\tNone registered.\n') > + else: > + for ext in ext_registry.Get(): And this would be easier written as for ext in ext_registry: by implementing a suitable iter method as e.g. a generator. Of course, you could also do: for ext in ext_registry: text += ... else: test += "None registered" Then we wouldn't even need __nonzero__ or __len__ yet. Although __len__ would probably be useful anyway, although I'm not yet sure that the number of registered extension is really the same as the length of the registry, that is whether it might not be better to add a length() method for that. Bernhard -- Intevation GmbH http://intevation.de/ Skencil http://sketch.sourceforge.net/ Thuban http://thuban.intevation.org/ From bh at intevation.de Thu Aug 5 11:32:17 2004 From: bh at intevation.de (Bernhard Herzog) Date: Thu, 05 Aug 2004 11:32:17 +0200 Subject: Patch for adding version info for Extensions In-Reply-To: (Bernhard Herzog's message of "Wed, 04 Aug 2004 20:25:24 +0200") References: <20040729124048.GA27358@intevation.de> Message-ID: Bernhard Herzog writes: > Of course, you could also do: > > for ext in ext_registry: > text += ... > else: > test += "None registered" Forget that. It doesn't work. Bernhard -- Intevation GmbH http://intevation.de/ Skencil http://sketch.sourceforge.net/ Thuban http://thuban.intevation.org/ From cvs at intevation.de Fri Aug 6 20:12:41 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Fri, 6 Aug 2004 20:12:41 +0200 (CEST) Subject: bh: thuban/Thuban/UI baserenderer.py,1.9,1.9.2.1 Message-ID: <20040806181241.AE06813954@lists.intevation.de> Author: bh Update of /thubanrepository/thuban/Thuban/UI In directory doto:/tmp/cvs-serv7661/Thuban/UI Modified Files: Tag: thuban-1-0-branch baserenderer.py Log Message: Backport some fixes from HEAD: Fix some typos in comments and doc-strings (BaseRenderer.render_map_incrementally): Fix a logic bug in the optimization that tries not to draw layers under a raster layer. The bug was harmless. All it effectively did was to produce strange messages about not being able to draw Layer instances for all vector layers below a raster layer. Those layers would be invisible anyway because the raster layer currently always covers the entire window Index: baserenderer.py =================================================================== RCS file: /thubanrepository/thuban/Thuban/UI/baserenderer.py,v retrieving revision 1.9 retrieving revision 1.9.2.1 diff -u -d -r1.9 -r1.9.2.1 --- baserenderer.py 11 Nov 2003 18:16:20 -0000 1.9 +++ baserenderer.py 6 Aug 2004 18:12:39 -0000 1.9.2.1 @@ -1,4 +1,4 @@ -# Copyright (c) 2001, 2002, 2003 by Intevation GmbH +# Copyright (c) 2001, 2002, 2003, 2004 by Intevation GmbH # Authors: # Bernhard Herzog # Jonathan Coles @@ -42,7 +42,7 @@ # (layer_class, draw_function) pairs. If the renderer has to draw a # non-builtin layer type, i.e. a layer that is not a subclass of Layer # or RasterLayer, it iterates through that list, tests whether the layer -# to be drawin is an instance of layer_class and if so calls +# to be drawn is an instance of layer_class and if so calls # draw_function with the renderer and the layer as arguments. Since # drawing is done incrementally, the draw_function should return an # iterable. The easiest way is to simply implement the draw_function as @@ -64,7 +64,7 @@ function should return an iterable. The easiest way is to simply implement the draw_function as a generator and to yield True in suitable places, or to return the empty tuple if it's not possible - to do the rendering in incrementally. + to do the rendering incrementally. """ _renderer_extensions.append((layer_class, function)) @@ -198,9 +198,10 @@ # if honor_visibility is true, only draw visible layers, # otherwise draw all layers if not self.honor_visibility or layer.Visible(): - if isinstance(layer, Layer) and seenRaster: - for i in self.draw_shape_layer_incrementally(layer): - yield True + if isinstance(layer, Layer): + if seenRaster: + for i in self.draw_shape_layer_incrementally(layer): + yield True elif isinstance(layer, RasterLayer) \ and Thuban.Model.resource.has_gdal_support(): self.draw_raster_layer(layer) From cvs at intevation.de Fri Aug 6 20:12:53 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Fri, 6 Aug 2004 20:12:53 +0200 (CEST) Subject: bh: thuban ChangeLog,1.624.2.7,1.624.2.8 Message-ID: <20040806181253.A0A1613954@lists.intevation.de> Author: bh Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv7679 Modified Files: Tag: thuban-1-0-branch ChangeLog Log Message: update ChangeLog Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.624.2.7 retrieving revision 1.624.2.8 diff -u -d -r1.624.2.7 -r1.624.2.8 --- ChangeLog 3 Jun 2004 15:29:16 -0000 1.624.2.7 +++ ChangeLog 6 Aug 2004 18:12:51 -0000 1.624.2.8 @@ -1,3 +1,17 @@ +2004-08-06 Bernhard Herzog + + Backport some fixes from HEAD + + * Thuban/UI/baserenderer.py: Fix some typos in comments and + doc-strings + (BaseRenderer.render_map_incrementally): Fix a logic bug in the + optimization that tries not to draw layers under a raster layer. + The bug was harmless. All it effectively did was to produce + strange messages about not being able to draw Layer instances for + all vector layers below a raster layer. Those layers would be + invisible anyway because the raster layer currently always covers + the entire window + 2004-06-03 Bernhard Herzog Backport some fixes from HEAD: From cvs at intevation.de Mon Aug 9 13:38:50 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Mon, 9 Aug 2004 13:38:50 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver mapfile.py,1.10,1.11 Message-ID: <20040809113850.1AB1513ABA@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver In directory doto:/tmp/cvs-serv13287/Extensions/umn_mapserver Modified Files: mapfile.py Log Message: Move the import AnnotationLayer to the function where it is needed, because it don't works if it stands at the beginning. (MF_Layer.__init__): Removed the extra numclassed variable. Now numclasses from the mapscript will be used. (MF_Layer.get_index): New. Return the index of the layer in mapfile. (MF_Layer.set_classes): New. A Classlist will be set to the layer. (MF_Layer.set_metadata): New. A Metadata mapscript object will set. (MF_Layer.remove_allclasses): New. All class of the layer will remove. (MF_Map.create_new_layer): New. A new Layer is created and associated with the mapscript object. (MF_Map.set_layerorder): New. The Layer order like in thuban is set in the mapscript. (MF_Map.add_thubanlayer): Now a new layerobj is created if no one is linked to the layer in thuban, else the layerobject linked to the thubanlayer will be used. AnnotationLayer will now store the filename of the shapefile. (MF_Map.remove_layer): If a layer is removed the associated object must be set new. Index: mapfile.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mapfile.py,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- mapfile.py 3 Aug 2004 11:46:00 -0000 1.10 +++ mapfile.py 9 Aug 2004 11:38:47 -0000 1.11 @@ -42,11 +42,10 @@ from Thuban.Model.classification import ClassGroupDefault, \ ClassGroupSingleton, ClassGroupRange -from Thuban.Model.layer import RasterLayer -from Extensions.umn_mapserver.mf_import import AnnotationLayer - from mapscript import layerObj, classObj, colorObj, styleObj, rectObj, symbolObj, \ pointObj, lineObj + +from Thuban.Model.layer import RasterLayer # ################################### # @@ -519,15 +518,13 @@ the class objects in the layer object will be stored in an array. The metadata are created as a new object. """ - self._mf_layer = mf_layer # Create Classes # there could be more then 1 - self._numclasses = mf_layer.numclasses i = -1 self._classes = [] - while i < self._numclasses-1: + while i < self._mf_layer.numclasses-1: i += 1 self._classes.append(MF_Class(self._mf_layer.getClass(i))) @@ -536,17 +533,26 @@ # Create Metadata self._metadata = MF_Metadata(self._mf_layer) + def get_index(self): + return self._mf_layer.index + def get_name(self): return self._mf_layer.name def get_data(self): return self._mf_layer.data - + def get_classes(self): return self._classes + def set_classes(self, new_classes): + self._classes = new_classes + def get_metadata(self): return self._metadata + + def set_metadata(self, new_metadata): + self._metadata = new_metadata def get_type(self): return shp_type[self._mf_layer.type] @@ -564,7 +570,6 @@ return False else: return True - #return self._mf_layer.status def get_group(self): return self._mf_layer.group @@ -572,7 +577,6 @@ def set_group(self, new_group): self._mf_layer.group = new_group - def set_name(self, newname): self._mf_layer.name = newname @@ -581,7 +585,6 @@ self._mf_layer.data = newdata else: self._mf_layer.data = newdata[:-4] - def set_status(self, newstatus): # status can set to true or false from thuban. @@ -617,8 +620,9 @@ def add_thubanclass(self, tb_class, type=""): """ Add a thuban class object - """ + """ new_class = MF_Class(classObj(self._mf_layer)) + self._classes.append(new_class) # set the class name to the Label form thuban if given, # else set it to the value if tb_class.GetLabel() != "": @@ -698,8 +702,11 @@ else: new_class.set_expressionstring(str(tb_class.GetValue())) new_class.set_status(tb_class.IsVisible()) - self._classes.append(new_class) + def remove_allclasses(self): + for i in range(0,len(self.get_classes()), 1): + self._mf_layer.removeClass(i) + self.set_classes([]) class MF_Scalebar: """ @@ -873,6 +880,18 @@ # Create Metadata self._metadata = MF_Metadata(self._mf_map) + def create_new_layer(self): + """ + the new layer must create inside the mapobj, because mapscript + need the mapscript object as parameter for layerObj + """ + new_layer = MF_Layer(layerObj(self._mf_map)) + self._layers.append(new_layer) + # the new created layer must remove from the mapobject + # because all layer will create new in export. + #self._mf_map.removeLayer(self._mf_map.numlayers-1) + return new_layer + def get_mappath(self): return self._mf_map.mappath @@ -945,6 +964,9 @@ # shows the order of layer as list return self._mf_map.getLayerOrder() + def set_layerorder(self, new_order): + self._mf_map.setLayerOrder(new_order) + def get_size(self): #returns the size return (self._mf_map.width, self._mf_map.height) @@ -977,7 +999,6 @@ newextent[2],newextent[3])) self._mf_map.setExtent(newextent[0],newextent[1], \ newextent[2],newextent[3]) - def set_size(self, newwidth, newheight): self._mf_map.width = newwidth @@ -1006,9 +1027,24 @@ """ Add a thuban layer """ - new_layer = MF_Layer(layerObj(self._mf_map)) + # this import statement placed here, because if it is placed at the + # beginning of this file, it produced the following error: + # NameError: global name 'AnnotationLayer' is not defined + # don't know why this error is produced and why it works + # if it is placed here instead of the beginning. + from Extensions.umn_mapserver.mf_import import AnnotationLayer + if hasattr(tb_layer,"extension_umn_layerobj"): + #print tb_layer.extension_umn_layerobj + #new_layer = MF_Layer(layerObj(self._mf_map)) + new_layer = tb_layer.extension_umn_layerobj + else: + new_layer = MF_Layer(layerObj(self._mf_map)) + self._layers.append(new_layer) + tb_layer.extension_umn_layerobj = new_layer + new_layer.remove_allclasses() + # init a list to set the layerorder + new_layer.get_index() new_layer.set_name(tb_layer.Title()) - # TODO: implement relative pathnames # yet only absolute pathnames in the LayerObj are set if isinstance(tb_layer, RasterLayer ): @@ -1018,11 +1054,11 @@ elif isinstance(tb_layer, AnnotationLayer): new_layer.set_type("annotation") new_layer.set_status(tb_layer.Visible()) + new_layer.set_data(tb_layer.ShapeStore().FileName()) else: new_layer.set_data(tb_layer.ShapeStore().FileName()) new_layer.set_status(tb_layer.Visible()) new_layer.set_type(tb_layer.ShapeType()) - if tb_layer.GetClassificationColumn(): new_layer.set_classitem(tb_layer.GetClassificationColumn()) if tb_layer.GetProjection(): @@ -1045,26 +1081,25 @@ new_layer.add_thubanclass( \ tb_layer.GetClassification().GetDefaultGroup(), \ type="default") - # set the projection to the layer. - # if the layer has its own definition use is, + # if the layer has its own definition use it, # else use the main projection if tb_layer.GetProjection(): new_layer.set_projection(tb_layer.GetProjection()) else: new_layer.set_projection(self._projection.get_projection()) - self._layers.append(new_layer) - - def remove_layer(self, nr): - #remove the last layer from the layer list and not the one which - # is removed in mapscript. This must be, becaus mapscript - # set the object links anew. Don't understand really :) - self._layers.pop() - self._mf_map.removeLayer(nr) - def remove_all_layers(self): - for i in range (self._mf_map.numlayers,0,-1): - self.remove_layer(i-1) + def remove_layer(self, delnr): + if delnr < len(self._layers): + # if a layer is removed, the links for the mapscript layer and + # the metadata must set new + # TODO: All other object in a layer obj must set a new, e.g proj. + for ll in range(len(self._layers)-1, delnr, -1): + self._layers[ll]._mf_layer = self._layers[ll-1]._mf_layer + self._layers[ll].set_metadata(self._layers[ll-1].get_metadata()) + + self._mf_map.removeLayer(delnr) + self._layers.pop(delnr) def save_map(self, filepath): # save the Map From cvs at intevation.de Mon Aug 9 13:39:39 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Mon, 9 Aug 2004 13:39:39 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver mf_export.py,1.7,1.8 Message-ID: <20040809113939.5766A13ABA@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver In directory doto:/tmp/cvs-serv13333/Extensions/umn_mapserver Modified Files: mf_export.py Log Message: (tb_layer_to_map): Add all layers which are exists in thuban to the mapobj. All removed Layers will be removed from the mapobj. Added comments to all functions. (thuban_to_map): No layer will be removed here. Index: mf_export.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mf_export.py,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- mf_export.py 3 Aug 2004 11:56:08 -0000 1.7 +++ mf_export.py 9 Aug 2004 11:39:37 -0000 1.8 @@ -52,6 +52,9 @@ # ################################### def tbproj_to_map(tb_map, map): + """ + set the projection from thuban to the mapscript + """ # TODO: epsg code support # epsg will convert to parameters at the moment tb_proj = tb_map.GetProjection() @@ -59,11 +62,34 @@ map.set_projection(tb_proj) def tblayer_to_map(tb_map, map): + """ + added all layers which are displayed in thuban to the mapscript + if the are new, else use the associated mapobjects. + All other layers will be removed + """ tb_layers = tb_map.Layers() + oldindex = map.get_layerorder() + indexlist = [] for layer in tb_layers: map.add_thubanlayer(layer) + layind = layer.extension_umn_layerobj.get_index() + indexlist.append(layind) + bigint = 0 + for rmnr in oldindex: + if rmnr > bigint: + bigint = rmnr + removelist = [] + for rnr in range(0, bigint+1, 1): + if rnr not in indexlist: + removelist.append(rnr) + for i in removelist: + map.remove_layer(i) + map.set_layerorder(tuple(indexlist)) def thuban_to_map(tb_context, map): + """ + add all context from thuban to the mapscript + """ # get the thuban map tb_map = tb_context.mainwindow.canvas.Map() # set the title @@ -78,6 +104,9 @@ tblayer_to_map(tb_map, map) def add_circle_symbol(map): + """ + Added a circle object like the one shown in thuban + """ if map.get_symbolset().get_symbol(1): return else: @@ -88,6 +117,10 @@ map.get_symbolset().add_symbol(new_symbol) def write_creatorcomment(path,file): + """ + Added a short comment to the created map file to show + that the file is generated automatic + """ thuban_umn_comment = "# \n" + \ "# Map file generated by Thuban (umn_mapserver Extension) \n" + \ "# \n \n" @@ -104,11 +137,12 @@ def export_mapfile(context): - + """ + Exports an existing mapobj and set all stuff from thuban to + the mapobj + """ theMap = context.mainwindow.canvas.Map().extension_umn_mapobj - theMap.remove_all_layers() - dlg = wxFileDialog(context.mainwindow, "Save file as...", ".", "", "UMN MapServer Mapfiles (*.map)|*.map|" \ "All files (*.*)|*.*", @@ -141,7 +175,6 @@ def _has_umn_mapobj(context): """Return true if a umn_mapobj exists""" return hasattr(context.mainwindow.canvas.Map(), "extension_umn_mapobj") - # ################################### # From cvs at intevation.de Mon Aug 9 13:40:12 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Mon, 9 Aug 2004 13:40:12 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver mf_handle.py,1.7,1.8 Message-ID: <20040809114012.28B2F13ABA@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver In directory doto:/tmp/cvs-serv13347/Extensions/umn_mapserver Modified Files: mf_handle.py Log Message: (_has_umn_mapobj_and_selectedlayer): Activating the layer menu. Now Layersettings for the mapserver kann be edited. Index: mf_handle.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mf_handle.py,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- mf_handle.py 3 Aug 2004 11:56:53 -0000 1.7 +++ mf_handle.py 9 Aug 2004 11:40:10 -0000 1.8 @@ -1334,7 +1334,7 @@ def _has_umn_mapobj_and_selectedlayer(context): """Return true if a umn_mapobj exists""" # temporary disabled - return False + #return False if context.mainwindow.has_selected_layer(): return hasattr(context.mainwindow.canvas.Map(), "extension_umn_mapobj") else: From cvs at intevation.de Mon Aug 9 13:41:37 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Mon, 9 Aug 2004 13:41:37 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver mf_import.py, 1.10, 1.11 Message-ID: <20040809114137.BC9FD13ABA@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver In directory doto:/tmp/cvs-serv13370/Extensions/umn_mapserver Modified Files: mf_import.py Log Message: Now all layers which are imported, will be linked with the associated MF_Layer. (import_mapfile): All layers, which are not selected, will be removed. Disable the "import layer from mapfile" menu option. Index: mf_import.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mf_import.py,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- mf_import.py 3 Aug 2004 11:58:05 -0000 1.10 +++ mf_import.py 9 Aug 2004 11:41:35 -0000 1.11 @@ -275,6 +275,8 @@ # because thuban don't supports annotation. layertitle = maplayer.get_name() annotationlayer = AnnotationLayer(layertitle,store) + # associate a copy of the maplayer object to the layer in thuban. + annotationlayer.extension_umn_layerobj = maplayer tb_map.AddLayer(annotationlayer) @@ -309,6 +311,9 @@ rasterlayer.SetVisible(maplayer.get_status()) #add the projection if exists set_projection_to_tb(rasterlayer, maplayer) + + # associate a copy of the maplayer object to the layer in thuban. + rasterlayer.extension_umn_layerobj = maplayer tb_map.AddLayer(rasterlayer) @@ -365,7 +370,6 @@ clazz_name = map_clazz.get_name() clazz = layer.GetClassification() prop = ClassGroupProperties() - # set the layerprojection if given # TODO check this, becaus it is not working correctly # set_projection_to_tb(layer, maplayer) @@ -479,7 +483,7 @@ set_projection_to_tb(layer, maplayer) # associate a copy of the maplayer object to the layer in thuban. - # layer.extension_umn_layerobj =maplayer + layer.extension_umn_layerobj =maplayer #add the layer into thuban tb_map.AddLayer(layer) @@ -536,7 +540,7 @@ # Parse mapfile mapobj = parse_mapfile(filename) - + # Show number of Layer found in file numlayers = len(mapobj.get_layers()) if numlayers == 0: @@ -651,7 +655,19 @@ set_projection_to_tb(tb_map,mapobj) selectedlayer = list(selectedlayer) - + # remove not selected layer from the mapfile + incount = 0 + delcount = 0 + newselect = [] + for iii in range(0, len(mapobj.get_layers()), 1): + if iii in selectedlayer: + newselect.append(selectedlayer[incount]-delcount) + incount += 1 + else: + mapobj.remove_layer(iii-delcount) + delcount += 1 + selectedlayer = newselect + # Check for each Layer if it is possible to show in Thuban for layernr in selectedlayer: @@ -674,13 +690,6 @@ add_annotationlayer(context, tb_map, mapobj, maplayer) layer_count += 1 - # remove alle layer from the mapobj, because the layer will be - # created new in export, and the unused layers are not needed - # TODO: Save the layers which are not used somewhere, to edit - # them later and export it. - ##~ for nr in range(len(mapobj.get_layers())-1, -1, -1): - ##~ mapobj.remove_layer(nr) - # add the map object to thuban, to use it later tb_map.extension_umn_mapobj = mapobj @@ -711,6 +720,7 @@ # check if an mapobj exists, to control the menuitem is available or not def _has_umn_mapobj(context): + return False """Return true if a umn_mapobj exists""" return hasattr(context.mainwindow.canvas.Map(), "extension_umn_mapobj") From cvs at intevation.de Mon Aug 9 13:42:14 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Mon, 9 Aug 2004 13:42:14 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver/sample iceland.map, 1.5, 1.6 Message-ID: <20040809114214.EC30013ABA@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver/sample In directory doto:/tmp/cvs-serv13390/Extensions/umn_mapserver/sample Modified Files: iceland.map Log Message: Set the status of the Annotation Layer from DEFAULT to OFF. The DEFAULT setting turns the layer on permanently. Index: iceland.map =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/sample/iceland.map,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- iceland.map 3 Aug 2004 11:58:55 -0000 1.5 +++ iceland.map 9 Aug 2004 11:42:11 -0000 1.6 @@ -193,7 +193,7 @@ NAME "cultural_type" TYPE ANNOTATION DATA cultural_landmark-point - STATUS DEFAULT + STATUS OFF LABELITEM "CLPTLABEL" CLASSITEM "CLPTLABEL" From cvs at intevation.de Mon Aug 9 13:42:55 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Mon, 9 Aug 2004 13:42:55 +0200 (CEST) Subject: jschuengel: thuban ChangeLog,1.679,1.680 Message-ID: <20040809114255.2053913ABA@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv13404 Modified Files: ChangeLog Log Message: updated ChangeLog Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.679 retrieving revision 1.680 diff -u -d -r1.679 -r1.680 --- ChangeLog 3 Aug 2004 12:00:47 -0000 1.679 +++ ChangeLog 9 Aug 2004 11:42:52 -0000 1.680 @@ -1,36 +1,81 @@ +2004-08-09 Jan Schüngel + + * ChangeLog: Rewrite the last ChangeLog entry to follow + the standard way. + + * Extensions/umn_mapserver/mapfile: Moved the import AnnotationLayer to + the function where it is needed, because it don't works if it stands + at the beginning. + (MF_Layer.__init__): Removed the extra numclassed variable. Now + numclasses from the mapscript will be used. + (MF_Layer.get_index): New. Return the index of the layer in mapfile. + (MF_Layer.set_classes): New. A Classlist will be set to the layer. + (MF_Layer.set_metadata): New. A Metadata mapscript object will set. + (MF_Layer.remove_allclasses): New. All class of the layer will remove. + (MF_Map.create_new_layer): New. A new Layer is created and associated + with the mapscript object. + (MF_Map.set_layerorder): New. The Layer order like in thuban is set in + the mapscript. + (MF_Map.add_thubanlayer): Now a new layerobj is created if no one is + linked to the layer in thuban, else the layerobject linked to the + thubanlayer will be used. + AnnotationLayer will now store the filename of the shapefile. + (MF_Map.remove_layer): If a layer is removed the associated object + must be set new. + + * Extensions/umn_mapserver/mf_export.py(tb_layer_to_map): Add all + layers which are exists in thuban to the mapobj. All removed Layers + will be removed from the mapobj. + Added comments to all functions. + (thuban_to_map): No layer will be removed here. + + * Extensions/umn_mapserver/mf_handle.py + (_has_umn_mapobj_and_selectedlayer): Activating the layer menu. Now + Layersettings for the mapserver kann be edited. + + * Extensions/umn_mapserver/mf_import.py: Now all layers which are + imported, will be linked with the associated MF_Layer. + (import_mapfile): All layers, which are not selected, will be removed. + Disable the "import layer from mapfile" menu option. + + * Extensions/umn_mapserver/sample/iceland.map: Set the status of the + Annotation Layer from DEFAULT to OFF. The DEFAULT setting turns the + layer on permanently. + 2004-08-03 Jan Schüngel - * Extensions/umn_mapserver/mapfile.py(MF_Metadata): Added a function - to remove all metadata. - (MF_Layer): Added two functions to handle the group setting. - Removed the extra numlayers variable, used the mapscript parameter - instead. - (MF_Map): Added a function to get the numlayers parameter. - Added a funtion to remove all layers. + * Extensions/umn_mapserver/mapfile.py(MF_Metadata.remove_allmetadata): + New. This function removes all metadata + (MF_Layer.set_group): New. Set the group setting. + (MF_Layer.get_group): New. Get the group setting. + (MF_Map): Removed the extra numlayers variable, used the mapscript + parameter instead. + (MF_Map.get_numlayers): New. This get numlayers. + (MF_Map.remove_all_layers): New. Removes all layers from the mapobj. (MF_Map.add_thubanlayer): Replaced the exception handling by a check if the object is an instance. Also added the annotation layer here to export, but only the layer is created in the mapfile. - * Extensions/umn_mapserver/mf_export.py: Removed the check if a - mapobj exist, because its not needed anymore. The export function is - only available if a mapobj exist. - Added an extra function to remove all layers. + * Extensions/umn_mapserver/mf_export.py(export_mapfile): Removed + the check if a mapobj exist, because its not needed anymore. The + export function is only available if a mapobj exist. + Use the new function to remove all layers. - * Extensions/umn_mapserver/mf_handle.py: Added a group option and the - metadata button to the Layer dialog. - The layer dialog is temporary disabled. - (Metadata_CustomDataTable): Added some funktions to show the grid + * Extensions/umn_mapserver/mf_handle.py(Layer_Dialog): Added a group + option and the metadata button. The layer dialog is temporary disabled. + (Metadata_CustomDataTable): Added some functions to show the grid correct. - * Extensions/umn_mapserver/mf_import.py: Added a Class and a function - to show the Annotation layer in thuban. The layer don't do anything. - Its only to show the layer. Necessary to save the layer order. - Added a funtion to import only layers to thuban and not the other - settings like projection or scalebar. - Moved the _has_umn_mapobj function and the create_new_mapfile - functions from mf_handle.py to mf_import.py. - (select_layer2import): Moved the code for showing the number of layer - from import_mapfile to this function. + * Extensions/umn_mapserver/mf_import.py: Moved the code for showing + the number of layer from import_mapfile to this function. + (AnnotationLayer): New. This Class shows the Annotation layer in + thuban. The layer don't do anything. It's only to show the layer + and to save the layer order. + (add_annotationlayer): New. Import an annotation layer to thuban. + (select_layer2import): New. Import only layers to thuban and not + the other settings like projection or scalebar. + (create_new_mapfile): Moved the _has_umn_mapobj function and the + create_new_mapfile functions from mf_handle.py to mf_import.py. * Extensions/umn_mapserver/sample/iceland.map: Added the group parameter to the roads and cultural layers. Also added a new From cvs at intevation.de Tue Aug 10 02:23:38 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Tue, 10 Aug 2004 02:23:38 +0200 (CEST) Subject: jan: thuban/Doc/technotes coding_guidelines.txt,1.1,1.2 Message-ID: <20040810002338.ABB47139AD@lists.intevation.de> Author: jan Update of /thubanrepository/thuban/Doc/technotes In directory doto:/tmp/cvs-serv28157 Modified Files: coding_guidelines.txt Log Message: Added rule 'Method names start with lower case letter' Index: coding_guidelines.txt =================================================================== RCS file: /thubanrepository/thuban/Doc/technotes/coding_guidelines.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- coding_guidelines.txt 26 Feb 2004 11:22:30 -0000 1.1 +++ coding_guidelines.txt 10 Aug 2004 00:23:36 -0000 1.2 @@ -68,6 +68,15 @@ - Use "obj is None" when testing for None not just "obj". The object in question might be false without being None. + - Method names start with lower case letter. + + The main reason is that we should, in the long term, adopt the more + common naming styles used in python code. For Thuban this basically + means not to start method names with upper case letters. For Thuban this + would be a substantial change and even though it would be easy to retain + the old method names for a while for backwards compatibility it's not + something that should be done soon. However, new classes should + follow this rule. Test Suite From cvs at intevation.de Tue Aug 10 02:24:17 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Tue, 10 Aug 2004 02:24:17 +0200 (CEST) Subject: jan: thuban ChangeLog,1.680,1.681 Message-ID: <20040810002417.79F76139AD@lists.intevation.de> Author: jan Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv28183 Modified Files: ChangeLog Log Message: added a technote Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.680 retrieving revision 1.681 diff -u -d -r1.680 -r1.681 --- ChangeLog 9 Aug 2004 11:42:52 -0000 1.680 +++ ChangeLog 10 Aug 2004 00:24:15 -0000 1.681 @@ -1,3 +1,8 @@ +2004-08-10 Jan-Oliver Wagner + + * Doc/technotes/coding_guidelines.txt: Added rule 'Method names start with + lower case letter' + 2004-08-09 Jan Schüngel * ChangeLog: Rewrite the last ChangeLog entry to follow From jan at intevation.de Tue Aug 10 02:42:02 2004 From: jan at intevation.de (Jan-Oliver Wagner) Date: Tue, 10 Aug 2004 02:42:02 +0200 Subject: [Thuban-devel] Re: Patch for adding version info for Extensions In-Reply-To: References: <20040729124048.GA27358@intevation.de> Message-ID: <20040810004202.GA5414@intevation.de> Hi, thanks to Bernhard Herzog for the comments. I considered most, but have two quetions remaining. On Wed, Aug 04, 2004 at 08:25:24PM +0200, Bernhard Herzog wrote: > Jan-Oliver Wagner writes: > > I decided to have a explicit registration for the extensions. > > > > Let me know what you think. > > > > Attached is a patch (based on current CVS HEAD) and a new > > file Thuban/UI/extensionregistry.py > [...] > > class ThubanExtensionDesc: > > I'd omit the Thuban prefix from that name. If ExtensionDesc is too > ambigious in the code that imports this, that importing code can always > use import ... as... to choose a different name. This applies to > ThubanExtensionRegistry, too. Done. > > min_thuban_versions -- Minimum Thuban versions required to > > run the extension. This is a dictionary > > where the major release numbers ('X.Y') > > are the keys and the minor release > > number is the contents (e.g. 'Z'). > > Example: { '1.0' : '0' } > > I asked Jan yesterday why he chose this representation. His goal was to > make it possible for an extension to state that it can use e.g. 1.0.1 > and later from the 1.0 branch and 1.1.2 from the 1.1 branch. That is, > neither 1.0.0 nor 1.1.1 would work, but 1.0.3 and 1.1.5 would. > > I have two issues with this: > > 1. Should we support it at all? > > We only need this if we backport features from newer Thuban versions to > an older one. Currently this would mean that we backport from cvs HEAD > to the 1.0 branch. > > 2. Is this the right representation for the interface of ThubanExtensionDesc? > > I think it's too complicated. I suggest the following, using the same > versions as in my example above: > > [(1, 0, 1), (1, 1, 2)] > > That, is a simple list of versions, with each version a tuple of > numbers. Representing a single version as a tuple of numbers has the > advantage that we don't have to parse the version numbers anymore and > comparisons are done numerically. I opt for 1. and would like to remove this part. Its more like a solution looking for a problem. Better lets wait until we face a real problem. Ok to drop this again? > > def Get(self): > > return self.registry > > I'd lose the Get method and implement some others instead which match > the usage of the registry better. See below. See below. > Another thing: I think the Add method should be spelled add, that is all > lowercase. The main reason is that I think we should, in the long term, > adopt the more common naming styles used in python code. For Thuban > this basically means not to start method names with upper case letters. > For Thuban this would be a substantial change and even though it would > be easy to retain the old method names for a while for backwards > compatibility it's not something that should be done soon. OTOH, for > small new classes such as this or the ClassMapper it wouldn't be a > problem to adopt that naming scheme and, in fact, ClassMapper already > uses it. I've renamed Add to add and added your text to the coding guidelines in CVS. > > +ext_registry.Add(ThubanExtensionDesc( > > + name = 'gns2shp', > > + version = '1.0.0', > > + authors= [ 'Jan-Oliver Wagner' ], > > + copyright = '2003, 2004 Intevation GmbH', > > + desc = _("Converts GNS (Geographical Name Service\n" \ > > + "of NIMA) to Shapefile format and\n" \ > > + "displays the data."), > > + min_thuban_versions = { '1.0' : '0' })) > > That min_thuban_versions is wrong. 1.0.0 doesn't have the extension > registry :) The same applies to the other places where you call > ThubanExtensionDesc. See above. I opt to remove min_thuban_versions. > > --- Thuban/UI/about.py 26 Mar 2004 18:15:35 -0000 1.12 > > +++ Thuban/UI/about.py 29 Jul 2004 12:27:14 -0000 > > @@ -70,6 +72,14 @@ class About(wxDialog): > > text+= '\t%s %s\n' % (name, version) > > text += '\n' > > > > + text += _('Extensions:\n') > > + if len(ext_registry.Get()) == 0: > > I think we should implement either __len__ or __nonzero__ in > ThubanExtensionRegistry so that you could write > > if ext_registry: > > instead. Done (__nonzero__) > > + text += _('\tNone registered.\n') > > + else: > > + for ext in ext_registry.Get(): > > And this would be easier written as > > for ext in ext_registry: > > by implementing a suitable iter method as e.g. a generator. can you give me an example? Jan -- Jan-Oliver Wagner http://intevation.de/~jan/ Intevation GmbH http://intevation.de/ FreeGIS http://freegis.org/ From cvs at intevation.de Tue Aug 10 21:58:52 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Tue, 10 Aug 2004 21:58:52 +0200 (CEST) Subject: silke: thuban ChangeLog,1.681,1.682 Message-ID: <20040810195852.5EA15139C8@lists.intevation.de> Author: silke Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv13413 Modified Files: ChangeLog Log Message: Fixed encoding problem of about dialog: Added function unicodeToLocale() to convert special characters to users locale encoding Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.681 retrieving revision 1.682 diff -u -d -r1.681 -r1.682 --- ChangeLog 10 Aug 2004 00:24:15 -0000 1.681 +++ ChangeLog 10 Aug 2004 19:58:49 -0000 1.682 @@ -1,3 +1,10 @@ + +2004-08-10 Silke Reimer + + * Thuban/UI/about.py: Fixed encoding problem of about dialog: Added + function unicodeToLocale() to convert special characters to users locale + encoding + 2004-08-10 Jan-Oliver Wagner * Doc/technotes/coding_guidelines.txt: Added rule 'Method names start with From cvs at intevation.de Tue Aug 10 21:58:52 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Tue, 10 Aug 2004 21:58:52 +0200 (CEST) Subject: silke: thuban/Thuban/UI about.py,1.12,1.13 Message-ID: <20040810195852.4D3E313954@lists.intevation.de> Author: silke Update of /thubanrepository/thuban/Thuban/UI In directory doto:/tmp/cvs-serv13413/Thuban/UI Modified Files: about.py Log Message: Fixed encoding problem of about dialog: Added function unicodeToLocale() to convert special characters to users locale encoding Index: about.py =================================================================== RCS file: /thubanrepository/thuban/Thuban/UI/about.py,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- about.py 26 Mar 2004 18:15:35 -0000 1.12 +++ about.py 10 Aug 2004 19:58:50 -0000 1.13 @@ -14,6 +14,8 @@ from wxPython.wx import * +import locale + from Thuban import _ from Thuban.version import versions from Thuban.Model.resource import gdal_support_status @@ -33,9 +35,9 @@ # characters to get byte strings in latin1. lead_developer = 'Bernhard Herzog' developers = [ 'Jonathan Coles', 'Frank Koormann', - 'Martin M\xfcller', 'Jan-Oliver Wagner' ] + unicodeToLocale(u'Martin M\xfcller'), 'Jan-Oliver Wagner' ] translators = [ ( _('French'), 'Daniel Calvelo Aros' ), - ( _('German'), 'Bj\xf6rn Broscheit'), + ( _('German'), unicodeToLocale(u'Bj\xf6rn Broscheit')), ( _('Italian'), 'Maurizio Napolitano'), ( _('Portuguese (Brazilian)'), 'Eduardo Patto Kanegae'), ( _('Russian'), 'Alex Shevlakov'), @@ -128,4 +130,11 @@ def OnCancel(self, event): self.EndModal(wxID_CANCEL) + +def unicodeToLocale(unicodeStr): + " Function to convert a unicode object to an object \ in the user's locale encoding" + + + import locale + return unicodeStr.encode(locale.getlocale()[1]) From joey at infodrom.org Tue Aug 10 22:36:31 2004 From: joey at infodrom.org (Martin Schulze) Date: Tue, 10 Aug 2004 22:36:31 +0200 Subject: silke: thuban/Thuban/UI about.py,1.12,1.13 In-Reply-To: <20040810195852.4D3E313954@lists.intevation.de> References: <20040810195852.4D3E313954@lists.intevation.de> Message-ID: <20040810203631.GC8361@finlandia.infodrom.north.de> cvs at intevation.de wrote: > +import locale ^^^^^^^^^^^^^ > + > from Thuban import _ > from Thuban.version import versions > from Thuban.Model.resource import gdal_support_status > @@ -33,9 +35,9 @@ > # characters to get byte strings in latin1. > lead_developer = 'Bernhard Herzog' > developers = [ 'Jonathan Coles', 'Frank Koormann', > - 'Martin M\xfcller', 'Jan-Oliver Wagner' ] > + unicodeToLocale(u'Martin M\xfcller'), 'Jan-Oliver Wagner' ] > translators = [ ( _('French'), 'Daniel Calvelo Aros' ), > - ( _('German'), 'Bj\xf6rn Broscheit'), > + ( _('German'), unicodeToLocale(u'Bj\xf6rn Broscheit')), > ( _('Italian'), 'Maurizio Napolitano'), > ( _('Portuguese (Brazilian)'), 'Eduardo Patto Kanegae'), > ( _('Russian'), 'Alex Shevlakov'), > @@ -128,4 +130,11 @@ > def OnCancel(self, event): > self.EndModal(wxID_CANCEL) > > + > +def unicodeToLocale(unicodeStr): > + " Function to convert a unicode object to an object \ in the user's locale encoding" > + > + > + import locale ^^^^^^^^^^^^^ > + return unicodeStr.encode(locale.getlocale()[1]) Do you need to import the module twice? (yes, I know Python won't import it twice). I'd also expect "from locale import getlocale", though. Regards, Joey -- Life is too short to run proprietary software. -- Bdale Garbee From Silke.Reimer at intevation.de Wed Aug 11 10:04:20 2004 From: Silke.Reimer at intevation.de (Silke Reimer) Date: Wed, 11 Aug 2004 10:04:20 +0200 Subject: silke: thuban/Thuban/UI about.py,1.12,1.13 In-Reply-To: <20040810203631.GC8361@finlandia.infodrom.north.de> References: <20040810195852.4D3E313954@lists.intevation.de> <20040810203631.GC8361@finlandia.infodrom.north.de> Message-ID: <20040811080420.GA31460@intevation.de> On Tue, Aug 10, 2004 at 10:36:31PM +0200, Martin Schulze wrote: > cvs at intevation.de wrote: > > +import locale Oh, sorry. This shouldn't be there. I forgot to delete it after my test codings that I did before. > ^^^^^^^^^^^^^ > > > + > > from Thuban import _ > > from Thuban.version import versions > > from Thuban.Model.resource import gdal_support_status > > @@ -33,9 +35,9 @@ > > # characters to get byte strings in latin1. > > lead_developer = 'Bernhard Herzog' > > developers = [ 'Jonathan Coles', 'Frank Koormann', > > - 'Martin M\xfcller', 'Jan-Oliver Wagner' ] > > + unicodeToLocale(u'Martin M\xfcller'), 'Jan-Oliver Wagner' ] > > translators = [ ( _('French'), 'Daniel Calvelo Aros' ), > > - ( _('German'), 'Bj\xf6rn Broscheit'), > > + ( _('German'), unicodeToLocale(u'Bj\xf6rn Broscheit')), > > ( _('Italian'), 'Maurizio Napolitano'), > > ( _('Portuguese (Brazilian)'), 'Eduardo Patto Kanegae'), > > ( _('Russian'), 'Alex Shevlakov'), > > @@ -128,4 +130,11 @@ > > def OnCancel(self, event): > > self.EndModal(wxID_CANCEL) > > > > + > > +def unicodeToLocale(unicodeStr): > > + " Function to convert a unicode object to an object \ in the user's locale encoding" > > + > > + > > + import locale > ^^^^^^^^^^^^^ > > > + return unicodeStr.encode(locale.getlocale()[1]) > > Do you need to import the module twice? (yes, I know Python won't import it twice). > > I'd also expect "from locale import getlocale", though. OK. I can change this. This would make the code better to read anyway. Regards, Silke -- Silke Reimer Intevation GmbH http://intevation.de/ FreeGIS http://freegis.org/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://www.intevation.de/pipermail/thuban-devel/attachments/20040811/bb9798fe/attachment.bin From cvs at intevation.de Wed Aug 11 10:09:47 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Wed, 11 Aug 2004 10:09:47 +0200 (CEST) Subject: silke: thuban/Thuban/UI about.py,1.13,1.14 Message-ID: <20040811080947.8D88013ABA@lists.intevation.de> Author: silke Update of /thubanrepository/thuban/Thuban/UI In directory doto:/tmp/cvs-serv26963/Thuban/UI Modified Files: about.py Log Message: Small changes to encoding related stuff to avoid too many and too enhanced imports of locale Index: about.py =================================================================== RCS file: /thubanrepository/thuban/Thuban/UI/about.py,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- about.py 10 Aug 2004 19:58:50 -0000 1.13 +++ about.py 11 Aug 2004 08:09:44 -0000 1.14 @@ -14,8 +14,6 @@ from wxPython.wx import * -import locale - from Thuban import _ from Thuban.version import versions from Thuban.Model.resource import gdal_support_status @@ -135,6 +133,7 @@ " Function to convert a unicode object to an object \ in the user's locale encoding" - import locale - return unicodeStr.encode(locale.getlocale()[1]) + from locale import getlocale + + return unicodeStr.encode(getlocale()[1]) From cvs at intevation.de Wed Aug 11 10:09:47 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Wed, 11 Aug 2004 10:09:47 +0200 (CEST) Subject: silke: thuban ChangeLog,1.682,1.683 Message-ID: <20040811080947.9D83513ABC@lists.intevation.de> Author: silke Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv26963 Modified Files: ChangeLog Log Message: Small changes to encoding related stuff to avoid too many and too enhanced imports of locale Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.682 retrieving revision 1.683 diff -u -d -r1.682 -r1.683 --- ChangeLog 10 Aug 2004 19:58:49 -0000 1.682 +++ ChangeLog 11 Aug 2004 08:09:43 -0000 1.683 @@ -1,3 +1,7 @@ +2004-08-11 Silke Reimer + + * Thuban/UI/about.py: Small changes to encoding related stuff to avoid + too many and too enhanced imports of locale 2004-08-10 Silke Reimer From bh at intevation.de Wed Aug 11 11:46:47 2004 From: bh at intevation.de (Bernhard Herzog) Date: Wed, 11 Aug 2004 11:46:47 +0200 Subject: silke: thuban/Thuban/UI about.py,1.13,1.14 In-Reply-To: <20040811080947.8D88013ABA@lists.intevation.de> (cvs@intevation.de's message of "Wed, 11 Aug 2004 10:09:47 +0200 (CEST)") References: <20040811080947.8D88013ABA@lists.intevation.de> Message-ID: cvs at intevation.de writes: > --- about.py 10 Aug 2004 19:58:50 -0000 1.13 > +++ about.py 11 Aug 2004 08:09:44 -0000 1.14 > @@ -14,8 +14,6 @@ > > from wxPython.wx import * > > -import locale > - > from Thuban import _ > from Thuban.version import versions > from Thuban.Model.resource import gdal_support_status > @@ -135,6 +133,7 @@ > " Function to convert a unicode object to an object \ in the user's locale encoding" What's that backslash doing there? Also, the line is much too long. See coding_guidelines.txt for how to format doc-strings. > > > - import locale > - return unicodeStr.encode(locale.getlocale()[1]) > + from locale import getlocale > + > + return unicodeStr.encode(getlocale()[1]) I'm sorry to pick on this too, :), but I'd have preferred to remove the import from unicodeToLocale and keep the one at the top of the module. In almost all cases, imports should be done at the top of the module and not inside functions. This is also covered by coding_guidelines.txt, btw. Bernhard -- Intevation GmbH http://intevation.de/ Skencil http://sketch.sourceforge.net/ Thuban http://thuban.intevation.org/ From joey at infodrom.org Wed Aug 11 16:34:17 2004 From: joey at infodrom.org (Martin Schulze) Date: Wed, 11 Aug 2004 16:34:17 +0200 Subject: [Thuban-devel] Re: RfD: Support for layer specific resources In-Reply-To: References: <20040615190159.GT1019@finlandia.infodrom.north.de> <20040713141846.GA9814@finlandia.infodrom.north.de> <20040713142901.GA13410@finlandia.infodrom.north.de> <20040713150122.GR4134@finlandia.infodrom.north.de> <20040718034419.GC4134@finlandia.infodrom.north.de> <20040727104502.GK1334@finlandia.infodrom.north.de> Message-ID: <20040811143417.GB3511@finlandia.infodrom.north.de> Bernhard Herzog wrote: > > In order to use the new ClassMapper I'd assume that we'll need > > something like the following: > > > > > > from Thuban.Lib.classmapper import ClassMapper > > > > _properties_dialogs = ClassMapper() > > > > def add_properties_dialog(layer_class, dialog_class): > > _properties_dialogs.add(layer_class, dialog_class) > > > > def get_properties_dialog_class(layer): > > return _properties_dialogs.get(layer) > > I think in practice only the mainwindow code will look up the dialogs, > so I'd say, the mapper should be in Thuban/UI/mainwindow.py. I'd also > omit the extra functions a simple > > from Thuban.Lib.classmapper import ClassMapper > > layer_properties_dialogs = ClassMapper() > > should suffice. Ok. layer_properties_dialogs should become a global variable, I guess? The classifier doesn't know about the main window, so it cannot be a variable inside mainwindow, I'd assume. > > And for Thuban.UI.classifier: > > > > add_properties_dialog(Layer, Classifier) > > add_properties_dialog(RasterLayer, Classifier) I'm not sure how I am supposed to implement this since classifier.py doesn't import mainwindow and I don't know if it would be a good idea to do so. However, in order to call layer_properties_dialogs.add() the variable needs to be made public somehow. What is the preferred method of doing so? > > as well as for Thuban.UI.mainwindow: > > > > def OpenLayerProperties(self, layer, group = None): > > dialog_class = get_properties_dialog_class(layer) > > > > if dialog_class is not None: > > name = "layer_properties" + str(id(layer)) > > self.OpenOrRaiseDialog(name, dialog_class, layer, group = group) > > > > Right? > > Yes, after adapting to my suggestion above. Great. Regards, Joey -- Everybody talks about it, but nobody does anything about it! -- Mark Twain From cvs at intevation.de Fri Aug 13 18:18:48 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Fri, 13 Aug 2004 18:18:48 +0200 (CEST) Subject: joey: thuban/Extensions/wms/test test_ogclib.py,1.6,1.7 Message-ID: <20040813161848.A2F2213B44@lists.intevation.de> Author: joey Update of /thubanrepository/thuban/Extensions/wms/test In directory doto:/tmp/cvs-serv27963 Modified Files: test_ogclib.py Log Message: Adjusted a comment Index: test_ogclib.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/wms/test/test_ogclib.py,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- test_ogclib.py 19 Mar 2004 17:02:11 -0000 1.6 +++ test_ogclib.py 13 Aug 2004 16:18:46 -0000 1.7 @@ -76,7 +76,7 @@ if foo_tuple[0] != bar_tuple[0]: self.fail("%s != %s" %(foo_tuple[0], bar_tuple[0])) - # Check for same number of HTTP GET arguments + # Check for same length of entire HTTP GET argument string if len(foo_tuple) != len(bar_tuple): self.fail("One URL has no arguments"); From cvs at intevation.de Fri Aug 13 18:37:23 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Fri, 13 Aug 2004 18:37:23 +0200 (CEST) Subject: joey: thuban ChangeLog,1.683,1.684 Message-ID: <20040813163723.807D213B44@lists.intevation.de> Author: joey Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv28299 Modified Files: ChangeLog Log Message: Update for the ChangeLog Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.683 retrieving revision 1.684 diff -u -d -r1.683 -r1.684 --- ChangeLog 11 Aug 2004 08:09:43 -0000 1.683 +++ ChangeLog 13 Aug 2004 16:37:21 -0000 1.684 @@ -1,3 +1,8 @@ +2004-08-13 Martin Schulze + + * Extensions/wms/test/test_ogclib.py (TestOGCLib.compare_URLs): + Adjusted a comment + 2004-08-11 Silke Reimer * Thuban/UI/about.py: Small changes to encoding related stuff to avoid From bh at intevation.de Thu Aug 19 20:18:04 2004 From: bh at intevation.de (Bernhard Herzog) Date: Thu, 19 Aug 2004 20:18:04 +0200 Subject: [Thuban-devel] Re: RfD: Support for layer specific resources References: <20040615190159.GT1019@finlandia.infodrom.north.de> <20040713141846.GA9814@finlandia.infodrom.north.de> <20040713142901.GA13410@finlandia.infodrom.north.de> <20040713150122.GR4134@finlandia.infodrom.north.de> <20040718034419.GC4134@finlandia.infodrom.north.de> <20040727104502.GK1334@finlandia.infodrom.north.de> <20040811143417.GB3511@finlandia.infodrom.north.de> Message-ID: Martin Schulze writes: > layer_properties_dialogs should become a global variable, I guess? Yes. >> > And for Thuban.UI.classifier: >> > >> > add_properties_dialog(Layer, Classifier) >> > add_properties_dialog(RasterLayer, Classifier) > > I'm not sure how I am supposed to implement this since > classifier.py doesn't import mainwindow and I don't know if it > would be a good idea to do so. You could put that code into Thuban.UI.mainwindow which already depends on Thuban.UI.classifier because it currently refers to the dialogs in there directly. That would keep the module dependencies the same as now. Bernhard -- Intevation GmbH http://intevation.de/ Skencil http://sketch.sourceforge.net/ Thuban http://thuban.intevation.org/ From thuban-bugs at intevation.de Fri Aug 20 15:02:06 2004 From: thuban-bugs at intevation.de (Request Tracker) Date: Fri, 20 Aug 2004 15:02:06 +0200 (CEST) Subject: [bug #2585] (thuban) internal encoding of thuban Message-ID: <20040820130206.F0EBF13B12@lists.intevation.de> this bug's URL: http://intevation.de/rt/webrt?serial_num=2585 ------------------------------------------------------------------------- Subject: internal encoding of thuban Currently thuban uses latin1 as internal encoding. This can generate problems when the user's encoding is differing from latin1. Example: on Fedora Core 2, my encoding: de_DE.UTF-8, wxGTK compiled with GKT2. This produces a segmentation fault when loading the default projektions since they have special french characters. Possible solution (coming from Bernhard H., thanks!): Instead of latin1 use the user's encoding as internal encoding of Thuban. Implementation should not be too difficult. Some work has to be done to adapt test cases. -------------------------------------------- Managed by Request Tracker From cvs at intevation.de Fri Aug 20 18:50:24 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Fri, 20 Aug 2004 18:50:24 +0200 (CEST) Subject: silke: thuban/Thuban/UI about.py,1.14,1.15 Message-ID: <20040820165024.4F13D13B13@lists.intevation.de> Author: silke Update of /thubanrepository/thuban/Thuban/UI In directory doto:/tmp/cvs-serv32700/Thuban/UI Modified Files: about.py Log Message: Changes to be consistent with coding style Index: about.py =================================================================== RCS file: /thubanrepository/thuban/Thuban/UI/about.py,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- about.py 11 Aug 2004 08:09:44 -0000 1.14 +++ about.py 20 Aug 2004 16:50:22 -0000 1.15 @@ -2,6 +2,7 @@ # Authors: # Jonathan Coles # Bernhard Reiter +# Silke Reimer # # This program is free software under the GPL (>=v2) # Read the file COPYING coming with Thuban for details. @@ -14,6 +15,8 @@ from wxPython.wx import * +from locale import getlocale + from Thuban import _ from Thuban.version import versions from Thuban.Model.resource import gdal_support_status @@ -130,10 +133,7 @@ def unicodeToLocale(unicodeStr): - " Function to convert a unicode object to an object \ in the user's locale encoding" - - - from locale import getlocale + "Function to convert unicode to the user's locale encoding" return unicodeStr.encode(getlocale()[1]) From cvs at intevation.de Fri Aug 20 18:50:24 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Fri, 20 Aug 2004 18:50:24 +0200 (CEST) Subject: silke: thuban ChangeLog,1.684,1.685 Message-ID: <20040820165024.2B4FC13B12@lists.intevation.de> Author: silke Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv32700 Modified Files: ChangeLog Log Message: Changes to be consistent with coding style Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.684 retrieving revision 1.685 diff -u -d -r1.684 -r1.685 --- ChangeLog 13 Aug 2004 16:37:21 -0000 1.684 +++ ChangeLog 20 Aug 2004 16:50:21 -0000 1.685 @@ -1,3 +1,8 @@ +2004-08-11 Silke Reimer + + * Thuban/UI/about.py: + small changes to be consistent with coding style. + 2004-08-13 Martin Schulze * Extensions/wms/test/test_ogclib.py (TestOGCLib.compare_URLs): From cvs at intevation.de Fri Aug 20 18:59:23 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Fri, 20 Aug 2004 18:59:23 +0200 (CEST) Subject: silke: thuban ChangeLog,1.685,1.686 Message-ID: <20040820165923.66A2213B12@lists.intevation.de> Author: silke Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv382 Modified Files: ChangeLog Log Message: Fix bug in projection handling of layers Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.685 retrieving revision 1.686 diff -u -d -r1.685 -r1.686 --- ChangeLog 20 Aug 2004 16:50:21 -0000 1.685 +++ ChangeLog 20 Aug 2004 16:59:20 -0000 1.686 @@ -1,4 +1,10 @@ -2004-08-11 Silke Reimer +2004-08-20 Silke Reimer + + * Thuban/Model/layer.py: + Fixes bug in projection handling: Otherwise very large region might not + have valid values in the layer's projection. + +2004-08-20 Silke Reimer * Thuban/UI/about.py: small changes to be consistent with coding style. @@ -16,8 +22,8 @@ 2004-08-10 Silke Reimer * Thuban/UI/about.py: Fixed encoding problem of about dialog: Added - function unicodeToLocale() to convert special characters to users locale - encoding + function unicodeToLocale() to convert special characters to users + locale encoding 2004-08-10 Jan-Oliver Wagner From cvs at intevation.de Fri Aug 20 18:59:23 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Fri, 20 Aug 2004 18:59:23 +0200 (CEST) Subject: silke: thuban/Thuban/Model layer.py,1.58,1.59 Message-ID: <20040820165923.7A42F13BCA@lists.intevation.de> Author: silke Update of /thubanrepository/thuban/Thuban/Model In directory doto:/tmp/cvs-serv382/Thuban/Model Modified Files: layer.py Log Message: Fix bug in projection handling of layers Index: layer.py =================================================================== RCS file: /thubanrepository/thuban/Thuban/Model/layer.py,v retrieving revision 1.58 retrieving revision 1.59 diff -u -d -r1.58 -r1.59 --- layer.py 3 Jun 2004 15:17:54 -0000 1.58 +++ layer.py 20 Aug 2004 16:59:21 -0000 1.59 @@ -2,6 +2,7 @@ # Authors: # Bernhard Herzog # Jonathan Coles +# Silke Reimer # # This program is free software under the GPL (>=v2) # Read the file COPYING coming with Thuban for details. @@ -226,7 +227,11 @@ form (minx, miny, maxx, maxy) in unprojected coordinates. """ if self.projection is not None: - bbox = self.projection.ForwardBBox(bbox) + # Ensure that region lies within the layer's bounding box + # Otherwise projection of the region would lead to incorrect + # values. + clipbbox = self.ClipBoundingBox(bbox) + bbox = self.projection.ForwardBBox(clipbbox) return self.store.ShapesInRegion(bbox) def GetClassificationColumn(self): @@ -301,6 +306,29 @@ items.append(self.__classification) return (_("Layer '%s'") % self.Title(), items) + + def ClipBoundingBox(self, bbox): + """ Clip bbox to layer's bounding box. + + Returns that part of bbox that lies within the layers bounding box. + If bbox is completely outside of the layers bounding box, bbox is + returned. It is assumed that bbox has sensible values, i.e. bminx + < bmaxx and bminy < bmaxy. + """ + bminx, bminy, bmaxx, bmaxy = bbox + lminx, lminy, lmaxx, lmaxy = self.LatLongBoundingBox() + if bminx > lmaxx or bmaxx < lminx: + left, right = bminx, bmaxx + else: + left = max(lminx, bminx) + right = min(lmaxx, bmaxx) + if bminy > lmaxy or bmaxy < lminy: + bottom, top = bminy, bmaxy + else: + bottom = max(lminy, bminy) + top = min(lmaxy, bmaxy) + + return (left, bottom, right, top) if resource.has_gdal_support(): From cvs at intevation.de Fri Aug 20 18:59:23 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Fri, 20 Aug 2004 18:59:23 +0200 (CEST) Subject: silke: thuban/test test_layer.py,1.30,1.31 Message-ID: <20040820165923.9D4DF13BCB@lists.intevation.de> Author: silke Update of /thubanrepository/thuban/test In directory doto:/tmp/cvs-serv382/test Modified Files: test_layer.py Log Message: Fix bug in projection handling of layers Index: test_layer.py =================================================================== RCS file: /thubanrepository/thuban/test/test_layer.py,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- test_layer.py 3 Jun 2004 15:18:07 -0000 1.30 +++ test_layer.py 20 Aug 2004 16:59:21 -0000 1.31 @@ -190,6 +190,12 @@ self.assertFloatSeqEqual(layer.ShapesBoundingBox([0]), (90.0, -8.90043373, 120, 11.1616263)) + self.assertFloatSeqEqual(layer.ClipBoundingBox((-180, -6, 100, +120)), + (90.0, -6, 100, 11.1616263)) + shapes = layer.ShapesInRegion((-180, -170, 200, +120)) + print "Shapes", shapes + self.assertEquals([s.ShapeID() for s in shapes],[0]) + def test_empty_layer(self): """Test Layer with empty shape file""" # create an empty shape file From jan at intevation.de Fri Aug 20 22:54:46 2004 From: jan at intevation.de (Jan-Oliver Wagner) Date: Fri, 20 Aug 2004 22:54:46 +0200 Subject: [Thuban-devel] silke: thuban/test test_layer.py,1.30,1.31 In-Reply-To: <20040820165923.9D4DF13BCB@lists.intevation.de> References: <20040820165923.9D4DF13BCB@lists.intevation.de> Message-ID: <20040820205446.GA24215@intevation.de> On Fri, Aug 20, 2004 at 06:59:23PM +0200, cvs at intevation.de wrote: > retrieving revision 1.31 > diff -u -d -r1.30 -r1.31 > --- test_layer.py 3 Jun 2004 15:18:07 -0000 1.30 > +++ test_layer.py 20 Aug 2004 16:59:21 -0000 1.31 > @@ -190,6 +190,12 @@ > self.assertFloatSeqEqual(layer.ShapesBoundingBox([0]), > (90.0, -8.90043373, 120, 11.1616263)) > > + self.assertFloatSeqEqual(layer.ClipBoundingBox((-180, -6, 100, +120)), > + (90.0, -6, 100, 11.1616263)) > + shapes = layer.ShapesInRegion((-180, -170, 200, +120)) > + print "Shapes", shapes shouldn't this print statement be removed? > + self.assertEquals([s.ShapeID() for s in shapes],[0]) > + > def test_empty_layer(self): > """Test Layer with empty shape file""" > # create an empty shape file -- Jan-Oliver Wagner http://intevation.de/~jan/ Intevation GmbH http://intevation.de/ FreeGIS http://freegis.org/ From joey at infodrom.org Tue Aug 24 14:53:21 2004 From: joey at infodrom.org (Martin Schulze) Date: Tue, 24 Aug 2004 14:53:21 +0200 Subject: [Thuban-devel] Re: RfD: Support for layer specific resources In-Reply-To: References: <20040713141846.GA9814@finlandia.infodrom.north.de> <20040713142901.GA13410@finlandia.infodrom.north.de> <20040713150122.GR4134@finlandia.infodrom.north.de> <20040718034419.GC4134@finlandia.infodrom.north.de> <20040727104502.GK1334@finlandia.infodrom.north.de> <20040811143417.GB3511@finlandia.infodrom.north.de> Message-ID: <20040824125321.GB853@finlandia.infodrom.north.de> Bernhard Herzog wrote: > Martin Schulze writes: > > > layer_properties_dialogs should become a global variable, I guess? > > Yes. > > >> > And for Thuban.UI.classifier: > >> > > >> > add_properties_dialog(Layer, Classifier) > >> > add_properties_dialog(RasterLayer, Classifier) > > > > I'm not sure how I am supposed to implement this since > > classifier.py doesn't import mainwindow and I don't know if it > > would be a good idea to do so. > > You could put that code into Thuban.UI.mainwindow which already depends > on Thuban.UI.classifier because it currently refers to the dialogs in > there directly. That would keep the module dependencies the same as > now. Err??? Are you really sure you want this code appear in mainwindow.py? Similar code is required for other layers, too (e.g. currently WMS layers). Should that code go into mainwindow as well? Both would somehow pervert the idea of a modular design of Thuban. Regards, Joey -- Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald E. Knuth