27 |
|
|
28 |
BaseProjection.__init__(self, params) |
BaseProjection.__init__(self, params) |
29 |
|
|
30 |
self.SetName(name) |
if name is None: |
31 |
self.SetAllParameters(params) |
self.name = _("Unknown") |
32 |
|
elif isinstance(name, StringTypes): |
33 |
|
self.name = name |
34 |
|
|
35 |
|
self.params = params |
36 |
|
|
37 |
def ForwardBBox(self, bbox): |
def ForwardBBox(self, bbox): |
38 |
"""Return the bounding box of the corners of the bounding box bbox |
"""Return the bounding box of the corners of the bounding box bbox |
49 |
xs.append(x); ys.append(y) |
xs.append(x); ys.append(y) |
50 |
x, y = self.Forward(urx, lly) |
x, y = self.Forward(urx, lly) |
51 |
xs.append(x); ys.append(y) |
xs.append(x); ys.append(y) |
52 |
|
|
53 |
return min(xs), min(ys), max(xs), max(ys) |
return min(xs), min(ys), max(xs), max(ys) |
54 |
|
|
55 |
def GetName(self): |
def GetName(self): |
56 |
"""Return the name of the projection.""" |
"""Return the name of the projection.""" |
57 |
return self.name |
return self.name |
58 |
|
|
|
def SetName(self, name): |
|
|
"""Set the name of the projection. |
|
|
|
|
|
If 'name' is None, the name will be set to 'Unknown' |
|
|
in the local language. |
|
|
""" |
|
|
|
|
|
if name is None: |
|
|
self.name = _("Unknown") |
|
|
elif isinstance(name, StringTypes): |
|
|
self.name = name |
|
|
|
|
59 |
def GetParameter(self, param): |
def GetParameter(self, param): |
60 |
"""Return the projection value for the given parameter. |
"""Return the projection value for the given parameter. |
61 |
|
|
75 |
"""Return list of 'parameter=value' strings""" |
"""Return list of 'parameter=value' strings""" |
76 |
return self.params |
return self.params |
77 |
|
|
|
def SetAllParameters(self, params): |
|
|
"""Set the projection's parameters to the given parameter list.""" |
|
|
self.params = params |
|
|
|
|
|
def SetProjection(self, proj): |
|
|
"""Set the projection properties to those of the given projection. |
|
|
|
|
|
This does not copy the object. |
|
|
""" |
|
|
|
|
|
self.SetName(proj.name) |
|
|
self.SetAllParameters(proj.params) |
|
|
|
|
78 |
def __repr__(self): |
def __repr__(self): |
79 |
return self.name + ": " + repr(self.params) |
return self.name + ": " + repr(self.params) |
80 |
|
|
106 |
self.__projs.append(proj) |
self.__projs.append(proj) |
107 |
|
|
108 |
def Remove(self, proj): |
def Remove(self, proj): |
109 |
"""Remove the objection proj from the projection file. |
"""Remove the object proj from the projection file. |
110 |
|
|
111 |
Raises a ValueError is proj is not found. |
Raises a ValueError is proj is not found. |
112 |
""" |
""" |
113 |
|
|
114 |
self.__projs.remove(proj) |
self.__projs.remove(proj) |
115 |
|
|
116 |
|
def Replace(self, oldproj, newproj): |
117 |
|
"""Replace the object 'oldproj' with 'newproj'. |
118 |
|
|
119 |
|
Raises ValueError if oldproj is not in the file. |
120 |
|
""" |
121 |
|
|
122 |
|
# |
123 |
|
# see if the projection already exists. |
124 |
|
# this only works if Projection doesn't override __eq__ |
125 |
|
# |
126 |
|
self.__projs[self.__projs.index(oldproj)] = newproj |
127 |
|
|
128 |
def GetFilename(self): |
def GetFilename(self): |
129 |
"""Return the filename where the ProjFile was read or will be |
"""Return the filename where the ProjFile was read or will be |
130 |
written to. |
written to. |