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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 726 - (hide annotations)
Thu Apr 24 16:05:56 2003 UTC (21 years, 10 months ago) by jonathan
Original Path: trunk/thuban/Thuban/Model/proj.py
File MIME type: text/x-python
File size: 2163 byte(s)
(Projection.SetName): New. Allows the name of the projection to be changed.
(ProjFile): Use a dictionary instead of a list so that removing
        projections is easier and we are sure about uniqueness.
(ProjFile.Remove): Remove the given projection object.

1 bh 6 # Copyright (c) 2001 by Intevation GmbH
2     # Authors:
3     # Bernhard Herzog <[email protected]>
4     #
5     # This program is free software under the GPL (>=v2)
6     # Read the file COPYING coming with Thuban for details.
7    
8     __version__ = "$Revision$"
9    
10 jonathan 726 from types import StringTypes
11    
12 bh 6 import Projection
13     BaseProjection = Projection.Projection
14     del Projection
15    
16     class Projection(BaseProjection):
17    
18     """A proj4 projection object that remembers the parameters"""
19    
20 jonathan 695 def __init__(self, params, name = "Unknown"):
21 bh 6 BaseProjection.__init__(self, params)
22     self.params = params
23 jonathan 695 self.name = name
24 bh 6
25     def ForwardBBox(self, bbox):
26     """Return the bounding box of the corners of the bounding box bbox
27     """
28     # This is not really the correct way to determine the bbox of a
29     # projected shape, but for now it works well enough
30     llx, lly, urx, ury = bbox
31     xs = []; ys = []
32     x, y = self.Forward(llx, lly)
33     xs.append(x); ys.append(y)
34     x, y = self.Forward(llx, ury)
35     xs.append(x); ys.append(y)
36     x, y = self.Forward(urx, ury)
37     xs.append(x); ys.append(y)
38     x, y = self.Forward(urx, lly)
39     xs.append(x); ys.append(y)
40     return min(xs), min(ys), max(xs), max(ys)
41 jonathan 695
42     def GetName(self):
43     return self.name
44    
45 jonathan 726 def SetName(self, name):
46     if isinstance(name, StringTypes):
47     self.name = name
48    
49 jonathan 708 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 jonathan 695 return self.params
60    
61     def __repr__(self):
62 jonathan 726 return self.name + ": " + repr(self.params)
63 jonathan 695
64     class ProjFile:
65    
66     def __init__(self, filename):
67 jonathan 726 self.projs = {}
68 jonathan 695
69     self.SetFileName(filename)
70    
71     def Add(self, proj):
72 jonathan 726 self.projs[proj] = 0
73 jonathan 695
74 jonathan 726 def Remove(self, proj):
75     if self.projs.has_key(proj):
76     del self.projs[proj]
77    
78 jonathan 695 def GetFileName(self):
79     return self.filename
80    
81     def SetFileName(self, filename):
82     self.filename = filename
83    
84     def GetProjections(self):
85 jonathan 726 return self.projs.keys()

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26