From cvs at intevation.de Thu Jul 1 16:35:10 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Thu, 1 Jul 2004 16:35:10 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver mf_handle.py,NONE,1.1 Message-ID: <20040701143510.32C4A1393B@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver In directory doto:/tmp/cvs-serv4123 Added Files: mf_handle.py Log Message: This module extents Thuban with the possibility to edit the mapfile content. --- NEW FILE: mf_handle.py --- (This appears to be a binary file; contents omitted.) From cvs at intevation.de Thu Jul 1 16:36:39 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Thu, 1 Jul 2004 16:36:39 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver mf_import.py,1.3,1.4 Message-ID: <20040701143639.E5DA71393B@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver In directory doto:/tmp/cvs-serv4150 Modified Files: mf_import.py Log Message: Added the possibility to import mapfiles without any layer selected. So it is possible to edit the other settings in a mapfile. (import_mapfile): Added code to use the editing functions. Added the possibility to import the projection to a layer if one is defined. Status settings (On,Off) will now set in thuban (visible, invisible). fixed a bug with with classnames. If no classname is set in mapfile the value in Thuban will set to the expression. Index: mf_import.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mf_import.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- mf_import.py 23 Jun 2004 12:40:45 -0000 1.3 +++ mf_import.py 1 Jul 2004 14:36:37 -0000 1.4 @@ -99,49 +99,48 @@ if numlayers == 0: context.mainwindow.RunMessageBox(_('Loading Layer'), _("No Layer found.")) - return else: context.mainwindow.RunMessageBox(_('Loading Layer'), _("%s Layer loaded from file.") % numlayers) + selectedlayer = [] # Show a dialog to select layers to load into thuban - lst = [] - for layernr in range(0, numlayers,1): - lst.append(mapobj.get_layers()[layernr].get_name() + - " (" + mapobj.get_layers()[layernr].get_type() +")" ) - - dlgsize = (300,130+len(lst)*20) - if dlgsize[1] >= 300: - dlgsize = (300,300) - dlg = wxMultipleChoiceDialog(context.mainwindow, - "Select the layers from the\n" + - "list to load into thuban.\n" + - "annotation not supported !", - "Select Layer.", lst, size = dlgsize) - if (dlg.ShowModal() == wxID_OK): - selectedlayer = dlg.GetValue() - else: - selectedlayer = [] + if numlayers != 0: + lst = [] + for layernr in range(0, numlayers,1): + lst.append(mapobj.get_layers()[layernr].get_name() + + " (" + mapobj.get_layers()[layernr].get_type() +")" ) + + dlgsize = (300,130+len(lst)*20) + if dlgsize[1] >= 300: + dlgsize = (300,300) + dlg = wxMultipleChoiceDialog(context.mainwindow, + "Select the layers from the\n" + + "list to load into thuban.\n" + + "annotation not supported !", + "Select Layer.", lst, size = dlgsize) + if (dlg.ShowModal() == wxID_OK): + selectedlayer = dlg.GetValue() # counter to show the numer of layer loaded into Tuban layer_count = 0 # thuban map context tb_map = context.mainwindow.canvas.Map() - # set the name of the map in thuban + # set the titel an projection tb_map.SetTitle(mapobj.get_name()) - # set the projection in thuban only if one layer selected - if len(selectedlayer) != 0: - set_projection_to_tb(tb_map,mapobj) + 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] layertitle = maplayer.get_name() + #check if rasterlayer if maplayer.get_type() == 'raster': imgpath = maplayer.get_data() try: - if os.path.isabs(mapobj.get_shapepath()): - filename = mapobj.get_shapepath() +'/' + imgpath + if os.path.isabs(imgpath): + filename = imgpath else: filename = filepath +"/" + mapobj.get_shapepath() +'/' + imgpath # Normalize the pathname by collapses @@ -152,11 +151,12 @@ _("Can't open the rasterlayer '%s'.") % layertitle) else: rasterlayer = RasterLayer(maplayer.get_name(), filename) + # set the visible status + rasterlayer.SetVisible(maplayer.get_status()) + #add the projection if exists + set_projection_to_tb(rasterlayer, maplayer) tb_map.AddLayer(rasterlayer) layer_count += 1 - # TODO check this, because if the projection is not set - # correctly, adding the raster layer will show an error - # set_projection_to_tb(rasterlayer, maplayer) #check if polygonlayer if ((maplayer.get_type() == 'polygon') or @@ -240,10 +240,11 @@ # Regular expressions # Logical expressions expressionstring = map_clazz.get_expressionstring() - if (((map_numclazzes == 1) & (not expressionstring)) or ((map_numclazzes > 1) & (expressionstring == None)) or (expressionstring == '/./')): + if clazz_name == None: + clazz_name = "" new_group = ClassGroupDefault(props = prop, label = clazz_name) clazz.SetDefaultGroup(new_group) defaultclazzset = True @@ -264,7 +265,7 @@ theexpression = int(expressionstring[1:-1]) except: theexpression = expressionstring[1:-1] - if clazz_name == 'none': + if clazz_name == None: clazz_name = str(theexpression) new_group = ClassGroupSingleton(value = theexpression, props = prop, @@ -283,15 +284,40 @@ clazz.SetDefaultGroup(new_group) defaultclazzset = None + # set the visible status + layer.SetVisible(maplayer.get_status()) + # 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) + #add the layer into thuban tb_map.AddLayer(layer) + + # maybe remove all used layers + # for nr in range(len(selectedlayer)-1, -1, -1): + # print selectedlayer[nr] + # mapobj.remove_layer(selectedlayer[nr]) + + # 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 # fit the new map to the window context.mainwindow.canvas.FitMapToWindow() # show a message how many layer were loaded into thuban - context.mainwindow.RunMessageBox(_('Layer loaded'), - _("%s Layer loaded into Thuban") % layer_count) + # if the number of layers is not null + if numlayers != 0: + context.mainwindow.RunMessageBox(_('Layer loaded'), + _("%s Layer loaded into Thuban") % layer_count) def set_projection_to_tb(tb_con, mapobj): """ @@ -302,8 +328,15 @@ mapobj -- The mapobject (from mapscript) """ if (mapobj.get_projection().get_params() != None): - projparam = mapobj.get_projection().get_params() - tb_con.SetProjection(Projection(projparam)) + projparams = mapobj.get_projection().get_params() + # check if it is an latlong projection, becaues one + # more parameter is needed in that case + for param in projparams: + projkey = param.split("=") + if projkey[0] == "proj": + if projkey[1] == "latlong": + projparams.append("to_meter=0.017453") + tb_con.SetProjection(Projection(projparams)) if mapobj.get_projection().get_epsgcode() != None: projepsg = mapobj.get_projection().get_epsgproj() tb_con.SetProjection(projepsg) From cvs at intevation.de Thu Jul 1 16:37:31 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Thu, 1 Jul 2004 16:37:31 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver mf_export.py,1.1,1.2 Message-ID: <20040701143731.2804E1393B@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver In directory doto:/tmp/cvs-serv4179 Modified Files: mf_export.py Log Message: Added the possibility to save a new mapfile or use the old one which is imported or new created. Added code to use the editing functions. Remove some not needed import statements Index: mf_export.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mf_export.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- mf_export.py 23 Jun 2004 12:37:48 -0000 1.1 +++ mf_export.py 1 Jul 2004 14:37:29 -0000 1.2 @@ -25,7 +25,7 @@ #import os, sys # mapscript -from mapscript import mapObj, layerObj +from mapscript import mapObj # wxPython support from wxPython.wx import wxFileDialog, \ @@ -46,7 +46,7 @@ from Thuban.UI.mainwindow import main_menu # import Map Object for the Mapfile -from mapfile import MF_Map, MF_Layer +from mapfile import MF_Map # ################################### # @@ -70,7 +70,6 @@ tb_bbox = tb_map.ProjectedBoundingBox() # Size must be set before, because mapscript checks it # when extent is set - map.set_size(300,400) map.set_extent(tb_bbox) def thuban_to_map(tb_context, map): @@ -86,7 +85,10 @@ def export_mapfile(context): - theMap = MF_Map(mapObj("")) + if hasattr(context.mainwindow.canvas.Map(), "extension_umn_mapobj"): + theMap = context.mainwindow.canvas.Map().extension_umn_mapobj + else: + theMap = MF_Map(mapObj("")) dlg = wxFileDialog(context.mainwindow, "Save file as...", ".", "", "UMN MapServer Mapfiles (*.map)|*.map|" \ @@ -103,7 +105,15 @@ # save the map with the integrated mapscript saver theMap.save_map(path) - + + # 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) + # ################################### # # Hook in MapServer Extension into Thuban From cvs at intevation.de Thu Jul 1 16:39:02 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Thu, 1 Jul 2004 16:39:02 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver mapfile.py,1.2,1.3 Message-ID: <20040701143902.4CD831393B@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver In directory doto:/tmp/cvs-serv4209 Modified Files: mapfile.py Log Message: Added new types which are need for the editing functions. Added needed set-functions for the editing functions. Added the possibility to export rasterimages. Added new classes (MF_Web, MF_Label, MF_Legend, MF_Symbol, MF_SymbolSet). MF_Symbol and MF_SymbolSet are not needed at the moment. (MF_Class.set_thubanstyle): Now point layers will set to a default symbol to show a circle in mapserver and not only a 1px dot. (MF_Style.__init__): Fixed a bug with the color. Color was not set correct before. (MF_Size): Removed, because it is not needed. Index: mapfile.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mapfile.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- mapfile.py 23 Jun 2004 12:39:52 -0000 1.2 +++ mapfile.py 1 Jul 2004 14:39:00 -0000 1.3 @@ -13,10 +13,10 @@ mapscript are not implemented yet in this extension: DBFInfo, errorObj, fontSetObj, graticuleObj, imageObj, itemObj, - labelCacheMemberObj, labelCacheObj, labelObj, legendObj, lineObj, + labelCacheMemberObj, labelCacheObj, lineObj, markerCacheMembet, msTiledSHPLayerInfo, OutputFormat, pointObj, queryMapObj, referenzMapObj, resultCacheMemberObj, resultCacheObj, scalebarObj, - shapefileObj, shapeObj, styleObj, symbolObj, symbolSetObj, VectorObj, WebObj + shapefileObj, shapeObj, VectorObj, WebObj """ __version__ = "$Revision$" @@ -34,8 +34,8 @@ from Thuban.Model.color import Color, Transparent -from mapscript import layerObj, classObj, colorObj, styleObj, rectObj, \ - colorObj +from mapscript import layerObj, classObj, colorObj, styleObj, rectObj + # ################################### # @@ -51,6 +51,38 @@ 5:'circle', 6:'query'} +unit_type = { 0:"inches", + 1:"feet", + 2:"miles", + 3:"meters", + 4:"kilometers", + 5:"dd"} + +legend_status_type = { 0:"OFF", + 1:"ON", + 3:"embed" } + # 2 = Default but will not be imported because + # mapscript dont support it and its not allowed + +layer_status_type = { 0:"OFF", + 1:"ON", + 2:"default"} + +legend_position_type = { 0:"ul", + 1:"lr", + 2:"ur", + 3:"ll", + 6:"uc", + 7:"lc"} + +label_size_type = { 0:"tiny", + 1:"small", + 2:"medium", + 3:"large", + 4:"giant" } + +label_font_type = { 0:"truetype", + 1:"bitmap" } # ################################################## @@ -129,6 +161,16 @@ def get_blue(self): return self._color.blue + def set_rgbcolor(self, red, green, blue): + self._color.red = red + self._color.green = green + self._color.blue = blue + + self._tbc_red = (float(self.get_red())/255) + self._tbc_green = (float(self.get_green())/255) + self._tbc_blue = (float(self.get_blue())/255) + self._thubancolor = Color(self._tbc_red, self._tbc_green, self._tbc_blue) + def get_mfcolor(self): return self._color @@ -143,28 +185,6 @@ self._thubancolor = thuban_color -class MF_Size: - """ - Handle sizes. - This is not implemented as a Class in mapscript but - seems to be helpful. - """ - - def __init__(self, mf_width, mf_height): - self._width = mf_width - self._height = mf_height - - def get_width(self): - return self._width - - def get_height(self): - return self._height - - def set_size(self, newwidth, newheight): - self._width = newwidth - self._height = newheight - - class MF_Metadata: """ Metadata is not a Object in mapscript witch can be used @@ -299,14 +319,22 @@ self._expression = self._clazz.getExpressionString() def add_thubanstyle(self, tb_style, type="default"): + """ + added a thuban style object to the mapobject + """ new_styleobj = MF_Style(styleObj(self._clazz)) if type == "line": new_styleobj.set_color(tb_style.GetLineColor()) - elif type == "circle": + elif type == "point": # set a default symbol to show circles not only a small dot # symbol "circle" must create before # TODO: create a Symbol (more see MF_SymbolSet) - new_styleobj.set_symbol('circle') + # first the default symbol circle will be created and the size 8 + new_styleobj.set_symbolname('circle') + new_styleobj.set_size(8) + if tb_style.GetLineColor() != Transparent: + new_styleobj.set_linecolor(tb_style.GetLineColor()) + new_styleobj.set_color(tb_style.GetFill()) else: new_styleobj.set_size(tb_style.GetLineWidth()) new_styleobj.set_linecolor(tb_style.GetLineColor()) @@ -411,8 +439,12 @@ def set_name(self, newname): self._mf_layer.name = newname - def set_data(self, newdata): - self._mf_layer.data = newdata[:-4] + def set_data(self, newdata, type="shape"): + if type == "raster": + 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. @@ -426,6 +458,8 @@ # if type = arc its a in shapetype line if tb_type == "arc": self._mf_layer.type = 1 + if tb_type == "raster": + self._mf_layer.type = 3 if shp_type.has_key(tb_type): self._mf_layer.type = tb_type else: @@ -442,36 +476,41 @@ self._mfnewprojstring = self._mfnewprojstring+ "," + field self._mf_layer.setProjection(self._mfnewprojstring[1:]) self._projection.set_projection(newprojection) - else: - print "no projection" - def add_thubanclass(self, tb_class): + def add_thubanclass(self, tb_class, type=""): + """ + Add a thuban class object + """ new_class = MF_Class(classObj(self._mf_layer)) new_class.set_name(tb_class.GetLabel()) if self.get_type() == "line": new_class.add_thubanstyle(tb_class.GetProperties(), type="line") + elif self.get_type() == "point": + new_class.add_thubanstyle(tb_class.GetProperties(), type="point") else: new_class.add_thubanstyle(tb_class.GetProperties()) - if tb_class.GetDisplayText() == "DEFAULT": + if (type == "default"): return - #new_class.set_expressionstring('/./') + elif (tb_class.Matches("DEFAULT")): + new_class.set_expressionstring('/./') else: - new_class.set_expressionstring(str(tb_class.GetDisplayText())) + new_class.set_expressionstring(str(tb_class.GetValue())) self._classes.append(new_class) + class MF_Map: """ The following parameters and functions, which the mapscript style obj contains, are used: - name, numlayers, extent, shapepath, imagecolor, imagetype, getLayer, - getProjection, getMetaData, getFirstMetaDataKey, getNextMetaDataKey, + name, numlayers, extent, shapepath, imagecolor, imagetype, units, getLayer, + status, getProjection, getMetaData, getFirstMetaDataKey, getNextMetaDataKey, save(), setExtent(), height, width, setProjection() The following parameters and functions are not used: - status, maxsize, layers, symbolset, fontset, labelcache, - transparent, interlace, imagequality, cellsize, units, debug, datapattern, + maxsize, layers, symbolset, fontset, labelcache, + transparent, interlace, imagequality, cellsize, debug, datapattern, templatepattern, configoptions zoomPoint(), zoomRectangle(), zoomScale(), getLayerOrder(), setLayerOrder(), clone(), removeLayer(), getLayerByName(), getSymbolByName(), @@ -497,6 +536,8 @@ self._mf_map = mf_map self._extent = MF_Rectangle(self._mf_map.extent) self._imagecolor = MF_Color(self._mf_map.imagecolor) + self._web = MF_Web(self._mf_map.web) + self._legend = MF_Legend(self._mf_map.legend) # if the map name is not set it will return a MS string. if self._mf_map.name != "MS": @@ -532,6 +573,18 @@ self._metadata.add_metadata(self._metafkey,self._metakeydata) self._metafkey = self._mf_map.getNextMetaDataKey(self._metafkey) + def get_status(self): + if layer_status_type[self._mf_map.status] == "OFF": + return false + else: + return true + + def get_web(self): + return self._web + + def get_legend(self): + return self._legend + def get_extent(self): return self._extent @@ -552,7 +605,18 @@ 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 + return (self._mf_map.width, self._mf_map.height) + + def get_units(self): + #returns the unittype + return unit_type[self._mf_map.units] + + def get_imagecolor(self): + return self._imagecolor def set_name(self, newname): # whitespace musst be replaced, either no @@ -564,8 +628,11 @@ def set_extent(self, newextent): # TODO: add the shown extend here instead of the total self._newrect = MF_Rectangle(rectObj()) - self._newrect.set_rect(newextent[0],newextent[1],newextent[2],newextent[3]) - self._mf_map.setExtent(newextent[0],newextent[1],newextent[2],newextent[3]) + try: + self._newrect.set_rect(newextent[0],newextent[1],newextent[2],newextent[3]) + self._mf_map.setExtent(newextent[0],newextent[1],newextent[2],newextent[3]) + except: + return def set_size(self, newwidth, newheight): self._mf_map.width = newwidth @@ -578,42 +645,215 @@ self._mfnewprojstring = self._mfnewprojstring+ "," + field self._mf_map.setProjection(self._mfnewprojstring[1:]) self._projection.set_projection(projection) + + def set_units(self, units): + if unit_type.has_key(units): + self._mf_map.units = units + else: + for unit_paar_nr in unit_type: + if unit_type[unit_paar_nr] == units: + self._mf_map.units = unit_paar_nr def add_thubanlayer(self, tb_layer): + """ + Add a thuban layer + """ new_layer = MF_Layer(layerObj(self._mf_map)) new_layer.set_name(tb_layer.Title()) # TODO: implement relative pathnames # yet only absolute pathnames in the LayerObj are set - new_layer.set_data(tb_layer.ShapeStore().FileName()) - - new_layer.set_status(tb_layer.Visible()) - new_layer.set_type(tb_layer.ShapeType()) + try: + new_layer.set_data(tb_layer.ShapeStore().FileName()) + except: + new_layer.set_data(tb_layer.GetImageFilename(), type="raster") + new_layer.set_type("raster") + else: + 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(): + new_layer.set_projection(tb_layer.GetProjection()) + if tb_layer.GetClassification().GetNumGroups() > 0: + for group in range(0, tb_layer.GetClassification().GetNumGroups(), 1): + new_layer.add_thubanclass(tb_layer.GetClassification().GetGroup(group)) + new_layer.add_thubanclass(tb_layer.GetClassification().GetDefaultGroup()) + else: + 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, 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()) - - if tb_layer.GetClassificationColumn(): - new_layer.set_classitem(tb_layer.GetClassificationColumn()) - if tb_layer.GetProjection(): - new_layer.set_projection(tb_layer.GetProjection()) - if tb_layer.GetClassification().GetNumGroups() > 0: - for group in range(0, tb_layer.GetClassification().GetNumGroups(), 1): - new_layer.add_thubanclass(tb_layer.GetClassification().GetGroup(group)) - new_layer.add_thubanclass(tb_layer.GetClassification().GetDefaultGroup()) - else: - new_layer.add_thubanclass(tb_layer.GetClassification().GetDefaultGroup()) self._layers.append(new_layer) + def remove_layer(self, nr): + self._mf_map.removeLayer(nr) + self._numlayers -= 1 + self._layers.remove(self._layers[nr]) + def save_map(self, filepath): # save the Map # maybe an own saver can implement here self._mf_map.save(filepath) + + +class MF_Web: + """ + Save the Web settings + + The following parametes are used: + imagepath, imageurl + + The following parameters are not used: + log, map, template, queryformat, header, footer, empty, error, extent, + minscale, maxscale, mintemplate, maxtemplate + """ + def __init__(self, mf_web): + self._mf_web = mf_web + + def get_imagepath(self): + return self._mf_web.imagepath + + def set_imagepath(self, new_imagepath): + self._mf_web.imagepath = new_imagepath + + def get_imageurl(self): + return self._mf_web.imageurl + + def set_imageurl(self, new_imageurl): + self._mf_web.imagepath = new_imageurl + + def get_queryformat(self): + return self._mf_web.queryformat + + def set_queryformat(self, new_queryformat): + self._mf_web.imagepath = new_queryformat + + +class MF_Label: + """ + The following parameters from mapscript are used: + type, color, size, offsetx, offsety, + + The following parameters are not used: + font, outlinecolor, shadowcolor, shadowsizex, shadowsizey, + backgroundcolor, backgroundshadowcolor, backgroundshadowsizex, + backgroundshadowsizey, sizescaled, minsize, maxsize, position, angle, + autoangle, buffer, antialias, wrap, minfeaturesize, + autominfeaturesize, mindistance, partials, force + """ + def __init__(self, mf_label): + """ + Create a legend obj from the existing mapfile + """ + self._label = mf_label + self._color = MF_Color(self._label.color) + + def get_size(self): + return self._label.size + + def set_size(self, new_size): + if label_size_type.has_key(new_size): + self._label.size = new_size + for label_size_type_nr in label_size_type: + if label_size_type[label_size_type_nr] == new_size: + self._label.size = label_size_type_nr + else: + self._label.size = new_size + + def get_color(self): + return self._color + + def get_type(self): + return label_font_type[self._label.type] + + def set_type(self, new_type): + if label_font_type.has_key(new_type): + self._label.type = new_type + else: + for label_font_type_nr in label_font_type: + if label_font_type[label_font_type_nr] == new_type: + self._label.type = label_font_type_nr + + def get_offset(self): + return (self._label.offsetx, self._label.offsety) + + def set_offset(self, new_offsetx, new_offsety): + self._label.offsetx = new_offsetx + self._label.offsety = new_offsety + + +class MF_Legend: + """ + The following parameters are (not) used: + imagecolor, label, keysizex, keysizey, status, position, + + The following parameters are not used: + keyspacingx, keyspacingy, + outlinecolor, height, width, postlabelcache, template, map + """ + def __init__(self, mf_legend): + """ + Create a legend obj from the existing mapfile + """ + self._mf_legend = mf_legend + self._imagecolor = MF_Color(self._mf_legend.imagecolor) + self._label = MF_Label(self._mf_legend.label) + def get_imagecolor(self): + return self._imagecolor + + def get_label(self): + return self._label + + def get_keysize(self): + return (self._mf_legend.keysizex, self._mf_legend.keysizey) + + def set_keysize(self, new_keysizex, new_keysizey): + self._mf_legend.keysizex = new_keysizex + self._mf_legend.keysizey = new_keysizey + + def get_keyspacing(self): + return (self._mf_legend.keyspacingx, self._mf_legend.keyspacingy) + + def set_keyspacing(self, new_keyspacingx, new_keyspacingy): + self._mf_legend.keyspacingx = new_keyspacingx + self._mf_legend.keyspacingy = new_keyspacingy + + def get_status(self, art="integer"): + if art == "string": + return legend_status_type[self._mf_legend.status] + else: + return self._mf_legend.status + + def set_status(self, new_status): + if legend_status_type.has_key(new_status): + self._mf_legend.status = new_status + else: + for legend_status_type_nr in legend_status_type: + if legend_status_type[legend_status_type_nr] == new_status: + self._mf_legend.status = legend_status_type_nr + + def get_position(self, art="integer"): + if art == "string": + return legend_position_type[self._mf_legend.position] + else: + return self._mf_legend.position + + def set_position(self, new_position): + if legend_position_type.has_key(new_position): + self._mf_legend.position = new_position + else: + for legend_position_type_nr in legend_position_type: + if legend_position_type[legend_position_type_nr] == new_position: + self._mf_legend.position = legend_position_type_nr + + class MF_Projection: """ The following parameter, which the mapscript style obj contains is used: @@ -624,10 +864,10 @@ def __init__(self, mf_projection): """ Create a projection object from the given mapscript projection - object. If it is a epsg code the extracted from the string - (e.g."init=epsg:xxxx"), else the projection parameters will - be splitted and an array with the parameters will be creaded. - """ + object. If it is a epsg code the extracted from the string + (e.g."init=epsg:xxxx"), else the projection parameters will + be splitted and an array with the parameters will be creaded. + """ self._mfprojstring = mf_projection self._projstring = self._mfprojstring self._epsgcode = None @@ -688,11 +928,11 @@ self._mfnewprojstring = self._mfnewprojstring+ "+" + field self._mfprojstring = self._mfnewprojstring + class MF_Style: """ The following parameters, which the mapscript style obj contains, are used: - color, backgroundcolor, outlinecolor, size, symbolname The following are not used: @@ -710,10 +950,9 @@ """ self._style = mf_style if self._style.color.red == -1: - self._maincolor = None + self._color = None else: - self._maincolor = MF_Color(self._style.color) - self._color = MF_Color(self._style.color) + self._color = MF_Color(self._style.color) if self._style.outlinecolor.red == -1: self._outlinecolor = None else: @@ -747,5 +986,5 @@ def set_symbolname(self, newsymbol): # its possible to use stringnames instead of numbers - self._style.symbolname = 'circle' + self._style.symbolname = newsymbol From cvs at intevation.de Thu Jul 1 16:39:31 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Thu, 1 Jul 2004 16:39:31 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver README,1.3,1.4 Message-ID: <20040701143931.35D4B1393B@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver In directory doto:/tmp/cvs-serv4229 Modified Files: README Log Message: Added the hints to use the export and editing functions, too. Index: README =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/README,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- README 23 Jun 2004 12:41:19 -0000 1.3 +++ README 1 Jul 2004 14:39:29 -0000 1.4 @@ -72,10 +72,12 @@ python setup.py install -2. Add the umn_mapserver extension import statement to ~/.thuban/thubanstart.py +2. Add the umn_mapserver extension import statements to ~/.thuban/thubanstart.py if you run thuban directly from the source directory the statement is: import Extensions.umn_mapserver.mf_import + import Extensions.umn_mapserver.mf_export + import Extensions.umn_mapserver.mf_handle More about how to use an extension see README in thuban/Examples/simple_extensions. From cvs at intevation.de Thu Jul 1 16:40:13 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Thu, 1 Jul 2004 16:40:13 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver/sample iceland.map, 1.1, 1.2 Message-ID: <20040701144013.8CF831393B@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver/sample In directory doto:/tmp/cvs-serv4241 Modified Files: iceland.map Log Message: Added the new parameter "UNITS METERS". Change the political layer to status OFF. Index: iceland.map =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/sample/iceland.map,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- iceland.map 16 Jun 2004 10:47:58 -0000 1.1 +++ iceland.map 1 Jul 2004 14:40:11 -0000 1.2 @@ -16,6 +16,7 @@ NAME ISLAND STATUS ON SIZE 600 450 +UNITS METERS EXTENT 622877.17 7019306.94 1095667.78 7447709.31 SHAPEPATH "../../../Data/iceland" @@ -77,7 +78,7 @@ NAME "political" DATA political TYPE POLYGON - STATUS ON + STATUS OFF CLASS NAME "test" STYLE From cvs at intevation.de Thu Jul 1 16:41:12 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Thu, 1 Jul 2004 16:41:12 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver/sample README,1.1,1.2 Message-ID: <20040701144112.0A6DE1393B@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver/sample In directory doto:/tmp/cvs-serv4253 Modified Files: README Log Message: Added some more details to setup the sample in the MapServer. Index: README =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/sample/README,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- README 16 Jun 2004 10:47:19 -0000 1.1 +++ README 1 Jul 2004 14:41:09 -0000 1.2 @@ -8,10 +8,11 @@ Howto view this sample in UMN MapServer (webserver): - Copy the three files included in this directory to your webserver. - To use the iceland data you must edit the data path in iceland.map, so - that it matches to the directory where the data is. At the moment the data - path is relative to this directory. + Copy the three files included in this directory to a new directory on + your webserver. For example "Iceland". To use the iceland data you + must edit the data path in iceland.map, so that it matches to the + directory where the data is. At the moment the data path is relative + to this directory. The data is in the thuban/Data/iceland directory. iceland.html: the template for the mapfile. From cvs at intevation.de Thu Jul 1 16:43:28 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Thu, 1 Jul 2004 16:43:28 +0200 (CEST) Subject: jschuengel: thuban ChangeLog,1.662,1.663 Message-ID: <20040701144328.8A1CE1393B@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv4287 Modified Files: ChangeLog Log Message: Added the functionality to handle the content thuban is not able to handle directly. Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.662 retrieving revision 1.663 diff -u -d -r1.662 -r1.663 --- ChangeLog 28 Jun 2004 10:55:10 -0000 1.662 +++ ChangeLog 1 Jul 2004 14:43:26 -0000 1.663 @@ -1,3 +1,50 @@ +2004-07-01 Jan Schüngel + + Added the functionality to handle the content thuban is not + able to handle directly. + + * Extensions/umn_mapserver/mf_handle.py: New. This module extents + Thuban with the possibility to edit the mapfile content. + + * Extensions/umn_mapserver/mf_import.py: Added the possibility + to import mapfiles without any layer selected. So it is possible + to edit the other settings in a mapfile. + (import_mapfile): Added code to use the editing functions. + Added the possibility to import the projection to a layer if one + is defined. + Status settings (On,Off) will now set in thuban (visible, invisible). + fixed a bug with with classnames. If no classname is set in mapfile + the value in Thuban will set to the expression. + + * Extensions/umn_mapserver/mf_export.py(export_mapfile): Added the + possibility to save a new mapfile or use the old one which is + imported or new created. + Added code to use the editing functions. + Remove some not needed import statements + + * Extensions/umn_mapserver/mapfile.py: Added new types which are + need for the editing functions. + Added needed set-functions for the editing functions. + Added the possibility to export rasterimages. + Added new classes (MF_Web, MF_Label, MF_Legend, MF_Symbol, + MF_SymbolSet). MF_Symbol and MF_SymbolSet are not needed at the + moment. + (MF_Class.set_thubanstyle): Now point layers will set to a default + symbol to show a circle in mapserver and not only a 1px dot. + (MF_Style.__init__): Fixed a bug with the color. Color was not set + correct before. + (MF_Size): Removed, because it is not needed. + + * Extensions/umn_mapserver/README: Added the hints to use the + export and editing functions, too. + + * Extensions/umn_mapserver/sample/iceland.map: Added the + new parameter "UNITS METERS". + Change the political layer to status OFF. + + * Extensions/umn_mapserver/sample/README: Added some + more details to setup the sample in the MapServer. + 2004-06-26 Bernhard Reiter * Extensions/svgexport/test/test_svgmapwriter.py: From cvs at intevation.de Tue Jul 6 16:28:54 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Tue, 6 Jul 2004 16:28:54 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver mapfile.py,1.3,1.4 Message-ID: <20040706142854.5CA671395E@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver In directory doto:/tmp/cvs-serv4485 Modified Files: mapfile.py Log Message: Added the symbolObj, pointObj and line Obj and add the scalebar_status_type, scalebar_style_type and scalebar_position_type. Added the symbol- and symbolsetObject (MF_Symbol,MF_Symbolset). The are only used to create a Symbol like the circle in Thuban. Added the scalebarObject (MF_Scalebar) (MF_Class): Added set_status and get_status. (MF_Layer.add_thubanclass): Added code to set the class status (MF_Map): Added code to handle the symbols and scalebar (MF_Label): Added the set_partials and get_partials functions Index: mapfile.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mapfile.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- mapfile.py 1 Jul 2004 14:39:00 -0000 1.3 +++ mapfile.py 6 Jul 2004 14:28:52 -0000 1.4 @@ -34,7 +34,8 @@ from Thuban.Model.color import Color, Transparent -from mapscript import layerObj, classObj, colorObj, styleObj, rectObj +from mapscript import layerObj, classObj, colorObj, styleObj, rectObj, symbolObj, \ + pointObj, lineObj # ################################### @@ -63,6 +64,21 @@ 3:"embed" } # 2 = Default but will not be imported because # mapscript dont support it and its not allowed +scalebar_status_type = { 0:"OFF", + 1:"ON", + 3:"embed" } + # 2 = Default but will not be imported because + # mapscript dont support it and its not allowed + +scalebar_style_type = { 0:"0", + 1:"1" } + +scalebar_position_type = { 0:"ul", + 1:"lr", + 2:"ur", + 3:"ll", + 6:"uc", + 7:"lc"} layer_status_type = { 0:"OFF", 1:"ON", @@ -236,8 +252,40 @@ getPoints(), setStyle() """ - def __init__(self, mf_symbol): - print "nothing" + def __init__(self, mf_symbol = "newone"): + # create a circle Object like shown in Thuban + # because Thuban don't support other symbols + if mf_symbol == "newone": + mf_symbol = symbolObj("") + newpoint = pointObj() + newpoint.x = 1 + newpoint.y = 1 + newline = lineObj() + newline.add(newpoint) + mf_symbol.setPoints(newline) + + self._symbol = mf_symbol + + def get_symbolObj(self): + return self._symbol + + def get_name(self): + return self._symbol.name + + def set_name(self, new_name): + self._symbol.name = new_name + + def set_type(self, new_type): + # TODO include a function to set the type by a string + self._symbol.type = new_type + + def set_filled(self, new_filled): + if new_filled: + self._symbol.filled = 1 + else: + self._symbol.filled = 0 + + class MF_SymbolSet: """ @@ -252,8 +300,33 @@ # create an extra symbol file and not to include it direct to the # mapfile itself def __init__(self, mf_symbolset): - print "nothing" + self._symbolset = mf_symbolset + + # Initial Symbol List + self._symbols = [] + self._numsymbols = self._symbolset.numsymbols + self._i = 1 + while self._i < self._numsymbols: + self._symbols.append(MF_Symbol(self._symbolset.getSymbol(self._i))) + self._i += 1 +# POINT +# 1 1 +# END + + def add_symbol(self, new_symbol): + self._symbolset.appendSymbol(new_symbol.get_symbolObj()) + self._symbols.append(new_symbol) + # the save function must be run to set the symbols to the + # mapfile. I don't know why this ist so but it must be. + self._symbolset.save("tempsymbol") + os.remove("tempsymbol") + + def get_symbol(self, symbolnr): + if symbolnr < self._numsymbols: + return self._symbols[symbolnr-1] + else: + return None class MF_Class: """ @@ -318,6 +391,18 @@ self._clazz.setExpression(newstring) self._expression = self._clazz.getExpressionString() + def get_status(self): + if self._clazz.status == 1: + return True + else: + return False + + def set_status(self, new_status): + if new_status: + self._clazz.status = 1 + else: + self._clazz.status = 0 + def add_thubanstyle(self, tb_style, type="default"): """ added a thuban style object to the mapobject @@ -341,6 +426,7 @@ new_styleobj.set_color(tb_style.GetFill()) + class MF_Layer: """ The following parameters and functions, which the mapscript style obj @@ -495,8 +581,89 @@ new_class.set_expressionstring('/./') else: new_class.set_expressionstring(str(tb_class.GetValue())) + new_class.set_status(tb_class.IsVisible()) self._classes.append(new_class) +class MF_Scalebar: + """ + The following settings are (not) used: + imagecolor, height, width, style, intervals, label, color, backgroundcolor, + outlinecolor, units, status, position, postlabelcache + """ + def __init__(self, mf_scalebar): + self._scalebar = mf_scalebar + self._color = MF_Color(self._scalebar.color) + self._imagecolor = MF_Color(self._scalebar.imagecolor) + self._label = MF_Label(self._scalebar.label) + + def get_label(self): + return self._label + + def get_color(self): + return self._color + + def get_imagecolor(self): + return self._imagecolor + + def get_style(self): + return self._scalebar.style + + def set_style(self, new_style): + self._scalebar.style = new_style + + def get_size(self): + #returns the size + return (self._scalebar.width, self._scalebar.height) + + def set_size(self, new_width, new_height): + self._scalebar.width = new_width + self._scalebar.height = new_height + + def get_intervals(self): + return self._scalebar.intervals + + def set_intervals(self, new_intervals): + self._scalebar.intervals = new_intervals + + def get_units(self): + #returns the unittype + return unit_type[self._scalebar.units] + + def set_units(self, units): + if unit_type.has_key(units): + self._scalebar.units = units + else: + for unit_paar_nr in unit_type: + if unit_type[unit_paar_nr] == units: + self._scalebar.units = unit_paar_nr + + def get_status(self, art="integer"): + if art == "string": + return scalebar_status_type[self._scalebar.status] + else: + return self._scalebar.status + + def set_status(self, new_status): + if scalebar_status_type.has_key(new_status): + self._scalebar.status = new_status + else: + for scalebar_status_type_nr in scalebar_status_type: + if scalebar_status_type[scalebar_status_type_nr] == new_status: + self._scalebar.status = scalebar_status_type_nr + + def get_position(self, art="integer"): + if art == "string": + return scalebar_position_type[self._scalebar.position] + else: + return self._scalebar.position + + def set_position(self, new_position): + if scalebar_position_type.has_key(new_position): + self._scalebar.position = new_position + else: + for scalebar_position_type_nr in legend_position_type: + if scalebar_position_type[scalebar_position_type_nr] == new_position: + self._scalebar.position = scalebar_position_type_nr class MF_Map: """ @@ -538,6 +705,10 @@ self._imagecolor = MF_Color(self._mf_map.imagecolor) self._web = MF_Web(self._mf_map.web) self._legend = MF_Legend(self._mf_map.legend) + self._scalebar = MF_Scalebar(self._mf_map.scalebar) + + # symbols + self._symbolset = MF_SymbolSet(self._mf_map.symbolset) # if the map name is not set it will return a MS string. if self._mf_map.name != "MS": @@ -573,12 +744,18 @@ self._metadata.add_metadata(self._metafkey,self._metakeydata) self._metafkey = self._mf_map.getNextMetaDataKey(self._metafkey) + def get_symbolset(self): + return self._symbolset + def get_status(self): if layer_status_type[self._mf_map.status] == "OFF": return false else: return true + def get_scalebar(self): + return self._scalebar + def get_web(self): return self._web @@ -659,7 +836,7 @@ Add a thuban layer """ new_layer = MF_Layer(layerObj(self._mf_map)) - new_layer.set_name(tb_layer.Title()) + new_layer.set_name(tb_layer.Title()) # TODO: implement relative pathnames # yet only absolute pathnames in the LayerObj are set @@ -668,6 +845,7 @@ except: new_layer.set_data(tb_layer.GetImageFilename(), type="raster") new_layer.set_type("raster") + new_layer.set_status(tb_layer.Visible()) else: new_layer.set_status(tb_layer.Visible()) new_layer.set_type(tb_layer.ShapeType()) @@ -769,6 +947,21 @@ def get_color(self): return self._color + def get_partials(self): + if self._label.partials == 1: + return True + else: + return False + + def set_partials(self, new_partials): + # if partials = True + if new_partials: + self._label.partials = 1 + elif new_partials == False: + self._label.partials = 0 + else: + print "Boolean exspected" + def get_type(self): return label_font_type[self._label.type] @@ -852,7 +1045,6 @@ for legend_position_type_nr in legend_position_type: if legend_position_type[legend_position_type_nr] == new_position: self._mf_legend.position = legend_position_type_nr - class MF_Projection: """ From cvs at intevation.de Tue Jul 6 16:29:38 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Tue, 6 Jul 2004 16:29:38 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver mf_export.py,1.2,1.3 Message-ID: <20040706142938.64F7F1395E@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver In directory doto:/tmp/cvs-serv4544 Modified Files: mf_export.py Log Message: Added MF_Symbol to import from mapfile. Added a function to create a circle object like the one from thuban if no one exists. Index: mf_export.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mf_export.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- mf_export.py 1 Jul 2004 14:37:29 -0000 1.2 +++ mf_export.py 6 Jul 2004 14:29:36 -0000 1.3 @@ -46,7 +46,7 @@ from Thuban.UI.mainwindow import main_menu # import Map Object for the Mapfile -from mapfile import MF_Map +from mapfile import MF_Map, MF_Symbol # ################################### # @@ -83,6 +83,18 @@ tbextent_to_map(tb_map, map) tblayer_to_map(tb_map, map) +def add_circle_symbol(map): + if map.get_symbolset().get_symbol(1): + return + else: + new_symbol = MF_Symbol() + new_symbol.set_name("circle") + new_symbol.set_type(2) + new_symbol.set_filled(True) + map.get_symbolset().add_symbol(new_symbol) + + + def export_mapfile(context): if hasattr(context.mainwindow.canvas.Map(), "extension_umn_mapobj"): @@ -103,6 +115,9 @@ # set all thuban context to the mapobj thuban_to_map(context, theMap) + #add symbol + add_circle_symbol(theMap) + # save the map with the integrated mapscript saver theMap.save_map(path) From cvs at intevation.de Tue Jul 6 16:30:47 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Tue, 6 Jul 2004 16:30:47 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver mf_handle.py,1.1,1.2 Message-ID: <20040706143047.D4D561395E@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver In directory doto:/tmp/cvs-serv4563 Modified Files: mf_handle.py Log Message: All colors are now set when press ok in the assosiated dialog and not at the end of the colordialog. Added the Dialog for the Scalebar. (Label_Dialog): Added the offset option Index: mf_handle.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mf_handle.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- mf_handle.py 1 Jul 2004 14:35:07 -0000 1.1 +++ mf_handle.py 6 Jul 2004 14:30:45 -0000 1.2 @@ -51,7 +51,8 @@ from Thuban.UI.colordialog import ColorDialog from mapfile import unit_type, legend_status_type, legend_position_type, \ - label_font_type + label_font_type, scalebar_status_type, scalebar_style_type, \ + scalebar_position_type # ################################### # @@ -60,6 +61,7 @@ # ################################### ID_COLOR_CHANGE= 8001 +ID_IMGCOLOR_CHANGE = 8002 class Map_Dialog(wxDialog): @@ -166,8 +168,6 @@ self.bluecolor = int(round(self.retcolor.blue*255)) self.previewcolor.SetBackgroundColour(wxColour((self.redcolor), int(self.greencolor), int(self.bluecolor))) - self.tb_map_umn.get_imagecolor().set_rgbcolor(self.redcolor, - self.greencolor, self.bluecolor) def RunDialog(self): self.ShowModal() @@ -184,6 +184,9 @@ def OnOK(self, event): self.tb_map_umn.set_size(int(self.text_width.GetValue()), int(self.text_height.GetValue())) self.tb_map_umn.set_units(self.choice_units.GetStringSelection()) + previewcolor = self.previewcolor.GetBackgroundColour() + self.tb_map_umn.get_imagecolor().set_rgbcolor(previewcolor.Red(), + previewcolor.Green(), previewcolor.Blue()) self.result ="OK" self.end_dialog(self.result) @@ -357,7 +360,7 @@ box_color.Add(button, 1, wxEXPAND|wxALL, 5) top.Add(box_color,0, wxEXPAND |wxALL, 5) - # create the positionbox + # status umn_legend_status= self.umn_legend.get_status(art="string") possible_choices = [] for key in legend_status_type: @@ -401,6 +404,7 @@ top.Fit(self) def OnChangeLabel(self, event): + self.umn_label = self.umn_legend.get_label() dialog = Label_Dialog(self, -1, "This is a wxDialog", size=wxSize(350, 200), style = wxDEFAULT_DIALOG_STYLE ) @@ -423,8 +427,6 @@ self.bluecolor = int(round(self.retcolor.blue*255)) self.previewcolor.SetBackgroundColour(wxColour((self.redcolor), int(self.greencolor), int(self.bluecolor))) - self.umn_legend.get_imagecolor().set_rgbcolor(self.redcolor, - self.greencolor, self.bluecolor) def RunDialog(self): self.ShowModal() @@ -443,6 +445,9 @@ self.umn_legend.set_keyspacing(self.text_keyspacing_width.GetValue(),self.text_keyspacing_height.GetValue()) self.umn_legend.set_status(self.choice_status.GetStringSelection()) self.umn_legend.set_position(self.choice_position.GetStringSelection()) + previewcolor = self.previewcolor.GetBackgroundColour() + self.umn_legend.get_imagecolor().set_rgbcolor(previewcolor.Red(), + previewcolor.Green(), previewcolor.Blue()) self.result ="OK" self.end_dialog(self.result) @@ -462,8 +467,7 @@ top = wxBoxSizer(wxVERTICAL) # get the web object - #self.tb_map = parent.canvas.Map() - self.umn_label = parent.umn_legend.get_label() + self.umn_label = parent.umn_label # size labelsize= wxStaticBox(self, 1010, _("Size"), style = 0, name = "Size Box", ) @@ -513,7 +517,7 @@ # Offset - offset= wxStaticBox(self, 1010, _("KeySpacing"), style = 0, name = "KeySpacing Box", ) + offset= wxStaticBox(self, 1010, _("Offset"), style = 0, name = "Offset Box", ) box_offset = wxStaticBoxSizer(offset, wxVERTICAL) umn_label_offset = self.umn_label.get_offset() box_offsetX = wxBoxSizer(wxHORIZONTAL) @@ -532,6 +536,14 @@ box_offset.Add(box_offsetY, 0, wxALIGN_RIGHT | wxALL, 2) top.Add(box_offset,0, wxEXPAND |wxALL, 5) + # offset + umn_partials = self.umn_label.get_partials() + self.choice_partials = wxRadioBox(self, -1, choices=["True","False"], + label='partials', majorDimension=1, + name='partials check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS) + self.choice_partials.SetStringSelection(str(umn_partials)) + top.Add(self.choice_partials,0, wxEXPAND |wxALL, 5) + #buttons box_buttons = wxBoxSizer(wxHORIZONTAL) @@ -562,8 +574,6 @@ self.bluecolor = int(round(self.retcolor.blue*255)) self.previewcolor.SetBackgroundColour(wxColour((self.redcolor), int(self.greencolor), int(self.bluecolor))) - self.umn_label.get_color().set_rgbcolor(self.redcolor, - self.greencolor, self.bluecolor) def RunDialog(self): self.ShowModal() @@ -581,12 +591,253 @@ self.umn_label.set_size(self.text_labelsize.GetValue()) self.umn_label.set_offset(self.text_offsetx.GetValue(), self.text_offsety.GetValue()) self.umn_label.set_type(self.choice_type.GetStringSelection()) + if self.choice_partials.GetStringSelection() == "True": + self.umn_label.set_partials(True) + else: + self.umn_label.set_partials(False) + previewcolor = self.previewcolor.GetBackgroundColour() + self.umn_label.get_color().set_rgbcolor(previewcolor.Red(), + previewcolor.Green(), previewcolor.Blue()) self.result ="OK" self.end_dialog(self.result) def OnCancel(self, event): self.end_dialog(None) +class Scalebar_Dialog(wxDialog): + + def __init__(self, parent, ID, title, + pos=wxDefaultPosition, size=wxDefaultSize, + style=wxDEFAULT_DIALOG_STYLE): + + # initialize the Dialog + wxDialog.__init__(self, parent, ID, title, pos, size, style) + + #add all boxes to this top box + top = wxBoxSizer(wxVERTICAL) + + # get the web object + self.tb_map = parent.canvas.Map() + self.umn_scalebar = self.tb_map.extension_umn_mapobj.get_scalebar() + + # color chooser + box_colorStatic = wxStaticBox(self, 1011, _("Color"), style = 0, name = "color") + box_color = wxStaticBoxSizer(box_colorStatic, wxVERTICAL) + # preview box + self.previewcolor = wxPanel(self, 99, name = 'colorPanel', style = wxSIMPLE_BORDER | wxCLIP_CHILDREN) + color = self.umn_scalebar.get_color() + self.previewcolor.SetBackgroundColour(wxColour(color.get_red(), + color.get_green(), color.get_blue())) + box_color.Add(self.previewcolor, 1, wxGROW | wxALL, 5) + # color change button, opens a new color dialog + button = wxButton(self, ID_COLOR_CHANGE, _("Change Color")) + button.SetFocus() + EVT_BUTTON(self, ID_COLOR_CHANGE, self.OnChangeColor) + box_color.Add(button, 1, wxEXPAND|wxALL, 5) + #top.Add(box_color,0, wxEXPAND |wxALL, 5) + # show the two color chooser horizontal + colorHor = wxBoxSizer(wxHORIZONTAL) + colorHor.Add(box_color,0, wxEXPAND |wxALL, 5) + + # imagecolor chooser + box_imgcolorStatic = wxStaticBox(self, 1011, _("Image Color"), style = 0, name = "imgcolor") + box_imgcolor = wxStaticBoxSizer(box_imgcolorStatic, wxVERTICAL) + # preview box + self.previewimgcolor = wxPanel(self, 99, name = 'colorPanel', style = wxSIMPLE_BORDER | wxCLIP_CHILDREN) + color = self.umn_scalebar.get_imagecolor() + self.previewimgcolor.SetBackgroundColour(wxColour(color.get_red(), + color.get_green(), color.get_blue())) + box_imgcolor.Add(self.previewimgcolor, 1, wxGROW | wxALL, 5) + # color change button, opens a new color dialog + button = wxButton(self, ID_IMGCOLOR_CHANGE, _("Change ImageColor")) + button.SetFocus() + EVT_BUTTON(self, ID_IMGCOLOR_CHANGE, self.OnChangeImageColor) + box_imgcolor.Add(button, 1, wxEXPAND|wxALL, 5) + colorHor.Add(box_imgcolor,0, wxEXPAND |wxALL, 5) + #top.Add(box_imgcolor,0, wxEXPAND |wxALL, 5) + top.Add(colorHor,0, wxEXPAND |wxALL, 5) + + # create the intervals + intervalsStatic = wxStaticBox(self, 1010, _("Intervals"), style = 0, name = "Intervals Box", ) + box_intervals = wxStaticBoxSizer(intervalsStatic, wxVERTICAL) + umn_scalebar_intervals = self.umn_scalebar.get_intervals() + self.text_intervals = wxSpinCtrl(self, -1, + value=str(umn_scalebar_intervals), max=100, min=0, + name='intervals', style=wxSP_ARROW_KEYS) + box_intervals.Add(self.text_intervals, 0, wxALIGN_RIGHT | wxALL, 2) + hori2 = wxBoxSizer(wxHORIZONTAL) + hori2.Add(box_intervals,0, wxEXPAND |wxALL, 5) + + #style + umn_scalebar_style= self.umn_scalebar.get_style() + possible_choices = [] + for key in scalebar_style_type: + possible_choices.append(scalebar_style_type[key]) + self.choice_style = wxRadioBox(self, -1, choices=possible_choices, + label='Style', majorDimension=1, + name='style check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS) + self.choice_style.SetSelection(umn_scalebar_style) + hori2.Add(self.choice_style, 1, wxEXPAND|wxALL, 5) + top.Add(hori2, 1, wxEXPAND|wxALL, 5) + + #create size settings + try: + insidetxt = self.umn_scalebar.get_size() + except: + insidetxt = (0,0) + # create the Size Box + staticSize = wxStaticBox(self, -1, _("Size"), style = 0, name = "sizeBox", ) + box_size = wxStaticBoxSizer(staticSize, wxHORIZONTAL) + + box_sizepartWidth = wxBoxSizer(wxHORIZONTAL) + box_sizepartWidth.Add(wxStaticText(self, -1, _("Width: ")), 0, wxALL, 4) + self.text_width = wxTextCtrl(self, -1, str(insidetxt[0])) + box_sizepartWidth.Add(self.text_width, 2, wxALL, 4) + box_size.Add(box_sizepartWidth, 0, wxALIGN_RIGHT | wxALL, 5) + box_sizepartHeight = wxBoxSizer(wxHORIZONTAL) + box_sizepartHeight.Add(wxStaticText(self, -1, _("Height: ")), 0, wxALL, 4) + self.text_height = wxTextCtrl(self, -1, str(insidetxt[1])) + box_sizepartHeight.Add(self.text_height, 2, wxALL, 4) + box_size.Add(box_sizepartHeight, 0, wxALIGN_RIGHT | wxALL, 5) + top.Add(box_size, 1, wxEXPAND|wxALL, 5) + + # status + umn_scalebar_status= self.umn_scalebar.get_status(art="string") + possible_choices = [] + for key in legend_status_type: + possible_choices.append(scalebar_status_type[key]) + self.choice_status = wxRadioBox(self, -1, choices=possible_choices, + label='Status', majorDimension=1, + name='status check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS) + self.choice_status.SetStringSelection(umn_scalebar_status) + top.Add(self.choice_status,0, wxEXPAND |wxALL, 5) + + # position + umn_scalebar_position= self.umn_scalebar.get_position(art="string") + possible_choices = [] + for key in scalebar_position_type: + possible_choices.append(scalebar_position_type[key]) + self.choice_position = wxRadioBox(self, -1, choices=possible_choices, + label='Position', majorDimension=1, + name='position check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS) + self.choice_position.SetStringSelection(umn_scalebar_position) + top.Add(self.choice_position,0, wxEXPAND |wxALL, 5) + + + #get the set unittype + insideunit = self.umn_scalebar .get_units() + #create the Unittype selector + box_unitsStatic = wxStaticBox(self, -1, _("Unit Type"), style = 0, name = "unittype") + box_units = wxStaticBoxSizer(box_unitsStatic, wxVERTICAL) + sam = [] + for key in unit_type: + sam.append(unit_type[key]) + self.choice_units = wxChoice(self, 40, (80, 50), choices = sam) + self.choice_units.SetStringSelection(insideunit) + box_units.Add(self.choice_units,0, wxEXPAND, wxALL, 5) + top.Add(box_units, 1, wxEXPAND|wxALL, 5) + + #test button for label + button = wxButton(self, ID_LABEL_CHANGE, _("Change Label")) + EVT_BUTTON(self, ID_LABEL_CHANGE, self.OnChangeLabel) + top.Add(button, 1, wxEXPAND|wxALL, 5) + + #buttons + box_buttons = wxBoxSizer(wxHORIZONTAL) + button = wxButton(self, wxID_OK, _("OK")) + box_buttons.Add(button, 0, wxALL, 5) + button = wxButton(self, wxID_CANCEL, _("Cancel")) + button.SetFocus() + box_buttons.Add(button, 0, wxALL, 5) + #set the button funcitons + EVT_BUTTON(self, wxID_OK, self.OnOK) + EVT_BUTTON(self, wxID_CANCEL, self.OnCancel) + top.Add(box_buttons, 0, wxALIGN_RIGHT) + + # final layout settings + self.SetSizer(top) + top.Fit(self) + + def OnChangeLabel(self, event): + # set the umn_label for scalebar so the Label_Dialog can be used + self.umn_label = self.umn_scalebar.get_label() + dialog = Label_Dialog(self, -1, "This is a wxDialog", size=wxSize(350, 200), + style = wxDEFAULT_DIALOG_STYLE + ) + dialog.CenterOnScreen() + if dialog.ShowModal() == wxID_OK: + return + dialog.Destroy() + + def OnChangeImageColor(self, event): + cur = self.umn_scalebar.get_imagecolor().get_thubancolor() + dialog = ColorDialog(self) + dialog.SetColor(cur) + self.retcolor = None + if dialog.ShowModal() == wxID_OK: + self.retcolor = dialog.GetColor() + dialog.Destroy() + if self.retcolor: + self.redcolor = int(round(self.retcolor.red*255)) + self.greencolor = int(round(self.retcolor.green*255)) + self.bluecolor = int(round(self.retcolor.blue*255)) + self.previewimgcolor.SetBackgroundColour(wxColour((self.redcolor), + int(self.greencolor), int(self.bluecolor))) + + def OnChangeColor(self, event): + cur = self.umn_scalebar.get_color().get_thubancolor() + dialog = ColorDialog(self) + dialog.SetColor(cur) + self.retcolor = None + if dialog.ShowModal() == wxID_OK: + self.retcolor = dialog.GetColor() + dialog.Destroy() + if self.retcolor: + self.redcolor = int(round(self.retcolor.red*255)) + self.greencolor = int(round(self.retcolor.green*255)) + self.bluecolor = int(round(self.retcolor.blue*255)) + self.previewcolor.SetBackgroundColour(wxColour((self.redcolor), + int(self.greencolor), int(self.bluecolor))) + + def RunDialog(self): + self.ShowModal() + self.Destroy() + + def end_dialog(self, result): + self.result = result + if self.result is not None: + self.EndModal(wxID_OK) + else: + self.EndModal(wxID_CANCEL) + self.Show(False) + + def OnOK(self, event): + self.umn_scalebar.set_status(self.choice_status.GetStringSelection()) + self.umn_scalebar.set_units(self.choice_units.GetStringSelection()) + self.umn_scalebar.set_intervals(self.text_intervals.GetValue()) + self.umn_scalebar.set_style(self.choice_style.GetSelection()) + self.umn_scalebar.set_position(self.choice_position.GetStringSelection()) + self.umn_scalebar.set_size(int(self.text_width.GetValue()), int(self.text_height.GetValue())) + + previewcolor = self.previewcolor.GetBackgroundColour() + self.umn_scalebar.get_color().set_rgbcolor(previewcolor.Red(), + previewcolor.Green(), previewcolor.Blue()) + previewimgcolor = self.previewimgcolor.GetBackgroundColour() + self.umn_scalebar.get_imagecolor().set_rgbcolor(previewimgcolor.Red(), + previewimgcolor.Green(), previewimgcolor.Blue()) + self.result ="OK" + self.end_dialog(self.result) + + def OnCancel(self, event): + self.end_dialog(None) + + +def scalebarsettings(context): + win = Scalebar_Dialog(context.mainwindow, -1, "This is a wxDialog", size=wxSize(350, 200), + style = wxDEFAULT_DIALOG_STYLE + ) + win.CenterOnScreen() + val = win.ShowModal() def mapsettings(context): win = Map_Dialog(context.mainwindow, -1, "This is a wxDialog", size=wxSize(350, 200), @@ -650,5 +901,11 @@ helptext = _("Edit the Legend Setting"))) # finally add the new entry to the extensions menu mapserver_menu.InsertItem("Legend Settings") + +# register the new command (Scalebar Settings Dialog) +registry.Add(Command("Scalebar Settings", _("Scalebar Settings"), scalebarsettings, + helptext = _("Edit the Scalebar Setting"))) +# finally add the new entry to the extensions menu +mapserver_menu.InsertItem("Scalebar Settings") From cvs at intevation.de Tue Jul 6 16:31:30 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Tue, 6 Jul 2004 16:31:30 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver mf_import.py,1.4,1.5 Message-ID: <20040706143130.45A461395E@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver In directory doto:/tmp/cvs-serv4595 Modified Files: mf_import.py Log Message: Added code to import the status of the Classes. Fixed a bug with the projection. Now the to_meter parameter will be added to the Projection only if it doesn't exists. Index: mf_import.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mf_import.py,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- mf_import.py 1 Jul 2004 14:36:37 -0000 1.4 +++ mf_import.py 6 Jul 2004 14:31:28 -0000 1.5 @@ -246,6 +246,7 @@ if clazz_name == None: clazz_name = "" new_group = ClassGroupDefault(props = prop, label = clazz_name) + new_group.SetVisible(map_clazz.get_status()) clazz.SetDefaultGroup(new_group) defaultclazzset = True # break, because alle classes behind the one which definies the @@ -270,9 +271,11 @@ new_group = ClassGroupSingleton(value = theexpression, props = prop, label = clazz_name) + new_group.SetVisible(map_clazz.get_status()) clazz.AppendGroup(new_group) else: new_group = ClassGroupSingleton( props = prop, label = clazz_name) + new_group.SetVisible(map_clazz.get_status()) clazz.AppendGroup(new_group) # if there is no default layer set, @@ -331,11 +334,16 @@ projparams = mapobj.get_projection().get_params() # check if it is an latlong projection, becaues one # more parameter is needed in that case + addtometer = False for param in projparams: projkey = param.split("=") if projkey[0] == "proj": if projkey[1] == "latlong": - projparams.append("to_meter=0.017453") + addtometer = True + if projkey[0] == "to_meter": + addtometer = False + if addtometer == True: + projparams.append("to_meter=0.017453") tb_con.SetProjection(Projection(projparams)) if mapobj.get_projection().get_epsgcode() != None: projepsg = mapobj.get_projection().get_epsgproj() From cvs at intevation.de Tue Jul 6 16:35:18 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Tue, 6 Jul 2004 16:35:18 +0200 (CEST) Subject: jschuengel: thuban ChangeLog,1.663,1.664 Message-ID: <20040706143518.D0F071392D@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv4621 Modified Files: ChangeLog Log Message: update ChangeLog Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.663 retrieving revision 1.664 diff -u -d -r1.663 -r1.664 --- ChangeLog 1 Jul 2004 14:43:26 -0000 1.663 +++ ChangeLog 6 Jul 2004 14:35:16 -0000 1.664 @@ -1,3 +1,31 @@ +2004-07-06 Jan Schüngel + + * Extensions/umn_mapserver/mapfile.py: Added the symbolObj, pointObj + and line Obj and add the scalebar_status_type, scalebar_style_type and + scalebar_position_type. + Added the symbol- and symbolsetObject (MF_Symbol,MF_Symbolset). The + are only used to create a Symbol like the circle in Thuban. + Added the scalebarObject (MF_Scalebar) + (MF_Class): Added set_status and get_status. + (MF_Layer.add_thubanclass): Added code to set the class status + (MF_Map): Added code to handle the symbols and scalebar + (MF_Label): Added the set_partials and get_partials functions + + * Extensions/umn_mapserver/mf_export.py: Added MF_Symbol to import + from mapfile. Added a function to create a circle object like the one + from thuban if no one exists. + + * Extensions/umn_mapserver/mf_handle.py: All colors are now set when + press ok in the assosiated dialog and not at the end of the + colordialog. + Added the Dialog for the Scalebar. + (Label_Dialog): Added the offset option + + * Extensions/umn_mapserver/mf_import.py: Added code to import the + status of the Classes. + Fixed a bug with the projection. Now the to_meter parameter will be + added to the Projection only if it doesn't exists. + 2004-07-01 Jan Schüngel Added the functionality to handle the content thuban is not From bh at intevation.de Tue Jul 6 18:03:52 2004 From: bh at intevation.de (Bernhard Herzog) Date: Tue, 06 Jul 2004 18:03:52 +0200 Subject: jschuengel: thuban/Extensions/umn_mapserver mf_handle.py,1.1,1.2 In-Reply-To: <20040706143047.D4D561395E@lists.intevation.de> (cvs@intevation.de's message of "Tue, 6 Jul 2004 16:30:47 +0200 (CEST)") References: <20040706143047.D4D561395E@lists.intevation.de> Message-ID: cvs at intevation.de writes: > Index: mf_handle.py > =================================================================== > RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mf_handle.py,v > retrieving revision 1.1 > retrieving revision 1.2 > diff -u -d -r1.1 -r1.2 > --- mf_handle.py 1 Jul 2004 14:35:07 -0000 1.1 > +++ mf_handle.py 6 Jul 2004 14:30:45 -0000 1.2 [...] > @@ -443,6 +445,9 @@ > self.umn_legend.set_keyspacing(self.text_keyspacing_width.GetValue(),self.text_keyspacing_height.GetValue()) Please keep lines shorter than 80 characters. > + try: > + insidetxt = self.umn_scalebar.get_size() > + except: > + insidetxt = (0,0) Bare excepts, that is excepts without an explicit exception class, are almost always a bad idea. They often hide errors that will be hard to track down later, especially if -- as in this case -- they're silent, i.e. do not print any information to stdout/stderr or pop up an error dialog. In this particular case I don't see why you would even want to catch an exception. How can self.umn_scalebar.get_size() fail? Bernhard -- Intevation GmbH http://intevation.de/ Skencil http://sketch.sourceforge.net/ Thuban http://thuban.intevation.org/ From bh at intevation.de Tue Jul 6 18:06:41 2004 From: bh at intevation.de (Bernhard Herzog) Date: Tue, 06 Jul 2004 18:06:41 +0200 Subject: Extensions/umn_mapserver/test/test_mapserver.py doesn't run Message-ID: The tests for the umn_mapserver extension are broken: Traceback (most recent call last): File "test_mapserver.py", line 27, in ? from Extensions.umn_mapserver.mapfile import MF_Color, \ ImportError: cannot import name MF_Size MF_Size has been removed some time ago but the tests haven't been updated. Bernhard -- Intevation GmbH http://intevation.de/ Skencil http://sketch.sourceforge.net/ Thuban http://thuban.intevation.org/ From cvs at intevation.de Wed Jul 7 14:51:45 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Wed, 7 Jul 2004 14:51:45 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver mapfile.py,1.4,1.5 Message-ID: <20040707125145.37C90139FE@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver In directory doto:/tmp/cvs-serv26443 Modified Files: mapfile.py Log Message: Added some new settings to edit (outputformat, label, imagetype) Index: mapfile.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mapfile.py,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- mapfile.py 6 Jul 2004 14:28:52 -0000 1.4 +++ mapfile.py 7 Jul 2004 12:51:42 -0000 1.5 @@ -59,11 +59,16 @@ 4:"kilometers", 5:"dd"} +# TODO: generate the list dynamical by alle supported formats. +# At the moment outputformat only get by name. +image_type = ["png","jpeg","wbmp","GTiff"] + legend_status_type = { 0:"OFF", 1:"ON", 3:"embed" } # 2 = Default but will not be imported because # mapscript dont support it and its not allowed + scalebar_status_type = { 0:"OFF", 1:"ON", 3:"embed" } @@ -97,8 +102,19 @@ 3:"large", 4:"giant" } -label_font_type = { 0:"truetype", - 1:"bitmap" } +#TODO: build in truetype (0:"truetype") support +label_font_type = { 1:"bitmap" } + +label_position_type = { 0:"ul", + 1:"lr", + 2:"ur", + 3:"ll", + 4:"cr", + 5:"cl", + 6:"uc", + 7:"lc", + 8:"cc", + 10:"auto"} # ################################################## @@ -241,6 +257,15 @@ # ################################################## # Classes for MapServer Objects as they are # explicitly defined in a mapfile +class MF_Outputformat: + + def __init__(self, mf_outputformat): + self._outputformat = mf_outputformat + + def get_name(self): + return self._outputformat.name + + class MF_Symbol: """ @@ -706,6 +731,7 @@ self._web = MF_Web(self._mf_map.web) self._legend = MF_Legend(self._mf_map.legend) self._scalebar = MF_Scalebar(self._mf_map.scalebar) + self._outputformat = MF_Outputformat(self._mf_map.outputformat) # symbols self._symbolset = MF_SymbolSet(self._mf_map.symbolset) @@ -744,14 +770,29 @@ self._metadata.add_metadata(self._metafkey,self._metakeydata) self._metafkey = self._mf_map.getNextMetaDataKey(self._metafkey) + def get_outputformat(self): + return self._outputformat + + def get_imagetype(self): + return self._mf_map.imagetype + + def set_imagetype(self, new_imagetype): + self._mf_map.setImageType(new_imagetype) + def get_symbolset(self): return self._symbolset def get_status(self): - if layer_status_type[self._mf_map.status] == "OFF": - return false + if self._mf_map.status == 1: + return True else: - return true + return False + + def set_status(self, new_status): + if new_status: + self._mf_map.status = 1 + else: + self._mf_map.status = 0 def get_scalebar(self): return self._scalebar @@ -778,7 +819,7 @@ return self._shapepath # where are the shape files located.. def get_imagetype(self): - return self._imagetype + return self._mf_map.imagetype def get_layerorder(self): # shows the order of layer as list @@ -961,6 +1002,50 @@ self._label.partials = 0 else: print "Boolean exspected" + + def get_buffer(self): + return self._label.buffer + + def set_buffer(self, new_buffer): + self._label.buffer = new_buffer + + def get_mindistance(self): + return self._label.mindistance + + def set_mindistance(self, new_mindistance): + self._label.mindistance = new_mindistance + + def get_minfeaturesize(self): + return self._label.minfeaturesize + + def set_minfeaturesize(self, new_minfeaturesize): + self._label.minfeaturesize = new_minfeaturesize + + def get_position(self, art="integer"): + if art == "string": + return label_position_type[self._label.position] + else: + return self._label.position + + def set_position(self, new_position): + if label_position_type.has_key(new_position): + self._label.position = new_position + else: + for label_position_type_nr in label_position_type: + if label_position_type[label_position_type_nr] == new_position: + self._label.position = label_position_type_nr + + def get_force(self): + if self._label.force == 1: + return True + else: + return False + + def set_force(self, new_force): + if new_force: + self._label.force = 1 + else: + self._label.force = 0 def get_type(self): return label_font_type[self._label.type] From cvs at intevation.de Wed Jul 7 14:52:18 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Wed, 7 Jul 2004 14:52:18 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver mf_handle.py,1.2,1.3 Message-ID: <20040707125218.1A5DE139FE@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver In directory doto:/tmp/cvs-serv26469 Modified Files: mf_handle.py Log Message: Added some setting to the Label Dialog and add the OutputDialog. Make some changes to the code order. Index: mf_handle.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mf_handle.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- mf_handle.py 6 Jul 2004 14:30:45 -0000 1.2 +++ mf_handle.py 7 Jul 2004 12:52:16 -0000 1.3 @@ -52,7 +52,7 @@ from mapfile import unit_type, legend_status_type, legend_position_type, \ label_font_type, scalebar_status_type, scalebar_style_type, \ - scalebar_position_type + scalebar_position_type, label_position_type, image_type # ################################### # @@ -84,11 +84,7 @@ wxALL|wxALIGN_CENTER_VERTICAL, 4) #create size settings - try: - insidetxt = self.tb_map_umn.get_size() - except: - insidetxt = (0,0) - # create the Size Box + insidetxt = self.tb_map_umn.get_size() staticSize = wxStaticBox(self, 1010, _("Size"), style = 0, name = "staticBox", ) box_size = wxStaticBoxSizer(staticSize, wxVERTICAL) @@ -132,6 +128,14 @@ EVT_BUTTON(self, ID_COLOR_CHANGE, self.OnChangeColor) box_color.Add(button, 1, wxEXPAND|wxALL, 5) + # status + umn_status = self.tb_map_umn.get_status() + self.choice_status = wxRadioBox(self, -1, choices=["True","False"], + label='status', majorDimension=1, + name='status check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS) + self.choice_status.SetStringSelection(str(umn_status)) + + #buttons box_buttons = wxBoxSizer(wxHORIZONTAL) button = wxButton(self, wxID_OK, _("OK")) @@ -147,7 +151,8 @@ top.Add(box_name, 0, wxEXPAND |wxALL, 5) top.Add(box_size, 0, wxEXPAND |wxALL, 5) top.Add(box_units,0, wxEXPAND |wxALL, 5) - top.Add(box_color,0, wxEXPAND |wxALL, 5) + top.Add(box_color,0, wxEXPAND |wxALL, 5) + top.Add(self.choice_status,0, wxEXPAND |wxALL, 5) top.Add(box_buttons, 0, wxALIGN_RIGHT) # final layout settings @@ -182,8 +187,13 @@ self.Show(False) def OnOK(self, event): - self.tb_map_umn.set_size(int(self.text_width.GetValue()), int(self.text_height.GetValue())) + self.tb_map_umn.set_size(int(self.text_width.GetValue()), + int(self.text_height.GetValue())) self.tb_map_umn.set_units(self.choice_units.GetStringSelection()) + if self.choice_status.GetStringSelection() == "True": + self.tb_map_umn.set_status(True) + else: + self.tb_map_umn.set_status(False) previewcolor = self.previewcolor.GetBackgroundColour() self.tb_map_umn.get_imagecolor().set_rgbcolor(previewcolor.Red(), previewcolor.Green(), previewcolor.Blue()) @@ -194,8 +204,8 @@ self.end_dialog(None) -class Web_Dialog(wxDialog): - +class OutputFormat_Dialog(wxDialog): + def __init__(self, parent, ID, title, pos=wxDefaultPosition, size=wxDefaultSize, style=wxDEFAULT_DIALOG_STYLE): @@ -203,8 +213,73 @@ # initialize the Dialog wxDialog.__init__(self, parent, ID, title, pos, size, style) - #add all boxes to this top box + # get the web object + self.tb_map = parent.canvas.Map() + self.tb_map_umn = self.tb_map.extension_umn_mapobj + + #get the outputformat + umn_imagetype = self.tb_map_umn.get_imagetype() + #Imagetype selector + box_imagetypeStatic = wxStaticBox(self, -1, _("Image Type"), style = 0, name = "imagetype") + box_imagetype = wxStaticBoxSizer(box_imagetypeStatic, wxVERTICAL) + self.choice_imgtype = wxChoice(self, 8060, (80, 50), choices = image_type) + EVT_CHOICE(self, 8060, self.EvtChoiceBox) + self.choice_imgtype.SetStringSelection(umn_imagetype) + box_imagetype.Add(self.choice_imgtype,0, wxEXPAND, wxALL, 5) + + #buttons + box_buttons = wxBoxSizer(wxHORIZONTAL) + button = wxButton(self, wxID_OK, _("OK")) + box_buttons.Add(button, 0, wxALL, 5) + button = wxButton(self, wxID_CANCEL, _("Cancel")) + box_buttons.Add(button, 0, wxALL, 5) + #set the button funcitons + EVT_BUTTON(self, wxID_OK, self.OnOK) + EVT_BUTTON(self, wxID_CANCEL, self.OnCancel) + + #add all boxes to the box top top = wxBoxSizer(wxVERTICAL) + top.Add(box_imagetype,0, wxEXPAND |wxALL, 5) + top.Add(box_buttons, 0, wxALIGN_RIGHT) + # final layout settings + self.SetSizer(top) + top.Fit(self) + + def EvtChoiceBox(self, event): + print self.choice_imgtype.GetStringSelection() + outformat = self.tb_map_umn.get_outputformat().get_name() + print outformat + + + def RunDialog(self): + self.ShowModal() + self.Destroy() + + def end_dialog(self, result): + self.result = result + if self.result is not None: + self.EndModal(wxID_OK) + else: + self.EndModal(wxID_CANCEL) + self.Show(False) + + def OnOK(self, event): + self.tb_map_umn.set_imagetype(self.choice_imgtype.GetStringSelection()) + self.result ="OK" + self.end_dialog(self.result) + + def OnCancel(self, event): + self.end_dialog(None) + + +class Web_Dialog(wxDialog): + + def __init__(self, parent, ID, title, + pos=wxDefaultPosition, size=wxDefaultSize, + style=wxDEFAULT_DIALOG_STYLE): + + # initialize the Dialog + wxDialog.__init__(self, parent, ID, title, pos, size, style) # get the web object self.tb_map = parent.canvas.Map() @@ -216,7 +291,6 @@ wxALL|wxALIGN_CENTER_VERTICAL, 4) box_name.Add(wxStaticText(self, -1, self.tb_map.Title()), 0, wxALL|wxALIGN_CENTER_VERTICAL, 4) - top.Add(box_name, 0, wxEXPAND |wxALL, 5) # Imagepath box_imagepath = wxBoxSizer(wxHORIZONTAL) @@ -225,7 +299,6 @@ self.text_imagepath = wxTextCtrl(self, -1, str(self.umn_web.get_imagepath())) box_imagepath.Add(self.text_imagepath, 0, wxALL|wxALIGN_CENTER_VERTICAL, 4) - top.Add(box_imagepath, 0, wxEXPAND |wxALL, 5) # Imageurl box_imageurl = wxBoxSizer(wxHORIZONTAL) @@ -234,7 +307,6 @@ self.text_imageurl = wxTextCtrl(self, -1, str(self.umn_web.get_imageurl())) box_imageurl.Add(self.text_imageurl, 0, wxALL|wxALIGN_CENTER_VERTICAL, 4) - top.Add(box_imageurl, 0, wxEXPAND |wxALL, 5) # queryformat # include from a query dialog later @@ -255,7 +327,13 @@ box_buttons.Add(button, 0, wxALL, 5) #set the button funcitons EVT_BUTTON(self, wxID_OK, self.OnOK) - EVT_BUTTON(self, wxID_CANCEL, self.OnCancel) + EVT_BUTTON(self, wxID_CANCEL, self.OnCancel) + + # compose the final dialog + top = wxBoxSizer(wxVERTICAL) + top.Add(box_name, 0, wxEXPAND |wxALL, 5) + top.Add(box_imagepath, 0, wxEXPAND |wxALL, 5) + top.Add(box_imageurl, 0, wxEXPAND |wxALL, 5) top.Add(box_buttons, 0, wxALIGN_RIGHT) # final layout settings @@ -277,7 +355,7 @@ def OnOK(self, event): self.umn_web.set_imagepath(self.text_imagepath.GetValue()) self.umn_web.set_imageurl(self.text_imageurl.GetValue()) - self.umn_web.set_queryformat(self.text_queryformat.GetValue()) + #self.umn_web.set_queryformat(self.text_queryformat.GetValue()) self.result ="OK" self.end_dialog(self.result) @@ -297,9 +375,6 @@ # initialize the Dialog wxDialog.__init__(self, parent, ID, title, pos, size, style) - #add all boxes to this top box - top = wxBoxSizer(wxVERTICAL) - # get the web object self.tb_map = parent.canvas.Map() self.umn_legend = self.tb_map.extension_umn_mapobj.get_legend() @@ -322,7 +397,6 @@ name='keyheight', style=wxSP_ARROW_KEYS) box_sizepartHeight.Add(self.text_keysize_height, 2, wxALL, 2) box_keysize.Add(box_sizepartHeight, 0, wxALIGN_RIGHT | wxALL, 2) - top.Add(box_keysize,0, wxEXPAND |wxALL, 5) # create the Keyspacing keySpacing= wxStaticBox(self, 1010, _("KeySpacing"), style = 0, name = "KeySpacing Box", ) @@ -342,7 +416,6 @@ name='spacingheight', style=wxSP_ARROW_KEYS) box_sizepartHeight.Add(self.text_keyspacing_height, 2, wxALL, 2) box_keyspacing.Add(box_sizepartHeight, 0, wxALIGN_RIGHT | wxALL, 2) - top.Add(box_keyspacing,0, wxEXPAND |wxALL, 5) # color chooser box_colorStatic = wxStaticBox(self, 1011, _("ImageColor"), style = 0, name = "imagecolor") @@ -358,7 +431,6 @@ button.SetFocus() EVT_BUTTON(self, ID_COLOR_CHANGE, self.OnChangeColor) box_color.Add(button, 1, wxEXPAND|wxALL, 5) - top.Add(box_color,0, wxEXPAND |wxALL, 5) # status umn_legend_status= self.umn_legend.get_status(art="string") @@ -369,7 +441,6 @@ label='Status', majorDimension=1, name='status check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS) self.choice_status.SetStringSelection(umn_legend_status) - top.Add(self.choice_status,0, wxEXPAND |wxALL, 5) # create the positionbox umn_legend_position= self.umn_legend.get_position(art="string") @@ -380,13 +451,10 @@ label='Position', majorDimension=1, name='position check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS) self.choice_position.SetStringSelection(umn_legend_position) - top.Add(self.choice_position,0, wxEXPAND |wxALL, 5) - #test button for label - button = wxButton(self, ID_LABEL_CHANGE, _("Change Label")) - button.SetFocus() + # button for label + labelbutton = wxButton(self, ID_LABEL_CHANGE, _("Change Label")) EVT_BUTTON(self, ID_LABEL_CHANGE, self.OnChangeLabel) - top.Add(button, 1, wxEXPAND|wxALL, 5) #buttons box_buttons = wxBoxSizer(wxHORIZONTAL) @@ -397,6 +465,15 @@ #set the button funcitons EVT_BUTTON(self, wxID_OK, self.OnOK) EVT_BUTTON(self, wxID_CANCEL, self.OnCancel) + + # compose the final layout + top = wxBoxSizer(wxVERTICAL) + top.Add(box_keysize,0, wxEXPAND |wxALL, 5) + top.Add(box_keyspacing,0, wxEXPAND |wxALL, 5) + top.Add(box_color,0, wxEXPAND |wxALL, 5) + top.Add(self.choice_status,0, wxEXPAND |wxALL, 5) + top.Add(self.choice_position,0, wxEXPAND |wxALL, 5) + top.Add(labelbutton, 1, wxEXPAND|wxALL, 5) top.Add(box_buttons, 0, wxALIGN_RIGHT) # final layout settings @@ -405,7 +482,7 @@ def OnChangeLabel(self, event): self.umn_label = self.umn_legend.get_label() - dialog = Label_Dialog(self, -1, "This is a wxDialog", size=wxSize(350, 200), + dialog = Label_Dialog(self, -1, "Legend Label Settings", size=wxSize(350, 200), style = wxDEFAULT_DIALOG_STYLE ) dialog.CenterOnScreen() @@ -441,8 +518,10 @@ self.Show(False) def OnOK(self, event): - self.umn_legend.set_keysize(self.text_keysize_width.GetValue(),self.text_keysize_height.GetValue()) - self.umn_legend.set_keyspacing(self.text_keyspacing_width.GetValue(),self.text_keyspacing_height.GetValue()) + self.umn_legend.set_keysize(self.text_keysize_width.GetValue(), + self.text_keysize_height.GetValue()) + self.umn_legend.set_keyspacing(self.text_keyspacing_width.GetValue(), + self.text_keyspacing_height.GetValue()) self.umn_legend.set_status(self.choice_status.GetStringSelection()) self.umn_legend.set_position(self.choice_position.GetStringSelection()) previewcolor = self.previewcolor.GetBackgroundColour() @@ -463,9 +542,6 @@ # initialize the Dialog wxDialog.__init__(self, parent, ID, title, pos, size, style) - #add all boxes to this top box - top = wxBoxSizer(wxVERTICAL) - # get the web object self.umn_label = parent.umn_label @@ -474,14 +550,11 @@ box_labelsize = wxStaticBoxSizer(labelsize, wxVERTICAL) umn_label_size= self.umn_label.get_size() box_size = wxBoxSizer(wxHORIZONTAL) - box_size.Add(wxStaticText(self, -1, _("Size: ")), 0, wxALL, 2) self.text_labelsize = wxSpinCtrl(self, -1, value=str(umn_label_size), max=10, min=0, name='size', style=wxSP_ARROW_KEYS) box_size.Add(self.text_labelsize, 2, wxALL, 2) box_labelsize.Add(box_size, 0, wxALIGN_RIGHT | wxALL, 2) - top.Add(box_labelsize,0, wxEXPAND |wxALL, 5) - # color chooser box_colorStatic = wxStaticBox(self, 1011, _("Color"), style = 0, name = "color") @@ -497,7 +570,6 @@ button.SetFocus() EVT_BUTTON(self, ID_COLOR_CHANGE, self.OnChangeColor) box_color.Add(button, 1, wxEXPAND|wxALL, 5) - top.Add(box_color,0, wxEXPAND |wxALL, 5) #get the set type insidetype = self.umn_label.get_type() @@ -513,9 +585,7 @@ self.choice_type = wxChoice(self, 40, (80, 50), choices = sam) self.choice_type.SetStringSelection(insidetype) box_type.Add(self.choice_type,0, wxEXPAND, wxALL, 5) - top.Add(box_type,0,wxEXPAND |wxALL, 5) - - + # Offset offset= wxStaticBox(self, 1010, _("Offset"), style = 0, name = "Offset Box", ) box_offset = wxStaticBoxSizer(offset, wxVERTICAL) @@ -534,17 +604,68 @@ name='offsetY', style=wxSP_ARROW_KEYS) box_offsetY.Add(self.text_offsety, 2, wxALL, 2) box_offset.Add(box_offsetY, 0, wxALIGN_RIGHT | wxALL, 2) - top.Add(box_offset,0, wxEXPAND |wxALL, 5) - # offset + # partials umn_partials = self.umn_label.get_partials() self.choice_partials = wxRadioBox(self, -1, choices=["True","False"], label='partials', majorDimension=1, name='partials check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS) self.choice_partials.SetStringSelection(str(umn_partials)) - top.Add(self.choice_partials,0, wxEXPAND |wxALL, 5) - + + # force + umn_force = self.umn_label.get_force() + self.choice_force = wxRadioBox(self, -1, choices=["True","False"], + label='force', majorDimension=1, + name='force check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS) + self.choice_force.SetStringSelection(str(umn_force)) + + # buffer + buffer = wxStaticBox(self, 1010, _("Buffer"), style = 0, name = "Buffer Box", ) + box_buffer = wxStaticBoxSizer(buffer, wxVERTICAL) + umn_buffer= self.umn_label.get_buffer() + box_buffertext = wxBoxSizer(wxHORIZONTAL) + self.text_buffer = wxSpinCtrl(self, -1, + value=str(umn_buffer), max=10, min=0, + name='size', style=wxSP_ARROW_KEYS) + box_buffertext.Add(self.text_buffer, 2, wxALL, 2) + box_buffer.Add(box_buffertext, 0, wxALIGN_RIGHT | wxALL, 2) + + # minfeaturesize + minfeaturesize = wxStaticBox(self, 1010, _("Minfeaturesize"), style = 0, + name = "Minfeaturesize Box", ) + box_minfeaturesize = wxStaticBoxSizer(minfeaturesize, wxVERTICAL) + umn_minfeaturesize= self.umn_label.get_minfeaturesize() + box_minfeaturesizetext = wxBoxSizer(wxHORIZONTAL) + self.text_minfeaturesize = wxSpinCtrl(self, -1, + value=str(umn_minfeaturesize), max=10, min=-1, + name='minfeaturesize', style=wxSP_ARROW_KEYS) + box_minfeaturesizetext.Add(self.text_minfeaturesize, 2, wxALL, 2) + box_minfeaturesize.Add(box_minfeaturesizetext, 0, + wxALIGN_RIGHT | wxALL, 2) + + # mindistance + mindistance = wxStaticBox(self, 1010, _("Mindistance"), style = 0, + name = "Mindistance Box", ) + box_mindistance = wxStaticBoxSizer(mindistance, wxVERTICAL) + umn_mindistance= self.umn_label.get_mindistance() + box_mindistancetext = wxBoxSizer(wxHORIZONTAL) + self.text_mindistance = wxSpinCtrl(self, -1, + value=str(umn_mindistance), max=10, min=-1, + name='mindistance', style=wxSP_ARROW_KEYS) + box_mindistancetext.Add(self.text_mindistance, 2, wxALL, 2) + box_mindistance.Add(box_mindistancetext, 0, + wxALIGN_RIGHT | wxALL, 2) + # position + umn_label_position= self.umn_label.get_position(art="string") + possible_choices = [] + for key in label_position_type: + possible_choices.append(label_position_type[key]) + self.choice_position = wxRadioBox(self, -1, choices=possible_choices, + label='Position', majorDimension=1, + name='position check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS) + self.choice_position.SetStringSelection(umn_label_position) + #buttons box_buttons = wxBoxSizer(wxHORIZONTAL) button = wxButton(self, wxID_OK, _("OK")) @@ -554,8 +675,31 @@ #set the button funcitons EVT_BUTTON(self, wxID_OK, self.OnOK) EVT_BUTTON(self, wxID_CANCEL, self.OnCancel) - top.Add(box_buttons, 0, wxALIGN_RIGHT) + # compose the Dialog + top = wxBoxSizer(wxVERTICAL) + + top1 = wxBoxSizer(wxHORIZONTAL) + top1.Add(box_labelsize,0, wxEXPAND |wxALL, 5) + top1.Add(box_color,0, wxEXPAND |wxALL, 5) + top1.Add(box_minfeaturesize,0, wxEXPAND |wxALL, 5) + + top2 = wxBoxSizer(wxHORIZONTAL) + top2.Add(box_type,0,wxEXPAND |wxALL, 5) + top2.Add(box_offset,0, wxEXPAND |wxALL, 5) + top2.Add(box_mindistance,0, wxEXPAND |wxALL, 5) + + top3 = wxBoxSizer(wxHORIZONTAL) + top3.Add(self.choice_partials,0, wxEXPAND |wxALL, 5) + top3.Add(box_buffer,0, wxEXPAND |wxALL, 5) + top3.Add(self.choice_force,0, wxEXPAND |wxALL, 5) + + top.Add(top1, 0, wxEXPAND) + top.Add(top2, 0, wxEXPAND) + top.Add(top3, 0, wxEXPAND) + top.Add(self.choice_position,0, wxEXPAND |wxALL, 5) + top.Add(box_buttons, 0, wxALIGN_RIGHT) + # final layout settings self.SetSizer(top) top.Fit(self) @@ -598,6 +742,14 @@ previewcolor = self.previewcolor.GetBackgroundColour() self.umn_label.get_color().set_rgbcolor(previewcolor.Red(), previewcolor.Green(), previewcolor.Blue()) + self.umn_label.set_mindistance(self.text_mindistance.GetValue()) + self.umn_label.set_minfeaturesize(self.text_minfeaturesize.GetValue()) + self.umn_label.set_position(self.choice_position.GetStringSelection()) + self.umn_label.set_buffer(self.text_buffer.GetValue()) + if self.choice_force.GetStringSelection() == "True": + self.umn_label.set_force(True) + else: + self.umn_label.set_force(False) self.result ="OK" self.end_dialog(self.result) @@ -613,9 +765,6 @@ # initialize the Dialog wxDialog.__init__(self, parent, ID, title, pos, size, style) - #add all boxes to this top box - top = wxBoxSizer(wxVERTICAL) - # get the web object self.tb_map = parent.canvas.Map() self.umn_scalebar = self.tb_map.extension_umn_mapobj.get_scalebar() @@ -634,7 +783,6 @@ button.SetFocus() EVT_BUTTON(self, ID_COLOR_CHANGE, self.OnChangeColor) box_color.Add(button, 1, wxEXPAND|wxALL, 5) - #top.Add(box_color,0, wxEXPAND |wxALL, 5) # show the two color chooser horizontal colorHor = wxBoxSizer(wxHORIZONTAL) colorHor.Add(box_color,0, wxEXPAND |wxALL, 5) @@ -654,8 +802,6 @@ EVT_BUTTON(self, ID_IMGCOLOR_CHANGE, self.OnChangeImageColor) box_imgcolor.Add(button, 1, wxEXPAND|wxALL, 5) colorHor.Add(box_imgcolor,0, wxEXPAND |wxALL, 5) - #top.Add(box_imgcolor,0, wxEXPAND |wxALL, 5) - top.Add(colorHor,0, wxEXPAND |wxALL, 5) # create the intervals intervalsStatic = wxStaticBox(self, 1010, _("Intervals"), style = 0, name = "Intervals Box", ) @@ -678,7 +824,6 @@ name='style check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS) self.choice_style.SetSelection(umn_scalebar_style) hori2.Add(self.choice_style, 1, wxEXPAND|wxALL, 5) - top.Add(hori2, 1, wxEXPAND|wxALL, 5) #create size settings try: @@ -699,7 +844,6 @@ self.text_height = wxTextCtrl(self, -1, str(insidetxt[1])) box_sizepartHeight.Add(self.text_height, 2, wxALL, 4) box_size.Add(box_sizepartHeight, 0, wxALIGN_RIGHT | wxALL, 5) - top.Add(box_size, 1, wxEXPAND|wxALL, 5) # status umn_scalebar_status= self.umn_scalebar.get_status(art="string") @@ -710,7 +854,6 @@ label='Status', majorDimension=1, name='status check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS) self.choice_status.SetStringSelection(umn_scalebar_status) - top.Add(self.choice_status,0, wxEXPAND |wxALL, 5) # position umn_scalebar_position= self.umn_scalebar.get_position(art="string") @@ -721,8 +864,6 @@ label='Position', majorDimension=1, name='position check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS) self.choice_position.SetStringSelection(umn_scalebar_position) - top.Add(self.choice_position,0, wxEXPAND |wxALL, 5) - #get the set unittype insideunit = self.umn_scalebar .get_units() @@ -734,13 +875,11 @@ sam.append(unit_type[key]) self.choice_units = wxChoice(self, 40, (80, 50), choices = sam) self.choice_units.SetStringSelection(insideunit) - box_units.Add(self.choice_units,0, wxEXPAND, wxALL, 5) - top.Add(box_units, 1, wxEXPAND|wxALL, 5) + box_units.Add(self.choice_units,0, wxEXPAND, wxALL, 5) - #test button for label - button = wxButton(self, ID_LABEL_CHANGE, _("Change Label")) + # button for label + labelbutton = wxButton(self, ID_LABEL_CHANGE, _("Change Label")) EVT_BUTTON(self, ID_LABEL_CHANGE, self.OnChangeLabel) - top.Add(button, 1, wxEXPAND|wxALL, 5) #buttons box_buttons = wxBoxSizer(wxHORIZONTAL) @@ -751,7 +890,17 @@ box_buttons.Add(button, 0, wxALL, 5) #set the button funcitons EVT_BUTTON(self, wxID_OK, self.OnOK) - EVT_BUTTON(self, wxID_CANCEL, self.OnCancel) + EVT_BUTTON(self, wxID_CANCEL, self.OnCancel) + + # compose the dialog + top = wxBoxSizer(wxVERTICAL) + top.Add(colorHor,0, wxEXPAND |wxALL, 5) + top.Add(hori2, 1, wxEXPAND|wxALL, 5) + top.Add(box_size, 1, wxEXPAND|wxALL, 5) + top.Add(self.choice_status,0, wxEXPAND |wxALL, 5) + top.Add(self.choice_position,0, wxEXPAND |wxALL, 5) + top.Add(box_units, 1, wxEXPAND|wxALL, 5) + top.Add(labelbutton, 0, wxEXPAND|wxALL, 5) top.Add(box_buttons, 0, wxALIGN_RIGHT) # final layout settings @@ -761,7 +910,7 @@ def OnChangeLabel(self, event): # set the umn_label for scalebar so the Label_Dialog can be used self.umn_label = self.umn_scalebar.get_label() - dialog = Label_Dialog(self, -1, "This is a wxDialog", size=wxSize(350, 200), + dialog = Label_Dialog(self, -1, "Scalbar Label Settings", size=wxSize(350, 200), style = wxDEFAULT_DIALOG_STYLE ) dialog.CenterOnScreen() @@ -833,28 +982,35 @@ def scalebarsettings(context): - win = Scalebar_Dialog(context.mainwindow, -1, "This is a wxDialog", size=wxSize(350, 200), + win = Scalebar_Dialog(context.mainwindow, -1, "Scalebar Settings", size=wxSize(350, 200), style = wxDEFAULT_DIALOG_STYLE ) win.CenterOnScreen() val = win.ShowModal() def mapsettings(context): - win = Map_Dialog(context.mainwindow, -1, "This is a wxDialog", size=wxSize(350, 200), + win = Map_Dialog(context.mainwindow, -1, "Map Settings", size=wxSize(350, 200), style = wxDEFAULT_DIALOG_STYLE ) win.CenterOnScreen() val = win.ShowModal() +def outputformatsettings(context): + win = OutputFormat_Dialog(context.mainwindow, -1, "OutputFormat Settings", + size=wxSize(350, 200), style = wxDEFAULT_DIALOG_STYLE + ) + win.CenterOnScreen() + val = win.ShowModal() + def websettings(context): - win = Web_Dialog(context.mainwindow, -1, "This is a wxDialog", size=wxSize(350, 200), + win = Web_Dialog(context.mainwindow, -1, "Web Settings", size=wxSize(350, 200), style = wxDEFAULT_DIALOG_STYLE ) win.CenterOnScreen() val = win.ShowModal() def legendsettings(context): - win = Legend_Dialog(context.mainwindow, -1, "This is a wxDialog", size=wxSize(350, 200), + win = Legend_Dialog(context.mainwindow, -1, "Legend Settings", size=wxSize(350, 200), style = wxDEFAULT_DIALOG_STYLE ) win.CenterOnScreen() @@ -889,6 +1045,13 @@ helptext = _("Edit the Map Setting"))) # finally add the new entry to the extensions menu mapserver_menu.InsertItem("Map Settings") + +# register the new command (OutputFormat Settings Dialog) +registry.Add(Command("OutputFormat Settings", _("OutputFormat Settings"), + outputformatsettings, + helptext = _("Edit the OutputFormat Setting"))) +# finally add the new entry to the extensions menu +mapserver_menu.InsertItem("OutputFormat Settings") # register the new command (Map Settings Dialog) registry.Add(Command("Web Settings", _("Web Settings"), websettings, From cvs at intevation.de Wed Jul 7 14:53:07 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Wed, 7 Jul 2004 14:53:07 +0200 (CEST) Subject: jschuengel: thuban ChangeLog,1.664,1.665 Message-ID: <20040707125307.D0C2E139FE@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv26499 Modified Files: ChangeLog Log Message: update ChangeLog Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.664 retrieving revision 1.665 diff -u -d -r1.664 -r1.665 --- ChangeLog 6 Jul 2004 14:35:16 -0000 1.664 +++ ChangeLog 7 Jul 2004 12:53:05 -0000 1.665 @@ -1,3 +1,12 @@ +2004-07-07 Jan Schüngel + + * Extensions/umn_mapserver/mapfile.py: Added some new + settings to edit (outputformat, label, imagetype) + + * Extensions/umn_mapserver/mf_handle.py: Added some setting to + the Label Dialog and add the OutputDialog. + Make some changes to the code order. + 2004-07-06 Jan Schüngel * Extensions/umn_mapserver/mapfile.py: Added the symbolObj, pointObj From cvs at intevation.de Thu Jul 8 16:26:58 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Thu, 8 Jul 2004 16:26:58 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver mapfile.py,1.5,1.6 Message-ID: <20040708142658.A979213BCC@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver In directory doto:/tmp/cvs-serv25025 Modified Files: mapfile.py Log Message: Added code to generade and get a list of supported outputformats. This formats are not alle supported because there is no possibility to get the outputformat without the name known. Make some formal changes to the code. (MF_Map.set_name()): Fixed a bug if the name is None. Index: mapfile.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mapfile.py,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- mapfile.py 7 Jul 2004 12:51:42 -0000 1.5 +++ mapfile.py 8 Jul 2004 14:26:56 -0000 1.6 @@ -13,10 +13,15 @@ mapscript are not implemented yet in this extension: DBFInfo, errorObj, fontSetObj, graticuleObj, imageObj, itemObj, - labelCacheMemberObj, labelCacheObj, lineObj, - markerCacheMembet, msTiledSHPLayerInfo, OutputFormat, pointObj, queryMapObj, - referenzMapObj, resultCacheMemberObj, resultCacheObj, scalebarObj, - shapefileObj, shapeObj, VectorObj, WebObj + labelCacheMemberObj, labelCacheObj, + markerCacheMembet, msTiledSHPLayerInfo, queryMapObj, + referenzMapObj, resultCacheMemberObj, resultCacheObj, + shapefileObj, shapeObj, VectorObj + +the following are only used to create a necessary object. They are not +realy created as a MF_Object. + + lineObj, pointObj """ __version__ = "$Revision$" @@ -36,12 +41,14 @@ from mapscript import layerObj, classObj, colorObj, styleObj, rectObj, symbolObj, \ pointObj, lineObj - # ################################### # # Definition of dictionaries # +# the dictonaries are like in mapscript and are used to make it +# easear to unterstand the key from mapscript for the settings +# # ################################### shp_type = { 0:'point', @@ -53,41 +60,35 @@ 6:'query'} unit_type = { 0:"inches", - 1:"feet", - 2:"miles", - 3:"meters", - 4:"kilometers", - 5:"dd"} - -# TODO: generate the list dynamical by alle supported formats. -# At the moment outputformat only get by name. -image_type = ["png","jpeg","wbmp","GTiff"] + 1:"feet", + 2:"miles", + 3:"meters", + 4:"kilometers", + 5:"dd"} legend_status_type = { 0:"OFF", - 1:"ON", - 3:"embed" } - # 2 = Default but will not be imported because - # mapscript dont support it and its not allowed - + 1:"ON", + 3:"embed" } + # 2 = Default but is not allowed here + scalebar_status_type = { 0:"OFF", - 1:"ON", - 3:"embed" } - # 2 = Default but will not be imported because - # mapscript dont support it and its not allowed - + 1:"ON", + 3:"embed" } + # 2 = Default but is not allowed here + scalebar_style_type = { 0:"0", 1:"1" } scalebar_position_type = { 0:"ul", - 1:"lr", - 2:"ur", - 3:"ll", - 6:"uc", - 7:"lc"} + 1:"lr", + 2:"ur", + 3:"ll", + 6:"uc", + 7:"lc"} layer_status_type = { 0:"OFF", - 1:"ON", - 2:"default"} + 1:"ON", + 2:"default"} legend_position_type = { 0:"ul", 1:"lr", @@ -106,15 +107,15 @@ label_font_type = { 1:"bitmap" } label_position_type = { 0:"ul", - 1:"lr", - 2:"ur", - 3:"ll", - 4:"cr", - 5:"cl", - 6:"uc", - 7:"lc", - 8:"cc", - 10:"auto"} + 1:"lr", + 2:"ur", + 3:"ll", + 4:"cr", + 5:"cl", + 6:"uc", + 7:"lc", + 8:"cc", + 10:"auto"} # ################################################## @@ -174,11 +175,12 @@ """ def __init__(self, mf_color): self._color = mf_color - self._tbc_red = (float(self.get_red())/255) self._tbc_green = (float(self.get_green())/255) self._tbc_blue = (float(self.get_blue())/255) - self._thubancolor = Color(self._tbc_red, self._tbc_green, self._tbc_blue) + self._thubancolor = Color(self._tbc_red, + self._tbc_green, + self._tbc_blue) # TODO : Check if it is necessary to use rgb colors alone # or whether it is sufficient to only use the Thuban Color. @@ -201,7 +203,9 @@ self._tbc_red = (float(self.get_red())/255) self._tbc_green = (float(self.get_green())/255) self._tbc_blue = (float(self.get_blue())/255) - self._thubancolor = Color(self._tbc_red, self._tbc_green, self._tbc_blue) + self._thubancolor = Color(self._tbc_red, + self._tbc_green, + self._tbc_blue) def get_mfcolor(self): return self._color @@ -241,7 +245,6 @@ Metadata are not really needed at the moment. """ - def __init__(self): self.data = {} @@ -254,11 +257,23 @@ def add_metadata(self, key, data): self.data[key] = data -# ################################################## +# ################################################ # Classes for MapServer Objects as they are # explicitly defined in a mapfile -class MF_Outputformat: +class MF_Outputformat: + """ + The Outputformat defines which and how the image is + created by the mapserver. + + The following settings are used: + name + + The following settings are not used: + mimetye, driver, extension, renderer, imagemode, transparent, + bands, numfrotmatoptions, formatoptions, refcount, inmapfile + setExtension(), setMimetype(), setOption(), getOption() + """ def __init__(self, mf_outputformat): self._outputformat = mf_outputformat @@ -266,20 +281,25 @@ return self._outputformat.name - class MF_Symbol: """ defines a single symbol which is used in the Symbolset - name, type, sizex, sizey, points, numpoints, filled, stylelength, + the following settings are used: + name, type, + + the following settings are not used: + sizex, sizey, points, numpoints, filled, stylelength, style, imagepath, transparent, transparentcolor, character, antialias, font, gap, position, linecap, linejoin, linejoinmaxsize, setPoints(), getPoints(), setStyle() - """ - + """ def __init__(self, mf_symbol = "newone"): # create a circle Object like shown in Thuban # because Thuban don't support other symbols + + # TODO: include the options to create a symbol, but + # first implement a methode to edit Symbols in Thuban if mf_symbol == "newone": mf_symbol = symbolObj("") newpoint = pointObj() @@ -300,30 +320,35 @@ def set_name(self, new_name): self._symbol.name = new_name + def get_type(self): + return self._symbol.type + def set_type(self, new_type): # TODO include a function to set the type by a string self._symbol.type = new_type + def get_filled(self): + return self._symbol.filled + def set_filled(self, new_filled): if new_filled: self._symbol.filled = 1 else: self._symbol.filled = 0 - - + class MF_SymbolSet: """ defines a set of symbols, may be there can only be one - filename, imagecachesize, numsymbols, symbol, getSymbol(), - getSymbolByName(), index(), appendSymbol(), removeSymbol(), + the following settings are used: + numsymbols, + appendSymbol() + + filename, imagecachesize, symbol, getSymbol(), + getSymbolByName(), index(), removeSymbol(), save() """ - - # TODO: include the symbolset, but found only the possibility to - # create an extra symbol file and not to include it direct to the - # mapfile itself def __init__(self, mf_symbolset): self._symbolset = mf_symbolset @@ -335,15 +360,12 @@ self._symbols.append(MF_Symbol(self._symbolset.getSymbol(self._i))) self._i += 1 -# POINT -# 1 1 -# END - def add_symbol(self, new_symbol): self._symbolset.appendSymbol(new_symbol.get_symbolObj()) self._symbols.append(new_symbol) # the save function must be run to set the symbols to the # mapfile. I don't know why this ist so but it must be. + # the file is empty then an we can delete it self._symbolset.save("tempsymbol") os.remove("tempsymbol") @@ -353,17 +375,17 @@ else: return None + class MF_Class: """ The following parameters and functions, which the mapscript style obj contains, are used: - styles, numstyles, name, + styles, numstyles, name, status, keyimage, layer, getExpressionString(), setExpression(), getMetaData(), getFirstMetaDataKey(), getNextMetaDataKey(), getStyle() The following parameters and functions are not used: - status, label, title, template, type, minscale, maxscale, layer, - debig, keyimage, + label, title, template, type, minscale, maxscale, debug, setExpression(), setText(), setMetaData(), drawLegendIcon(), createLegendIcon(), insertStyle(), removeStyle(), moveStyleUp(), moveStyleDown() @@ -609,11 +631,17 @@ new_class.set_status(tb_class.IsVisible()) self._classes.append(new_class) + class MF_Scalebar: """ + Represent the scalebar for a map + + The following settings are used: + label, color, imagecolor, style, intervals, units, + status, position, height, width + The following settings are (not) used: - imagecolor, height, width, style, intervals, label, color, backgroundcolor, - outlinecolor, units, status, position, postlabelcache + backgroundcolor,outlinecolor, postlabelcache """ def __init__(self, mf_scalebar): self._scalebar = mf_scalebar @@ -662,8 +690,8 @@ if unit_type[unit_paar_nr] == units: self._scalebar.units = unit_paar_nr - def get_status(self, art="integer"): - if art == "string": + def get_status(self, mode="integer"): + if mode == "string": return scalebar_status_type[self._scalebar.status] else: return self._scalebar.status @@ -676,8 +704,8 @@ if scalebar_status_type[scalebar_status_type_nr] == new_status: self._scalebar.status = scalebar_status_type_nr - def get_position(self, art="integer"): - if art == "string": + def get_position(self, mode="integer"): + if mode == "string": return scalebar_position_type[self._scalebar.position] else: return self._scalebar.position @@ -687,9 +715,11 @@ self._scalebar.position = new_position else: for scalebar_position_type_nr in legend_position_type: - if scalebar_position_type[scalebar_position_type_nr] == new_position: + if scalebar_position_type[scalebar_position_type_nr] \ + == new_position: self._scalebar.position = scalebar_position_type_nr + class MF_Map: """ The following parameters and functions, which the mapscript style obj @@ -697,42 +727,56 @@ name, numlayers, extent, shapepath, imagecolor, imagetype, units, getLayer, status, getProjection, getMetaData, getFirstMetaDataKey, getNextMetaDataKey, - save(), setExtent(), height, width, setProjection() + save(), setExtent(), height, width, setProjection(), setImageType(), - The following parameters and functions are not used: maxsize, layers, symbolset, fontset, labelcache, transparent, interlace, imagequality, cellsize, debug, datapattern, templatepattern, configoptions zoomPoint(), zoomRectangle(), zoomScale(), getLayerOrder(), setLayerOrder(), clone(), removeLayer(), getLayerByName(), getSymbolByName(), - prepareQuery(), prepareImage(), setImageType(), setOutputFormat(), draw(), + prepareQuery(), prepareImage(), setOutputFormat(), draw(), drawQuery(), drawLegend(), drawScalebar(), embedLegend(), drawLabelCache(), - nextLabel(), queryByPoint(), queryByRecht(), queryByFeatures(), queryByShape(), - setWKTProjection(), saveQuery(), saveQueryASGML(), - setMetaData(), removeMetaData(), setSymbolSet(), getNumSymbols(), setFontSet(), - saveMapContext(), loadMapContext(), moveLayerUp(), moveLayerDown(), - getLayersDrawingOrder(), setLayersDrawingOrder(), setConfigOption(), - getConfigOption(), applyConfigOptions(), applySLD(), applySLDURL(), gernerateSLD(), - procecssTemplate(), processLegemdTemplate(), processQueryTemplate(), + nextLabel(), queryByPoint(), queryByRecht(), queryByFeatures(), + queryByShape(), setWKTProjection(), saveQuery(), saveQueryASGML(), + setMetaData(), removeMetaData(), setSymbolSet(), getNumSymbols(), + setFontSet(), saveMapContext(), loadMapContext(), moveLayerUp(), + moveLayerDown(), getLayersDrawingOrder(), setLayersDrawingOrder(), + setConfigOption(), getConfigOption(), applyConfigOptions(), applySLD(), + applySLDURL(), gernerateSLD(), procecssTemplate(), processLegemdTemplate(), processQueryTemplate(), getOutputFormatByName(), appendOutputFormat(), removeOutputFormat(), """ - def __init__(self, mf_map): """ Create the map object from the mapfile mapobject which is given. All layers in the mapfile will be written to an array. """ - self._mf_map = mf_map self._extent = MF_Rectangle(self._mf_map.extent) self._imagecolor = MF_Color(self._mf_map.imagecolor) self._web = MF_Web(self._mf_map.web) self._legend = MF_Legend(self._mf_map.legend) self._scalebar = MF_Scalebar(self._mf_map.scalebar) - self._outputformat = MF_Outputformat(self._mf_map.outputformat) + # TODO: generate the list dynamical by alle supported formats. + # At the moment outputformat only get by name, but in a next + # version there may be a function to get the outputformat by id + # then there is no need to define the formattypes here + image_types = ['gif', 'png', 'png24', 'jpeg', 'wbmp', \ + 'swf', 'pdf', 'imagemap'] + self._alloutputformats = [] + self._imagetype = self._mf_map.imagetype + # create a temp imagtype, because the function getOutputFormatByName() + # set the imagetype to the received OutputFormat + for fmtname in image_types: + theformat = self._mf_map.getOutputFormatByName(fmtname) + if theformat: + self._alloutputformats.append(MF_Outputformat(theformat)) + self._mf_map.setImageType(self._imagetype) + + self._outputformat = MF_Outputformat(self._mf_map.outputformat) + # symbols self._symbolset = MF_SymbolSet(self._mf_map.symbolset) @@ -773,6 +817,9 @@ def get_outputformat(self): return self._outputformat + def get_alloutputformats(self): + return self._alloutputformats + def get_imagetype(self): return self._mf_map.imagetype @@ -816,7 +863,8 @@ return self._name def get_shapepath(self): - return self._shapepath # where are the shape files located.. + # where are the shape files located.. + return self._shapepath def get_imagetype(self): return self._mf_map.imagetype @@ -839,7 +887,8 @@ def set_name(self, newname): # whitespace musst be replaced, either no # mapfile will be shown in the mapserver - newname = newname.replace(" ","_") + if newname: + newname = newname.replace(" ","_") self._name = newname self._mf_map.name = newname @@ -847,8 +896,10 @@ # TODO: add the shown extend here instead of the total self._newrect = MF_Rectangle(rectObj()) try: - self._newrect.set_rect(newextent[0],newextent[1],newextent[2],newextent[3]) - self._mf_map.setExtent(newextent[0],newextent[1],newextent[2],newextent[3]) + self._newrect.set_rect(newextent[0],newextent[1], \ + newextent[2],newextent[3]) + self._mf_map.setExtent(newextent[0],newextent[1], \ + newextent[2],newextent[3]) except: return @@ -871,7 +922,10 @@ for unit_paar_nr in unit_type: if unit_type[unit_paar_nr] == units: self._mf_map.units = unit_paar_nr - + + def get_metadata(self): + return self._metadata + def add_thubanlayer(self, tb_layer): """ Add a thuban layer @@ -896,14 +950,20 @@ if tb_layer.GetProjection(): new_layer.set_projection(tb_layer.GetProjection()) if tb_layer.GetClassification().GetNumGroups() > 0: - for group in range(0, tb_layer.GetClassification().GetNumGroups(), 1): - new_layer.add_thubanclass(tb_layer.GetClassification().GetGroup(group)) - new_layer.add_thubanclass(tb_layer.GetClassification().GetDefaultGroup()) + for group in range(0, \ + tb_layer.GetClassification().GetNumGroups(), 1): + new_layer.add_thubanclass( \ + tb_layer.GetClassification().GetGroup(group)) + new_layer.add_thubanclass( \ + tb_layer.GetClassification().GetDefaultGroup()) else: - new_layer.add_thubanclass(tb_layer.GetClassification().GetDefaultGroup(), type="default") + 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, else use the main projection + # if the layer has its own definition use is, + # else use the main projection if tb_layer.GetProjection(): new_layer.set_projection(tb_layer.GetProjection()) else: @@ -926,10 +986,10 @@ Save the Web settings The following parametes are used: - imagepath, imageurl + imagepath, imageurl, queryformat, The following parameters are not used: - log, map, template, queryformat, header, footer, empty, error, extent, + log, map, template, header, footer, empty, error, extent, minscale, maxscale, mintemplate, maxtemplate """ def __init__(self, mf_web): @@ -945,7 +1005,7 @@ return self._mf_web.imageurl def set_imageurl(self, new_imageurl): - self._mf_web.imagepath = new_imageurl + self._mf_web.imageurl = new_imageurl def get_queryformat(self): return self._mf_web.queryformat @@ -957,14 +1017,14 @@ class MF_Label: """ The following parameters from mapscript are used: - type, color, size, offsetx, offsety, + type, color, size, offsetx, offsety, partials, force, buffer, + minfeaturesize, mindistance, The following parameters are not used: - font, outlinecolor, shadowcolor, shadowsizex, shadowsizey, + font, outlinecolor, shadowcolor, shadowsizex, shadowsizey, backgroundcolor, backgroundshadowcolor, backgroundshadowsizex, backgroundshadowsizey, sizescaled, minsize, maxsize, position, angle, - autoangle, buffer, antialias, wrap, minfeaturesize, - autominfeaturesize, mindistance, partials, force + autoangle, antialias, wrap, autominfeaturesize, """ def __init__(self, mf_label): """ @@ -1001,7 +1061,7 @@ elif new_partials == False: self._label.partials = 0 else: - print "Boolean exspected" + print "must be boolean" def get_buffer(self): return self._label.buffer @@ -1021,8 +1081,8 @@ def set_minfeaturesize(self, new_minfeaturesize): self._label.minfeaturesize = new_minfeaturesize - def get_position(self, art="integer"): - if art == "string": + def get_position(self, mode="integer"): + if mode == "string": return label_position_type[self._label.position] else: return self._label.position @@ -1103,8 +1163,8 @@ self._mf_legend.keyspacingx = new_keyspacingx self._mf_legend.keyspacingy = new_keyspacingy - def get_status(self, art="integer"): - if art == "string": + def get_status(self, mode="integer"): + if mode == "string": return legend_status_type[self._mf_legend.status] else: return self._mf_legend.status @@ -1117,8 +1177,8 @@ if legend_status_type[legend_status_type_nr] == new_status: self._mf_legend.status = legend_status_type_nr - def get_position(self, art="integer"): - if art == "string": + def get_position(self, mode="integer"): + if mode == "string": return legend_position_type[self._mf_legend.position] else: return self._mf_legend.position @@ -1128,7 +1188,7 @@ self._mf_legend.position = new_position else: for legend_position_type_nr in legend_position_type: - if legend_position_type[legend_position_type_nr] == new_position: + if legend_position_type[legend_position_type_nr]== new_position: self._mf_legend.position = legend_position_type_nr class MF_Projection: @@ -1167,7 +1227,7 @@ epsg -- EPSG code as string """ #Needed only for this function - from Thuban.Model.resource import get_system_proj_file, EPSG_PROJ_FILE, \ + from Thuban.Model.resource import get_system_proj_file, EPSG_PROJ_FILE,\ EPSG_DEPRECATED_PROJ_FILE proj_file, warnings = get_system_proj_file(EPSG_PROJ_FILE) From cvs at intevation.de Thu Jul 8 16:28:00 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Thu, 8 Jul 2004 16:28:00 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver mf_handle.py,1.3,1.4 Message-ID: <20040708142800.8E77213BCC@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver In directory doto:/tmp/cvs-serv25048 Modified Files: mf_handle.py Log Message: Removed the image_type import statement, because its not needed anymore. The Outputformat is now given as string from the object. Make some formal changes to the code. Index: mf_handle.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mf_handle.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- mf_handle.py 7 Jul 2004 12:52:16 -0000 1.3 +++ mf_handle.py 8 Jul 2004 14:27:58 -0000 1.4 @@ -52,7 +52,7 @@ from mapfile import unit_type, legend_status_type, legend_position_type, \ label_font_type, scalebar_status_type, scalebar_style_type, \ - scalebar_position_type, label_position_type, image_type + scalebar_position_type, label_position_type # ################################### # @@ -85,7 +85,8 @@ #create size settings insidetxt = self.tb_map_umn.get_size() - staticSize = wxStaticBox(self, 1010, _("Size"), style = 0, name = "staticBox", ) + staticSize = wxStaticBox(self, 1010, _("Size"), style = 0, + name = "staticBox", ) box_size = wxStaticBoxSizer(staticSize, wxVERTICAL) box_sizepartWidth = wxBoxSizer(wxHORIZONTAL) @@ -94,16 +95,17 @@ box_sizepartWidth.Add(self.text_width, 2, wxALL, 4) box_size.Add(box_sizepartWidth, 0, wxALIGN_RIGHT | wxALL, 5) box_sizepartHeight = wxBoxSizer(wxHORIZONTAL) - box_sizepartHeight.Add(wxStaticText(self, -1, _("Height: ")), 0, wxALL, 4) + box_sizepartHeight.Add(wxStaticText(self, -1, _("Height: ")), 0, + wxALL, 4) self.text_height = wxTextCtrl(self, -1, str(insidetxt[1])) box_sizepartHeight.Add(self.text_height, 2, wxALL, 4) box_size.Add(box_sizepartHeight, 0, wxALIGN_RIGHT | wxALL, 5) - #get the set unittype + #unittype insideunit = self.tb_map_umn.get_units() - - #create the Unittype selector - box_unitsStatic = wxStaticBox(self, 1011, _("Unit Type"), style = 0, name = "imagecolor") + #Unittype selector + box_unitsStatic = wxStaticBox(self, 1011, _("Unit Type"), + style = 0, name = "imagecolor") box_units = wxStaticBoxSizer(box_unitsStatic, wxVERTICAL) sam = [] for key in unit_type: @@ -113,11 +115,13 @@ box_units.Add(self.choice_units,0, wxEXPAND, wxALL, 5) # color chouser - box_colorStatic = wxStaticBox(self, 1011, _("ImageColor"), style = 0, name = "imagecolor") + box_colorStatic = wxStaticBox(self, 1011, _("ImageColor"), + style = 0, name = "imagecolor") box_color = wxStaticBoxSizer(box_colorStatic, wxVERTICAL) # preview box - self.previewcolor = wxPanel(self,99, name = 'backgroundPanel', style = wxSIMPLE_BORDER | wxCLIP_CHILDREN) + self.previewcolor = wxPanel(self,99, name = 'backgroundPanel', + style = wxSIMPLE_BORDER | wxCLIP_CHILDREN) imagecolor = self.tb_map_umn.get_imagecolor() self.previewcolor.SetBackgroundColour(wxColour(imagecolor.get_red(), imagecolor.get_green(), imagecolor.get_blue())) @@ -135,14 +139,13 @@ name='status check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS) self.choice_status.SetStringSelection(str(umn_status)) - #buttons box_buttons = wxBoxSizer(wxHORIZONTAL) button = wxButton(self, wxID_OK, _("OK")) box_buttons.Add(button, 0, wxALL, 5) button = wxButton(self, wxID_CANCEL, _("Cancel")) box_buttons.Add(button, 0, wxALL, 5) - #set the button funcitons + #button functions EVT_BUTTON(self, wxID_OK, self.OnOK) EVT_BUTTON(self, wxID_CANCEL, self.OnCancel) @@ -217,12 +220,18 @@ self.tb_map = parent.canvas.Map() self.tb_map_umn = self.tb_map.extension_umn_mapobj - #get the outputformat + #get the imagetype umn_imagetype = self.tb_map_umn.get_imagetype() + # create a list with the outputformat names + umn_outputformats = [] + for format in self.tb_map_umn.get_alloutputformats(): + umn_outputformats.append(format.get_name()) #Imagetype selector - box_imagetypeStatic = wxStaticBox(self, -1, _("Image Type"), style = 0, name = "imagetype") + box_imagetypeStatic = wxStaticBox(self, -1, _("Image Type"), + style = 0, name = "imagetype") box_imagetype = wxStaticBoxSizer(box_imagetypeStatic, wxVERTICAL) - self.choice_imgtype = wxChoice(self, 8060, (80, 50), choices = image_type) + self.choice_imgtype = wxChoice(self, 8060, (80, 50), + choices = umn_outputformats) EVT_CHOICE(self, 8060, self.EvtChoiceBox) self.choice_imgtype.SetStringSelection(umn_imagetype) box_imagetype.Add(self.choice_imgtype,0, wxEXPAND, wxALL, 5) @@ -246,10 +255,7 @@ top.Fit(self) def EvtChoiceBox(self, event): - print self.choice_imgtype.GetStringSelection() outformat = self.tb_map_umn.get_outputformat().get_name() - print outformat - def RunDialog(self): self.ShowModal() @@ -296,7 +302,8 @@ box_imagepath = wxBoxSizer(wxHORIZONTAL) box_imagepath.Add(wxStaticText(self, -1, _("Imagepath:")), 0, wxALL|wxALIGN_LEFT, 4) - self.text_imagepath = wxTextCtrl(self, -1, str(self.umn_web.get_imagepath())) + self.text_imagepath = wxTextCtrl(self, -1, + str(self.umn_web.get_imagepath())) box_imagepath.Add(self.text_imagepath, 0, wxALL|wxALIGN_CENTER_VERTICAL, 4) @@ -304,20 +311,10 @@ box_imageurl = wxBoxSizer(wxHORIZONTAL) box_imageurl.Add(wxStaticText(self, -1, _("Imageurl:")), 0, wxALL|wxALIGN_LEFT, 4) - self.text_imageurl = wxTextCtrl(self, -1, str(self.umn_web.get_imageurl())) + self.text_imageurl = wxTextCtrl(self, -1, + str(self.umn_web.get_imageurl())) box_imageurl.Add(self.text_imageurl, 0, wxALL|wxALIGN_CENTER_VERTICAL, 4) - - # queryformat - # include from a query dialog later - """box_queryformat = wxBoxSizer(wxHORIZONTAL) - box_queryformat.Add(wxStaticText(self, -1, _("Queryformat:")), 0, - wxALL|wxALIGN_LEFT, 4) - self.text_queryformat = wxTextCtrl(self, -1, str(self.umn_web.get_queryformat())) - box_queryformat.Add(self.text_queryformat, 0, - wxALL|wxALIGN_CENTER_VERTICAL, 4) - top.Add(box_queryformat, 0, wxEXPAND |wxALL, 5) - """ #buttons box_buttons = wxBoxSizer(wxHORIZONTAL) @@ -355,7 +352,6 @@ def OnOK(self, event): self.umn_web.set_imagepath(self.text_imagepath.GetValue()) self.umn_web.set_imageurl(self.text_imageurl.GetValue()) - #self.umn_web.set_queryformat(self.text_queryformat.GetValue()) self.result ="OK" self.end_dialog(self.result) @@ -363,7 +359,6 @@ self.end_dialog(None) - ID_LABEL_CHANGE = 8011 class Legend_Dialog(wxDialog): @@ -380,7 +375,8 @@ self.umn_legend = self.tb_map.extension_umn_mapobj.get_legend() # create the Keysize - keySize = wxStaticBox(self, 1010, _("KeySize"), style = 0, name = "KeySize Box", ) + keySize = wxStaticBox(self, 1010, _("KeySize"), style = 0, + name = "KeySize Box", ) box_keysize = wxStaticBoxSizer(keySize, wxVERTICAL) umn_legend_keysize = self.umn_legend.get_keysize() box_sizepartWidth = wxBoxSizer(wxHORIZONTAL) @@ -399,29 +395,32 @@ box_keysize.Add(box_sizepartHeight, 0, wxALIGN_RIGHT | wxALL, 2) # create the Keyspacing - keySpacing= wxStaticBox(self, 1010, _("KeySpacing"), style = 0, name = "KeySpacing Box", ) + keySpacing= wxStaticBox(self, 1010, _("KeySpacing"), style = 0, + name = "KeySpacing Box", ) box_keyspacing = wxStaticBoxSizer(keySpacing, wxVERTICAL) umn_legend_keyspacing = self.umn_legend.get_keyspacing() box_sizepartWidth = wxBoxSizer(wxHORIZONTAL) box_sizepartWidth.Add(wxStaticText(self, -1, _("Width: ")), 0, wxALL, 2) self.text_keyspacing_width = wxSpinCtrl(self, -1, - value=str(umn_legend_keyspacing[0]), max=100, min=0, - name='spacingwidth', style=wxSP_ARROW_KEYS) + value=str(umn_legend_keyspacing[0]), max=100, + min=0, name='spacingwidth', style=wxSP_ARROW_KEYS) box_sizepartWidth.Add(self.text_keyspacing_width, 2, wxALL, 2) box_keyspacing.Add(box_sizepartWidth, 0, wxALIGN_RIGHT | wxALL, 2) box_sizepartHeight = wxBoxSizer(wxHORIZONTAL) box_sizepartHeight.Add(wxStaticText(self, -1, _("Height: ")), 0, wxALL, 2), self.text_keyspacing_height = wxSpinCtrl(self, -1, - value=str(umn_legend_keyspacing[1]), max=100, min=0, - name='spacingheight', style=wxSP_ARROW_KEYS) + value=str(umn_legend_keyspacing[1]), max=100, + min=0,name='spacingheight', style=wxSP_ARROW_KEYS) box_sizepartHeight.Add(self.text_keyspacing_height, 2, wxALL, 2) box_keyspacing.Add(box_sizepartHeight, 0, wxALIGN_RIGHT | wxALL, 2) # color chooser - box_colorStatic = wxStaticBox(self, 1011, _("ImageColor"), style = 0, name = "imagecolor") + box_colorStatic = wxStaticBox(self, 1011, _("ImageColor"), style = 0, + name = "imagecolor") box_color = wxStaticBoxSizer(box_colorStatic, wxVERTICAL) # preview box - self.previewcolor = wxPanel(self, 99, name = 'imagecolorPanel', style = wxSIMPLE_BORDER | wxCLIP_CHILDREN) + self.previewcolor = wxPanel(self, 99, name = 'imagecolorPanel', + style = wxSIMPLE_BORDER | wxCLIP_CHILDREN) imagecolor = self.umn_legend.get_imagecolor() self.previewcolor.SetBackgroundColour(wxColour(imagecolor.get_red(), imagecolor.get_green(), imagecolor.get_blue())) @@ -433,7 +432,7 @@ box_color.Add(button, 1, wxEXPAND|wxALL, 5) # status - umn_legend_status= self.umn_legend.get_status(art="string") + umn_legend_status= self.umn_legend.get_status(mode="string") possible_choices = [] for key in legend_status_type: possible_choices.append(legend_status_type[key]) @@ -443,13 +442,15 @@ self.choice_status.SetStringSelection(umn_legend_status) # create the positionbox - umn_legend_position= self.umn_legend.get_position(art="string") + umn_legend_position= self.umn_legend.get_position(mode="string") possible_choices = [] for key in legend_position_type: possible_choices.append(legend_position_type[key]) self.choice_position = wxRadioBox(self, -1, choices=possible_choices, - label='Position', majorDimension=1, - name='position check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS) + label='Position', majorDimension=1, + name='position check', + size=wxDefaultSize, + style=wxRA_SPECIFY_ROWS) self.choice_position.SetStringSelection(umn_legend_position) # button for label @@ -482,7 +483,8 @@ def OnChangeLabel(self, event): self.umn_label = self.umn_legend.get_label() - dialog = Label_Dialog(self, -1, "Legend Label Settings", size=wxSize(350, 200), + dialog = Label_Dialog(self, -1, "Legend Label Settings", + size=wxSize(350, 200), style = wxDEFAULT_DIALOG_STYLE ) dialog.CenterOnScreen() @@ -502,8 +504,9 @@ self.redcolor = int(round(self.retcolor.red*255)) self.greencolor = int(round(self.retcolor.green*255)) self.bluecolor = int(round(self.retcolor.blue*255)) - self.previewcolor.SetBackgroundColour(wxColour((self.redcolor), - int(self.greencolor), int(self.bluecolor))) + self.previewcolor.SetBackgroundColour(wxColour(int(self.redcolor), + int(self.greencolor), + int(self.bluecolor))) def RunDialog(self): self.ShowModal() @@ -546,7 +549,8 @@ self.umn_label = parent.umn_label # size - labelsize= wxStaticBox(self, 1010, _("Size"), style = 0, name = "Size Box", ) + labelsize= wxStaticBox(self, 1010, _("Size"), style = 0, + name = "Size Box", ) box_labelsize = wxStaticBoxSizer(labelsize, wxVERTICAL) umn_label_size= self.umn_label.get_size() box_size = wxBoxSizer(wxHORIZONTAL) @@ -557,10 +561,12 @@ box_labelsize.Add(box_size, 0, wxALIGN_RIGHT | wxALL, 2) # color chooser - box_colorStatic = wxStaticBox(self, 1011, _("Color"), style = 0, name = "color") + box_colorStatic = wxStaticBox(self, 1011, _("Color"), style = 0, + name = "color") box_color = wxStaticBoxSizer(box_colorStatic, wxVERTICAL) # preview box - self.previewcolor = wxPanel(self, 99, name = 'colorPanel', style = wxSIMPLE_BORDER | wxCLIP_CHILDREN) + self.previewcolor = wxPanel(self, 99, name = 'colorPanel', + style = wxSIMPLE_BORDER | wxCLIP_CHILDREN) color = self.umn_label.get_color() self.previewcolor.SetBackgroundColour(wxColour(color.get_red(), color.get_green(), color.get_blue())) @@ -575,7 +581,8 @@ insidetype = self.umn_label.get_type() #create the type selector for fonttype (Bitmap, TrueType) # TODO: Truetype is not supported yet - box_typeStatic = wxStaticBox(self, 1011, _("Type"), style = 0, name = "type") + box_typeStatic = wxStaticBox(self, 1011, _("Type"), style = 0, + name = "type") box_type = wxStaticBoxSizer(box_typeStatic, wxVERTICAL) sam = [] for key in label_font_type: @@ -587,7 +594,8 @@ box_type.Add(self.choice_type,0, wxEXPAND, wxALL, 5) # Offset - offset= wxStaticBox(self, 1010, _("Offset"), style = 0, name = "Offset Box", ) + offset= wxStaticBox(self, 1010, _("Offset"), style = 0, + name = "Offset Box", ) box_offset = wxStaticBoxSizer(offset, wxVERTICAL) umn_label_offset = self.umn_label.get_offset() box_offsetX = wxBoxSizer(wxHORIZONTAL) @@ -608,8 +616,10 @@ # partials umn_partials = self.umn_label.get_partials() self.choice_partials = wxRadioBox(self, -1, choices=["True","False"], - label='partials', majorDimension=1, - name='partials check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS) + label='partials', majorDimension=1, + name='partials check', + size=wxDefaultSize, + style=wxRA_SPECIFY_ROWS) self.choice_partials.SetStringSelection(str(umn_partials)) # force @@ -620,7 +630,8 @@ self.choice_force.SetStringSelection(str(umn_force)) # buffer - buffer = wxStaticBox(self, 1010, _("Buffer"), style = 0, name = "Buffer Box", ) + buffer = wxStaticBox(self, 1010, _("Buffer"), style = 0, + name = "Buffer Box", ) box_buffer = wxStaticBoxSizer(buffer, wxVERTICAL) umn_buffer= self.umn_label.get_buffer() box_buffertext = wxBoxSizer(wxHORIZONTAL) @@ -631,8 +642,8 @@ box_buffer.Add(box_buffertext, 0, wxALIGN_RIGHT | wxALL, 2) # minfeaturesize - minfeaturesize = wxStaticBox(self, 1010, _("Minfeaturesize"), style = 0, - name = "Minfeaturesize Box", ) + minfeaturesize = wxStaticBox(self, 1010, _("Minfeaturesize"), + style = 0, name = "Minfeaturesize Box") box_minfeaturesize = wxStaticBoxSizer(minfeaturesize, wxVERTICAL) umn_minfeaturesize= self.umn_label.get_minfeaturesize() box_minfeaturesizetext = wxBoxSizer(wxHORIZONTAL) @@ -657,13 +668,15 @@ wxALIGN_RIGHT | wxALL, 2) # position - umn_label_position= self.umn_label.get_position(art="string") + umn_label_position= self.umn_label.get_position(mode="string") possible_choices = [] for key in label_position_type: possible_choices.append(label_position_type[key]) self.choice_position = wxRadioBox(self, -1, choices=possible_choices, - label='Position', majorDimension=1, - name='position check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS) + label='Position', majorDimension=1, + name='position check', + size=wxDefaultSize, + style=wxRA_SPECIFY_ROWS) self.choice_position.SetStringSelection(umn_label_position) #buttons @@ -716,8 +729,9 @@ self.redcolor = int(round(self.retcolor.red*255)) self.greencolor = int(round(self.retcolor.green*255)) self.bluecolor = int(round(self.retcolor.blue*255)) - self.previewcolor.SetBackgroundColour(wxColour((self.redcolor), - int(self.greencolor), int(self.bluecolor))) + self.previewcolor.SetBackgroundColour(wxColour(int(self.redcolor), + int(self.greencolor), + int(self.bluecolor))) def RunDialog(self): self.ShowModal() @@ -733,7 +747,8 @@ def OnOK(self, event): self.umn_label.set_size(self.text_labelsize.GetValue()) - self.umn_label.set_offset(self.text_offsetx.GetValue(), self.text_offsety.GetValue()) + self.umn_label.set_offset(self.text_offsetx.GetValue(), + self.text_offsety.GetValue()) self.umn_label.set_type(self.choice_type.GetStringSelection()) if self.choice_partials.GetStringSelection() == "True": self.umn_label.set_partials(True) @@ -770,10 +785,12 @@ self.umn_scalebar = self.tb_map.extension_umn_mapobj.get_scalebar() # color chooser - box_colorStatic = wxStaticBox(self, 1011, _("Color"), style = 0, name = "color") + box_colorStatic = wxStaticBox(self, 1011, _("Color"), style = 0, + name = "color") box_color = wxStaticBoxSizer(box_colorStatic, wxVERTICAL) # preview box - self.previewcolor = wxPanel(self, 99, name = 'colorPanel', style = wxSIMPLE_BORDER | wxCLIP_CHILDREN) + self.previewcolor = wxPanel(self, 99, name = 'colorPanel', + style = wxSIMPLE_BORDER | wxCLIP_CHILDREN) color = self.umn_scalebar.get_color() self.previewcolor.SetBackgroundColour(wxColour(color.get_red(), color.get_green(), color.get_blue())) @@ -788,10 +805,12 @@ colorHor.Add(box_color,0, wxEXPAND |wxALL, 5) # imagecolor chooser - box_imgcolorStatic = wxStaticBox(self, 1011, _("Image Color"), style = 0, name = "imgcolor") + box_imgcolorStatic = wxStaticBox(self, 1011, _("Image Color"), + style = 0, name = "imgcolor") box_imgcolor = wxStaticBoxSizer(box_imgcolorStatic, wxVERTICAL) # preview box - self.previewimgcolor = wxPanel(self, 99, name = 'colorPanel', style = wxSIMPLE_BORDER | wxCLIP_CHILDREN) + self.previewimgcolor = wxPanel(self, 99, name = 'colorPanel', + style = wxSIMPLE_BORDER|wxCLIP_CHILDREN) color = self.umn_scalebar.get_imagecolor() self.previewimgcolor.SetBackgroundColour(wxColour(color.get_red(), color.get_green(), color.get_blue())) @@ -804,7 +823,8 @@ colorHor.Add(box_imgcolor,0, wxEXPAND |wxALL, 5) # create the intervals - intervalsStatic = wxStaticBox(self, 1010, _("Intervals"), style = 0, name = "Intervals Box", ) + intervalsStatic = wxStaticBox(self, 1010, _("Intervals"), style = 0, + name = "Intervals Box", ) box_intervals = wxStaticBoxSizer(intervalsStatic, wxVERTICAL) umn_scalebar_intervals = self.umn_scalebar.get_intervals() self.text_intervals = wxSpinCtrl(self, -1, @@ -831,7 +851,8 @@ except: insidetxt = (0,0) # create the Size Box - staticSize = wxStaticBox(self, -1, _("Size"), style = 0, name = "sizeBox", ) + staticSize = wxStaticBox(self, -1, _("Size"), style = 0, + name="sizeBox") box_size = wxStaticBoxSizer(staticSize, wxHORIZONTAL) box_sizepartWidth = wxBoxSizer(wxHORIZONTAL) @@ -840,13 +861,14 @@ box_sizepartWidth.Add(self.text_width, 2, wxALL, 4) box_size.Add(box_sizepartWidth, 0, wxALIGN_RIGHT | wxALL, 5) box_sizepartHeight = wxBoxSizer(wxHORIZONTAL) - box_sizepartHeight.Add(wxStaticText(self, -1, _("Height: ")), 0, wxALL, 4) + box_sizepartHeight.Add(wxStaticText(self, -1, _("Height: ")), 0, + wxALL, 4) self.text_height = wxTextCtrl(self, -1, str(insidetxt[1])) box_sizepartHeight.Add(self.text_height, 2, wxALL, 4) box_size.Add(box_sizepartHeight, 0, wxALIGN_RIGHT | wxALL, 5) # status - umn_scalebar_status= self.umn_scalebar.get_status(art="string") + umn_scalebar_status= self.umn_scalebar.get_status(mode="string") possible_choices = [] for key in legend_status_type: possible_choices.append(scalebar_status_type[key]) @@ -856,19 +878,21 @@ self.choice_status.SetStringSelection(umn_scalebar_status) # position - umn_scalebar_position= self.umn_scalebar.get_position(art="string") + umn_scalebar_position= self.umn_scalebar.get_position(mode="string") possible_choices = [] for key in scalebar_position_type: possible_choices.append(scalebar_position_type[key]) self.choice_position = wxRadioBox(self, -1, choices=possible_choices, - label='Position', majorDimension=1, - name='position check', size=wxDefaultSize, style=wxRA_SPECIFY_ROWS) + label='Position', majorDimension=1, + name='position check', size=wxDefaultSize, + style=wxRA_SPECIFY_ROWS) self.choice_position.SetStringSelection(umn_scalebar_position) #get the set unittype insideunit = self.umn_scalebar .get_units() #create the Unittype selector - box_unitsStatic = wxStaticBox(self, -1, _("Unit Type"), style = 0, name = "unittype") + box_unitsStatic = wxStaticBox(self, -1, _("Unit Type"), style = 0, + name = "unittype") box_units = wxStaticBoxSizer(box_unitsStatic, wxVERTICAL) sam = [] for key in unit_type: @@ -910,7 +934,8 @@ def OnChangeLabel(self, event): # set the umn_label for scalebar so the Label_Dialog can be used self.umn_label = self.umn_scalebar.get_label() - dialog = Label_Dialog(self, -1, "Scalbar Label Settings", size=wxSize(350, 200), + dialog = Label_Dialog(self, -1, "Scalbar Label Settings", + size=wxSize(350, 200), style = wxDEFAULT_DIALOG_STYLE ) dialog.CenterOnScreen() @@ -930,8 +955,9 @@ self.redcolor = int(round(self.retcolor.red*255)) self.greencolor = int(round(self.retcolor.green*255)) self.bluecolor = int(round(self.retcolor.blue*255)) - self.previewimgcolor.SetBackgroundColour(wxColour((self.redcolor), - int(self.greencolor), int(self.bluecolor))) + self.previewimgcolor.SetBackgroundColour(wxColour(int(self.redcolor), + int(self.greencolor), + int(self.bluecolor))) def OnChangeColor(self, event): cur = self.umn_scalebar.get_color().get_thubancolor() @@ -945,8 +971,9 @@ self.redcolor = int(round(self.retcolor.red*255)) self.greencolor = int(round(self.retcolor.green*255)) self.bluecolor = int(round(self.retcolor.blue*255)) - self.previewcolor.SetBackgroundColour(wxColour((self.redcolor), - int(self.greencolor), int(self.bluecolor))) + self.previewcolor.SetBackgroundColour(wxColour(int(self.redcolor), + int(self.greencolor), + int(self.bluecolor))) def RunDialog(self): self.ShowModal() @@ -966,7 +993,8 @@ self.umn_scalebar.set_intervals(self.text_intervals.GetValue()) self.umn_scalebar.set_style(self.choice_style.GetSelection()) self.umn_scalebar.set_position(self.choice_position.GetStringSelection()) - self.umn_scalebar.set_size(int(self.text_width.GetValue()), int(self.text_height.GetValue())) + self.umn_scalebar.set_size(int(self.text_width.GetValue()), + int(self.text_height.GetValue())) previewcolor = self.previewcolor.GetBackgroundColour() self.umn_scalebar.get_color().set_rgbcolor(previewcolor.Red(), @@ -982,37 +1010,37 @@ def scalebarsettings(context): - win = Scalebar_Dialog(context.mainwindow, -1, "Scalebar Settings", size=wxSize(350, 200), - style = wxDEFAULT_DIALOG_STYLE - ) + win = Scalebar_Dialog(context.mainwindow, -1, "Scalebar Settings", + size=wxSize(350, 200), + style = wxDEFAULT_DIALOG_STYLE) win.CenterOnScreen() val = win.ShowModal() def mapsettings(context): - win = Map_Dialog(context.mainwindow, -1, "Map Settings", size=wxSize(350, 200), - style = wxDEFAULT_DIALOG_STYLE - ) + win = Map_Dialog(context.mainwindow, -1, "Map Settings", + size=wxSize(350, 200), + style = wxDEFAULT_DIALOG_STYLE) win.CenterOnScreen() val = win.ShowModal() def outputformatsettings(context): win = OutputFormat_Dialog(context.mainwindow, -1, "OutputFormat Settings", - size=wxSize(350, 200), style = wxDEFAULT_DIALOG_STYLE - ) + size=wxSize(350, 200), + style = wxDEFAULT_DIALOG_STYLE) win.CenterOnScreen() val = win.ShowModal() def websettings(context): - win = Web_Dialog(context.mainwindow, -1, "Web Settings", size=wxSize(350, 200), - style = wxDEFAULT_DIALOG_STYLE - ) + win = Web_Dialog(context.mainwindow, -1, "Web Settings", + size=wxSize(350, 200), + style = wxDEFAULT_DIALOG_STYLE) win.CenterOnScreen() val = win.ShowModal() def legendsettings(context): - win = Legend_Dialog(context.mainwindow, -1, "Legend Settings", size=wxSize(350, 200), - style = wxDEFAULT_DIALOG_STYLE - ) + win = Legend_Dialog(context.mainwindow, -1, "Legend Settings", + size=wxSize(350, 200), + style = wxDEFAULT_DIALOG_STYLE) win.CenterOnScreen() val = win.ShowModal() @@ -1028,14 +1056,17 @@ # ################################### # find the extensions menu (create it anew if not found) -experimental_menu = main_menu.FindOrInsertMenu("experimental", _("Experimenta&l")) +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")) +mapserver_menu = experimental_menu.FindOrInsertMenu("mapserver", + _("&MapServer")) # register the new command registry.Add(Command("create_new_mapfile", _("Create an empty MapObj"), \ - create_new_mapfile, helptext = _("Create a new empty mapscript MapObj"))) + 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") @@ -1054,19 +1085,22 @@ mapserver_menu.InsertItem("OutputFormat Settings") # register the new command (Map Settings Dialog) -registry.Add(Command("Web Settings", _("Web Settings"), websettings, +registry.Add(Command("Web Settings", _("Web Settings"), + websettings, helptext = _("Edit the Web Setting"))) # finally add the new entry to the extensions menu mapserver_menu.InsertItem("Web Settings") # register the new command (Legend Settings Dialog) -registry.Add(Command("Legend Settings", _("Legend Settings"), legendsettings, +registry.Add(Command("Legend Settings", _("Legend Settings"), + legendsettings, helptext = _("Edit the Legend Setting"))) # finally add the new entry to the extensions menu mapserver_menu.InsertItem("Legend Settings") # register the new command (Scalebar Settings Dialog) -registry.Add(Command("Scalebar Settings", _("Scalebar Settings"), scalebarsettings, +registry.Add(Command("Scalebar Settings", _("Scalebar Settings"), + scalebarsettings, helptext = _("Edit the Scalebar Setting"))) # finally add the new entry to the extensions menu mapserver_menu.InsertItem("Scalebar Settings") From cvs at intevation.de Thu Jul 8 16:29:08 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Thu, 8 Jul 2004 16:29:08 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver/test test.map,1.1,1.2 Message-ID: <20040708142908.E2F0C13BCC@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver/test In directory doto:/tmp/cvs-serv25066/test Modified Files: test.map Log Message: Added a new class to the cultural Layer to test expressions and the the status of that layer from on to default. Changed the data path the the correct Thuban Data Added the Outputformat Object and Symbol Object Index: test.map =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/test/test.map,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- test.map 10 Jun 2004 10:29:00 -0000 1.1 +++ test.map 8 Jul 2004 14:29:06 -0000 1.2 @@ -18,10 +18,28 @@ SIZE 600 450 EXTENT 622877.17 7019306.94 1095667.78 7447709.31 -SHAPEPATH "data" +SHAPEPATH "../../../Data/iceland" IMAGECOLOR 255 255 255 IMAGETYPE PNG + OUTPUTFORMAT + NAME png + MIMETYPE image/png + DRIVER GD/PNG + EXTENSION png + IMAGEMODE PC256 + TRANSPARENT FALSE + END + + SYMBOL + NAME "circle" + TYPE ELLIPSE + FILLED TRUE + POINTS + 1 1 + END + END + PROJECTION proj=utm ellps=WGS84 @@ -31,10 +49,55 @@ #"init=epsg:26915" END +# Scalebarobject +SCALEBAR + COLOR 0 0 0 + IMAGECOLOR 255 255 255 + INTERVALS 4 + LABEL + SIZE MEDIUM + TYPE BITMAP + BUFFER 0 + COLOR 0 0 0 + FORCE FALSE + MINDISTANCE -1 + MINFEATURESIZE -1 + OFFSET 0 0 + PARTIALS TRUE + END + POSITION LL + SIZE 200 3 + STATUS OFF + STYLE 0 + UNITS MILES + END + +# Legend +LEGEND + IMAGECOLOR 255 255 255 + KEYSIZE 20 10 + KEYSPACING 5 5 + LABEL + SIZE MEDIUM + TYPE BITMAP + BUFFER 0 + COLOR 0 0 0 + FORCE FALSE + MINDISTANCE -1 + MINFEATURESIZE -1 + OFFSET 0 0 + PARTIALS TRUE + POSITION CC + END + POSITION LL + STATUS OFF + END + + WEB TEMPLATE iceland.html - # IMAGEPATH "/tmp/" - # IMAGEURL "/tmp/" + IMAGEPATH "/tmpimg/" + IMAGEURL "/tmpurl/" #LOG "/tmp/iceland.log" MINSCALE 100000 MAXSCALE 3000000 @@ -64,7 +127,7 @@ TYPE POLYGON STATUS ON CLASS - NAME "test" + NAME "testclass" STYLE OUTLINECOLOR 0 0 0 COLOR 100 200 100 @@ -99,12 +162,22 @@ NAME "cultural" DATA cultural_landmark-point TYPE POINT - STATUS ON + STATUS default + CLASSITEM 'CLPOINT_' + CLASS + NAME "Punkt 9" + EXPRESSION "9" + STYLE + COLOR 200 200 0 + SYMBOL 'circle' + SIZE 7 + END + END CLASS NAME "test3" STYLE COLOR 200 0 0 - SYMBOL 'circle' + SYMBOL 'circle' SIZE 7 END END From cvs at intevation.de Thu Jul 8 16:29:51 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Thu, 8 Jul 2004 16:29:51 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver/test test_mapserver.py, 1.2, 1.3 Message-ID: <20040708142951.84D5F13BCC@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver/test In directory doto:/tmp/cvs-serv25088/test Modified Files: test_mapserver.py Log Message: Added new test for most of the new setting which were added during the last changes. Removed the MF_Size Test. Index: test_mapserver.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/test/test_mapserver.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- test_mapserver.py 16 Jun 2004 10:52:01 -0000 1.2 +++ test_mapserver.py 8 Jul 2004 14:29:49 -0000 1.3 @@ -23,10 +23,14 @@ # Import necessary classes from Thuban from Thuban.Model.color import Color, Transparent +from Thuban.Model.proj import Projection + # Import the Classes to test from Extensions.umn_mapserver.mapfile import MF_Color, \ - MF_Rectangle, MF_Size, MF_Style, MF_Map, MF_Projection, \ - MF_Class, MF_Layer + MF_Rectangle, MF_Style, MF_Map, MF_Projection, \ + MF_Class, MF_Layer, MF_Metadata, MF_Outputformat, \ + MF_Symbol, MF_SymbolSet, MF_Scalebar, \ + MF_Label, MF_Legend, MF_Web from Extensions.umn_mapserver.mapfile import shp_type @@ -35,141 +39,280 @@ testMap = mapObj(testMapfile) -class mapserver_import_Test_generalClasses(unittest.TestCase): +class mapserver_generalClasses(unittest.TestCase): + + def setUp(self): + """ + Running this funktion befor each test + """ + self.eq = self.assertEquals + def test_MF_Color(self): """ Testing Color Objects from MapServer. """ - eq = self.assertEquals - # IMAGECOLOR 255 255 255 testcolor = MF_Color(testMap.imagecolor) - eq(testcolor.get_red(), 255) - eq(testcolor.get_green(), 255) - eq(testcolor.get_blue(), 255) + self.eq(testcolor.get_red(), 255) + self.eq(testcolor.get_green(), 255) + self.eq(testcolor.get_blue(), 255) # set Color with Thuban color obj testthubancolor = Color(0.5,1,0) testcolor.set_thubancolor(testthubancolor) - eq(testcolor.get_red(),127) - eq(testcolor.get_green(),255) - eq(testcolor.get_blue(),0) + self.eq(testcolor.get_red(),127) + self.eq(testcolor.get_green(),255) + self.eq(testcolor.get_blue(),0) # check if Thubancolor is set correct testtbcolor = testcolor.get_thubancolor() - eq(testtbcolor.red, 0.5) - eq(testtbcolor.green, 1) - eq(testtbcolor.blue, 0) - - + self.eq(testtbcolor.red, 0.5) + self.eq(testtbcolor.green, 1) + self.eq(testtbcolor.blue, 0) + + def test_MF_Rectangle(self): """ Testing rectangle objects by example like the mapfile parameter extent. """ - eq = self.assertEquals - # EXTENT 622877.17 7019306.94 1095667.78 7447709.31 testrect = MF_Rectangle(testMap.extent) - eq(testrect.get_minx(), 622877.17) - eq(testrect.get_miny(), 7019306.94) - eq(testrect.get_maxx(), 1095667.78) - eq(testrect.get_maxy(), 7447709.31) - - def test_MF_Size(self): + self.eq(testrect.get_minx(), 622877.17) + self.eq(testrect.get_miny(), 7019306.94) + self.eq(testrect.get_maxx(), 1095667.78) + self.eq(testrect.get_maxy(), 7447709.31) + + # Set a new Rectangle and test if is set correctly + testrect.set_rect(50,50,200,200) + self.eq(testrect.get_rect(), (50,50,200,200)) + self.eq(testrect.get_minx(), 50) + self.eq(testrect.get_miny(), 50) + self.eq(testrect.get_maxx(), 200) + self.eq(testrect.get_maxy(), 200) + + + def test_MF_Metadata(self): """ - Testing size object by an example parameter. + Testing the meta data """ - eq = self.assertEquals + # set up to keys to test + testmetadata = MF_Metadata() + self.eq(testMap.getMetaData("titel"), "Iceland Test") + testmetadata.add_metadata("test", "test eintrag") + self.eq(testmetadata.get_metadatabykey("test"),"test eintrag") - # SIZE 600 450 - testsize = MF_Size(testMap.width, testMap.height) - eq(testsize.get_width(), 600) - eq(testsize.get_height(), 450) - - # TODO: - #def test_MF_Metadata(self): + # generate the MetaData from the testMap + testMap2 = MF_Map(testMap) + testmetadata = testMap2.get_metadata() + self.eq(testmetadata.get_metadatabykey("titel"),"Iceland Test") -class mapserver_import_Test(unittest.TestCase): - def test_MF_Class(self): +class mapserver_Classes(unittest.TestCase): + + def setUp(self): """ - Testing the class object. + Running this funktion befor each test """ + self.eq = self.assertEquals + + + def test_MF_OutputFormat(self): + """ + Testing the outputformat object + """ + testoutputformat = MF_Outputformat(testMap.getOutputFormatByName("png")) + self.eq(testoutputformat.get_name(),"png") + + + def test_MF_Symbolset(self): + """ + Testing the symbolset + """ + testsymbolset = MF_SymbolSet(testMap.symbolset) + self.eq(testsymbolset.get_symbol(1).get_name(), "circle") + + + def test_MF_Symbol(self): + """ + Testing the symbol object + """ + testsymbol = MF_Symbol(testMap.symbolset.getSymbolByName("circle")) + self.eq(testsymbol.get_name(), "circle") + assert(testsymbol.get_symbolObj(), testMap.symbolset.getSymbolByName("circle")) - eq = self.assertEquals + testsymbol.set_filled(True) + self.eq(testsymbol.get_filled(), True) + testsymbol.set_type(4) + self.eq(testsymbol.get_type(), 4) + + + def test_MF_Class(self): + """ + Testing the class object. + """ # only test the number of styles at the moment testclass = MF_Class(testMap.getLayer(0).getClass(0)) - eq (len(testclass.get_styles()), testMap.getLayer(0).getClass(0).numstyles) - - + self.eq (len(testclass.get_styles()), testMap.getLayer(0).getClass(0).numstyles) + + # check the name + self.eq(testclass.get_name(), "testclass") + testclass.set_name("checkout") + self.eq(testclass.get_name(), "checkout") + + # check the expressionstring + testclass = MF_Class(testMap.getLayer(2).getClass(0)) + self.eq(testclass.get_expressionstring(), '"9"') + testclass.set_expressionstring("3") + self.eq(testclass.get_expressionstring(), '"3"') + + def test_MF_Layer(self): """ Testing the layer object with some sample data and classes. """ - - eq = self.assertEquals - - testlayer = MF_Layer(testMap.getLayer(0)) + testlayer = MF_Layer(testMap.getLayer(2)) # NAME 'political' only from layer 1 - eq(testlayer.get_name(), 'political') + self.eq(testlayer.get_name(), 'cultural') + testlayer.set_name('checkout') + self.eq(testlayer.get_name(), 'checkout') # check number of classes - eq(len(testlayer.get_classes()), testMap.getLayer(0).numclasses) + self.eq(len(testlayer.get_classes()), testMap.getLayer(2).numclasses) + # check classitem + self.eq(testlayer.get_classitem(), "CLPOINT_") + testlayer.set_classitem("CLCHECK") + self.eq(testlayer.get_classitem(), "CLCHECK") + # check data + self.eq(testlayer.get_data(), "cultural_landmark-point") + testlayer.set_data("test.shp") + # .shp will be cutted becouse the source is always a .shp, + # or maybe a grafik + self.eq(testlayer.get_data(), "test") + # check projection (used the pojection obj a little bit) + self.eq(testlayer.get_projection().get_projection(), "+proj=latlong+ellps=clrk66") # TYPE POLYGON - eq(testlayer.get_type(), 'polygon') - - + self.eq(testlayer.get_type(), "point") + testlayer.set_type("circle") + self.eq(testlayer.get_type(), "circle") + # Check status + # 0 = off, 1 = on, 2 = default + self.eq(testlayer.get_status(), True) + testlayer.set_status(False) + self.eq(testlayer.get_status(), False) + + def test_MF_Map(self): """ Testing the mapfile object with samples. """ - eq = self.assertEquals - testmap = MF_Map(testMap) # NAME 'ISLAND' - eq(testmap.get_name(), 'ISLAND') - eq(len(testmap.get_layers()), testMap.numlayers) + self.eq(testmap.get_name(), 'ISLAND') + self.eq(len(testmap.get_layers()), testMap.numlayers) + + testmapfile = mapObj("") + newtestmap = MF_Map(testmapfile) + # proj=utm + # ellps=clrk66 + # zone=26 + # north + # test see in test_MF_Projection + testproj = Projection(['proj=utm', 'ellps=clrk66', 'zone=26', 'north']) + newtestmap.set_projection(testproj) + self.eq(testmapfile.getProjection(), "+proj=utm+ellps=clrk66+zone=26+north") + self.eq(newtestmap.get_projection().get_params(), ['proj=utm', 'ellps=clrk66', 'zone=26', 'north']) - + self.eq(testmap.get_size(), (600,450)) + testmap.set_size(500,600) + self.eq(testmap.get_size(), (500,600)) + + + def test_MF_Scalebar(self): + """ + Test the Scalebarobj from the testfile + """ + testscalebar = MF_Scalebar(testMap.scalebar) + self.eq(testscalebar.get_position(mode="string"),"ll") + self.eq(testscalebar.get_position(), 3) + self.eq(testscalebar.get_intervals(), 4) + self.eq(testscalebar.get_status(mode="string"), "OFF") + + + def test_MF_Label(self): + """ + Test a Label object. In this test use the Label from + from the Scalebarobj in the testfile + """ + testlabel = MF_Label(testMap.scalebar.label) + self.eq(testlabel.get_force(), False) + self.eq(testlabel.get_buffer(),0) + self.eq(testlabel.get_type(), "bitmap") + + + def test_MF_Legend(self): + """ + test the legend object from the testfile + """ + testlegend = MF_Legend(testMap.legend) + self.eq(testlegend.get_status(), False) + testlegend.set_status(True) + self.eq(testlegend.get_status(), True) + testlegend.set_position("ul") + self.eq(testlegend.get_position(mode="string"), "ul") + testlegend.set_keyspacing(4,5) + self.eq(testlegend.get_keyspacing(), (4,5)) + testlegend.set_keysize(6,7) + self.eq(testlegend.get_keysize(), (6,7)) + + def test_MF_Projection(self): """ Projection object is tested with parameters and an epsg code. """ - eq = self.assertEquals - # proj=utm # ellps=clrk66 # zone=26 # north testproj = MF_Projection(testMap.getProjection()) if testproj.get_params(): - eq(testproj.get_params(), ['proj=utm','ellps=WGS84','zone=26','north']) + self.eq(testproj.get_params(), ['proj=utm','ellps=WGS84','zone=26','north']) #"init=epsg:26915" if testproj.get_epsgcode(): - eq(testproj.get_epsgcode(), '26915') + self.eq(testproj.get_epsgcode(), '26915') def test_MF_Style(self): """ Tests a style object with all parameters. """ - eq = self.assertEquals - teststyle = MF_Style(testMap.getLayer(0).getClass(0).getStyle(0)) # OUTLINECOLOR 0 0 0 - eq(teststyle.get_outlinecolor().get_red(), 0) + self.eq(teststyle.get_outlinecolor().get_red(), 0) # COLOR 100 200 100 - eq(teststyle.get_color().get_red(), 100) - eq(teststyle.get_color().get_green(), 200) - eq(teststyle.get_color().get_blue(), 100) + self.eq(teststyle.get_color().get_red(), 100) + self.eq(teststyle.get_color().get_green(), 200) + self.eq(teststyle.get_color().get_blue(), 100) # SIZE 2 - eq(teststyle.get_size(), 2) + self.eq(teststyle.get_size(), 2) + + + def test_MF_Web(self): + """ + Tests a web object + """ + testweb = MF_Web(testMap.web) + self.eq(testweb.get_imagepath(), "/tmpimg/") + testweb.set_imagepath("/tmppathset/") + self.eq(testweb.get_imagepath(), "/tmppathset/") + self.eq(testweb.get_imageurl(),"/tmpurl/") + testweb.set_imageurl("/tmpurlset/") + self.eq(testweb.get_imageurl(), "/tmpurlset/") + - if __name__ == '__main__': unittest.main() From cvs at intevation.de Thu Jul 8 16:30:55 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Thu, 8 Jul 2004 16:30:55 +0200 (CEST) Subject: jschuengel: thuban ChangeLog,1.665,1.666 Message-ID: <20040708143055.CF80B13BCC@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv25109 Modified Files: ChangeLog Log Message: update ChangeLog Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.665 retrieving revision 1.666 diff -u -d -r1.665 -r1.666 --- ChangeLog 7 Jul 2004 12:53:05 -0000 1.665 +++ ChangeLog 8 Jul 2004 14:30:53 -0000 1.666 @@ -1,3 +1,25 @@ +2004-07-08 Jan Schüngel + + * Extensions/umn_mapserver/mapfile.py: Added code to generade and get + a list of supported outputformats. This formats are not alle supported + because there is no possibility to get the outputformat without the + name known. Make some formal changes to the code. + (MF_Map.set_name()): Fixed a bug if the name is None. + + * Extensions/umn_mapserver/mf_handle.py: Removed the image_type import + statement, because its not needed anymore. The Outputformat is now + given as string from the object. Make some formal changes to the code. + + * Extensions/umn_mapserver/test/test_mapserver.py: Added new test for + most of the new setting which were added during the last changes. + Removed the MF_Size Test. + + * Extensions/umn_mapserver/test/test.map: Added a new class to the + cultural Layer to test expressions and the the status of that layer + from on to default. + Changed the data path the the correct Thuban Data + Added the Outputformat Object and Symbol Object + 2004-07-07 Jan Schüngel * Extensions/umn_mapserver/mapfile.py: Added some new From cvs at intevation.de Tue Jul 13 13:07:47 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Tue, 13 Jul 2004 13:07:47 +0200 (CEST) Subject: bh: thuban/Thuban/UI baserenderer.py,1.10,1.11 Message-ID: <20040713110747.9EDC313954@lists.intevation.de> Author: bh Update of /thubanrepository/thuban/Thuban/UI In directory doto:/tmp/cvs-serv23741/Thuban/UI Modified Files: baserenderer.py Log Message: (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 The a strange messages about not being able to draw Layer instances for all vector layers below a raster layer which 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.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- baserenderer.py 28 May 2004 17:29:30 -0000 1.10 +++ baserenderer.py 13 Jul 2004 11:07:45 -0000 1.11 @@ -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 Tue Jul 13 13:07:48 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Tue, 13 Jul 2004 13:07:48 +0200 (CEST) Subject: bh: thuban ChangeLog,1.666,1.667 Message-ID: <20040713110748.D6FD7139D2@lists.intevation.de> Author: bh Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv23741 Modified Files: ChangeLog Log Message: (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 The a strange messages about not being able to draw Layer instances for all vector layers below a raster layer which would be invisible anyway because the raster layer currently always covers the entire window Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.666 retrieving revision 1.667 diff -u -d -r1.666 -r1.667 --- ChangeLog 8 Jul 2004 14:30:53 -0000 1.666 +++ ChangeLog 13 Jul 2004 11:07:45 -0000 1.667 @@ -1,3 +1,14 @@ +2004-07-13 Bernhard Herzog + + * Thuban/UI/baserenderer.py + (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 The a + strange messages about not being able to draw Layer instances for + all vector layers below a raster layer which would be invisible + anyway because the raster layer currently always covers the entire + window + 2004-07-08 Jan Schüngel * Extensions/umn_mapserver/mapfile.py: Added code to generade and get From joey at infodrom.org Tue Jul 13 16:18:46 2004 From: joey at infodrom.org (Martin Schulze) Date: Tue, 13 Jul 2004 16:18:46 +0200 Subject: [Thuban-devel] Re: RfD: Support for layer specific resources In-Reply-To: References: <20040519144813.GX716@finlandia.infodrom.north.de> <20040524162641.GQ716@finlandia.infodrom.north.de> <20040530162635.GA20524@finlandia.infodrom.north.de> <20040609153905.GJ1019@finlandia.infodrom.north.de> <20040615190159.GT1019@finlandia.infodrom.north.de> Message-ID: <20040713141846.GA9814@finlandia.infodrom.north.de> Hi Bernhard! Hope you and the team had enjoyed LinuxTag and you're all fine back. Bernhard Herzog wrote: > > Are you looking for something like this? > > > > class foo: > > def __init__(self): > > _mapping = [] > > > > def register_class_dialog(self, class, dlg_class): > > _mapping.append((class, dlg_class)) > > > > def get_dialog_class(self, instance): > > return proper_class > > > > def has_dialoc_class(self, instance): > > return true or false > > Yes. Although the names shouldn't be specific to dialogs. The class > should be usable for the renderes too. Looks like you could want the following? class Mapping: "Implements a mapping of class pairs def __init__(self): _mapping = [] def register_class(self, key_class, client_class): _mapping.append((key_class, client_class)) def get_class(self, instance): for key_class, client_class in _mapping: if isinstance(instance, key_class): return client_class return None def has_dialog_class(self, instance): if self.get_class(instance) is not None: return true return false The code is not yet tested, though. Regards, Joey -- If nothing changes, everything will remain the same. -- Barne's Law From joey at infodrom.org Tue Jul 13 16:29:01 2004 From: joey at infodrom.org (Martin Schulze) Date: Tue, 13 Jul 2004 16:29:01 +0200 Subject: [Thuban-devel] Re: RfD: Support for layer specific resources In-Reply-To: <20040713141846.GA9814@finlandia.infodrom.north.de> References: <20040524162641.GQ716@finlandia.infodrom.north.de> <20040530162635.GA20524@finlandia.infodrom.north.de> <20040609153905.GJ1019@finlandia.infodrom.north.de> <20040615190159.GT1019@finlandia.infodrom.north.de> <20040713141846.GA9814@finlandia.infodrom.north.de> Message-ID: <20040713142901.GA13410@finlandia.infodrom.north.de> Martin Schulze wrote: > Hi Bernhard! > > Hope you and the team had enjoyed LinuxTag and you're all fine back. > > Bernhard Herzog wrote: > > > Are you looking for something like this? > > > > > > class foo: > > > def __init__(self): > > > _mapping = [] > > > > > > def register_class_dialog(self, class, dlg_class): > > > _mapping.append((class, dlg_class)) > > > > > > def get_dialog_class(self, instance): > > > return proper_class > > > > > > def has_dialoc_class(self, instance): > > > return true or false > > > > Yes. Although the names shouldn't be specific to dialogs. The class > > should be usable for the renderes too. > > Looks like you could want the following? > > class Mapping: > "Implements a mapping of class pairs > > def __init__(self): > _mapping = [] > > def register_class(self, key_class, client_class): > _mapping.append((key_class, client_class)) > > def get_class(self, instance): > for key_class, client_class in _mapping: > if isinstance(instance, key_class): > return client_class > return None > > def has_dialog_class(self, instance): Make that has_class_mapping() instead. > if self.get_class(instance) is not None: > return true > return false > > > The code is not yet tested, though. Regards, Joey -- If nothing changes, everything will remain the same. -- Barne's Law From joey at infodrom.org Tue Jul 13 17:01:22 2004 From: joey at infodrom.org (Martin Schulze) Date: Tue, 13 Jul 2004 17:01:22 +0200 Subject: [Thuban-devel] Re: RfD: Support for layer specific resources In-Reply-To: <20040713142901.GA13410@finlandia.infodrom.north.de> References: <20040524162641.GQ716@finlandia.infodrom.north.de> <20040530162635.GA20524@finlandia.infodrom.north.de> <20040609153905.GJ1019@finlandia.infodrom.north.de> <20040615190159.GT1019@finlandia.infodrom.north.de> <20040713141846.GA9814@finlandia.infodrom.north.de> <20040713142901.GA13410@finlandia.infodrom.north.de> Message-ID: <20040713150122.GR4134@finlandia.infodrom.north.de> Sorry for the flood of mails. Attached please find the test case and the real implementation for the Mapping class. Hope this is what you want. Regards, Joey -- If nothing changes, everything will remain the same. -- Barne's Law -------------- next part -------------- A non-text attachment was scrubbed... Name: mapping.py Type: text/x-python Size: 529 bytes Desc: not available Url : http://www.intevation.de/pipermail/thuban-devel/attachments/20040713/36f72d23/mapping.py -------------- next part -------------- A non-text attachment was scrubbed... Name: test_mapping.py Type: text/x-python Size: 1058 bytes Desc: not available Url : http://www.intevation.de/pipermail/thuban-devel/attachments/20040713/36f72d23/test_mapping.py From cvs at intevation.de Wed Jul 14 12:32:31 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Wed, 14 Jul 2004 12:32:31 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver/test test_mapserver.py, 1.3, 1.4 Message-ID: <20040714103231.8FCE61393B@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver/test In directory doto:/tmp/cvs-serv9151/test Modified Files: test_mapserver.py Log Message: Moved the testMap definition from global to the setUp function. Now the testMap will initialize new on each test. Index: test_mapserver.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/test/test_mapserver.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- test_mapserver.py 8 Jul 2004 14:29:49 -0000 1.3 +++ test_mapserver.py 14 Jul 2004 10:32:29 -0000 1.4 @@ -34,17 +34,15 @@ from Extensions.umn_mapserver.mapfile import shp_type -# using the sample map -testMapfile = 'test.map' -testMap = mapObj(testMapfile) - - class mapserver_generalClasses(unittest.TestCase): def setUp(self): """ Running this funktion befor each test """ + # using the sample map + testMapfile = 'test.map' + self.testMap = mapObj(testMapfile) self.eq = self.assertEquals @@ -53,7 +51,7 @@ Testing Color Objects from MapServer. """ # IMAGECOLOR 255 255 255 - testcolor = MF_Color(testMap.imagecolor) + testcolor = MF_Color(self.testMap.imagecolor) self.eq(testcolor.get_red(), 255) self.eq(testcolor.get_green(), 255) self.eq(testcolor.get_blue(), 255) @@ -78,7 +76,7 @@ the mapfile parameter extent. """ # EXTENT 622877.17 7019306.94 1095667.78 7447709.31 - testrect = MF_Rectangle(testMap.extent) + testrect = MF_Rectangle(self.testMap.extent) self.eq(testrect.get_minx(), 622877.17) self.eq(testrect.get_miny(), 7019306.94) self.eq(testrect.get_maxx(), 1095667.78) @@ -99,12 +97,12 @@ """ # set up to keys to test testmetadata = MF_Metadata() - self.eq(testMap.getMetaData("titel"), "Iceland Test") + self.eq(self.testMap.getMetaData("titel"), "Iceland Test") testmetadata.add_metadata("test", "test eintrag") self.eq(testmetadata.get_metadatabykey("test"),"test eintrag") # generate the MetaData from the testMap - testMap2 = MF_Map(testMap) + testMap2 = MF_Map(self.testMap) testmetadata = testMap2.get_metadata() self.eq(testmetadata.get_metadatabykey("titel"),"Iceland Test") @@ -115,6 +113,9 @@ """ Running this funktion befor each test """ + # using the sample map + testMapfile = 'test.map' + self.testMap = mapObj(testMapfile) self.eq = self.assertEquals @@ -122,7 +123,7 @@ """ Testing the outputformat object """ - testoutputformat = MF_Outputformat(testMap.getOutputFormatByName("png")) + testoutputformat = MF_Outputformat(self.testMap.getOutputFormatByName("png")) self.eq(testoutputformat.get_name(),"png") @@ -130,7 +131,7 @@ """ Testing the symbolset """ - testsymbolset = MF_SymbolSet(testMap.symbolset) + testsymbolset = MF_SymbolSet(self.testMap.symbolset) self.eq(testsymbolset.get_symbol(1).get_name(), "circle") @@ -138,9 +139,9 @@ """ Testing the symbol object """ - testsymbol = MF_Symbol(testMap.symbolset.getSymbolByName("circle")) + testsymbol = MF_Symbol(self.testMap.symbolset.getSymbolByName("circle")) self.eq(testsymbol.get_name(), "circle") - assert(testsymbol.get_symbolObj(), testMap.symbolset.getSymbolByName("circle")) + assert(testsymbol.get_symbolObj(), self.testMap.symbolset.getSymbolByName("circle")) testsymbol.set_filled(True) self.eq(testsymbol.get_filled(), True) @@ -154,8 +155,8 @@ Testing the class object. """ # only test the number of styles at the moment - testclass = MF_Class(testMap.getLayer(0).getClass(0)) - self.eq (len(testclass.get_styles()), testMap.getLayer(0).getClass(0).numstyles) + testclass = MF_Class(self.testMap.getLayer(0).getClass(0)) + self.eq (len(testclass.get_styles()), self.testMap.getLayer(0).getClass(0).numstyles) # check the name self.eq(testclass.get_name(), "testclass") @@ -163,7 +164,7 @@ self.eq(testclass.get_name(), "checkout") # check the expressionstring - testclass = MF_Class(testMap.getLayer(2).getClass(0)) + testclass = MF_Class(self.testMap.getLayer(2).getClass(0)) self.eq(testclass.get_expressionstring(), '"9"') testclass.set_expressionstring("3") self.eq(testclass.get_expressionstring(), '"3"') @@ -174,13 +175,13 @@ Testing the layer object with some sample data and classes. """ - testlayer = MF_Layer(testMap.getLayer(2)) + testlayer = MF_Layer(self.testMap.getLayer(2)) # NAME 'political' only from layer 1 self.eq(testlayer.get_name(), 'cultural') testlayer.set_name('checkout') self.eq(testlayer.get_name(), 'checkout') # check number of classes - self.eq(len(testlayer.get_classes()), testMap.getLayer(2).numclasses) + self.eq(len(testlayer.get_classes()), self.testMap.getLayer(2).numclasses) # check classitem self.eq(testlayer.get_classitem(), "CLPOINT_") testlayer.set_classitem("CLCHECK") @@ -208,33 +209,26 @@ """ Testing the mapfile object with samples. """ - testmap = MF_Map(testMap) + testMapp = MF_Map(self.testMap) # NAME 'ISLAND' - self.eq(testmap.get_name(), 'ISLAND') - self.eq(len(testmap.get_layers()), testMap.numlayers) + self.eq(testMapp.get_name(), 'ISLAND') + self.eq(len(testMapp.get_layers()), self.testMap.numlayers) - testmapfile = mapObj("") - newtestmap = MF_Map(testmapfile) - # proj=utm - # ellps=clrk66 - # zone=26 - # north # test see in test_MF_Projection testproj = Projection(['proj=utm', 'ellps=clrk66', 'zone=26', 'north']) - newtestmap.set_projection(testproj) - self.eq(testmapfile.getProjection(), "+proj=utm+ellps=clrk66+zone=26+north") - self.eq(newtestmap.get_projection().get_params(), ['proj=utm', 'ellps=clrk66', 'zone=26', 'north']) + testMapp.set_projection(testproj) + self.eq(testMapp.get_projection().get_params(), ['proj=utm', 'ellps=clrk66', 'zone=26', 'north']) - self.eq(testmap.get_size(), (600,450)) - testmap.set_size(500,600) - self.eq(testmap.get_size(), (500,600)) + self.eq(testMapp.get_size(), (600,450)) + testMapp.set_size(500,600) + self.eq(testMapp.get_size(), (500,600)) def test_MF_Scalebar(self): """ Test the Scalebarobj from the testfile """ - testscalebar = MF_Scalebar(testMap.scalebar) + testscalebar = MF_Scalebar(self.testMap.scalebar) self.eq(testscalebar.get_position(mode="string"),"ll") self.eq(testscalebar.get_position(), 3) self.eq(testscalebar.get_intervals(), 4) @@ -246,7 +240,7 @@ Test a Label object. In this test use the Label from from the Scalebarobj in the testfile """ - testlabel = MF_Label(testMap.scalebar.label) + testlabel = MF_Label(self.testMap.scalebar.label) self.eq(testlabel.get_force(), False) self.eq(testlabel.get_buffer(),0) self.eq(testlabel.get_type(), "bitmap") @@ -256,7 +250,7 @@ """ test the legend object from the testfile """ - testlegend = MF_Legend(testMap.legend) + testlegend = MF_Legend(self.testMap.legend) self.eq(testlegend.get_status(), False) testlegend.set_status(True) self.eq(testlegend.get_status(), True) @@ -277,7 +271,7 @@ # ellps=clrk66 # zone=26 # north - testproj = MF_Projection(testMap.getProjection()) + testproj = MF_Projection(self.testMap.getProjection()) if testproj.get_params(): self.eq(testproj.get_params(), ['proj=utm','ellps=WGS84','zone=26','north']) @@ -290,7 +284,7 @@ """ Tests a style object with all parameters. """ - teststyle = MF_Style(testMap.getLayer(0).getClass(0).getStyle(0)) + teststyle = MF_Style(self.testMap.getLayer(0).getClass(0).getStyle(0)) # OUTLINECOLOR 0 0 0 self.eq(teststyle.get_outlinecolor().get_red(), 0) # COLOR 100 200 100 @@ -305,7 +299,7 @@ """ Tests a web object """ - testweb = MF_Web(testMap.web) + testweb = MF_Web(self.testMap.web) self.eq(testweb.get_imagepath(), "/tmpimg/") testweb.set_imagepath("/tmppathset/") self.eq(testweb.get_imagepath(), "/tmppathset/") From cvs at intevation.de Wed Jul 14 12:33:26 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Wed, 14 Jul 2004 12:33:26 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver/sample iceland.map, 1.2, 1.3 Message-ID: <20040714103326.9B93A1393B@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver/sample In directory doto:/tmp/cvs-serv9168/sample Modified Files: iceland.map Log Message: Include three new classes in the Line Layer, to test logical Expressions. Set the status of the class "Point9" in the Point Layer to off Index: iceland.map =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/sample/iceland.map,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- iceland.map 1 Jul 2004 14:40:11 -0000 1.2 +++ iceland.map 14 Jul 2004 10:33:24 -0000 1.3 @@ -100,17 +100,44 @@ TYPE LINE STATUS ON CLASS - NAME "test2" + NAME "Begin - 418" + EXPRESSION ([RDLINE_ID] <= 418) + STYLE + COLOR 255 255 255 + SIZE 1 + SYMBOL 0 + END + END + CLASS + NAME "419 - 836" + EXPRESSION ([RDLINE_ID] > 418 AND [RDLINE_ID] <= 836) STYLE - #OUTLINECOLOR 0 0 0 - color 50 50 50 + COLOR 127 127 127 + SIZE 1 + SYMBOL 0 END - END - - PROJECTION + END + CLASS + NAME "837 - End" + EXPRESSION ([RDLINE_ID] > 836) + STYLE + COLOR 0 0 0 + SIZE 1 + SYMBOL 0 + END + END + CLASS + NAME "Rest" + STYLE + COLOR 100 100 100 + SIZE 1 + Symbol 0 + END + END + PROJECTION proj=latlong ellps=clrk66 - END + END END LAYER @@ -122,6 +149,7 @@ CLASS NAME "Point 9" EXPRESSION '9' + STATUS OFF STYLE COLOR 255 200 0 SYMBOL 'circle' From cvs at intevation.de Wed Jul 14 12:34:12 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Wed, 14 Jul 2004 12:34:12 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver mf_import.py,1.5,1.6 Message-ID: <20040714103412.3321B1393B@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver In directory doto:/tmp/cvs-serv9181 Modified Files: mf_import.py Log Message: Replace the exception handling on loading the layers by an if statement.It is not necessary to us the exception there. The Filepath creation now use os.path.join to build the path. Index: mf_import.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mf_import.py,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- mf_import.py 6 Jul 2004 14:31:28 -0000 1.5 +++ mf_import.py 14 Jul 2004 10:34:10 -0000 1.6 @@ -138,18 +138,19 @@ #check if rasterlayer if maplayer.get_type() == 'raster': imgpath = maplayer.get_data() - try: + # if there is no imagepath defined, the Raster Layer could not load + if imgpath == None: + context.mainwindow.RunMessageBox(_('Error Loading Raster Layer'), + _("Can't open the rasterlayer '%s'.") % layertitle) + else: if os.path.isabs(imgpath): - filename = imgpath + filename = imgpath else: - filename = filepath +"/" + mapobj.get_shapepath() +'/' + imgpath + filename = os.path.join(filepath,mapobj.get_shapepath(),imgpath) # Normalize the pathname by collapses # redundant separators and up-level references filename = os.path.normpath(filename) - except: - context.mainwindow.RunMessageBox(_('Error Loading Raster Layer'), - _("Can't open the rasterlayer '%s'.") % layertitle) - else: + rasterlayer = RasterLayer(maplayer.get_name(), filename) # set the visible status rasterlayer.SetVisible(maplayer.get_status()) @@ -163,19 +164,21 @@ (maplayer.get_type() == 'line') or (maplayer.get_type() == 'circle') or (maplayer.get_type() == 'point')): - try: + + if mapobj.get_layers()[layernr].get_data(): if os.path.isabs(mapobj.get_layers()[layernr].get_data()): filename = mapobj.get_layers()[layernr].get_data() +".shp" else: - filename = filepath + "/" + mapobj.get_shapepath() + "/" + \ - mapobj.get_layers()[layernr].get_data() +".shp" + filename = os.path.join(filepath, mapobj.get_shapepath(), \ + mapobj.get_layers()[layernr].get_data()) + filename = filename + ".shp" # Normalize the pathname by collapses # redundant separators and up-level references filename = os.path.normpath(filename) - except: + else: context.mainwindow.RunMessageBox(_('Error Loading Layer'), _("no shp file definied, maybe used a feature obj '%s'.") % layertitle) - continue + # try to open the layer try: store = context.application.Session().OpenShapefile(filename) layer_count += 1 @@ -365,7 +368,6 @@ return MF_Map(theMap) - # ################################### # # Hook in MapServer Extension into Thuban @@ -373,7 +375,7 @@ # ################################### # register the new command -registry.Add(Command("import_mapfile", _("Import Mapfile"), import_mapfile, +registry.Add(Command("import_mapfile", _("Import mapfile"), import_mapfile, helptext = _("Import a mapfile"))) # find the extensions menu (create it anew if not found) From cvs at intevation.de Wed Jul 14 12:35:53 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Wed, 14 Jul 2004 12:35:53 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver mf_handle.py,1.4,1.5 Message-ID: <20040714103553.2910613BC7@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver In directory doto:/tmp/cvs-serv9201 Modified Files: mf_handle.py Log Message: Removed the import Thuban.UI.mainwindow clause, because it is not needed. Added the command Refresh() to all "OnChangeColor()" functions, because the color preview window was not updated on a color change. Added the function to check if a mapobject exists and used it to set the status of the menu items. If no mapobject exists the settings could not be edditied. (Map_Dialog): Moved the imagetype selector from the Outputformat_Dialog to Map_Dialog and removed Outputformat_Dialog. (Web_Dialog): Removed the name label and added the template textbox. Index: mf_handle.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mf_handle.py,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- mf_handle.py 8 Jul 2004 14:27:58 -0000 1.4 +++ mf_handle.py 14 Jul 2004 10:35:51 -0000 1.5 @@ -39,9 +39,6 @@ # instance registry. from Thuban.UI.command import registry, Command -# The instance of the main menu of the Thuban application -import Thuban.UI.mainwindow - # needed to add the new menu from Thuban.UI.mainwindow import main_menu @@ -101,6 +98,26 @@ box_sizepartHeight.Add(self.text_height, 2, wxALL, 4) box_size.Add(box_sizepartHeight, 0, wxALIGN_RIGHT | wxALL, 5) + # get the web object + self.tb_map = parent.canvas.Map() + self.tb_map_umn = self.tb_map.extension_umn_mapobj + + #get the imagetype + umn_imagetype = self.tb_map_umn.get_imagetype() + # create a list with the outputformat names + umn_outputformats = [] + for format in self.tb_map_umn.get_alloutputformats(): + umn_outputformats.append(format.get_name()) + #Imagetype selector + box_imagetypeStatic = wxStaticBox(self, -1, _("Image Type"), + style = 0, name = "imagetype") + box_imagetype = wxStaticBoxSizer(box_imagetypeStatic, wxVERTICAL) + self.choice_imgtype = wxChoice(self, 8060, (80, 50), + choices = umn_outputformats) + EVT_CHOICE(self, 8060, self.EvtChoiceBox) + self.choice_imgtype.SetStringSelection(umn_imagetype) + box_imagetype.Add(self.choice_imgtype,0, wxEXPAND, wxALL, 5) + #unittype insideunit = self.tb_map_umn.get_units() #Unittype selector @@ -153,6 +170,7 @@ top = wxBoxSizer(wxVERTICAL) top.Add(box_name, 0, wxEXPAND |wxALL, 5) top.Add(box_size, 0, wxEXPAND |wxALL, 5) + top.Add(box_imagetype,0, wxEXPAND |wxALL, 5) top.Add(box_units,0, wxEXPAND |wxALL, 5) top.Add(box_color,0, wxEXPAND |wxALL, 5) top.Add(self.choice_status,0, wxEXPAND |wxALL, 5) @@ -176,6 +194,11 @@ self.bluecolor = int(round(self.retcolor.blue*255)) self.previewcolor.SetBackgroundColour(wxColour((self.redcolor), int(self.greencolor), int(self.bluecolor))) + # refresh the colorbox to show the new color + self.previewcolor.Refresh() + + def EvtChoiceBox(self, event): + outformat = self.tb_map_umn.get_outputformat().get_name() def RunDialog(self): self.ShowModal() @@ -200,76 +223,6 @@ previewcolor = self.previewcolor.GetBackgroundColour() self.tb_map_umn.get_imagecolor().set_rgbcolor(previewcolor.Red(), previewcolor.Green(), previewcolor.Blue()) - self.result ="OK" - self.end_dialog(self.result) - - def OnCancel(self, event): - self.end_dialog(None) - - -class OutputFormat_Dialog(wxDialog): - - def __init__(self, parent, ID, title, - pos=wxDefaultPosition, size=wxDefaultSize, - style=wxDEFAULT_DIALOG_STYLE): - - # initialize the Dialog - wxDialog.__init__(self, parent, ID, title, pos, size, style) - - # get the web object - self.tb_map = parent.canvas.Map() - self.tb_map_umn = self.tb_map.extension_umn_mapobj - - #get the imagetype - umn_imagetype = self.tb_map_umn.get_imagetype() - # create a list with the outputformat names - umn_outputformats = [] - for format in self.tb_map_umn.get_alloutputformats(): - umn_outputformats.append(format.get_name()) - #Imagetype selector - box_imagetypeStatic = wxStaticBox(self, -1, _("Image Type"), - style = 0, name = "imagetype") - box_imagetype = wxStaticBoxSizer(box_imagetypeStatic, wxVERTICAL) - self.choice_imgtype = wxChoice(self, 8060, (80, 50), - choices = umn_outputformats) - EVT_CHOICE(self, 8060, self.EvtChoiceBox) - self.choice_imgtype.SetStringSelection(umn_imagetype) - box_imagetype.Add(self.choice_imgtype,0, wxEXPAND, wxALL, 5) - - #buttons - box_buttons = wxBoxSizer(wxHORIZONTAL) - button = wxButton(self, wxID_OK, _("OK")) - box_buttons.Add(button, 0, wxALL, 5) - button = wxButton(self, wxID_CANCEL, _("Cancel")) - box_buttons.Add(button, 0, wxALL, 5) - #set the button funcitons - EVT_BUTTON(self, wxID_OK, self.OnOK) - EVT_BUTTON(self, wxID_CANCEL, self.OnCancel) - - #add all boxes to the box top - top = wxBoxSizer(wxVERTICAL) - top.Add(box_imagetype,0, wxEXPAND |wxALL, 5) - top.Add(box_buttons, 0, wxALIGN_RIGHT) - # final layout settings - self.SetSizer(top) - top.Fit(self) - - def EvtChoiceBox(self, event): - outformat = self.tb_map_umn.get_outputformat().get_name() - - def RunDialog(self): - self.ShowModal() - self.Destroy() - - def end_dialog(self, result): - self.result = result - if self.result is not None: - self.EndModal(wxID_OK) - else: - self.EndModal(wxID_CANCEL) - self.Show(False) - - def OnOK(self, event): self.tb_map_umn.set_imagetype(self.choice_imgtype.GetStringSelection()) self.result ="OK" self.end_dialog(self.result) @@ -290,14 +243,17 @@ # get the web object self.tb_map = parent.canvas.Map() self.umn_web = self.tb_map.extension_umn_mapobj.get_web() - - # create name - box_name = wxBoxSizer(wxHORIZONTAL) - box_name.Add(wxStaticText(self, -1, _("Map-Name:")), 0, - wxALL|wxALIGN_CENTER_VERTICAL, 4) - box_name.Add(wxStaticText(self, -1, self.tb_map.Title()), 0, - wxALL|wxALIGN_CENTER_VERTICAL, 4) - + + # Template + box_template = wxBoxSizer(wxHORIZONTAL) + box_template.Add(wxStaticText(self, -1, _("Template:")), 0, + wxALL|wxALIGN_LEFT, 4) + self.text_template = wxTextCtrl(self, -1, + str(self.umn_web.get_template())) + self.text_template.SetSize((250,self.text_template.GetSize()[1])) + box_template.Add(self.text_template, 0, + wxALL|wxALIGN_CENTER_VERTICAL, 4) + # Imagepath box_imagepath = wxBoxSizer(wxHORIZONTAL) box_imagepath.Add(wxStaticText(self, -1, _("Imagepath:")), 0, @@ -328,7 +284,7 @@ # compose the final dialog top = wxBoxSizer(wxVERTICAL) - top.Add(box_name, 0, wxEXPAND |wxALL, 5) + top.Add(box_template, 0, wxEXPAND |wxALL, 5) top.Add(box_imagepath, 0, wxEXPAND |wxALL, 5) top.Add(box_imageurl, 0, wxEXPAND |wxALL, 5) top.Add(box_buttons, 0, wxALIGN_RIGHT) @@ -350,6 +306,7 @@ self.Show(False) def OnOK(self, event): + self.umn_web.set_template(self.text_template.GetValue()) self.umn_web.set_imagepath(self.text_imagepath.GetValue()) self.umn_web.set_imageurl(self.text_imageurl.GetValue()) self.result ="OK" @@ -507,6 +464,8 @@ self.previewcolor.SetBackgroundColour(wxColour(int(self.redcolor), int(self.greencolor), int(self.bluecolor))) + # refresh the colorbox to show the new color + self.previewcolor.Refresh() def RunDialog(self): self.ShowModal() @@ -732,6 +691,8 @@ self.previewcolor.SetBackgroundColour(wxColour(int(self.redcolor), int(self.greencolor), int(self.bluecolor))) + # refresh the colorbox to show the new color + self.previewcolor.Refresh() def RunDialog(self): self.ShowModal() @@ -958,6 +919,8 @@ self.previewimgcolor.SetBackgroundColour(wxColour(int(self.redcolor), int(self.greencolor), int(self.bluecolor))) + # refresh the colorbox to show the new color + self.previewimgcolor.Refresh() def OnChangeColor(self, event): cur = self.umn_scalebar.get_color().get_thubancolor() @@ -974,6 +937,8 @@ self.previewcolor.SetBackgroundColour(wxColour(int(self.redcolor), int(self.greencolor), int(self.bluecolor))) + # refresh the colorbox to show the new color + self.previewcolor.Refresh() def RunDialog(self): self.ShowModal() @@ -1049,6 +1014,14 @@ 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 +def _has_umn_mapobj(context): + """Return true if a umn_mapobj exists""" + return hasattr(context.mainwindow.canvas.Map(), "extension_umn_mapobj") + + # ################################### # # Hook in MapServer Extension into Thuban @@ -1062,47 +1035,48 @@ mapserver_menu = experimental_menu.FindOrInsertMenu("mapserver", _("&MapServer")) - # register the new command -registry.Add(Command("create_new_mapfile", _("Create an empty MapObj"), \ - create_new_mapfile, - helptext = _("Create a new empty mapscript MapObj"))) +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") +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") # register the new command (Map Settings Dialog) -registry.Add(Command("Map Settings", _("Map Settings"), mapsettings, - helptext = _("Edit the Map Setting"))) +registry.Add(Command("Map Settings", _("Map"), mapsettings, + helptext = _("Edit the Map Setting"), \ + sensitive = _has_umn_mapobj)) # finally add the new entry to the extensions menu -mapserver_menu.InsertItem("Map Settings") +mapserver_edit_menu.InsertItem("Map Settings") -# register the new command (OutputFormat Settings Dialog) -registry.Add(Command("OutputFormat Settings", _("OutputFormat Settings"), - outputformatsettings, - helptext = _("Edit the OutputFormat Setting"))) -# finally add the new entry to the extensions menu -mapserver_menu.InsertItem("OutputFormat Settings") # register the new command (Map Settings Dialog) -registry.Add(Command("Web Settings", _("Web Settings"), +registry.Add(Command("Web Settings", _("Web"), websettings, - helptext = _("Edit the Web Setting"))) + helptext = _("Edit the Web Setting"), \ + sensitive = _has_umn_mapobj)) # finally add the new entry to the extensions menu -mapserver_menu.InsertItem("Web Settings") +mapserver_edit_menu.InsertItem("Web Settings") # register the new command (Legend Settings Dialog) -registry.Add(Command("Legend Settings", _("Legend Settings"), +registry.Add(Command("Legend Settings", _("Legend"), legendsettings, - helptext = _("Edit the Legend Setting"))) + helptext = _("Edit the Legend Setting"), \ + sensitive = _has_umn_mapobj)) # finally add the new entry to the extensions menu -mapserver_menu.InsertItem("Legend Settings") +mapserver_edit_menu.InsertItem("Legend Settings") # register the new command (Scalebar Settings Dialog) -registry.Add(Command("Scalebar Settings", _("Scalebar Settings"), +registry.Add(Command("Scalebar Settings", _("Scalebar"), scalebarsettings, - helptext = _("Edit the Scalebar Setting"))) + helptext = _("Edit the Scalebar Setting"), \ + sensitive = _has_umn_mapobj)) # finally add the new entry to the extensions menu -mapserver_menu.InsertItem("Scalebar Settings") +mapserver_edit_menu.InsertItem("Scalebar Settings") From cvs at intevation.de Wed Jul 14 12:36:42 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Wed, 14 Jul 2004 12:36:42 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver mf_export.py,1.3,1.4 Message-ID: <20040714103642.463C313BC7@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver In directory doto:/tmp/cvs-serv9273 Modified Files: mf_export.py Log Message: Added the function to check if a mapobject exists and used it to set the status of the menu items. If no mapfile exists the settings could not be edditied. Define after which menuitem the exportitem will include. Index: mf_export.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mf_export.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- mf_export.py 6 Jul 2004 14:29:36 -0000 1.3 +++ mf_export.py 14 Jul 2004 10:36:40 -0000 1.4 @@ -101,6 +101,7 @@ theMap = context.mainwindow.canvas.Map().extension_umn_mapobj else: theMap = MF_Map(mapObj("")) + context.mainwindow.canvas.Map().extension_umn_mapobj = theMap dlg = wxFileDialog(context.mainwindow, "Save file as...", ".", "", "UMN MapServer Mapfiles (*.map)|*.map|" \ @@ -129,6 +130,13 @@ 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 +def _has_umn_mapobj(context): + """Return true if a umn_mapobj exists""" + return hasattr(context.mainwindow.canvas.Map(), "extension_umn_mapobj") + + # ################################### # # Hook in MapServer Extension into Thuban @@ -136,15 +144,18 @@ # ################################### # register the new command -registry.Add(Command("export_new_mapfile", _("Export new Mapfile"), \ - export_mapfile, helptext = _("Create a new mapfile"))) +registry.Add(Command("export_new_mapfile", _("Export mapfile"), \ + export_mapfile, helptext = _("Create a new mapfile"), \ + sensitive = _has_umn_mapobj)) # find the extensions menu (create it anew if not found) -experimental_menu = main_menu.FindOrInsertMenu("experimental", _("Experimenta&l")) +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")) +mapserver_menu = experimental_menu.FindOrInsertMenu("mapserver", \ + _("&MapServer")) # finally add the new entry to the extensions menu -mapserver_menu.InsertItem("export_new_mapfile") +mapserver_menu.InsertItem("export_new_mapfile", after="edit_mapfile") From cvs at intevation.de Wed Jul 14 12:38:10 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Wed, 14 Jul 2004 12:38:10 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver mapfile.py,1.6,1.7 Message-ID: <20040714103810.7977313B80@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver In directory doto:/tmp/cvs-serv9291 Modified Files: mapfile.py Log Message: Added ClassGroupDefault to import. (MF_Symbolset): Removed the extra variable for numsymbols. (MF_Class.__init__): Added a comment to the exception clause. Removed the extent init, because it was not needed anymore. (MF_Layer.add_thubanclass): Added the code to set the class name to the expression value from thuban if no label is defined. Added the code to export Range expressions from thuban to the mapfile. (MF_Map.set_extent): Removed the exception and replace it by some if code. If the size of a map is not defined the size will be set to 1,1. This is necessary because if the extent is set, mapscript checks if the size is greater than zero. (MF_Web): Added the get and set function for the template. Index: mapfile.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mapfile.py,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- mapfile.py 8 Jul 2004 14:26:56 -0000 1.6 +++ mapfile.py 14 Jul 2004 10:38:08 -0000 1.7 @@ -39,6 +39,9 @@ from Thuban.Model.color import Color, Transparent +from Thuban.Model.classification import ClassGroupDefault, \ + ClassGroupSingleton, ClassGroupRange + from mapscript import layerObj, classObj, colorObj, styleObj, rectObj, symbolObj, \ pointObj, lineObj @@ -354,9 +357,8 @@ # Initial Symbol List self._symbols = [] - self._numsymbols = self._symbolset.numsymbols self._i = 1 - while self._i < self._numsymbols: + while self._i < self._symbolset.numsymbols: self._symbols.append(MF_Symbol(self._symbolset.getSymbol(self._i))) self._i += 1 @@ -370,7 +372,7 @@ os.remove("tempsymbol") def get_symbol(self, symbolnr): - if symbolnr < self._numsymbols: + if symbolnr < self._symbolset.numsymbols: return self._symbols[symbolnr-1] else: return None @@ -409,6 +411,9 @@ self._expression = self._clazz.getExpressionString() self.metadata = MF_Metadata() + # try to get the first metaDatakey. If it does not exists, the following + # error will occur: + # MapServerError: getFirstMetaDataKey: Hash table error. Key does not exist try: self.metafkey = mf_class.getFirstMetaDataKey() except: @@ -522,14 +527,6 @@ self._projection = MF_Projection(self._mf_layer.getProjection()) - # Variable extent will not used for RasterLayer - # this variable is not necessary, because it comes directly - # from the shp file - try: - self._extent = MF_Rectangle(self._mf_layer.getExtent()) - except: - self._extent = None - # Create Metadata self._metadata = MF_Metadata() try: @@ -613,9 +610,20 @@ def add_thubanclass(self, tb_class, type=""): """ Add a thuban class object - """ + """ new_class = MF_Class(classObj(self._mf_layer)) - new_class.set_name(tb_class.GetLabel()) + # set the class name to the Label form thuban if given, + # else set it to the value + if tb_class.GetLabel() != "": + new_class.set_name(tb_class.GetLabel()) + else: + if isinstance(tb_class, ClassGroupDefault): + new_class.set_name("default") + elif isinstance(tb_class, ClassGroupSingleton): + new_class.set_name(str(tb_class.GetValue())) + else: + # TODO: set a name if the expression is a ogical + new_class.set_name("no name") if self.get_type() == "line": new_class.add_thubanstyle(tb_class.GetProperties(), type="line") elif self.get_type() == "point": @@ -624,10 +632,64 @@ new_class.add_thubanstyle(tb_class.GetProperties()) if (type == "default"): return + # removed the following two lines to check if the expressionstring + # is needed for points, because if expressionstring is a range type, + # no expressionstring in the default group is allowed elif (tb_class.Matches("DEFAULT")): - new_class.set_expressionstring('/./') + return + # new_class.set_expressionstring('/./') else: - new_class.set_expressionstring(str(tb_class.GetValue())) + #check which type of expression + if isinstance(tb_class, ClassGroupRange): + # get the needed infos from the Range-String + self._range_begin = tb_class.GetRange()[0] + self._range_min = str(tb_class.GetMin()) + self._range_max = str(tb_class.GetMax()) + self._range_end = tb_class.GetRange()[len(tb_class.GetRange())-1] + self._range_umn = "" + self._range_classitem = self.get_classitem() + # generate the operator + if self._range_begin == "[": + self._range_op1 = ">=" + elif self._range_begin == "]": + self._range_op1 = ">" + else: + print "error in Thuban class properties" + #build op1 string for the lower limit + self._range_op1 = "[" + self._range_classitem + "] " + \ + self._range_op1 + " " +\ + self._range_min + # build op2 string for the upper limit + if self._range_end == "[": + self._range_op2 = "<" + elif self._range_end == "]": + self._range_op2 = "<=" + else: + print "error in Thuban class properties" + + self._range_op2 = "[" + self._range_classitem + "] " + \ + self._range_op2 + " " +\ + self._range_max + # we only need AND here at the moment, becaus of the limits + # in thuban + self._range_combine = "AND" + # check if the one limit is set to inf and then + # remove the second expression becaus is not needed. + if self._range_min == "-inf": + self._range_combine = "" + self._range_op1 = "" + elif self._range_max == "inf": + self._range_combine = "" + self._range_op2 = "" + # build the expression together + self._range_umn = "(" + self._range_umn + \ + self._range_op1 + " " +\ + self._range_combine + \ + self._range_op2 + " )" + #set the expression to the mapscript + new_class.set_expressionstring(self._range_umn) + else: + new_class.set_expressionstring(str(tb_class.GetValue())) new_class.set_status(tb_class.IsVisible()) self._classes.append(new_class) @@ -894,14 +956,16 @@ def set_extent(self, newextent): # TODO: add the shown extend here instead of the total - self._newrect = MF_Rectangle(rectObj()) - try: - self._newrect.set_rect(newextent[0],newextent[1], \ - newextent[2],newextent[3]) - self._mf_map.setExtent(newextent[0],newextent[1], \ + # if no size is set or if it is zero, the size will set to 1. + if self.get_size()[0] == - 1: + print "define the size first to set extent" + print "size is now set to (1,1)" + self.set_size(1,1) + self._newrect = MF_Rectangle(rectObj(newextent[0],newextent[1], \ + newextent[2],newextent[3])) + self._mf_map.setExtent(newextent[0],newextent[1], \ newextent[2],newextent[3]) - except: - return + def set_size(self, newwidth, newheight): self._mf_map.width = newwidth @@ -950,12 +1014,19 @@ if tb_layer.GetProjection(): new_layer.set_projection(tb_layer.GetProjection()) if tb_layer.GetClassification().GetNumGroups() > 0: + singletonexists = False for group in range(0, \ tb_layer.GetClassification().GetNumGroups(), 1): + if isinstance(tb_layer.GetClassification().GetGroup(group), \ + ClassGroupSingleton): + singletonexists = True new_layer.add_thubanclass( \ tb_layer.GetClassification().GetGroup(group)) new_layer.add_thubanclass( \ tb_layer.GetClassification().GetDefaultGroup()) + # remove the classitem if one singleton exists + if singletonexists == False: + new_layer.set_classitem(None) else: new_layer.add_thubanclass( \ tb_layer.GetClassification().GetDefaultGroup(), \ @@ -1003,6 +1074,12 @@ def get_imageurl(self): return self._mf_web.imageurl + + def get_template(self): + return self._mf_web.template + + def set_template(self, new_template): + self._mf_web.template = new_template def set_imageurl(self, new_imageurl): self._mf_web.imageurl = new_imageurl From cvs at intevation.de Wed Jul 14 12:38:59 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Wed, 14 Jul 2004 12:38:59 +0200 (CEST) Subject: jschuengel: thuban ChangeLog,1.667,1.668 Message-ID: <20040714103859.A34151393B@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv9319 Modified Files: ChangeLog Log Message: update ChangeLog Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.667 retrieving revision 1.668 diff -u -d -r1.667 -r1.668 --- ChangeLog 13 Jul 2004 11:07:45 -0000 1.667 +++ ChangeLog 14 Jul 2004 10:38:57 -0000 1.668 @@ -1,3 +1,48 @@ +2004-07-14 Jan Schüngel + + * Extensions/umn_mapserver/mapfile.py: Added ClassGroupDefault to + import. + (MF_Symbolset): Removed the extra variable for numsymbols. + (MF_Class.__init__): Added a comment to the exception clause. + Removed the extent init, because it was not needed anymore. + (MF_Layer.add_thubanclass): Added the code to set the class name to + the expression value from thuban if no label is defined. + Added the code to export Range expressions from thuban to the mapfile. + (MF_Map.set_extent): Removed the exception and replace it by some if + code. If the size of a map is not defined the size will be set to 1,1. + This is necessary because if the extent is set, mapscript checks if + the size is greater than zero. + (MF_Web): Added the get and set function for the template. + + * Extensions/umn_mapserver/mf_export.py: Added the function to check + if a mapobject exists and used it to set the status of the menu items. + If no mapfile exists the settings could not be edditied. + Define after which menuitem the exportitem will include. + + * Extensions/umn_mapserver/mf_handle.py: Removed the import + Thuban.UI.mainwindow clause, because it is not needed. + Added the command Refresh() to all "OnChangeColor()" functions, + because the color preview window was not updated on a color change. + Added the function to check if a mapobject exists and used it to set the + status of the menu items. If no mapobject exists the settings could not + be edditied. + (Map_Dialog): Moved the imagetype selector from the + Outputformat_Dialog to Map_Dialog and removed Outputformat_Dialog. + (Web_Dialog): Removed the name label and added the template textbox. + + * Extensions/umn_mapserver/mf_import.py (import_mapfile): Replace + the exception handling on loading the layers by an if statement. It + is not necessary to us the exception there. + The Filepath creation now use os.path.join to build the path. + + * Extensions/umn_mapserver/test/test_mapserver.py: Moved the testMap + definition from global to the setUp function. Now the testMap will + initialize new on each test. + + * Extensions/umn_mapserver/sample/iceland.map: Include three new + classes in the Line Layer, to test logical Expressions. + Set the status of the class "Point9" in the Point Layer to off + 2004-07-13 Bernhard Herzog * Thuban/UI/baserenderer.py From thuban-bugs at intevation.de Wed Jul 14 20:48:32 2004 From: thuban-bugs at intevation.de (Request Tracker) Date: Wed, 14 Jul 2004 20:48:32 +0200 (CEST) Subject: [bug #2536] (thuban) add unicode support Message-ID: <20040714184832.CEEB31392D@lists.intevation.de> this bug's URL: http://intevation.de/rt/webrt?serial_num=2536 ------------------------------------------------------------------------- Subject: add unicode support Thuban should be able to handle unicode. Todo: Convert all text strings that enter thuban to unicode objects. Use unicode objects for all text inside thuban. Use a wx version with unicode support. -------------------------------------------- Managed by Request Tracker From cvs at intevation.de Thu Jul 15 16:30:39 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Thu, 15 Jul 2004 16:30:39 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver mf_import.py,1.6,1.7 Message-ID: <20040715143039.D08CE1393B@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver In directory doto:/tmp/cvs-serv5213 Modified Files: mf_import.py Log Message: Updated the discription. Split the funktion in to three smaller ones. The new functions are add_rasterlayer, add_polygonlayer and select_layer2import. Removed the mapfilepath and filepath initialisation, because its know include in the new functions. Now nothing will be imported if cancel is pressed in the layer choice dialog. Index: mf_import.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mf_import.py,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- mf_import.py 14 Jul 2004 10:34:10 -0000 1.6 +++ mf_import.py 15 Jul 2004 14:30:37 -0000 1.7 @@ -64,13 +64,254 @@ # # ################################### +def set_projection_to_tb(tb_con, mapobj): + """ + Helpfunction to set the projection in thuban. + + Parameters: + tb_con -- The thuban conext (mapobj or layerobj) + mapobj -- The mapobject (from mapscript) + """ + if (mapobj.get_projection().get_params() != None): + projparams = mapobj.get_projection().get_params() + # check if it is an latlong projection, becaues one + # more parameter is needed in that case + addtometer = False + for param in projparams: + projkey = param.split("=") + if projkey[0] == "proj": + if projkey[1] == "latlong": + addtometer = True + if projkey[0] == "to_meter": + addtometer = False + if addtometer == True: + projparams.append("to_meter=0.017453") + tb_con.SetProjection(Projection(projparams)) + if mapobj.get_projection().get_epsgcode() != None: + projepsg = mapobj.get_projection().get_epsgproj() + tb_con.SetProjection(projepsg) + + +def add_rasterlayer(context, tb_map, mapobj, maplayer): + """ + add a rasterlayer to thuban + + tb_map = context.mainwindow.canvas.Map() + + mapobj = the Mapobject created from the mapfile + + maplayer = layer obj to add to thuban + """ + imgpath = maplayer.get_data() + filepath = mapobj.get_mappath() + layertitle = maplayer.get_name() + # if there is no imagepath defined, the Raster Layer could not load + if imgpath == None: + context.mainwindow.RunMessageBox(_('Error Loading Raster Layer'), + _("Can't open the rasterlayer '%s'.") % layertitle) + else: + if os.path.isabs(imgpath): + filename = imgpath + else: + filename = os.path.join(filepath,mapobj.get_shapepath(),imgpath) + # Normalize the pathname by collapses + # redundant separators and up-level references + filename = os.path.normpath(filename) + + rasterlayer = RasterLayer(layertitle, filename) + # set the visible status + rasterlayer.SetVisible(maplayer.get_status()) + #add the projection if exists + set_projection_to_tb(rasterlayer, maplayer) + tb_map.AddLayer(rasterlayer) + + +def add_polygonlayer(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: + # create a new layer which will be added to thuban later + layer = Layer(layertitle, store) + # all classes of the maplayer + map_clazzes = maplayer.get_classes() + # number of layers loaded vom maplayer + map_numclazzes = len(map_clazzes) + # defaultclazzset is necessary to know if a default class is set + # in thuban. if is not and there are more them one class in the + # mapfile the colors of the default layer in thuban musst + # set to Transparence + defaultclazzset = None + + # create a class in thuban for every class in the maplayer + for map_clazznr in range(0, map_numclazzes, 1): + # define the color + map_clazz = map_clazzes[map_clazznr] + layer_style = map_clazz.get_styles()[0] + 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) + + # if outline color is defined use it else set transparent + if layer_style.get_outlinecolor(): + tb_color = layer_style.get_outlinecolor().get_thubancolor() + prop.SetLineColor(tb_color) + else: + prop.SetLineColor(Transparent) + # if color is defined use it as fillcolor + # but if the layer type is line use the color as linecolor + if layer_style.get_color(): + tb_color = layer_style.get_color().get_thubancolor() + if maplayer.get_type() == 'line': + prop.SetLineColor(tb_color) + else: + prop.SetFill(tb_color) + else: + prop.SetFill(Transparent) + + #set size for the line + if ((maplayer.get_type() == 'polygon') or + (maplayer.get_type() == 'line')): + if layer_style.get_size(): + prop.SetLineWidth(layer_style.get_size()) + + # generate special expression classes to show in thuban + # not all possibilities from the MapServer are supported now + # supporteed: + # String comparisons + # not supported: + # Regular expressions + # Logical expressions + expressionstring = map_clazz.get_expressionstring() + if (((map_numclazzes == 1) & (not expressionstring)) or + ((map_numclazzes > 1) & (expressionstring == None)) or + (expressionstring == '/./')): + if clazz_name == None: + clazz_name = "" + new_group = ClassGroupDefault(props = prop, label = clazz_name) + new_group.SetVisible(map_clazz.get_status()) + clazz.SetDefaultGroup(new_group) + defaultclazzset = True + # break, because alle classes behind the one which definies the + # default will be ignored by mapserver. See sample + # TODO: if possible set it as invisible class in thuban, but + # show the parts of that class as default. + # not possible at the moment ? + break + + # this is the String comparison. + # the expressionstring is enclosed by the ' or " indications + elif ((expressionstring[0] == "'") or + (expressionstring[0] == '"')): + expressionclassitem = maplayer.get_classitem().upper() + layer.SetClassificationColumn(expressionclassitem) + try: + theexpression = int(expressionstring[1:-1]) + except: + theexpression = expressionstring[1:-1] + if clazz_name == None: + clazz_name = str(theexpression) + new_group = ClassGroupSingleton(value = theexpression, + props = prop, + label = clazz_name) + new_group.SetVisible(map_clazz.get_status()) + clazz.AppendGroup(new_group) + elif (expressionstring[0] == "("): + context.mainwindow.RunMessageBox(_('Error Loading Layer'), + _("could not import the expression\n"+ \ + "%s \n from layer '%s', class %d (%s)'.")\ + %(expressionstring, layertitle, \ + map_clazznr, map_clazz.get_name())) + else: + new_group = ClassGroupSingleton(props = prop,label = clazz_name) + new_group.SetVisible(map_clazz.get_status()) + clazz.AppendGroup(new_group) + + # if there is no default layer set, + # the color and linecolor will set as Transparent. + if (not defaultclazzset): + proptp = ClassGroupProperties() + proptp.SetLineColor(Transparent) + new_group = ClassGroupDefault(props = proptp) + clazz.SetDefaultGroup(new_group) + defaultclazzset = None + + # set the visible status + layer.SetVisible(maplayer.get_status()) + # 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) + + #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 + """ + lst = [] + selectedlayer = [] + numlayers = len(mapobj.get_layers()) + for layernr in range(0, numlayers,1): + lst.append(mapobj.get_layers()[layernr].get_name() + + " (" + mapobj.get_layers()[layernr].get_type() +")" ) + + dlgsize = (300,130+len(lst)*20) + if dlgsize[1] >= 300: + dlgsize = (300,300) + dlg = wxMultipleChoiceDialog(context.mainwindow, + "Select the layers from the\n" + + "list to load into thuban.\n" + + "annotation not supported !", + "Select Layer.", lst, size = dlgsize) + if (dlg.ShowModal() == wxID_OK): + selectedlayer = dlg.GetValue() + return selectedlayer + + 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, but with some limitations. + Loaded polygon layer like polygon, line or point into thuban. + Raster layer are supported also. context - the thuban context """ @@ -85,15 +326,9 @@ else: return - # get the path to the file - mapfilepath = os.path.dirname(filename) # Parse mapfile mapobj = parse_mapfile(filename) - # set the filepath empty if shapepath is absolute - if os.path.isabs(mapobj.get_shapepath()): - filepath = "" - else: - filepath = mapfilepath + # Show number of Layer found in file numlayers = len(mapobj.get_layers()) if numlayers == 0: @@ -102,256 +337,60 @@ else: context.mainwindow.RunMessageBox(_('Loading Layer'), _("%s Layer loaded from file.") % numlayers) - - selectedlayer = [] - # Show a dialog to select layers to load into thuban + # Show a dialog to select layers to load into thuban only + # if the mapfile contains any layer if numlayers != 0: - lst = [] - for layernr in range(0, numlayers,1): - lst.append(mapobj.get_layers()[layernr].get_name() + - " (" + mapobj.get_layers()[layernr].get_type() +")" ) - - dlgsize = (300,130+len(lst)*20) - if dlgsize[1] >= 300: - dlgsize = (300,300) - dlg = wxMultipleChoiceDialog(context.mainwindow, - "Select the layers from the\n" + - "list to load into thuban.\n" + - "annotation not supported !", - "Select Layer.", lst, size = dlgsize) - if (dlg.ShowModal() == wxID_OK): - selectedlayer = dlg.GetValue() - + selectedlayer = select_layer2import(context,mapobj) + else: + selectedlayer = [] # counter to show the numer of layer loaded into Tuban layer_count = 0 - # thuban map context - tb_map = context.mainwindow.canvas.Map() - # set the titel an 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] - layertitle = maplayer.get_name() - - #check if rasterlayer - if maplayer.get_type() == 'raster': - imgpath = maplayer.get_data() - # if there is no imagepath defined, the Raster Layer could not load - if imgpath == None: - context.mainwindow.RunMessageBox(_('Error Loading Raster Layer'), - _("Can't open the rasterlayer '%s'.") % layertitle) - else: - if os.path.isabs(imgpath): - filename = imgpath - else: - filename = os.path.join(filepath,mapobj.get_shapepath(),imgpath) - # Normalize the pathname by collapses - # redundant separators and up-level references - filename = os.path.normpath(filename) - - rasterlayer = RasterLayer(maplayer.get_name(), filename) - # set the visible status - rasterlayer.SetVisible(maplayer.get_status()) - #add the projection if exists - set_projection_to_tb(rasterlayer, maplayer) - tb_map.AddLayer(rasterlayer) - layer_count += 1 - - #check if polygonlayer - if ((maplayer.get_type() == 'polygon') or - (maplayer.get_type() == 'line') or - (maplayer.get_type() == 'circle') or - (maplayer.get_type() == 'point')): + + # 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) - if mapobj.get_layers()[layernr].get_data(): - if os.path.isabs(mapobj.get_layers()[layernr].get_data()): - filename = mapobj.get_layers()[layernr].get_data() +".shp" - else: - filename = os.path.join(filepath, mapobj.get_shapepath(), \ - mapobj.get_layers()[layernr].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) + # 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 - except IOError: - # the layer couldn't be opened - context.mainwindow.RunMessageBox(_('Open Shapepath'), - _("Can't open the file '%s'.") % filename) - else: - # create a new layer which will be added to thuban later - layer = Layer(layertitle, store) - # all classes of the maplayer - map_clazzes = maplayer.get_classes() - # number of layers loaded vom maplayer - map_numclazzes = len(map_clazzes) - # defaultclazzset is necessary to know if a default class is set - # in thuban. if is not and there are more them one class in the - # mapfile the colors of the default layer in thuban musst - # set to Transparence - defaultclazzset = None - - # create a class in thuban for every class in the maplayer - for map_clazznr in range(0, map_numclazzes, 1): - # define the color - map_clazz = map_clazzes[map_clazznr] - layer_style = map_clazz.get_styles()[0] - 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) - - # if outline color is defined use it else set transparent - if layer_style.get_outlinecolor(): - tb_color = layer_style.get_outlinecolor().get_thubancolor() - prop.SetLineColor(tb_color) - else: - prop.SetLineColor(Transparent) - # if color is defined use it as fillcolor - # but if the layer type is line use the color as linecolor - if layer_style.get_color(): - tb_color = layer_style.get_color().get_thubancolor() - if maplayer.get_type() == 'line': - prop.SetLineColor(tb_color) - else: - prop.SetFill(tb_color) - else: - prop.SetFill(Transparent) - - #set size for the line - if ((maplayer.get_type() == 'polygon') or - (maplayer.get_type() == 'line')): - if layer_style.get_size(): - prop.SetLineWidth(layer_style.get_size()) - - # generate special expression classes to show in thuban - # not all possibilities from the MapServer are supported now - # supporteed: - # String comparisons - # not supported: - # Regular expressions - # Logical expressions - expressionstring = map_clazz.get_expressionstring() - if (((map_numclazzes == 1) & (not expressionstring)) or - ((map_numclazzes > 1) & (expressionstring == None)) or - (expressionstring == '/./')): - if clazz_name == None: - clazz_name = "" - new_group = ClassGroupDefault(props = prop, label = clazz_name) - new_group.SetVisible(map_clazz.get_status()) - clazz.SetDefaultGroup(new_group) - defaultclazzset = True - # break, because alle classes behind the one which definies the - # default will be ignored by mapserver. See sample - # TODO: if possible set it as invisible class in thuban, but - # show the parts of that class as default. - # not possible at the moment ? - break - - # this is the String comparison. - # the expressionstring is enclosed by the ' or " indications - elif ((expressionstring[0] == "'") or - (expressionstring[0] == '"')): - expressionclassitem = maplayer.get_classitem().upper() - layer.SetClassificationColumn(expressionclassitem) - try: - theexpression = int(expressionstring[1:-1]) - except: - theexpression = expressionstring[1:-1] - if clazz_name == None: - clazz_name = str(theexpression) - new_group = ClassGroupSingleton(value = theexpression, - props = prop, - label = clazz_name) - new_group.SetVisible(map_clazz.get_status()) - clazz.AppendGroup(new_group) - else: - new_group = ClassGroupSingleton( props = prop, label = clazz_name) - new_group.SetVisible(map_clazz.get_status()) - clazz.AppendGroup(new_group) - - # if there is no default layer set, - # the color and linecolor will set as Transparent. - if (not defaultclazzset): - proptp = ClassGroupProperties() - proptp.SetLineColor(Transparent) - new_group = ClassGroupDefault(props = proptp) - clazz.SetDefaultGroup(new_group) - defaultclazzset = None - - # set the visible status - layer.SetVisible(maplayer.get_status()) - # 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) - - #add the layer into thuban - tb_map.AddLayer(layer) - - # maybe remove all used layers - # for nr in range(len(selectedlayer)-1, -1, -1): - # print selectedlayer[nr] - # mapobj.remove_layer(selectedlayer[nr]) - # 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) + #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 - # add the map object to thuban, to use it later - tb_map.extension_umn_mapobj = mapobj + # 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) - # fit the new map to the window - context.mainwindow.canvas.FitMapToWindow() + # 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 numlayers != 0: + # fit the new map to the window + context.mainwindow.canvas.FitMapToWindow() + + context.mainwindow.RunMessageBox(_('Layer loaded'), + _("%s Layer loaded into Thuban") % layer_count) - # show a message how many layer were loaded into thuban - # if the number of layers is not null - if numlayers != 0: - context.mainwindow.RunMessageBox(_('Layer loaded'), - _("%s Layer loaded into Thuban") % layer_count) -def set_projection_to_tb(tb_con, mapobj): - """ - Helpfunction to set the projection in thuban. - - Parameters: - tb_con -- The thuban conext (mapobj or layerobj) - mapobj -- The mapobject (from mapscript) - """ - if (mapobj.get_projection().get_params() != None): - projparams = mapobj.get_projection().get_params() - # check if it is an latlong projection, becaues one - # more parameter is needed in that case - addtometer = False - for param in projparams: - projkey = param.split("=") - if projkey[0] == "proj": - if projkey[1] == "latlong": - addtometer = True - if projkey[0] == "to_meter": - addtometer = False - if addtometer == True: - projparams.append("to_meter=0.017453") - tb_con.SetProjection(Projection(projparams)) - if mapobj.get_projection().get_epsgcode() != None: - projepsg = mapobj.get_projection().get_epsgproj() - tb_con.SetProjection(projepsg) - def parse_mapfile(filename): """ Parse the mapfile. From cvs at intevation.de Thu Jul 15 16:31:39 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Thu, 15 Jul 2004 16:31:39 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver mapfile.py,1.7,1.8 Message-ID: <20040715143139.623DB1393B@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver In directory doto:/tmp/cvs-serv5238 Modified Files: mapfile.py Log Message: Added a function to get the mappath directly from the mapobj. Is needed becaus of the changes in mf_import.py. (MF_Layer.add_thubanclass): Added a new comment. (MF_Map.set_extent): Fixed a bug with exporting empty mapobj. If the mapobj is empty there is no extent get from thuban an so no one can set to th mapobj. Index: mapfile.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mapfile.py,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- mapfile.py 14 Jul 2004 10:38:08 -0000 1.7 +++ mapfile.py 15 Jul 2004 14:31:37 -0000 1.8 @@ -622,7 +622,9 @@ elif isinstance(tb_class, ClassGroupSingleton): new_class.set_name(str(tb_class.GetValue())) else: - # TODO: set a name if the expression is a ogical + # TODO: set a name if the expression is a logical + # if it is an logical expression and no name is set, + # the final name will be set after expression is created new_class.set_name("no name") if self.get_type() == "line": new_class.add_thubanstyle(tb_class.GetProperties(), type="line") @@ -686,6 +688,7 @@ self._range_op1 + " " +\ self._range_combine + \ self._range_op2 + " )" + #set the expression to the mapscript new_class.set_expressionstring(self._range_umn) else: @@ -876,6 +879,12 @@ self._metadata.add_metadata(self._metafkey,self._metakeydata) self._metafkey = self._mf_map.getNextMetaDataKey(self._metafkey) + + def get_mappath(self): + return self._mf_map.mappath + + + def get_outputformat(self): return self._outputformat @@ -961,10 +970,12 @@ print "define the size first to set extent" print "size is now set to (1,1)" self.set_size(1,1) - self._newrect = MF_Rectangle(rectObj(newextent[0],newextent[1], \ - newextent[2],newextent[3])) - self._mf_map.setExtent(newextent[0],newextent[1], \ - newextent[2],newextent[3]) + # if an empty map is export newextent will be none + if newextent: + self._newrect = MF_Rectangle(rectObj(newextent[0],newextent[1], \ + newextent[2],newextent[3])) + self._mf_map.setExtent(newextent[0],newextent[1], \ + newextent[2],newextent[3]) def set_size(self, newwidth, newheight): From cvs at intevation.de Thu Jul 15 16:32:53 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Thu, 15 Jul 2004 16:32:53 +0200 (CEST) Subject: jschuengel: thuban ChangeLog,1.668,1.669 Message-ID: <20040715143253.5FE6E1393B@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv5271 Modified Files: ChangeLog Log Message: updated ChangeLog Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.668 retrieving revision 1.669 diff -u -d -r1.668 -r1.669 --- ChangeLog 14 Jul 2004 10:38:57 -0000 1.668 +++ ChangeLog 15 Jul 2004 14:32:51 -0000 1.669 @@ -1,3 +1,22 @@ +2004-07-15 Jan Schüngel + + * Extensions/umn_mapserver/mapfile.py: Added a function to get the + mappath directly from the mapobj. Is needed because of the changes + in mf_import.py. + (MF_Layer.add_thubanclass): Added a new comment. + (MF_Map.set_extent): Fixed a bug with exporting empty mapobj. If the + mapobj is empty there is no extent get from thuban an so no one can + set to th mapobj. + + * Extensions/umn_mapserver/mf_import.py (import_mapfile): Updated + the discription. + Split the funktion in to three smaller ones. The new functions are + add_rasterlayer, add_polygonlayer and select_layer2import. + Removed the mapfilepath and filepath initialisation, because its know + include in the new functions. + Now nothing will be imported if cancel is pressed in the + layer choice dialog. + 2004-07-14 Jan Schüngel * Extensions/umn_mapserver/mapfile.py: Added ClassGroupDefault to From joey at infodrom.org Fri Jul 16 19:09:39 2004 From: joey at infodrom.org (Martin Schulze) Date: Fri, 16 Jul 2004 19:09:39 +0200 Subject: ImportError: libproj.so.0: cannot open shared object file Message-ID: <20040716170938.GU4134@finlandia.infodrom.north.de> Just for your information: The most recent version of proj in Debian unstable (4.4.8-1) does not provide libproj.so.0 anymore, but only libproj.0 &c. To get Thuban running again, you'll have to remove some (all?) .so files in the Lib directory and execute ?python setup.py install_local? again. Not sure if the shared library will be renamed into the .so version again in future versions of the proj package. Regards, Joey -- WARNING: Do not execute! This call violates patent DE10108564. http://www.elug.de/projekte/patent-party/patente/DE10108564 wget -O patinfo-`date +"%Y%m%d"`.html http://patinfo.ffii.org/ From bh at intevation.de Fri Jul 16 21:01:34 2004 From: bh at intevation.de (Bernhard Herzog) Date: Fri, 16 Jul 2004 21:01:34 +0200 Subject: [Thuban-devel] Re: RfD: Support for layer specific resources References: <20040524162641.GQ716@finlandia.infodrom.north.de> <20040530162635.GA20524@finlandia.infodrom.north.de> <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> Message-ID: Martin Schulze writes: > Sorry for the flood of mails. Attached please find the test case > and the real implementation for the Mapping class. Hope this is > what you want. Almost there. > class Mapping: The name is a bit too generic. Maybe ClassMapper? > """ > Implements a mapping of class pairs > """ Actually, it's a mapping of classes (and instances thereof) to arbitrary objects. The renderer extensions are usually functions, for instance. > mapping = [] What's that for? > def __init__(self): > mapping = [] > > def register_class(self, key_class, client_class): > self.mapping.append((key_class, client_class)) I'd simply call this method "add". > def get_class(self, instance): > for key_class, client_class in self.mapping: > if isinstance(instance, key_class): > return client_class > return None And this just "get". Makes the interface a little more like that of a normal dict. Also, client_class isn't restricted to classes. It can be an arbitrary Python object, so "obj" or "value" would be better. > def has_mapping(self, instance): > return self.get_class(instance) is not None Maybe just "has". The dict equivalent would be "has_key" but that doesn't fit this class all that well, though, because the instances aren't the keys, although the behave a bit like ones. Bernhard -- Intevation GmbH http://intevation.de/ Skencil http://sketch.sourceforge.net/ Thuban http://thuban.intevation.org/ From cvs at intevation.de Fri Jul 16 21:47:31 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Fri, 16 Jul 2004 21:47:31 +0200 (CEST) Subject: bh: thuban/test test_viewport.py,1.9,1.10 Message-ID: <20040716194731.3D577139DA@lists.intevation.de> Author: bh Update of /thubanrepository/thuban/test In directory doto:/tmp/cvs-serv12493/test Modified Files: test_viewport.py Log Message: * test/test_viewport.py (ViewPortTest.test_changing_map_projection): Check that changing the projection of an empty map shown in a viewport doesn't lead to exceptions in the viewport's handler for the MAP_PROJECTION_CHANGED messages * Thuban/UI/viewport.py (ViewPort.map_projection_changed): Only try to keep the same region visible when the map actually contains something Index: test_viewport.py =================================================================== RCS file: /thubanrepository/thuban/test/test_viewport.py,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- test_viewport.py 6 Oct 2003 17:31:44 -0000 1.9 +++ test_viewport.py 16 Jul 2004 19:47:28 -0000 1.10 @@ -1,4 +1,4 @@ -# Copyright (c) 2003 by Intevation GmbH +# Copyright (c) 2003, 2004 by Intevation GmbH # Authors: # Jonathan Coles # @@ -154,6 +154,45 @@ self.port.SetMap(self.map) self.check_messages([(90.582425142660739, SCALE_CHANGED), (MAP_REPLACED,)]) + + def test_changing_map_projection(self): + """Test ViewPort behavior when changing the map's projection + + The viewport subscribe's to the map's MAP_PROJECTION_CHANGED + messages and tries to adjust the viewport when the projection + changes to make sure the map is still visible in the window. + There was a bug at one point where the viewport couldn't cope + with the map not having a meaningful bounding box in this + situation. + """ + # Create a projection and an empty map. We can't use self.map + # here because we do need an empty one. + themap = Map("title", Projection(["proj=latlong", + "to_meter=.017453292519943", + "ellps=clrk66"])) + # Add the map to self.session so that it's properly destroyed in + # tearDown() + self.session.AddMap(themap) + + # Add the map to the view port and clear the messages. Then + # we're set for the actual test. + self.port.SetMap(themap) + self.clear_messages() + + # The test: set another projection. The viewport tries to + # adjust the view so that the currently visible region stays + # visible. The viewport has to take into account that the map + # is empty, which it didn't in Thuban/UI/viewport.py rev <= 1.16. + # This part of the test is OK when the SetProjection call does + # not lead to an exception. + themap.SetProjection(Projection(["proj=latlong", + "to_meter=.017453292519943", + "ellps=clrk66"])) + + # If the map weren't empty the viewport might send SCALE_CHANGED + # messages, but it must no do so in this case because the scale + # doesn't change. + self.check_messages([]) def testFitRectToWindow(self): rect = self.port.win_to_proj(9, 990) + self.port.win_to_proj(990, 9) From cvs at intevation.de Fri Jul 16 21:47:31 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Fri, 16 Jul 2004 21:47:31 +0200 (CEST) Subject: bh: thuban/Thuban/UI viewport.py,1.16,1.17 Message-ID: <20040716194731.5B9FA13A08@lists.intevation.de> Author: bh Update of /thubanrepository/thuban/Thuban/UI In directory doto:/tmp/cvs-serv12493/Thuban/UI Modified Files: viewport.py Log Message: * test/test_viewport.py (ViewPortTest.test_changing_map_projection): Check that changing the projection of an empty map shown in a viewport doesn't lead to exceptions in the viewport's handler for the MAP_PROJECTION_CHANGED messages * Thuban/UI/viewport.py (ViewPort.map_projection_changed): Only try to keep the same region visible when the map actually contains something Index: viewport.py =================================================================== RCS file: /thubanrepository/thuban/Thuban/UI/viewport.py,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- viewport.py 27 Nov 2003 16:04:42 -0000 1.16 +++ viewport.py 16 Jul 2004 19:47:29 -0000 1.17 @@ -1,4 +1,4 @@ -# Copyright (c) 2001, 2002, 2003 by Intevation GmbH +# Copyright (c) 2001, 2002, 2003, 2004 by Intevation GmbH # Authors: # Bernhard Herzog # Frank Koormann @@ -327,12 +327,17 @@ return self.map def map_projection_changed(self, map, old_proj): - """Subscribed to the map's MAP_PROJECTION_CHANGED message""" + """Subscribed to the map's MAP_PROJECTION_CHANGED message + + If the projection changes, the region shown is probably not + meaningful anymore in the new projection. Therefore this method + tries to keep the same region visible as before. + """ proj = self.map.GetProjection() bbox = None - if old_proj is not None and proj is not None: + if old_proj is not None and proj is not None and self.map.HasLayers(): width, height = self.GetPortSizeTuple() llx, lly = self.win_to_proj(0, height) urx, ury = self.win_to_proj(width, 0) From cvs at intevation.de Fri Jul 16 21:47:31 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Fri, 16 Jul 2004 21:47:31 +0200 (CEST) Subject: bh: thuban ChangeLog,1.669,1.670 Message-ID: <20040716194731.9C14213B16@lists.intevation.de> Author: bh Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv12493 Modified Files: ChangeLog Log Message: * test/test_viewport.py (ViewPortTest.test_changing_map_projection): Check that changing the projection of an empty map shown in a viewport doesn't lead to exceptions in the viewport's handler for the MAP_PROJECTION_CHANGED messages * Thuban/UI/viewport.py (ViewPort.map_projection_changed): Only try to keep the same region visible when the map actually contains something Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.669 retrieving revision 1.670 diff -u -d -r1.669 -r1.670 --- ChangeLog 15 Jul 2004 14:32:51 -0000 1.669 +++ ChangeLog 16 Jul 2004 19:47:29 -0000 1.670 @@ -1,3 +1,15 @@ +2004-07-16 Bernhard Herzog + + * test/test_viewport.py + (ViewPortTest.test_changing_map_projection): Check that changing + the projection of an empty map shown in a viewport doesn't lead to + exceptions in the viewport's handler for the + MAP_PROJECTION_CHANGED messages + + * Thuban/UI/viewport.py (ViewPort.map_projection_changed): Only + try to keep the same region visible when the map actually contains + something + 2004-07-15 Jan Schüngel * Extensions/umn_mapserver/mapfile.py: Added a function to get the From joey at infodrom.org Sun Jul 18 05:44:19 2004 From: joey at infodrom.org (Martin Schulze) Date: Sun, 18 Jul 2004 05:44:19 +0200 Subject: [Thuban-devel] Re: RfD: Support for layer specific resources In-Reply-To: References: <20040530162635.GA20524@finlandia.infodrom.north.de> <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> Message-ID: <20040718034419.GC4134@finlandia.infodrom.north.de> Are the attached files better? If so, where should it be placed? Thuban.UI sounds a bit weird as location. Thuban.Lib sounds more appropriate. Regards, Joey -- Those who don't understand Unix are condemned to reinvent it, poorly. -------------- next part -------------- A non-text attachment was scrubbed... Name: test_classmapper.py Type: text/x-python Size: 1024 bytes Desc: not available Url : http://www.intevation.de/pipermail/thuban-devel/attachments/20040718/c5c864d6/test_classmapper.py -------------- next part -------------- A non-text attachment was scrubbed... Name: classmapper.py Type: text/x-python Size: 987 bytes Desc: not available Url : http://www.intevation.de/pipermail/thuban-devel/attachments/20040718/c5c864d6/classmapper.py From joey at infodrom.org Sun Jul 18 07:11:42 2004 From: joey at infodrom.org (Martin Schulze) Date: Sun, 18 Jul 2004 07:11:42 +0200 Subject: ImportError: libproj.so.0: cannot open shared object file In-Reply-To: <20040716170938.GU4134@finlandia.infodrom.north.de> References: <20040716170938.GU4134@finlandia.infodrom.north.de> Message-ID: <20040718051142.GA16948@finlandia.infodrom.north.de> Martin Schulze wrote: > Just for your information: > > The most recent version of proj in Debian unstable (4.4.8-1) does not > provide libproj.so.0 anymore, but only libproj.0 &c. To get Thuban > running again, you'll have to remove some (all?) .so files in the Lib > directory and execute ?python setup.py install_local? again. > > Not sure if the shared library will be renamed into the .so version > again in future versions of the proj package. Looks like that was indeed a packaging bug which is fixed in the new version: proj (4.4.8-2) unstable; urgency=low * Use new /usr/share/misc/config.guess and config.sub instead of using patch from 4.4.7-3 as in 4.4.8-1, which led to wrong library so names (lacking the .so part). -- Peter S Galbraith Sat, 17 Jul 2004 12:16:26 -0400 Regards, Joey -- It's time to close the windows. From thuban-bugs at intevation.de Tue Jul 20 11:44:09 2004 From: thuban-bugs at intevation.de (Request Tracker) Date: Tue, 20 Jul 2004 11:44:09 +0200 (CEST) Subject: [bug #2549] (thuban) exception when trying to generate one class Message-ID: <20040720094409.34135139AE@lists.intevation.de> this bug's URL: http://intevation.de/rt/webrt?serial_num=2549 ------------------------------------------------------------------------- Subject: exception when trying to generate one class Operating System: GNU/Linux, Debian GNU/Linux Sarge Thuban version: CVS wxPython version: 2.4.2.4 Python version: 2.3.4 PySQLite version: 0.4.3 SQLite version: 2.8.13 GDAL version: 1.2.0 proj version: 4.4.7 the following exception occured when i try to generade classification from "Quantiles from Table" with only one class: Traceback (most recent call last): File "/big/home/janschu/project/thuban/Thuban/UI/classgen.py", line 269, in OnOK adjusted, self.clazz = \ File "/big/home/janschu/project/thuban/Thuban/Model/classgen.py", line 114, in generate_quantiles quantiles = calculate_quantiles(_list, percents, _range) File "/big/home/janschu/project/thuban/Thuban/Model/classgen.py", line 192, in calculate_quantiles raise ValueError("percents parameter must have more than one item") ValueError: percents parameter must have more than one item -------------------------------------------- Managed by Request Tracker From cvs at intevation.de Wed Jul 21 11:00:41 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Wed, 21 Jul 2004 11:00:41 +0200 (CEST) Subject: jan: thuban/Extensions/umn_mapserver README,1.4,1.5 Message-ID: <20040721090041.41C861397F@lists.intevation.de> Author: jan Update of /thubanrepository/thuban/Extensions/umn_mapserver In directory doto:/tmp/cvs-serv13849 Modified Files: README Log Message: Added hint that installation as root can be avoided. Removed all tabs. Index: README =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/README,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- README 1 Jul 2004 14:39:29 -0000 1.4 +++ README 21 Jul 2004 09:00:38 -0000 1.5 @@ -38,13 +38,15 @@ Download the UMN MapServer (http://mapserver.gis.umn.edu/dload.html) or use one on your system. The mapscript is included in the source package. - Unpack and compile the UMN MapServer and use the following optional parameters: - - proj: include projection support - gdal: include raster support - tiff: include tiff support - - In some cases gdal is not necessary and mapscript can install without gdal support. + Unpack and compile the UMN MapServer and use the following optional + parameters: + + proj: include projection support + gdal: include raster support + tiff: include tiff support + + In some cases gdal is not necessary and mapscript can install without + gdal support. A detailed install instruction can be found on the UMN MapServer Homepage. (http://mapserver.gis.umn.edu) @@ -68,16 +70,24 @@ Some warnings are ok during the build of python mapscript - At last we musst install mapscript as root. + At last we either install mapscript as root: python setup.py install + or (if you don't want to pollute your system with circumventing + the package installation system) you may set something + like this (not that the exact path depends on your system and + where you place the mapserver sources) for testing the stuff + temporarily: + + export PYTHONPATH=~/mapserver-4.2.0/mapscript/python/build/lib.linux-i686-2.3 + 2. Add the umn_mapserver extension import statements to ~/.thuban/thubanstart.py if you run thuban directly from the source directory the statement is: import Extensions.umn_mapserver.mf_import - import Extensions.umn_mapserver.mf_export - import Extensions.umn_mapserver.mf_handle + import Extensions.umn_mapserver.mf_export + import Extensions.umn_mapserver.mf_handle More about how to use an extension see README in thuban/Examples/simple_extensions. From cvs at intevation.de Wed Jul 21 11:01:41 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Wed, 21 Jul 2004 11:01:41 +0200 (CEST) Subject: jan: thuban ChangeLog,1.670,1.671 Message-ID: <20040721090141.151CE1397F@lists.intevation.de> Author: jan Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv13878 Modified Files: ChangeLog Log Message: improved README of mapserver extension Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.670 retrieving revision 1.671 diff -u -d -r1.670 -r1.671 --- ChangeLog 16 Jul 2004 19:47:29 -0000 1.670 +++ ChangeLog 21 Jul 2004 09:01:38 -0000 1.671 @@ -1,3 +1,8 @@ +2004-07-21 Jan-Oliver Wagner + + * Extensions/umn_mapserver/README: Added hint that + installation as root can be avoided. Removed all tabs. + 2004-07-16 Bernhard Herzog * test/test_viewport.py From jan at intevation.de Wed Jul 21 11:10:32 2004 From: jan at intevation.de (Jan-Oliver Wagner) Date: Wed, 21 Jul 2004 11:10:32 +0200 Subject: Issues for MapServer extensions Message-ID: <20040721091032.GA901@intevation.de> Hi Jan, I've tested the mapserver extension a little bit and have some comments: 1. When creating .map files, there should be a comment at the beginning of the file that this has been automatically created by the Thuban UMN Mapserver extension. 2. I have problems creating a .map file from iceland_sample_class.thuban (but happens with all iceland sampes): An unhandled exception occurred: msInitGDALOutputFormat(): General error message. No GDAL driver named `GTiff' available. What do I need to do to avoid this? Hmm: This problem occurs only if I first load a mapfile, the load another session. If I start with loading a session and then storing this as a mapfile all works fine. 3. I improved the README a little bit as it can be avoided to make a installation as root which some people (like me) do not want. 4. There are some error message when importing the sample map file. Are you working on this? 5. If I export the iceland_sample_class.thuban as a .map-file and import that again, the projection is lost. The rest looks identical - very nice. What about the projection? Best Jan -- Jan-Oliver Wagner http://intevation.de/~jan/ Intevation GmbH http://intevation.de/ FreeGIS http://freegis.org/ From jschuengel at intevation.de Wed Jul 21 11:54:05 2004 From: jschuengel at intevation.de (=?ISO-8859-1?Q?Jan_Sch=FCngel?=) Date: Wed, 21 Jul 2004 11:54:05 +0200 Subject: Issues for MapServer extensions In-Reply-To: <20040721091032.GA901@intevation.de> References: <20040721091032.GA901@intevation.de> Message-ID: <40FE3D3D.8040906@intevation.de> Hi, thanks for your comments. I write my answers directly behind the numbers. Greets Jan S. >1. When creating .map files, there should be a comment >at the beginning of the file that this has been >automatically created by the Thuban UMN Mapserver extension. > > I will try this, but the mapscript-saver don't support this, so I must open the map file manuell and write the text inside. I try it. >2. I have problems creating a .map file from >iceland_sample_class.thuban (but happens with all iceland >sampes): > An unhandled exception occurred: > msInitGDALOutputFormat(): General error message. No GDAL driver named > `GTiff' available. >What do I need to do to avoid this? >Hmm: This problem occurs only if I first load a mapfile, >the load another session. If I start with loading a session >and then storing this as a mapfile all works fine. > > I know this problem but I don't know how to solve it. For any idea I last very gratefully >3. I improved the README a little bit as it can be avoided >to make a installation as root which some people (like me) >do not want. > > ok its fine :) >4. There are some error message when importing the sample >map file. Are you working on this? > > O, I don't see any error messages when importing the sample mapfile. Can you send me an error log so I can look what's wrong ? >5. If I export the iceland_sample_class.thuban as a .map-file >and import that again, the projection is lost. The rest >looks identical - very nice. >What about the projection? > > In this case the problem is, that the layer need an projection to show in the mapserver. If there is no projection defined the layer will not shown. But if I set the layer in this case during the export, the set projection will be imported, too. I will look how to solve this. >Best > > Jan > > From thuban-bugs at intevation.de Thu Jul 22 09:57:05 2004 From: thuban-bugs at intevation.de (Request Tracker) Date: Thu, 22 Jul 2004 09:57:05 +0200 (CEST) Subject: [bug #2553] (thuban) Layer-Class visibility (dialog) is set incorrect by code Message-ID: <20040722075705.71075139A8@lists.intevation.de> this bug's URL: http://intevation.de/rt/webrt?serial_num=2553 ------------------------------------------------------------------------- Subject: Layer-Class visibility (dialog) is set incorrect by code Operating System: GNU/Linux Thuban version: CVS, 20040722 wxPython version: other, 2.4.2.4 Python version: other, 2.3.4 PySQLite version: 0.4.3 SQLite version: other, 2.8.13 GDAL version: other, 1.2.0.0 proj version: 4.4.7 if i set the visibility of a group by the code new_group = ClassGroupSingleton(label = "Classname") new_group.SetVisible(False) to invisible and then add the layer with that class to thuban, the layer is not shown. So far all works fine, but if i open the properties dialog, the singleton group is marked as visible, and its very difficult to mark it now to visible. -------------------------------------------- Managed by Request Tracker From cvs at intevation.de Thu Jul 22 14:37:30 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Thu, 22 Jul 2004 14:37:30 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver mf_export.py,1.4,1.5 Message-ID: <20040722123730.8BF0C139AE@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver In directory doto:/tmp/cvs-serv29780 Modified Files: mf_export.py Log Message: Added "import os" Removed the old "import Thuban.UI.mainwindow" code. (tbextent_to_map): Removed the extra function and at the code direct to "thuban_to_map" function. (write_creatorcomment): Added. Now a short comment is added to the beginning of an generated mapfile. (export_mapfile): Now the Path and filename are saved in to variables and not together in one variable. This is needed for the new write_creatorcomment function. Index: mf_export.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mf_export.py,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- mf_export.py 14 Jul 2004 10:36:40 -0000 1.4 +++ mf_export.py 22 Jul 2004 12:37:28 -0000 1.5 @@ -22,7 +22,7 @@ # # ################################### -#import os, sys +import os # mapscript from mapscript import mapObj @@ -39,9 +39,6 @@ # instance registry. from Thuban.UI.command import registry, Command -# The instance of the main menu of the Thuban application -#import Thuban.UI.mainwindow - # needed to add the new menu from Thuban.UI.mainwindow import main_menu @@ -66,12 +63,6 @@ for layer in tb_layers: map.add_thubanlayer(layer) -def tbextent_to_map(tb_map, map): - tb_bbox = tb_map.ProjectedBoundingBox() - # Size must be set before, because mapscript checks it - # when extent is set - map.set_extent(tb_bbox) - def thuban_to_map(tb_context, map): # get the thuban map tb_map = tb_context.mainwindow.canvas.Map() @@ -80,7 +71,11 @@ # set the projection tbproj_to_map(tb_map, map) # set the extend - tbextent_to_map(tb_map, map) + tb_bbox = tb_map.ProjectedBoundingBox() + # tb_bbox = tb_context.mainwindow.canvas.get_view_transform() + # Size must be set before, because mapscript checks it + # when extent is set + map.set_extent(tb_bbox) tblayer_to_map(tb_map, map) def add_circle_symbol(map): @@ -92,7 +87,21 @@ new_symbol.set_type(2) new_symbol.set_filled(True) map.get_symbolset().add_symbol(new_symbol) - + +def write_creatorcomment(path,file): + thuban_umn_comment = "# \n" + \ + "# Map file generated by Thuban (umn_mapserver Extension) \n" + \ + "# \n \n" + datafile = os.path.join(path,file) + + in_file = open(datafile,"r") + text_in_file = in_file.read() + in_file.close() + + out_file = open(datafile,"w") + out_file.write(thuban_umn_comment) + out_file.write(text_in_file) # text in Datei schreiben + out_file.close() # Datei schliessen def export_mapfile(context): @@ -108,7 +117,8 @@ "All files (*.*)|*.*", wxSAVE |wxOVERWRITE_PROMPT) if dlg.ShowModal() == wxID_OK: - path = dlg.GetPath() + path = dlg.GetDirectory() + file = dlg.GetFilename() dlg.Destroy() else: return @@ -118,9 +128,13 @@ #add symbol add_circle_symbol(theMap) - + # save the map with the integrated mapscript saver - theMap.save_map(path) + theMap.save_map(os.path.join(path,file)) + + # 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 From cvs at intevation.de Thu Jul 22 14:38:40 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Thu, 22 Jul 2004 14:38:40 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver mf_import.py,1.7,1.8 Message-ID: <20040722123840.3CFA2139AE@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver In directory doto:/tmp/cvs-serv29811 Modified Files: mf_import.py Log Message: Added the import module "re". Also added Range and the ClassGroupRange import from Thuban. Both are needed for the new range expression import. (create_rangeexpression): Added. Creates a Range Expression in Thuban style from a given mapfile expression. (added_rasterlayer): Make some small code changes. The shapepath is now stored in an extra variable and the clazz_name is set empty if no class name set in the mapfile. Changed the Error message for Range Expressions, becaus the new function create a error string which will be shown in the dialog. Index: mf_import.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mf_import.py,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- mf_import.py 15 Jul 2004 14:30:37 -0000 1.7 +++ mf_import.py 22 Jul 2004 12:38:38 -0000 1.8 @@ -16,13 +16,14 @@ # $Id$ + # ################################### # # import necessary modules # # ################################### -import os +import os, re from mapscript import mapObj @@ -49,9 +50,12 @@ from Thuban.UI.mainwindow import main_menu from Thuban.Model.classification import ClassGroupSingleton, \ + ClassGroupRange, \ ClassGroupProperties, \ ClassGroupDefault +from Thuban.Model.range import Range + # The Thuban color objects from Thuban.Model.color import Transparent @@ -91,6 +95,106 @@ projepsg = mapobj.get_projection().get_epsgproj() tb_con.SetProjection(projepsg) +def create_rangeexpression(mapexprstr): + """ + create a expressionstring in thuban style from an given + mapfile expressionstring + + mapexprstr = the expressionstring from the mapfile + """ + attribut_expr = "\[\w+\]" + attribut = re.compile(attribut_expr) + operator_expr = ">=|<=|<|>|=" + operator = re.compile(operator_expr) + #only and now supported + link_expr = "AND" + link = re.compile(link_expr) + oneexpr = "\s*\[\w+\]\s*>*<*=*\s*\w+" + theexpr = re.compile(oneexpr) + + # init the string variables to build the string later + thestring = "" + strbegin = None + strmin = None + strmax = None + strend = None + + link_result = link.findall(mapexprstr) + attr = attribut.findall(mapexprstr) + if len(link_result) == 0 and len(attr) == 1: + strattr = attr[0][1:-1] + expression = theexpr.findall(mapexprstr) + if expression: + operator_result = operator.search(mapexprstr) + if operator_result.group(0) == ">=": + strbegin = "[" + strmin = operator_result.string[operator_result.start()+2:].replace(" ","") + strmax = "oo" + strend = "]" + elif operator_result.group(0) == "<=": + strbegin = "[" + strmin = "-oo" + strmax = operator_result.string[operator_result.start()+2:].replace(" ","") + strend = "]" + elif operator_result.group(0) == ">": + strbegin = "]" + strmin = operator_result.string[operator_result.start()+1:].replace(" ","") + strmax = "oo" + strend = "]" + elif operator_result.group(0) == "<": + strbegin = "[" + strmin = "-oo" + strmax = operator_result.string[operator_result.start()+1:].replace(" ","") + strend = "[" + elif operator_result.group(0) == "=": + # create a singleton, not implemented yet + errorstring = "singleton creation not implemented yet" + else: + errorstring = "no operator found" + else: + errorstring = "no expression found" + elif len(link_result) == 1: + if attr[0] == attr[1]: + strattr = attr[0][1:-1] + first_expr,second_expr = mapexprstr.split("AND") + oneexpr_result = theexpr.findall(mapexprstr) + operator1_result = operator.search(first_expr) + operator2_result = operator.search(second_expr) + errorstring = "operators are wrong" + if operator1_result.group(0)[0] == "<" and \ + operator2_result.group(0)[0] == ">": + optemt = operator1_result + operator1_result = operator2_result + operator2_result = optemt + if operator1_result.group(0) == ">=": + strbegin = "[" + strmin = operator1_result.string[operator1_result.start()+2:].replace(" ","") + elif operator1_result.group(0) == ">": + strbegin = "]" + strmin = operator1_result.string[operator1_result.start()+1:].replace(" ","") + if operator2_result.group(0) == "<=": + strend = "]" + strmax = operator2_result.string[operator2_result.start()+2:].replace(" ","") + elif operator2_result.group(0) == "<" and operator1_result != ">" : + strend = "[" + strmax = operator2_result.string[operator2_result.start()+1:].replace(" ","") + if strmax < strmin: + errorstring = "values are wrong" + strbegin = None + else: + errorstring = "Attributes not equal" + elif len(link_result) == 0: + errorstring = "Link expression not supported" + else: + errorstring = "More then two expressions" + + #create the expression thestring + if strbegin and strmin and strmax and strend: + thestring = strbegin +strmin+";"+strmax + strend + return (strattr, thestring) + else: + return (None,errorstring) + def add_rasterlayer(context, tb_map, mapobj, maplayer): """ @@ -103,6 +207,7 @@ maplayer = layer obj to add to thuban """ imgpath = maplayer.get_data() + shapepath = mapobj.get_shapepath() filepath = mapobj.get_mappath() layertitle = maplayer.get_name() # if there is no imagepath defined, the Raster Layer could not load @@ -113,11 +218,10 @@ if os.path.isabs(imgpath): filename = imgpath else: - filename = os.path.join(filepath,mapobj.get_shapepath(),imgpath) + filename = os.path.join(filepath, shapepath,imgpath) # Normalize the pathname by collapses # redundant separators and up-level references filename = os.path.normpath(filename) - rasterlayer = RasterLayer(layertitle, filename) # set the visible status rasterlayer.SetVisible(maplayer.get_status()) @@ -242,18 +346,37 @@ except: theexpression = expressionstring[1:-1] if clazz_name == None: - clazz_name = str(theexpression) + clazz_name = str("") new_group = ClassGroupSingleton(value = theexpression, props = prop, label = clazz_name) new_group.SetVisible(map_clazz.get_status()) clazz.AppendGroup(new_group) elif (expressionstring[0] == "("): - context.mainwindow.RunMessageBox(_('Error Loading Layer'), - _("could not import the expression\n"+ \ - "%s \n from layer '%s', class %d (%s)'.")\ - %(expressionstring, layertitle, \ - map_clazznr, map_clazz.get_name())) + expressionclassitem, thubanexpr \ + = create_rangeexpression(expressionstring[1:-1]) + if expressionclassitem == None: + if clazz_name == None: + clazz_showtxt = "Nr. " + str(map_clazznr+1) + else: + clazz_showtxt = clazz_name + context.mainwindow.RunMessageBox(_('Error Loading Expression'), \ + _("%s \n" + \ + "Can't load the Expression from layer \n" + \ + "Layer: %s ; Class: %s\n" + \ + "Expression: %s")\ + %(thubanexpr, layer.title, clazz_showtxt, expressionstring[1:-1]) ) + else: + layer.SetClassificationColumn(expressionclassitem) + if clazz_name == None: + clazz_name = str("") + expressionrange = Range(thubanexpr) + new_group = ClassGroupRange(expressionrange, + props = prop, + label = clazz_name) + new_group.SetVisible(map_clazz.get_status()) + clazz.AppendGroup(new_group) + else: new_group = ClassGroupSingleton(props = prop,label = clazz_name) new_group.SetVisible(map_clazz.get_status()) @@ -345,7 +468,6 @@ selectedlayer = [] # 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 @@ -386,10 +508,11 @@ if numlayers != 0: # fit the new map to the window context.mainwindow.canvas.FitMapToWindow() - + # get the extent from the map and set it in thuban + #extentrect = mapobj.get_extent().get_rect() + #context.mainwindow.canvas.FitRectToWindow(extentrect) context.mainwindow.RunMessageBox(_('Layer loaded'), _("%s Layer loaded into Thuban") % layer_count) - def parse_mapfile(filename): """ From cvs at intevation.de Thu Jul 22 14:39:29 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Thu, 22 Jul 2004 14:39:29 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver/test test_mapserver.py, 1.4, 1.5 Message-ID: <20040722123929.76766139AE@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver/test In directory doto:/tmp/cvs-serv29828/test Modified Files: test_mapserver.py Log Message: Added a test for the range expression import. Index: test_mapserver.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/test/test_mapserver.py,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- test_mapserver.py 14 Jul 2004 10:32:29 -0000 1.4 +++ test_mapserver.py 22 Jul 2004 12:39:27 -0000 1.5 @@ -34,6 +34,8 @@ from Extensions.umn_mapserver.mapfile import shp_type +from Extensions.umn_mapserver.mf_import import create_rangeexpression + class mapserver_generalClasses(unittest.TestCase): def setUp(self): @@ -306,6 +308,88 @@ self.eq(testweb.get_imageurl(),"/tmpurl/") testweb.set_imageurl("/tmpurlset/") self.eq(testweb.get_imageurl(), "/tmpurlset/") + + +class mapserver_mf_import(unittest.TestCase): + + def setUp(self): + """ + Running this funktion befor each test + """ + # using the sample map + testMapfile = 'test.map' + self.testMap = mapObj(testMapfile) + self.eq = self.assertEquals + + + def test_create_rangeexpression(self): + """ + testing the range expression creation from the code in the mapfile + """ + # the expressions to test + # these expresions are like in thuban + test1 = "([ATTR] >= 1 AND [ATTR] <= 100)" # [min,max] + code,expr = create_rangeexpression(test1[1:-1]) + self.eq(code, "ATTR") + self.eq(expr,"[1;100]") + test2 = "([ATTR] >= 1 AND [ATTR] < 100)" # [min,max[ + code,expr = create_rangeexpression(test2[1:-1]) + self.eq(code, "ATTR") + self.eq(expr,"[1;100[") + test3 = "([ATTR] > 1 AND [ATTR] <= 100)" # ]min,max] + code,expr = create_rangeexpression(test3[1:-1]) + self.eq(code, "ATTR") + self.eq(expr,"]1;100]") + test4 = "([ATTR] > 1 AND [ATTR] < 100)" # ]min,max[ + code,expr = create_rangeexpression(test4[1:-1]) + self.eq(code, "ATTR") + self.eq(expr,"]1;100[") + + test5 = "([ATTR] <= 100)" # [-oo,max] , ]-oo,max] + code,expr = create_rangeexpression(test5[1:-1]) + self.eq(code, "ATTR") + self.eq(expr,"[-oo;100]") + test6 = "([ATTR] < 100)" # [-oo,max[ , ]-oo,max[ + code,expr = create_rangeexpression(test6[1:-1]) + self.eq(code, "ATTR") + self.eq(expr,"[-oo;100[") + test7 = "([ATTR] >= 1)" # [min,oo] , [min, oo[ + code,expr = create_rangeexpression(test7[1:-1]) + self.eq(code, "ATTR") + self.eq(expr,"[1;oo]") + test8 = "([ATTR] > 1)" # ]min,oo] , ]min, oo[ + code,expr = create_rangeexpression(test8[1:-1]) + self.eq(code, "ATTR") + self.eq(expr,"]1;oo]") + + # value equal, works but is not really usefull + test9= "([ATTR] < 1 AND [ATTR] >= 1)" + code,expr = create_rangeexpression(test9[1:-1]) + self.eq(code, "ATTR") + self.eq(expr,"[1;1[") + + # works but must be changed the order + test10= "([ATTR] <= 100 AND [ATTR] >= 1)" + code,expr = create_rangeexpression(test10[1:-1]) + self.eq(code, "ATTR") + self.eq(expr,"[1;100]") + + #singleton not implemented yet + test11 = "([ATTR] = 1)" + code,expr = create_rangeexpression(test11[1:-1]) + self.eq(code, None) + self.eq(expr,"singleton creation not implemented yet") + + # Attributes not equal + test12= "([ATTR] < 100 AND [ATTR2] >= 1)" + code,expr = create_rangeexpression(test12[1:-1]) + self.eq(code, None) + self.eq(expr,"Attributes not equal") + # dont works, is not supported by thuban + test13="([ATTR] > 100 AND [ATTR] < 1)" + code,expr = create_rangeexpression(test13[1:-1]) + self.eq(code, None) + self.eq(expr,"values are wrong") if __name__ == '__main__': From cvs at intevation.de Thu Jul 22 14:40:23 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Thu, 22 Jul 2004 14:40:23 +0200 (CEST) Subject: jschuengel: thuban ChangeLog,1.671,1.672 Message-ID: <20040722124023.6099C139AE@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv29843 Modified Files: ChangeLog Log Message: updated ChangeLog Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.671 retrieving revision 1.672 diff -u -d -r1.671 -r1.672 --- ChangeLog 21 Jul 2004 09:01:38 -0000 1.671 +++ ChangeLog 22 Jul 2004 12:40:20 -0000 1.672 @@ -1,3 +1,29 @@ +2004-07-22 Jan Schüngel + + * Extensions/umn_mapserver/mf_export.py: Added "import os" + Removed the old "import Thuban.UI.mainwindow" code. + (tbextent_to_map): Removed the extra function and at the code direct + to "thuban_to_map" function. + (write_creatorcomment): Added. Now a short comment is added to the + beginning of an generated mapfile. + (export_mapfile): Now the Path and filename are saved in to variables, + and not together in one variable. This is needed for the new + write_creatorcomment function. + + * Extensions/umn_mapserver/mf_import.py (import_mapfile): Added the + import module "re". Also added Range and the ClassGroupRange import + from Thuban. Both are needed for the new range expression import. + (create_rangeexpression): Added. Creates a Range Expression in Thuban + style from a given mapfile expression. + (added_rasterlayer): Make some small code changes. The shapepath is + now stored in an extra variable and the clazz_name is set empty if no + class name set in the mapfile. + Changed the Error message for Range Expressions, becaus the new + function create a error string which will be shown in the dialog. + + * Extensions/umn_mapserver/test/test_mapserver.py: Added a test for the + range expression import. + 2004-07-21 Jan-Oliver Wagner * Extensions/umn_mapserver/README: Added hint that From cvs at intevation.de Thu Jul 22 15:05:52 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Thu, 22 Jul 2004 15:05:52 +0200 (CEST) Subject: bh: thuban/test test_viewport.py,1.10,1.11 Message-ID: <20040722130552.35C321392D@lists.intevation.de> Author: bh Update of /thubanrepository/thuban/test In directory doto:/tmp/cvs-serv30233/test Modified Files: test_viewport.py Log Message: Use support.run_tests as the main function when running asa script. Index: test_viewport.py =================================================================== RCS file: /thubanrepository/thuban/test/test_viewport.py,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- test_viewport.py 16 Jul 2004 19:47:28 -0000 1.10 +++ test_viewport.py 22 Jul 2004 13:05:49 -0000 1.11 @@ -480,5 +480,4 @@ if __name__ == "__main__": - unittest.main() - + support.run_tests() From cvs at intevation.de Thu Jul 22 15:05:52 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Thu, 22 Jul 2004 15:05:52 +0200 (CEST) Subject: bh: thuban ChangeLog,1.672,1.673 Message-ID: <20040722130552.C08FD13944@lists.intevation.de> Author: bh Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv30233 Modified Files: ChangeLog Log Message: Use support.run_tests as the main function when running asa script. Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.672 retrieving revision 1.673 diff -u -d -r1.672 -r1.673 --- ChangeLog 22 Jul 2004 12:40:20 -0000 1.672 +++ ChangeLog 22 Jul 2004 13:05:50 -0000 1.673 @@ -1,3 +1,8 @@ +2004-07-22 Bernhard Herzog + + * test/test_viewport.py: Use support.run_tests as the main + function when running asa script. + 2004-07-22 Jan Schüngel * Extensions/umn_mapserver/mf_export.py: Added "import os" From cvs at intevation.de Thu Jul 22 15:07:54 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Thu, 22 Jul 2004 15:07:54 +0200 (CEST) Subject: bh: thuban/test test_viewport.py,1.11,1.12 Message-ID: <20040722130754.5711D13944@lists.intevation.de> Author: bh Update of /thubanrepository/thuban/test In directory doto:/tmp/cvs-serv30330/test Modified Files: test_viewport.py Log Message: * Thuban/UI/viewport.py (ViewPort.VisibleExtent): New. Return the visible extent of the map in projected coordinates * test/test_viewport.py (SimpleViewPortTest.test_default_size) (SimpleViewPortTest.test_init_with_size): Add some VisibleExtent() tests. (SimpleViewPortTest.test_visible_extent): New. The real test for VisibleExtent() Index: test_viewport.py =================================================================== RCS file: /thubanrepository/thuban/test/test_viewport.py,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- test_viewport.py 22 Jul 2004 13:05:49 -0000 1.11 +++ test_viewport.py 22 Jul 2004 13:07:52 -0000 1.12 @@ -56,6 +56,7 @@ self.assertEquals(port.GetPortSizeTuple(), (400, 300)) self.assertEquals(port.scale, 1.0) self.assertEquals(port.offset, (0, 0)) + self.assertEquals(port.VisibleExtent(), (0.0, -300.0, 400.0, 0.0)) finally: port.Destroy() @@ -64,6 +65,31 @@ port = ViewPort((1001, 1001)) try: self.assertEquals(port.GetPortSizeTuple(), (1001, 1001)) + self.assertEquals(port.VisibleExtent(), (0.0, -1001.0, 1001.0, 0.0)) + finally: + port.Destroy() + + def test_visible_extent(self): + """Test ViewPort.VisibleExtent()""" + class MockMap: + def ProjectedBoundingBox(self): + return (500, 400, 600, 500) + # noops that the viewport expects but which aren't needed + # here: + Subscribe = Unsubscribe = lambda *args: None + + map = MockMap() + port = ViewPort((1000, 1000)) + try: + port.SetMap(map) + # The viewport adjusts automatically to the map. Since both + # the map's bounding box and the viewport are square the map + # fits exactly. + self.assertEquals(port.VisibleExtent(), (500, 400, 600, 500)) + + # Zoom in a bit + port.ZoomFactor(2) + self.assertEquals(port.VisibleExtent(), (525, 425, 575, 475)) finally: port.Destroy() From cvs at intevation.de Thu Jul 22 15:07:54 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Thu, 22 Jul 2004 15:07:54 +0200 (CEST) Subject: bh: thuban/Thuban/UI viewport.py,1.17,1.18 Message-ID: <20040722130754.84728139AE@lists.intevation.de> Author: bh Update of /thubanrepository/thuban/Thuban/UI In directory doto:/tmp/cvs-serv30330/Thuban/UI Modified Files: viewport.py Log Message: * Thuban/UI/viewport.py (ViewPort.VisibleExtent): New. Return the visible extent of the map in projected coordinates * test/test_viewport.py (SimpleViewPortTest.test_default_size) (SimpleViewPortTest.test_init_with_size): Add some VisibleExtent() tests. (SimpleViewPortTest.test_visible_extent): New. The real test for VisibleExtent() Index: viewport.py =================================================================== RCS file: /thubanrepository/thuban/Thuban/UI/viewport.py,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- viewport.py 16 Jul 2004 19:47:29 -0000 1.17 +++ viewport.py 22 Jul 2004 13:07:52 -0000 1.18 @@ -431,6 +431,17 @@ offx, offy = self.offset return ((x - offx) / self.scale, (offy - y) / self.scale) + def VisibleExtent(self): + """Return the extent of the visible region in projected coordinates + + The return values is a tuple (llx, lly, urx, ury) describing the + region. + """ + width, height = self.GetPortSizeTuple() + llx, lly = self.win_to_proj(0, height) + urx, ury = self.win_to_proj(width, 0) + return (llx, lly, urx, ury) + def FitRectToWindow(self, rect): """Fit the rectangular region given by rect into the window. From cvs at intevation.de Thu Jul 22 15:07:55 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Thu, 22 Jul 2004 15:07:55 +0200 (CEST) Subject: bh: thuban ChangeLog,1.673,1.674 Message-ID: <20040722130755.287A0139D2@lists.intevation.de> Author: bh Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv30330 Modified Files: ChangeLog Log Message: * Thuban/UI/viewport.py (ViewPort.VisibleExtent): New. Return the visible extent of the map in projected coordinates * test/test_viewport.py (SimpleViewPortTest.test_default_size) (SimpleViewPortTest.test_init_with_size): Add some VisibleExtent() tests. (SimpleViewPortTest.test_visible_extent): New. The real test for VisibleExtent() Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.673 retrieving revision 1.674 diff -u -d -r1.673 -r1.674 --- ChangeLog 22 Jul 2004 13:05:50 -0000 1.673 +++ ChangeLog 22 Jul 2004 13:07:52 -0000 1.674 @@ -1,5 +1,16 @@ 2004-07-22 Bernhard Herzog + * Thuban/UI/viewport.py (ViewPort.VisibleExtent): New. Return the + visible extent of the map in projected coordinates + + * test/test_viewport.py (SimpleViewPortTest.test_default_size) + (SimpleViewPortTest.test_init_with_size): Add some VisibleExtent() + tests. + (SimpleViewPortTest.test_visible_extent): New. The real test for + VisibleExtent() + +2004-07-22 Bernhard Herzog + * test/test_viewport.py: Use support.run_tests as the main function when running asa script. From bh at intevation.de Thu Jul 22 16:40:17 2004 From: bh at intevation.de (Bernhard Herzog) Date: Thu, 22 Jul 2004 16:40:17 +0200 Subject: [Thuban-devel] Re: RfD: Support for layer specific resources References: <20040530162635.GA20524@finlandia.infodrom.north.de> <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> Message-ID: Martin Schulze writes: > Are the attached files better? Yes. Only nit: Please don't use "object" as identifier in new code. It's a Python builtin. > If so, where should it be placed? Thuban.UI sounds a bit weird as > location. Thuban.Lib sounds more appropriate. Yes. Thuban.Lib is better. Bernhard -- Intevation GmbH http://intevation.de/ Skencil http://sketch.sourceforge.net/ Thuban http://thuban.intevation.org/ From cvs at intevation.de Mon Jul 26 17:59:48 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Mon, 26 Jul 2004 17:59:48 +0200 (CEST) Subject: joey: thuban/test test_classmapper.py,NONE,1.1 Message-ID: <20040726155948.8F1AC139C8@lists.intevation.de> Author: joey Update of /thubanrepository/thuban/test In directory doto:/tmp/cvs-serv17724 Added Files: test_classmapper.py Log Message: Added a Test case for the new ClassMapper --- NEW FILE: test_classmapper.py --- # Copyright (c) 2004 by Intevation GmbH # Authors: # Martin Schulze # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ Test case for the Thuban ClassMapper. """ __version__ = "$Revision: 1.1 $" # $Source: /thubanrepository/thuban/test/test_classmapper.py,v $ # $Id: test_classmapper.py,v 1.1 2004/07/26 15:59:46 joey Exp $ import unittest import support support.initthuban() from Thuban.Lib.classmapper import ClassMapper class TestMapping(unittest.TestCase): def test_mapper(self): """ Test ClassMapper """ class MyClass: pass class MySecondClass: def hello(self): return "Hello World!" class MyThirdClass: def hello(self): return "Hello Earth!" mapping = ClassMapper() instance = MyClass() # See if an empty mapping really returns False # self.assertEqual(mapping.get(instance), None) self.assertEqual(mapping.has(instance), False) # See if an installed mapping works # mapping.add(MyClass, MySecondClass) self.assertEqual(mapping.get(instance), MySecondClass) self.assertEqual(mapping.has(instance), True) # Ensure that it's really the class we put in and the method # is available as expected. # myinst = mapping.get(instance)() self.assertEqual(myinst.hello(), "Hello World!") second = ClassMapper() # Test if a second mapper gets mixed ubp with the first one. # self.assertEqual(second.get(instance), None) second.add(MyClass, MyThirdClass) self.assertEqual(second.get(instance), MyThirdClass) self.assertEqual(second.has(instance), True) # Ensure that it's really the class we put in and the method # is available as expected. # myinst = second.get(instance)() self.assertEqual(myinst.hello(), "Hello Earth!") if __name__ == "__main__": support.run_tests() From cvs at intevation.de Mon Jul 26 18:08:09 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Mon, 26 Jul 2004 18:08:09 +0200 (CEST) Subject: joey: thuban/Thuban/Lib classmapper.py,NONE,1.1 Message-ID: <20040726160809.2604B139C8@lists.intevation.de> Author: joey Update of /thubanrepository/thuban/Thuban/Lib In directory doto:/tmp/cvs-serv17871 Added Files: classmapper.py Log Message: Added the new ClassMapper --- NEW FILE: classmapper.py --- # Copyright (c) 2004 by Intevation GmbH # Authors: # Martin Schulze # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ The provided class maintains a mapping between classes and objects. Instances of the class are used as keys, not classes, though. Usually layer classes and their instances are used in combination with layer property dialog classes in order to utilise the proper dialog for a given layer instance. """ __version__ = "$Revision: 1.1 $" # $Source: /thubanrepository/thuban/Thuban/Lib/classmapper.py,v $ # $Id: classmapper.py,v 1.1 2004/07/26 16:08:07 joey Exp $ class ClassMapper: """ Thuban class to implement a mapping of classes and objects, usually also classes. """ mapping = None def __init__(self): """ Initialises a mapping. """ self.mapping = [] def add(self, key_class, obj): """ Register an object with a class. This method adds the provided pair (key_class,obj) to the internal list. Subsequently instances of key_class are used to retrieved the stored object. """ self.mapping.append((key_class, obj)) def get(self, instance): """ Retrieve a stored object corresponding to the provided class instance. """ for key_class, obj in self.mapping: if isinstance(instance, key_class): return obj return None def has(self, instance): """ Determine if the ClassMapper contains an object corresponding to the provided instance """ return self.get(instance) is not None From cvs at intevation.de Mon Jul 26 18:09:13 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Mon, 26 Jul 2004 18:09:13 +0200 (CEST) Subject: joey: thuban ChangeLog,1.674,1.675 Message-ID: <20040726160913.18DC1139C8@lists.intevation.de> Author: joey Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv17892 Modified Files: ChangeLog Log Message: Finally added the new ClassMapper Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.674 retrieving revision 1.675 diff -u -d -r1.674 -r1.675 --- ChangeLog 22 Jul 2004 13:07:52 -0000 1.674 +++ ChangeLog 26 Jul 2004 16:09:10 -0000 1.675 @@ -1,3 +1,12 @@ +2004-07-26 Martin Schulze + + * Thuban/Lib/classmapper.py (ClassMapper.has): Added the new + ClassMapper + + * test/test_classmapper.py (TestMapping.test_mapper): Added a Test + case for the new ClassMapper + + 2004-07-22 Bernhard Herzog * Thuban/UI/viewport.py (ViewPort.VisibleExtent): New. Return the From thuban-bugs at intevation.de Tue Jul 27 06:53:30 2004 From: thuban-bugs at intevation.de (Request Tracker) Date: Tue, 27 Jul 2004 06:53:30 +0200 (CEST) Subject: [bug #2559] (thuban) can't zoom after opening a session Message-ID: <20040727045330.CB9411392D@lists.intevation.de> this bug's URL: http://intevation.de/rt/webrt?serial_num=2559 ------------------------------------------------------------------------- Subject: can't zoom after opening a session Operating System: GNU/Linux, suse 9.1 Thuban version: 1.0rc1 Python version: 2.3.3 GDAL version: 1.1.9 Create a map and zoom in on part of the map. Then save the session. Now close Thuban. Start Thuban and open the saved session. The map is initially zoomed very far out (can barely even make out where the map features are). Try to zoom in closer. You can zoom a few times, but it won't let you get nearly as close as you could before saving the session. Attempts to zoom futher just cause the map to recenter and redraw but you don't get any closer. -------------------------------------------- Managed by Request Tracker From joey at infodrom.org Tue Jul 27 12:45:03 2004 From: joey at infodrom.org (Martin Schulze) Date: Tue, 27 Jul 2004 12:45:03 +0200 Subject: [Thuban-devel] Re: RfD: Support for layer specific resources In-Reply-To: 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> Message-ID: <20040727104502.GK1334@finlandia.infodrom.north.de> Bernhard Herzog wrote: > Martin Schulze writes: > > > Are the attached files better? > > 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. Changed and committed, properly documented as well. > > If so, where should it be placed? Thuban.UI sounds a bit weird as > > location. Thuban.Lib sounds more appropriate. > > Yes. Thuban.Lib is better. Done. 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) 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? If so, where should add_properties_dialog and get_properties_dialog_class be placed? Maybe in Thuban.Lib.dialogs? Also, are the names ok? Regards, Joey -- WARNING: Do not execute! This call violates patent DE10108564. http://www.elug.de/projekte/patent-party/patente/DE10108564 wget -O patinfo-`date +"%Y%m%d"`.html http://patinfo.ffii.org/ From cvs at intevation.de Wed Jul 28 14:35:34 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Wed, 28 Jul 2004 14:35:34 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver mapfile.py,1.8,1.9 Message-ID: <20040728123534.4A6BD1397F@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver In directory doto:/tmp/cvs-serv24857 Modified Files: mapfile.py Log Message: Changed all class functions. Now all metadata will handle by the function and its not needed to initialize it from outside. Therefor the associated mapobj will be stored in the Metadata Object. So we can use thespecial functions from the associated mapobj to get the Metadata. Therefor all initialization code for the metadata is removed from the other classes. (MF_Layer): Added a function to get the metadata object. (MF_Map): Added a function to set the mappath, the path where the mapfile ist stored. Index: mapfile.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mapfile.py,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- mapfile.py 15 Jul 2004 14:31:37 -0000 1.8 +++ mapfile.py 28 Jul 2004 12:35:32 -0000 1.9 @@ -229,36 +229,45 @@ Metadata is not a Object in mapscript witch can be used by ease. Only the infos can get with the functions "getFirstMetaDataKey", "getNextMetaDataKey" and "getMetaData". - To get some special Metadata you need a key. So the metadata will - saved as an dictionary to geht the information with the key here. - - The metadata obj will be created and filled with infos like - the following code sample: - - self.metadata = MF_Metadata() + To get some special Metadata you need a key. So there is a special + function which create a list of the metadatakeys. + """ + def __init__(self, mapobj): + self.mapobj = mapobj + + def get_metadatakeys(self): + keylist = [] try: - self.metafkey = varia.getFirstMetaDataKey() + metafkey =self.mapobj.getFirstMetaDataKey() + keylist.append(metafkey) except: - self.metadata = None + return None else: - while self.metafkey: - self.metakeydata = varia.getMetaData(self.metafkey) - self.metadata.add_metadata(self.metafkey,self.metakeydata) - self.metafkey = varia.getNextMetaDataKey(self.metafkey) - - Metadata are not really needed at the moment. - """ - def __init__(self): - self.data = {} - + if metafkey: + while metafkey: + metafkey = self.mapobj.getNextMetaDataKey(metafkey) + if metafkey: + keylist.append(metafkey) + return keylist + def get_metadata(self): - return self.data + keylist = self.get_metadatakeys() + metadatalist = [] + if keylist: + for key in keylist: + metadatalist.append([key,self.mapobj.getMetaData(key)]) + return metadatalist + else: + return None def get_metadatabykey(self, key): - return self.data[key] + return self.mapobj.getMetaData(key) + + def remove_metadatabykey(self, key): + self.mapobj.removeMetaData(key) def add_metadata(self, key, data): - self.data[key] = data + self.mapobj.setMetaData(key,data) # ################################################ # Classes for MapServer Objects as they are @@ -410,19 +419,7 @@ else: self._expression = self._clazz.getExpressionString() - self.metadata = MF_Metadata() - # try to get the first metaDatakey. If it does not exists, the following - # error will occur: - # MapServerError: getFirstMetaDataKey: Hash table error. Key does not exist - try: - self.metafkey = mf_class.getFirstMetaDataKey() - except: - self.metadata = None - else: - while self.metafkey: - self.metakeydata = mf_class.getMetaData(self.metafkey) - self.metadata.add_metadata(self.metafkey,self.metakeydata) - self.metafkey = mf_class.getNextMetaDataKey(self.metafkey) + self.metadata = MF_Metadata(self._clazz) def get_styles(self): return self._styles @@ -528,16 +525,7 @@ self._projection = MF_Projection(self._mf_layer.getProjection()) # Create Metadata - self._metadata = MF_Metadata() - try: - self._metafkey = self._mf_layer.getFirstMetaDataKey() - except: - self._metadata = None - else: - while self._metafkey: - self._metakeydata = self._mf_layer.getMetaData(self._metafkey) - self._metadata.add_metadata(self._metafkey,self._metakeydata) - self._metafkey = self._mf_layer.getNextMetaDataKey(self._metafkey) + self._metadata = MF_Metadata(self._mf_layer) def get_name(self): return self._mf_layer.name @@ -547,7 +535,10 @@ def get_classes(self): return self._classes - + + def get_metadata(self): + return self._metadata + def get_type(self): return shp_type[self._mf_layer.type] @@ -622,10 +613,7 @@ elif isinstance(tb_class, ClassGroupSingleton): new_class.set_name(str(tb_class.GetValue())) else: - # TODO: set a name if the expression is a logical - # if it is an logical expression and no name is set, - # the final name will be set after expression is created - new_class.set_name("no name") + new_class.set_name(None) if self.get_type() == "line": new_class.add_thubanstyle(tb_class.GetProperties(), type="line") elif self.get_type() == "point": @@ -868,21 +856,14 @@ self._shapepath = "" # Create Metadata - self._metadata = MF_Metadata() - try: - self._metafkey = self._mf_map.getFirstMetaDataKey() - except: - self._metadata = None - else: - while self._metafkey: - self._metakeydata = self._mf_map.getMetaData(self._metafkey) - self._metadata.add_metadata(self._metafkey,self._metakeydata) - self._metafkey = self._mf_map.getNextMetaDataKey(self._metafkey) - + self._metadata = MF_Metadata(self._mf_map) + def get_mappath(self): return self._mf_map.mappath + def set_mappath(self, new_mappath): + self._mf_map.mappath = new_mappath def get_outputformat(self): @@ -934,9 +915,13 @@ return self._name def get_shapepath(self): - # where are the shape files located.. + # where are the shape files located. return self._shapepath + def set_shapepath(self, new_shapepath): + # where are the shape files located.. + self._shapepath = new_shapepath + def get_imagetype(self): return self._mf_map.imagetype @@ -1006,10 +991,10 @@ Add a thuban layer """ new_layer = MF_Layer(layerObj(self._mf_map)) - new_layer.set_name(tb_layer.Title()) - + new_layer.set_name(tb_layer.Title()) + # TODO: implement relative pathnames - # yet only absolute pathnames in the LayerObj are set + # yet only absolute pathnames in the LayerObj are set try: new_layer.set_data(tb_layer.ShapeStore().FileName()) except: @@ -1045,7 +1030,7 @@ # set the projection to the layer. # if the layer has its own definition use is, - # else use the main projection + # else use the main projection if tb_layer.GetProjection(): new_layer.set_projection(tb_layer.GetProjection()) else: From cvs at intevation.de Wed Jul 28 14:36:29 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Wed, 28 Jul 2004 14:36:29 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver mf_export.py,1.5,1.6 Message-ID: <20040728123629.C76AA1397F@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver In directory doto:/tmp/cvs-serv24883 Modified Files: mf_export.py Log Message: Changed the code to set the extent in the mapfile. Now the code is set by the displayed data in the Thuban-view. (export_mapfile): The shapepath is now set empty, until relative pathnames are supported. Index: mf_export.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mf_export.py,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- mf_export.py 22 Jul 2004 12:37:28 -0000 1.5 +++ mf_export.py 28 Jul 2004 12:36:27 -0000 1.6 @@ -70,9 +70,8 @@ map.set_name(tb_map.Title()) # set the projection tbproj_to_map(tb_map, map) - # set the extend - tb_bbox = tb_map.ProjectedBoundingBox() - # tb_bbox = tb_context.mainwindow.canvas.get_view_transform() + # set the extent + tb_bbox = tb_context.mainwindow.canvas.VisibleExtent() # Size must be set before, because mapscript checks it # when extent is set map.set_extent(tb_bbox) @@ -128,6 +127,9 @@ #add symbol add_circle_symbol(theMap) + + # shapepath vom mapfile + theMap.set_shapepath("") # save the map with the integrated mapscript saver theMap.save_map(os.path.join(path,file)) From cvs at intevation.de Wed Jul 28 14:37:30 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Wed, 28 Jul 2004 14:37:30 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver mf_handle.py,1.5,1.6 Message-ID: <20040728123730.CA8251397F@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver In directory doto:/tmp/cvs-serv24914 Modified Files: mf_handle.py Log Message: Added a dialog to handle metadata. Yet only mapfile metadata are supported. Layer and class supported are not implemented. Added a dialog to handle layer informations. The dialog only shows the selected layer at the moment. Index: mf_handle.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mf_handle.py,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- mf_handle.py 14 Jul 2004 10:35:51 -0000 1.5 +++ mf_handle.py 28 Jul 2004 12:37:28 -0000 1.6 @@ -30,6 +30,7 @@ # wxPython support # TODO: explicitly use from .. import from wxPython.wx import * +from wxPython.grid import * # Thuban # use _() already now for all strings that may later be translated @@ -315,6 +316,86 @@ def OnCancel(self, event): self.end_dialog(None) +ID_METADATA_CHANGE = 8020 + +from Extensions.umn_mapserver.mapfile import MF_Layer + +class Layer_Dialog(wxDialog): + + def __init__(self, parent, ID, title, + pos=wxDefaultPosition, size=wxDefaultSize, + style=wxDEFAULT_DIALOG_STYLE): + + # initialize the Dialog + wxDialog.__init__(self, parent, ID, title, pos, size, style) + + # get the web object + self.tb_layer = parent.current_layer() + + # create name + layer_name = wxBoxSizer(wxHORIZONTAL) + layer_name.Add(wxStaticText(self, -1, _("Layer-Name:")), 0, + wxALL|wxALIGN_CENTER_VERTICAL, 4) + 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) + + # buttons + box_buttons = wxBoxSizer(wxHORIZONTAL) + button = wxButton(self, wxID_OK, _("OK")) + box_buttons.Add(button, 0, wxALL, 5) + button = wxButton(self, wxID_CANCEL, _("Cancel")) + box_buttons.Add(button, 0, wxALL, 5) + #set the button funcitons + EVT_BUTTON(self, wxID_OK, self.OnOK) + EVT_BUTTON(self, wxID_CANCEL, self.OnCancel) + + # 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(box_buttons, 0, wxALIGN_RIGHT) + + # final layout settings + self.SetSizer(top) + top.Fit(self) + + def OnChangeMetadata(self, event): + # 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), + style = wxDEFAULT_DIALOG_STYLE + ) + dialog.CenterOnScreen() + if dialog.ShowModal() == wxID_OK: + return + dialog.Destroy() + + + def RunDialog(self): + self.ShowModal() + self.Destroy() + + def end_dialog(self, result): + self.result = result + if self.result is not None: + self.EndModal(wxID_OK) + else: + self.EndModal(wxID_CANCEL) + self.Show(False) + + def OnOK(self, event): + self.result ="OK" + self.end_dialog(self.result) + + def OnCancel(self, event): + self.end_dialog(None) + ID_LABEL_CHANGE = 8011 @@ -974,6 +1055,183 @@ self.end_dialog(None) +class Metadata_CustomDataTable(wxPyGridTableBase): + """ + """ + def __init__(self, data): + wxPyGridTableBase.__init__(self) + + self.colLabels = ['ID', 'Description'] + self.dataTypes = [wxGRID_VALUE_STRING, + wxGRID_VALUE_STRING + ] + + if data: + self.data = data + else: + self.data = [["",""]] #-------------------------------------------------- + # required methods for the wxPyGridTableBase interface + + def GetNumberRows(self): + return len(self.data) + 1 + + def GetNumberCols(self): + if self.data[0]: + return len(self.data[0]) + else: + return None + + def IsEmptyCell(self, row, col): + try: + return not self.data[row][col] + except IndexError: + return true + + # Get/Set values in the table. The Python version of these + # methods can handle any data-type, (as long as the Editor and + # Renderer understands the type too,) not just strings as in the + # C++ version. + def GetValue(self, row, col): + try: + return self.data[row][col] + except IndexError: + return '' + + def SetValue(self, row, col, value): + try: + self.data[row][col] = value + except IndexError: + # add a new row + self.data.append([''] * self.GetNumberCols()) + self.SetValue(row, col, value) + + # tell the grid we've added a row + msg = wxGridTableMessage(self, # The table + wxGRIDTABLE_NOTIFY_ROWS_APPENDED, # what we did to it + 1) # how many + + self.GetView().ProcessTableMessage(msg) + + +class Metadata_TableGrid(wxGrid): + def __init__(self, parent, data): + wxGrid.__init__(self, parent, -1, size=(600,400)) + + self.table = Metadata_CustomDataTable(data) + + # The second parameter means that the grid is to take ownership of the + # table and will destroy it when done. Otherwise you would need to keep + # a reference to it and call it's Destroy method later. + self.SetTable(self.table, true) + + self.SetRowLabelSize(0) + self.SetMargins(0,0) + self.AutoSizeColumns(False) + + EVT_GRID_CELL_LEFT_DCLICK(self, self.OnLeftDClick) + + def get_table(self): + return self.table + + # I do this because I don't like the default behaviour of not starting the + # cell editor on double clicks, but only a second click. + def OnLeftDClick(self, evt): + if self.CanEnableCellControl(): + self.EnableCellEditControl() + + +class Metadata_Dialog(wxDialog): + + def __init__(self, parent, ID, title, + pos=wxDefaultPosition, size=wxDefaultSize, + style=wxDEFAULT_DIALOG_STYLE): + + # initialize the Dialog + wxDialog.__init__(self, parent, ID, title, pos, size, style) + + # get the web object + if hasattr(parent,"umn_metadata"): + self.umn_metadata = parent.umn_metadata + else: + self.tb_map = parent.canvas.Map() + self.umn_metadata = self.tb_map.extension_umn_mapobj.get_metadata() + + + # at all items to the dataset + self.grid = Metadata_TableGrid(self, self.umn_metadata.get_metadata()) + + #buttons + box_buttons = wxBoxSizer(wxHORIZONTAL) + button = wxButton(self, wxID_OK, _("OK")) + box_buttons.Add(button, 0, wxALL, 5) + button = wxButton(self, wxID_CANCEL, _("Cancel")) + button.SetFocus() + box_buttons.Add(button, 0, wxALL, 5) + #set the button funcitons + EVT_BUTTON(self, wxID_OK, self.OnOK) + EVT_BUTTON(self, wxID_CANCEL, self.OnCancel) + + # compose the dialog + top = wxBoxSizer(wxVERTICAL) + top.Add(self.grid, 1, wxGROW|wxALL, 5) + top.Add(box_buttons, 0, wxALIGN_RIGHT) + + # final layout settings + self.SetSizer(top) + #top.Fit(self) + + def OnItemActivated(self, event): + self.currentItem = event.m_itemIndex + + def OnDoubleClick(self, event): + print "OnDoubleClick" +self.list.GetItemText(self.currentItem) + event.Skip() + + def OnSize(self, event): + w,h = self.GetClientSizeTuple() + self.list.SetDimensions(0, 0, w, h) + + def RunDialog(self): + self.ShowModal() + self.Destroy() + + def end_dialog(self, result): + self.result = result + if self.result is not None: + self.EndModal(wxID_OK) + else: + self.EndModal(wxID_CANCEL) + 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): + 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) + + def OnCancel(self, event): + self.end_dialog(None) + + + + +def metadatasettings(context): + win = Metadata_Dialog(context.mainwindow, -1, "Metadata Settings", + size=wxSize(350, 200), + style = wxDEFAULT_DIALOG_STYLE) + win.CenterOnScreen() + val = win.ShowModal() + + def scalebarsettings(context): win = Scalebar_Dialog(context.mainwindow, -1, "Scalebar Settings", size=wxSize(350, 200), @@ -1002,6 +1260,13 @@ win.CenterOnScreen() val = win.ShowModal() +def layersettings(context): + win = Layer_Dialog(context.mainwindow, -1, "Layer Settings", + size=wxSize(350, 200), + style = wxDEFAULT_DIALOG_STYLE) + win.CenterOnScreen() + val = win.ShowModal() + def legendsettings(context): win = Legend_Dialog(context.mainwindow, -1, "Legend Settings", size=wxSize(350, 200), @@ -1021,6 +1286,12 @@ """Return true if a umn_mapobj exists""" return hasattr(context.mainwindow.canvas.Map(), "extension_umn_mapobj") +def _has_umn_mapobj_and_selectedlayer(context): + """Return true if a umn_mapobj exists""" + if context.mainwindow.has_selected_layer(): + return hasattr(context.mainwindow.canvas.Map(), "extension_umn_mapobj") + else: + return False # ################################### # @@ -1063,6 +1334,14 @@ # finally add the new entry to the extensions menu mapserver_edit_menu.InsertItem("Web Settings") +# register the new command (Layer Settings Dialog) +registry.Add(Command("Layer Settings", _("Layer"), + layersettings, + helptext = _("Edit the Layer Setting of the aktive Layer"), \ + sensitive = _has_umn_mapobj_and_selectedlayer)) +# finally add the new entry to the extensions menu +mapserver_edit_menu.InsertItem("Layer Settings") + # register the new command (Legend Settings Dialog) registry.Add(Command("Legend Settings", _("Legend"), legendsettings, @@ -1078,5 +1357,13 @@ sensitive = _has_umn_mapobj)) # finally add the new entry to the extensions menu mapserver_edit_menu.InsertItem("Scalebar Settings") + +# register the new command (Scalebar Settings Dialog) +registry.Add(Command("Metadata Settings", _("Metadata"), + metadatasettings, + helptext = _("Edit the Metadata Setting"), \ + sensitive = _has_umn_mapobj)) +# finally add the new entry to the extensions menu +mapserver_edit_menu.InsertItem("Metadata Settings") From cvs at intevation.de Wed Jul 28 14:38:17 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Wed, 28 Jul 2004 14:38:17 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver/sample iceland.html, 1.1, 1.2 Message-ID: <20040728123817.82E9C1397F@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver/sample In directory doto:/tmp/cvs-serv24942/sample Modified Files: iceland.html Log Message: Added code to zoom and move the shown map in the browser. Index: iceland.html =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/sample/iceland.html,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- iceland.html 16 Jun 2004 10:49:47 -0000 1.1 +++ iceland.html 28 Jul 2004 12:38:15 -0000 1.2 @@ -45,6 +45,15 @@



+
+ Zoom Size
+ + Zoom In
+ + Zoom Out
+ + Pan
+
@@ -53,10 +62,12 @@ - + + + From cvs at intevation.de Wed Jul 28 14:41:08 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Wed, 28 Jul 2004 14:41:08 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver/sample iceland.map, 1.3, 1.4 Message-ID: <20040728124108.4A43A1397F@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver/sample In directory doto:/tmp/cvs-serv25010/sample Modified Files: iceland.map Log Message: Added a new metadata line to the mapobj and added metadata to the political layer. Index: iceland.map =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/sample/iceland.map,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- iceland.map 14 Jul 2004 10:33:24 -0000 1.3 +++ iceland.map 28 Jul 2004 12:41:06 -0000 1.4 @@ -42,6 +42,7 @@ METADATA titel "Iceland Test" + author "Jan Schuengel" END END @@ -92,6 +93,11 @@ proj=latlong ellps=clrk66 END + + METADATA + "landinfo" "Iceland" + "origin" "Thuban Sample Data" + END END LAYER @@ -101,7 +107,7 @@ STATUS ON CLASS NAME "Begin - 418" - EXPRESSION ([RDLINE_ID] <= 418) + EXPRESSION ([RDLINE_ID]<=418) STYLE COLOR 255 255 255 SIZE 1 From cvs at intevation.de Wed Jul 28 14:44:28 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Wed, 28 Jul 2004 14:44:28 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver mf_import.py,1.8,1.9 Message-ID: <20040728124428.4D7C81397F@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver In directory doto:/tmp/cvs-serv25094 Modified Files: mf_import.py Log Message: (import_mapfile): Changed the code for setting the extent in thuban. Now the extent is set to the given extent from the mapfile. Fixed a logical mistake. Now the extent is set when realy a layer is loaded, and not if one is selected to load. Index: mf_import.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mf_import.py,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- mf_import.py 22 Jul 2004 12:38:38 -0000 1.8 +++ mf_import.py 28 Jul 2004 12:44:26 -0000 1.9 @@ -393,9 +393,12 @@ # set the visible status layer.SetVisible(maplayer.get_status()) + #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) @@ -499,18 +502,17 @@ # 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 + 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 numlayers != 0: - # fit the new map to the window - context.mainwindow.canvas.FitMapToWindow() + if layer_count != 0: # get the extent from the map and set it in thuban - #extentrect = mapobj.get_extent().get_rect() - #context.mainwindow.canvas.FitRectToWindow(extentrect) + 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) From cvs at intevation.de Wed Jul 28 14:46:22 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Wed, 28 Jul 2004 14:46:22 +0200 (CEST) Subject: jschuengel: thuban/Extensions/umn_mapserver/test test_mapserver.py, 1.5, 1.6 Message-ID: <20040728124622.0BB0913954@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban/Extensions/umn_mapserver/test In directory doto:/tmp/cvs-serv25152/test Modified Files: test_mapserver.py Log Message: Changed the test for Metadata. Index: test_mapserver.py =================================================================== RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/test/test_mapserver.py,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- test_mapserver.py 22 Jul 2004 12:39:27 -0000 1.5 +++ test_mapserver.py 28 Jul 2004 12:46:19 -0000 1.6 @@ -98,7 +98,7 @@ Testing the meta data """ # set up to keys to test - testmetadata = MF_Metadata() + testmetadata = MF_Metadata(self.testMap) self.eq(self.testMap.getMetaData("titel"), "Iceland Test") testmetadata.add_metadata("test", "test eintrag") self.eq(testmetadata.get_metadatabykey("test"),"test eintrag") From cvs at intevation.de Wed Jul 28 14:47:06 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Wed, 28 Jul 2004 14:47:06 +0200 (CEST) Subject: jschuengel: thuban ChangeLog,1.675,1.676 Message-ID: <20040728124706.3CC4C13954@lists.intevation.de> Author: jschuengel Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv25179 Modified Files: ChangeLog Log Message: updated ChangeLog Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.675 retrieving revision 1.676 diff -u -d -r1.675 -r1.676 --- ChangeLog 26 Jul 2004 16:09:10 -0000 1.675 +++ ChangeLog 28 Jul 2004 12:47:04 -0000 1.676 @@ -1,3 +1,43 @@ +2004-07-28 Jan Schüngel + + * Extensions/umn_mapserver/mapfile.py(MF_Metadata): Changed all class + functions. Now all metadata will handle by the function and its not + needed to initialize it from outside. Therefor the associated mapobj + will be stored in the Metadata Object. So we can use the special + functions from the associated mapobj to get the Metadata. + Therefor all initialization code for the metadata is removed from the + other classes. + (MF_Layer): Added a function to get the metadata object. + (MF_Map): Added a function to set the mappath, the path where + the mapfile ist stored. + + * Extensions/umn_mapserver/mf_export.py(thuban_to_map): Changed the code + to set the extent in the mapfile. Now the code is set by the displayed + data in the Thuban-view. + (export_mapfile): The shapepath is now set empty, until relative + pathnames are supported. + + * Extension/umn_mapserver/mf_handle.py: Added a dialog to handle + metadata. Yet only mapfile metadata are supported. Layer and class + supported are not implemented. + Added a dialog to handle layer informations. The dialog only shows the + selected layer at the moment. + + * Extensions/umn_mapserver/mf_import.py(import_mapfile): Changed the + code for setting the extent in thuban. Now the extent is set to the + given extent from the mapfile. + Fixed a logical mistake. Now the extent is set when realy a layer is + loaded, and not if one is selected to load. + + * Extensions/umn_mapserver/sample/iceland.html: Added code to zoom and + move the shown map in the browser. + + * Extensions/umn_mapserver/sample/iceland.map: Added a new metadata + line to the mapobj and added metadata to the political layer. + + * Extensions/umn_mapserver/test/test_mapserver.py: Changed the test + for Metadata. + 2004-07-26 Martin Schulze * Thuban/Lib/classmapper.py (ClassMapper.has): Added the new From jan at intevation.de Thu Jul 29 14:40:48 2004 From: jan at intevation.de (Jan-Oliver Wagner) Date: Thu, 29 Jul 2004 14:40:48 +0200 Subject: Patch for adding version info for Extensions Message-ID: <20040729124048.GA27358@intevation.de> Hi, some time ago Bernhard Reiter proposed to introduce some versioning for extensions so that the about dialog informs about which extensions are loaded and who the author is etc. 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 Jan -- Jan-Oliver Wagner http://intevation.de/~jan/ Intevation GmbH http://intevation.de/ FreeGIS http://freegis.org/ -------------- next part -------------- A non-text attachment was scrubbed... Name: extensionregistry.py Type: text/x-python Size: 2827 bytes Desc: not available Url : http://www.intevation.de/pipermail/thuban-devel/attachments/20040729/e32f7edd/extensionregistry.py -------------- next part -------------- ? Extensions/wms-out Index: Extensions/gns2shp/gns2shp.py =================================================================== RCS file: /home/thuban/jail/thubanrepository/thuban/Extensions/gns2shp/gns2shp.py,v retrieving revision 1.3 diff -u -3 -p -r1.3 gns2shp.py --- Extensions/gns2shp/gns2shp.py 18 May 2004 21:09:50 -0000 1.3 +++ Extensions/gns2shp/gns2shp.py 29 Jul 2004 12:24:53 -0000 @@ -23,7 +23,7 @@ __version__ = '$Revision: 1.3 $' import os, sys -# only import GUI when not called as command line tool +# only import GUI and register when not called as command line tool if __name__ != '__main__': from wxPython.wx import * @@ -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' })) + def gns2shp(src_fname, dest_fname): """Convert a file from gns textformat into a Shapefile. Index: Extensions/importAPR/importAPR.py =================================================================== RCS file: /home/thuban/jail/thubanrepository/thuban/Extensions/importAPR/importAPR.py,v retrieving revision 1.4 diff -u -3 -p -r1.4 importAPR.py --- Extensions/importAPR/importAPR.py 11 May 2004 22:34:49 -0000 1.4 +++ Extensions/importAPR/importAPR.py 29 Jul 2004 12:24:53 -0000 @@ -27,9 +27,19 @@ from Thuban.UI.mainwindow import main_me from Thuban import _ from Thuban.Model.layer import Layer from Thuban.Model.classification import ClassGroupRange, ClassGroupSingleton +from Thuban.UI.extensionregistry import ThubanExtensionDesc, ext_registry from odb import ODBBaseObject from apr import APR_LClass, APR_TClr, APR_BLnSym, APR_BMkSym, APR_BShSym + +ext_registry.Add(ThubanExtensionDesc( + name = 'importAPR', + version = '0.1.0', + authors= [ 'Jan-Oliver Wagner' ], + copyright = '2003 Intevation GmbH', + desc = _("Import a ArcView project file (.apr)\n" \ + "and convert it to Thuban."), + min_thuban_versions = { '1.0' : '0' })) class ODBExtension(Extension): def TreeInfo(self): Index: Thuban/UI/about.py =================================================================== RCS file: /home/thuban/jail/thubanrepository/thuban/Thuban/UI/about.py,v retrieving revision 1.12 diff -u -3 -p -r1.12 about.py --- Thuban/UI/about.py 26 Mar 2004 18:15:35 -0000 1.12 +++ Thuban/UI/about.py 29 Jul 2004 12:27:14 -0000 @@ -18,6 +18,8 @@ from Thuban import _ from Thuban.version import versions from Thuban.Model.resource import gdal_support_status +from Thuban.UI.extensionregistry import ext_registry + class About(wxDialog): def __init__(self, parent): @@ -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: + text += _('\tNone registered.\n') + else: + for ext in ext_registry.Get(): + text += '\t%s %s\n' % (ext.name, ext.version) + text += '\n' + text += _('Lead Developer:\n') text += '\t%s\n\n' % lead_developer @@ -94,6 +104,22 @@ class About(wxDialog): "\tDevelopers list (public):\n\t\t\n" "\tThuban team at Intevation:\n\t\t\n" ) + + text += '\n\n' + + text += _("Details on the registered extensions:\n\n") + + if len(ext_registry.Get()) == 0: + text += _('\tNone registered.\n') + else: + for ext in ext_registry.Get(): + text += '%s %s:\n' % (ext.name, ext.version) + text += _('Copyright %s\n') % ext.copyright + text += _('Authors:\n') + for author in ext.authors: + text+= '\t%s\n' % author + text += ext.desc + text += '\n\n' self.text = text From cvs at intevation.de Sat Jul 31 13:06:54 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Sat, 31 Jul 2004 13:06:54 +0200 (CEST) Subject: jan: thuban/Doc/manual thuban-manual-de.xml,NONE,1.1 Message-ID: <20040731110654.7A5E713943@lists.intevation.de> Author: jan Update of /thubanrepository/thuban/Doc/manual In directory doto:/tmp/cvs-serv3274 Added Files: thuban-manual-de.xml Log Message: German Users Manual --- NEW FILE: thuban-manual-de.xml --- ]> Benutzerhandbuch für Thuban 1.0 JonathanColes Jan-OliverWagner FrankKoormann [...2157 lines suppressed...] Reseau Geodesique Francaise (France, Lambert Conic Conformal) UK National Grid (United Kingdom, Transverse Mercartor) Thuban uses the comprehensive PROJ library for projections. PROJ provides more than the four commonly used projections described above. If needed Thuban can be easily extended to a new projection covered by PROJ. From cvs at intevation.de Sat Jul 31 13:09:35 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Sat, 31 Jul 2004 13:09:35 +0200 (CEST) Subject: jan: thuban/Doc/manual Makefile,1.1,1.2 Message-ID: <20040731110935.A0DB113943@lists.intevation.de> Author: jan Update of /thubanrepository/thuban/Doc/manual In directory doto:/tmp/cvs-serv3310 Modified Files: Makefile Log Message: Added build instructions for german users manual. Index: Makefile =================================================================== RCS file: /thubanrepository/thuban/Doc/manual/Makefile,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Makefile 24 Jul 2003 09:05:44 -0000 1.1 +++ Makefile 31 Jul 2004 11:09:33 -0000 1.2 @@ -1,10 +1,14 @@ SRC_MAN=thuban-manual.xml +SRC_MAN_DE=thuban-manual-de.xml SRC_IMAGES=$(wildcard images/*.png) EPS_IMAGES=$(patsubst %.png,%.eps,$(SRC_IMAGES)) all: images man-all -man-all: man-html man-dvi man-ps man-pdf man-rtf +man-all: man-all-en man-all-de + +man-all-en: man-html man-dvi man-ps man-pdf man-rtf +man-all-de: man-html-de man-dvi-de man-ps-de man-pdf-de man-rtf-de man-html: db2html $(SRC_MAN) @@ -16,6 +20,17 @@ db2pdf $(SRC_MAN) man-rtf: db2rtf $(SRC_MAN) + +man-html-de: + db2html $(SRC_MAN_DE) +man-dvi-de: images + db2dvi $(SRC_MAN_DE) +man-ps-de: images + db2ps $(SRC_MAN_DE) +man-pdf-de: images + db2pdf $(SRC_MAN_DE) +man-rtf-de: + db2rtf $(SRC_MAN_DE) images: $(EPS_IMAGES) From cvs at intevation.de Sat Jul 31 13:12:22 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Sat, 31 Jul 2004 13:12:22 +0200 (CEST) Subject: jan: thuban/Doc/manual thuban-manual.xml,1.25,1.26 Message-ID: <20040731111222.416B713943@lists.intevation.de> Author: jan Update of /thubanrepository/thuban/Doc/manual In directory doto:/tmp/cvs-serv3351 Modified Files: thuban-manual.xml Log Message: Minor corrections in Introduction. Index: thuban-manual.xml =================================================================== RCS file: /thubanrepository/thuban/Doc/manual/thuban-manual.xml,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- thuban-manual.xml 16 May 2004 09:38:48 -0000 1.25 +++ thuban-manual.xml 31 Jul 2004 11:12:20 -0000 1.26 @@ -24,13 +24,11 @@ - 1.0.0 22-Jan-2004 @@ -68,9 +66,10 @@ Introduction Thuban is an interactive geographic data viewer. - It has been developed because there was no simple interactive + Its development had been started because there was no simple interactive viewer for geographic information available as Free Software. Thuban is - written in Python and C++ and uses the wxWindows library allowing it to + written mainly in Python and uses the wxWidgets (former wxWindows) + library allowing it to run on many different platforms, including GNU/Linux and Windows. @@ -84,7 +83,7 @@ Thuban arranges a session in a hierarchy. A session contains a map which - consists of layers. Each layer represents one kind of data set. For + consists of layers. Each layer represents a data set. For instance, there may be a layer for roads and another layer for buildings. These layers can either be vector shapes or images. @@ -397,6 +396,7 @@ French German Italian + Portuguese (Brazilian) Russian Spanish @@ -408,8 +408,11 @@ LC_ALL=fr_FR for the french language support). Please check your systems documentation for details and supported settings. Specifiying LC_ALL on the command line while launching thuban - allows appication specific language settings. + allows appication specific language settings: + + LC_ALL=fr_FR thuban.py + MS Windows users have to specify the language to be used via the control From cvs at intevation.de Sat Jul 31 13:14:10 2004 From: cvs at intevation.de (cvs@intevation.de) Date: Sat, 31 Jul 2004 13:14:10 +0200 (CEST) Subject: jan: thuban ChangeLog,1.676,1.677 Message-ID: <20040731111410.59AFB13943@lists.intevation.de> Author: jan Update of /thubanrepository/thuban In directory doto:/tmp/cvs-serv3377 Modified Files: ChangeLog Log Message: Started translation of Users Manual into german. Index: ChangeLog =================================================================== RCS file: /thubanrepository/thuban/ChangeLog,v retrieving revision 1.676 retrieving revision 1.677 diff -u -d -r1.676 -r1.677 --- ChangeLog 28 Jul 2004 12:47:04 -0000 1.676 +++ ChangeLog 31 Jul 2004 11:14:08 -0000 1.677 @@ -1,3 +1,14 @@ +2004-07-31 Jan-Oliver Wagner + + Started translation of Users Manual into german. + + * Doc/manual/thuban-manual-de.xml: New. German Users Manual. + + * Doc/manual/Makefile: Added build instructions for german + users manual. + + * Doc/manual/thuban-manual.xml: Minor corrections in Introduction. + 2004-07-28 Jan Schüngel * Extensions/umn_mapserver/mapfile.py(MF_Metadata): Changed all class @@ -88,7 +99,7 @@ * Extensions/umn_mapserver/test/test_mapserver.py: Added a test for the range expression import. - + 2004-07-21 Jan-Oliver Wagner * Extensions/umn_mapserver/README: Added hint that