/[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 708 - (hide annotations)
Wed Apr 23 08:44:52 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: 1909 byte(s)
(Projection.GetParameters): Renamed to GetAllParameters.
(Projection.GetParameter): Returns the value for the given parameter.

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     import Projection
11     BaseProjection = Projection.Projection
12     del Projection
13    
14     class Projection(BaseProjection):
15    
16     """A proj4 projection object that remembers the parameters"""
17    
18 jonathan 695 def __init__(self, params, name = "Unknown"):
19 bh 6 BaseProjection.__init__(self, params)
20     self.params = params
21 jonathan 695 self.name = name
22 bh 6
23     def ForwardBBox(self, bbox):
24     """Return the bounding box of the corners of the bounding box bbox
25     """
26     # This is not really the correct way to determine the bbox of a
27     # projected shape, but for now it works well enough
28     llx, lly, urx, ury = bbox
29     xs = []; ys = []
30     x, y = self.Forward(llx, lly)
31     xs.append(x); ys.append(y)
32     x, y = self.Forward(llx, ury)
33     xs.append(x); ys.append(y)
34     x, y = self.Forward(urx, ury)
35     xs.append(x); ys.append(y)
36     x, y = self.Forward(urx, lly)
37     xs.append(x); ys.append(y)
38     return min(xs), min(ys), max(xs), max(ys)
39 jonathan 695
40     def GetName(self):
41     return self.name
42    
43 jonathan 708 def GetParameter(self, param):
44    
45     for pair in self.params:
46     p, v = pair.split("=")
47     if p == param:
48     return v
49    
50     return ""
51    
52     def GetAllParameters(self):
53 jonathan 695 return self.params
54    
55     def __repr__(self):
56     return repr(self.params)
57    
58     class ProjFile:
59    
60     def __init__(self, filename):
61     self.projs = []
62    
63     self.SetFileName(filename)
64    
65     def Add(self, proj):
66     self.projs.append(proj)
67    
68     def GetFileName(self):
69     return self.filename
70    
71     def SetFileName(self, filename):
72     self.filename = filename
73    
74     def GetProjections(self):
75     return self.projs

Properties

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26