/[thuban]/trunk/thuban/Extensions/umn_mapserver/mapfile.py
ViewVC logotype

Diff of /trunk/thuban/Extensions/umn_mapserver/mapfile.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2300 by jschuengel, Thu Jul 15 14:31:37 2004 UTC revision 2301 by jschuengel, Wed Jul 28 12:35:32 2004 UTC
# Line 229  class MF_Metadata: Line 229  class MF_Metadata:
229      Metadata is not a Object in mapscript witch can be used      Metadata is not a Object in mapscript witch can be used
230      by ease. Only the infos can get with the functions      by ease. Only the infos can get with the functions
231      "getFirstMetaDataKey", "getNextMetaDataKey" and "getMetaData".      "getFirstMetaDataKey", "getNextMetaDataKey" and "getMetaData".
232      To get some special Metadata you need a key. So the metadata will      To get some special Metadata you need a key. So there is a special
233      saved as an dictionary to geht the information with the key here.      function which create a list of the metadatakeys.
234            """
235      The metadata obj will be created and filled with infos like      def __init__(self, mapobj):
236      the following code sample:          self.mapobj = mapobj
237        
238      self.metadata = MF_Metadata()      def get_metadatakeys(self):
239            keylist = []
240          try:          try:
241              self.metafkey = varia.getFirstMetaDataKey()              metafkey =self.mapobj.getFirstMetaDataKey()
242                keylist.append(metafkey)
243          except:          except:
244              self.metadata = None              return None
245          else:          else:
246              while self.metafkey:              if metafkey:
247                  self.metakeydata = varia.getMetaData(self.metafkey)                  while metafkey:
248                  self.metadata.add_metadata(self.metafkey,self.metakeydata)                      metafkey = self.mapobj.getNextMetaDataKey(metafkey)
249                  self.metafkey = varia.getNextMetaDataKey(self.metafkey)                      if metafkey:
250                                            keylist.append(metafkey)
251      Metadata are not really needed at the moment.                  return keylist
252      """  
     def __init__(self):  
         self.data = {}  
         
253      def get_metadata(self):      def get_metadata(self):
254          return self.data          keylist = self.get_metadatakeys()
255            metadatalist = []
256            if keylist:
257                for key in keylist:
258                    metadatalist.append([key,self.mapobj.getMetaData(key)])
259                return metadatalist
260            else:
261                return None
262            
263      def get_metadatabykey(self, key):      def get_metadatabykey(self, key):
264          return self.data[key]          return self.mapobj.getMetaData(key)
265    
266        def remove_metadatabykey(self, key):
267            self.mapobj.removeMetaData(key)
268            
269      def add_metadata(self, key, data):      def add_metadata(self, key, data):
270          self.data[key] = data          self.mapobj.setMetaData(key,data)
271    
272  # ################################################  # ################################################
273  # Classes for MapServer Objects as they are  # Classes for MapServer Objects as they are
# Line 410  class MF_Class: Line 419  class MF_Class:
419          else:          else:
420              self._expression = self._clazz.getExpressionString()              self._expression = self._clazz.getExpressionString()
421                    
422          self.metadata = MF_Metadata()          self.metadata = MF_Metadata(self._clazz)
         # 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)  
423    
424      def get_styles(self):      def get_styles(self):
425          return self._styles          return self._styles
# Line 528  class MF_Layer: Line 525  class MF_Layer:
525          self._projection = MF_Projection(self._mf_layer.getProjection())          self._projection = MF_Projection(self._mf_layer.getProjection())
526                    
527          # Create Metadata          # Create Metadata
528          self._metadata = MF_Metadata()          self._metadata = MF_Metadata(self._mf_layer)
         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)  
529    
530      def get_name(self):      def get_name(self):
531          return self._mf_layer.name          return self._mf_layer.name
# Line 547  class MF_Layer: Line 535  class MF_Layer:
535                    
536      def get_classes(self):      def get_classes(self):
537          return self._classes          return self._classes
538                
539        def get_metadata(self):
540            return self._metadata
541        
542      def get_type(self):      def get_type(self):
543          return shp_type[self._mf_layer.type]          return shp_type[self._mf_layer.type]
544    
# Line 622  class MF_Layer: Line 613  class MF_Layer:
613              elif isinstance(tb_class, ClassGroupSingleton):              elif isinstance(tb_class, ClassGroupSingleton):
614                  new_class.set_name(str(tb_class.GetValue()))                  new_class.set_name(str(tb_class.GetValue()))
615              else:              else:
616                  # TODO: set a name if the expression is a logical                            new_class.set_name(None)
                 # 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")  
617          if self.get_type() == "line":          if self.get_type() == "line":
618              new_class.add_thubanstyle(tb_class.GetProperties(), type="line")              new_class.add_thubanstyle(tb_class.GetProperties(), type="line")
619          elif self.get_type() == "point":          elif self.get_type() == "point":
# Line 868  class MF_Map: Line 856  class MF_Map:
856              self._shapepath = ""              self._shapepath = ""
857    
858          # Create Metadata          # Create Metadata
859          self._metadata = MF_Metadata()          self._metadata = MF_Metadata(self._mf_map)
860          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)  
       
861            
862      def get_mappath(self):      def get_mappath(self):
863          return self._mf_map.mappath          return self._mf_map.mappath
864            
865        def set_mappath(self, new_mappath):
866            self._mf_map.mappath = new_mappath
867            
868            
869      def get_outputformat(self):      def get_outputformat(self):
# Line 934  class MF_Map: Line 915  class MF_Map:
915          return self._name          return self._name
916            
917      def get_shapepath(self):      def get_shapepath(self):
918          # where are the shape files located..          # where are the shape files located.
919          return self._shapepath          return self._shapepath
920            
921        def set_shapepath(self, new_shapepath):
922            # where are the shape files located..
923            self._shapepath = new_shapepath
924        
925      def get_imagetype(self):      def get_imagetype(self):
926          return self._mf_map.imagetype          return self._mf_map.imagetype
927            
# Line 1006  class MF_Map: Line 991  class MF_Map:
991          Add a thuban layer          Add a thuban layer
992          """          """
993          new_layer = MF_Layer(layerObj(self._mf_map))          new_layer = MF_Layer(layerObj(self._mf_map))
994          new_layer.set_name(tb_layer.Title())                  new_layer.set_name(tb_layer.Title())
995            
996          # TODO: implement relative pathnames          # TODO: implement relative pathnames
997          # yet only absolute pathnames in the LayerObj are set          # yet only absolute pathnames in the LayerObj are set
998          try:          try:
999              new_layer.set_data(tb_layer.ShapeStore().FileName())              new_layer.set_data(tb_layer.ShapeStore().FileName())
1000          except:          except:
# Line 1045  class MF_Map: Line 1030  class MF_Map:
1030                
1031          # set the projection to the layer.          # set the projection to the layer.
1032          # if the layer has its own definition use is,          # if the layer has its own definition use is,
1033          # else use the main projection             # else use the main projection
1034          if tb_layer.GetProjection():          if tb_layer.GetProjection():
1035              new_layer.set_projection(tb_layer.GetProjection())              new_layer.set_projection(tb_layer.GetProjection())
1036          else:          else:

Legend:
Removed from v.2300  
changed lines
  Added in v.2301

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26