/[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 745 by jonathan, Fri Apr 25 10:26:50 2003 UTC revision 1250 by jonathan, Fri Jun 20 09:27:43 2003 UTC
# Line 15  import Projection Line 15  import Projection
15  BaseProjection = Projection.Projection  BaseProjection = Projection.Projection
16  del Projection  del Projection
17    
18    PROJ_UNITS_METERS  = 1
19    PROJ_UNITS_DEGREES = 2
20    
21  class Projection(BaseProjection):  class Projection(BaseProjection):
22    
23      """A proj4 projection object that remembers the parameters"""      """A proj4 projection object that remembers the parameters"""
# Line 28  class Projection(BaseProjection): Line 31  class Projection(BaseProjection):
31          BaseProjection.__init__(self, params)          BaseProjection.__init__(self, params)
32    
33          if name is None:          if name is None:
34              name = _("Unknown")              self.name = _("Unknown")
35            elif isinstance(name, StringTypes):
36                self.name = name
37    
38          self.params = params          self.params = params
         self.name = name  
39    
40      def ForwardBBox(self, bbox):      def ForwardBBox(self, bbox):
41          """Return the bounding box of the corners of the bounding box bbox          """Return the bounding box of the corners of the bounding box bbox
# Line 48  class Projection(BaseProjection): Line 52  class Projection(BaseProjection):
52          xs.append(x); ys.append(y)          xs.append(x); ys.append(y)
53          x, y = self.Forward(urx, lly)          x, y = self.Forward(urx, lly)
54          xs.append(x); ys.append(y)          xs.append(x); ys.append(y)
55            
56          return min(xs), min(ys), max(xs), max(ys)          return min(xs), min(ys), max(xs), max(ys)
57    
58      def GetName(self):      def GetName(self):
59          """Return the name of the projection."""          """Return the name of the projection."""
60          return self.name          return self.name
61    
     def SetName(self, name):  
         """Set the name of the projection."""  
         if isinstance(name, StringTypes):  
             self.name = name  
   
62      def GetParameter(self, param):      def GetParameter(self, param):
63          """Return the projection value for the given parameter.          """Return the projection value for the given parameter.
64    
# Line 78  class Projection(BaseProjection): Line 78  class Projection(BaseProjection):
78          """Return list of 'parameter=value' strings"""          """Return list of 'parameter=value' strings"""
79          return self.params          return self.params
80    
81        def GetProjectedUnits(self):
82            if self.GetParameter("proj") == "latlong":
83                return PROJ_UNITS_DEGREES
84            else:
85                return PROJ_UNITS_METERS
86    
87      def __repr__(self):      def __repr__(self):
88          return self.name + ": " + repr(self.params)          return self.name + ": " + repr(self.params)
89    
# Line 109  class ProjFile: Line 115  class ProjFile:
115              self.__projs.append(proj)              self.__projs.append(proj)
116    
117      def Remove(self, proj):      def Remove(self, proj):
118          """Remove the objection proj from the projection file.          """Remove the object proj from the projection file.
119    
120          Raises a ValueError is proj is not found.          Raises a ValueError is proj is not found.
121          """          """
122    
123          self.__projs.remove(proj)          self.__projs.remove(proj)
124    
125        def Replace(self, oldproj, newproj):
126            """Replace the object 'oldproj' with 'newproj'.
127            
128            Raises ValueError if oldproj is not in the file.
129            """
130    
131            #
132            # see if the projection already exists.
133            # this only works if Projection doesn't override __eq__
134            #
135            self.__projs[self.__projs.index(oldproj)] = newproj
136    
137      def GetFilename(self):      def GetFilename(self):
138          """Return the filename where the ProjFile was read or will be          """Return the filename where the ProjFile was read or will be
139          written to.          written to.

Legend:
Removed from v.745  
changed lines
  Added in v.1250

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26