/[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 6 by bh, Tue Aug 28 15:41:52 2001 UTC revision 726 by jonathan, Thu Apr 24 16:05:56 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 15  class Projection(BaseProjection): Line 17  class Projection(BaseProjection):
17    
18      """A proj4 projection object that remembers the parameters"""      """A proj4 projection object that remembers the parameters"""
19    
20      def __init__(self, params):      def __init__(self, params, name = "Unknown"):
21          BaseProjection.__init__(self, params)          BaseProjection.__init__(self, params)
22          self.params = params          self.params = params
23            self.name = name
24    
25      def ForwardBBox(self, bbox):      def ForwardBBox(self, bbox):
26          """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 35  class Projection(BaseProjection): Line 38  class Projection(BaseProjection):
38          x, y = self.Forward(urx, lly)          x, y = self.Forward(urx, lly)
39          xs.append(x); ys.append(y)          xs.append(x); ys.append(y)
40          return min(xs), min(ys), max(xs), max(ys)          return min(xs), min(ys), max(xs), max(ys)
41    
42        def GetName(self):
43            return self.name
44    
45        def SetName(self, name):
46            if isinstance(name, StringTypes):
47                self.name = name
48    
49        def GetParameter(self, param):
50    
51            for pair in self.params:
52                p, v = pair.split("=")
53                if p == param:
54                    return v
55    
56            return ""
57    
58        def GetAllParameters(self):
59            return self.params
60    
61        def __repr__(self):
62            return self.name + ": " + repr(self.params)
63    
64    class ProjFile:
65    
66        def __init__(self, filename):
67            self.projs = {}
68    
69            self.SetFileName(filename)
70        
71        def Add(self, proj):
72            self.projs[proj] = 0
73    
74        def Remove(self, proj):
75            if self.projs.has_key(proj):
76                del self.projs[proj]
77    
78        def GetFileName(self):
79            return self.filename
80    
81        def SetFileName(self, filename):
82            self.filename = filename
83    
84        def GetProjections(self):
85            return self.projs.keys()

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26