/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/Model/proj.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/Thuban/Model/proj.py

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

revision 726 by jonathan, Thu Apr 24 16:05:56 2003 UTC revision 738 by jonathan, Fri Apr 25 09:13:36 2003 UTC
# Line 40  class Projection(BaseProjection): Line 40  class Projection(BaseProjection):
40          return min(xs), min(ys), max(xs), max(ys)          return min(xs), min(ys), max(xs), max(ys)
41    
42      def GetName(self):      def GetName(self):
43            """Return the name of the projection."""
44          return self.name          return self.name
45    
46      def SetName(self, name):      def SetName(self, name):
47            """Set the name of the projection."""
48          if isinstance(name, StringTypes):          if isinstance(name, StringTypes):
49              self.name = name              self.name = name
50    
51      def GetParameter(self, param):      def GetParameter(self, param):
52            """Return the projection value for the given parameter.
53    
54            If 'param' exists as a valid parameter then the returned
55            value is a string with that value. If the parameter doesn't
56            exist an empty string is returned.
57            """
58    
59          for pair in self.params:          for pair in self.params:
60              p, v = pair.split("=")              p, v = pair.split("=")
# Line 56  class Projection(BaseProjection): Line 64  class Projection(BaseProjection):
64          return ""          return ""
65    
66      def GetAllParameters(self):      def GetAllParameters(self):
67            """Return list of 'parameter=value' strings"""
68          return self.params          return self.params
69    
70      def __repr__(self):      def __repr__(self):
# Line 64  class Projection(BaseProjection): Line 73  class Projection(BaseProjection):
73  class ProjFile:  class ProjFile:
74    
75      def __init__(self, filename):      def __init__(self, filename):
76          self.projs = {}          """Intialize the ProjFile.
77    
78            filename -- name of the file that this ProjFile represents.
79            """
80    
81            self.__projs = []
82    
83          self.SetFileName(filename)          self.SetFilename(filename)
84            
85      def Add(self, proj):      def Add(self, proj):
86          self.projs[proj] = 0          """Add the given projection to the end of the file. If 'proj'
87            already exists, it is replaced in the same location as the
88            original projection.
89            """
90    
91            try:
92                #
93                # see if the projection already exists.
94                # this only works if Projection doesn't override __eq__
95                #
96                self.__projs[self.__projs.index(proj)] = proj
97            except ValueError:
98                self.__projs.append(proj)
99    
100      def Remove(self, proj):      def Remove(self, proj):
101          if self.projs.has_key(proj):          """Remove the objection proj from the projection file.
102              del self.projs[proj]  
103            Raises a ValueError is proj is not found.
104            """
105    
106            self.__projs.remove(proj)
107    
108      def GetFileName(self):      def GetFilename(self):
109          return self.filename          """Return the filename where the ProjFile was read or will be
110            written to.
111            """
112    
113      def SetFileName(self, filename):          return self.__filename
114          self.filename = filename  
115        def SetFilename(self, filename):
116            """Set the filename where the ProjFile will be written to."""
117            self.__filename = filename
118    
119      def GetProjections(self):      def GetProjections(self):
120          return self.projs.keys()          """Return a list of the projections in the order they were read
121            from the file or will be written.
122    
123            This is not a deep copy list, so any modifications made to the
124            Projection objects will be written to the file.
125            """
126    
127            return self.__projs
128    

Legend:
Removed from v.726  
changed lines
  Added in v.738

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26