/[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 708 by jonathan, Wed Apr 23 08:44:52 2003 UTC revision 738 by jonathan, Fri Apr 25 09:13:36 2003 UTC
# Line 7  Line 7 
7    
8  __version__ = "$Revision$"  __version__ = "$Revision$"
9    
10    from types import StringTypes
11    
12  import Projection  import Projection
13  BaseProjection = Projection.Projection  BaseProjection = Projection.Projection
14  del Projection  del Projection
# Line 38  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):
47            """Set the name of the projection."""
48            if isinstance(name, StringTypes):
49                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 50  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):
71          return repr(self.params)          return self.name + ": " + repr(self.params)
72    
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.append(proj)          """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      def GetFileName(self):          try:
92          return self.filename              #
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 SetFileName(self, filename):      def Remove(self, proj):
101          self.filename = filename          """Remove the objection proj from the projection file.
102    
103            Raises a ValueError is proj is not found.
104            """
105    
106            self.__projs.remove(proj)
107    
108        def GetFilename(self):
109            """Return the filename where the ProjFile was read or will be
110            written to.
111            """
112    
113            return self.__filename
114    
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          """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.708  
changed lines
  Added in v.738

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26