1 |
jschuengel |
2235 |
# -*- coding:latin1 -*- |
2 |
|
|
# Copyright (C) 2004 by Intevation GmbH |
3 |
|
|
# Authors: |
4 |
|
|
# Jan Schüngel <[email protected]> |
5 |
|
|
# |
6 |
|
|
# This program is free software under the GPL (>=v2) |
7 |
|
|
# Read the file COPYING coming with Thuban for details. |
8 |
|
|
|
9 |
|
|
""" |
10 |
|
|
Classes to represent '.map'-file Objects. |
11 |
|
|
|
12 |
|
|
The following Classes, which are implemented in |
13 |
|
|
mapscript are not implemented yet in this extension: |
14 |
|
|
|
15 |
|
|
DBFInfo, errorObj, fontSetObj, graticuleObj, imageObj, itemObj, |
16 |
|
|
labelCacheMemberObj, labelCacheObj, labelObj, legendObj, lineObj, |
17 |
|
|
markerCacheMembet, msTiledSHPLayerInfo, OutputFormat, pointObj, queryMapObj, |
18 |
|
|
referenzMapObj, resultCacheMemberObj, resultCacheObj, scalebarObj, |
19 |
|
|
shapefileObj, shapeObj, styleObj, symbolObj, symbolSetObj, VectorObj, WebObj |
20 |
|
|
""" |
21 |
|
|
|
22 |
|
|
__version__ = "$Revision$" |
23 |
|
|
# $Source$ |
24 |
|
|
# $Id$ |
25 |
|
|
|
26 |
|
|
|
27 |
|
|
# ################################################## |
28 |
|
|
# |
29 |
|
|
# import necessary modules from python and/or thuban |
30 |
|
|
# |
31 |
|
|
# ################################################## |
32 |
|
|
|
33 |
|
|
|
34 |
|
|
from Thuban.Model.color import Color |
35 |
|
|
|
36 |
|
|
# ################################### |
37 |
|
|
# |
38 |
|
|
# Definition of dictionaries |
39 |
|
|
# |
40 |
|
|
# ################################### |
41 |
|
|
|
42 |
|
|
shp_type = { 0:'point', |
43 |
|
|
1:'line', |
44 |
|
|
2:'polygon', |
45 |
|
|
3:'raster', |
46 |
|
|
4:'annotation', |
47 |
|
|
5:'circle', |
48 |
|
|
6:'query'} |
49 |
|
|
|
50 |
|
|
|
51 |
|
|
|
52 |
|
|
# ################################################## |
53 |
|
|
# |
54 |
|
|
# Class Definition |
55 |
|
|
# |
56 |
|
|
# ################################################## |
57 |
|
|
|
58 |
|
|
# ################################################## |
59 |
|
|
# General Classes that are not explicitly defined through |
60 |
|
|
# a mapfile, but rather some helper-classes. |
61 |
|
|
|
62 |
|
|
class MF_Rectangle: |
63 |
|
|
""" |
64 |
|
|
Represents an rectanle with the bottom left |
65 |
|
|
and top right corner. |
66 |
|
|
""" |
67 |
|
|
def __init__(self,mf_rect): |
68 |
|
|
self._rect = mf_rect |
69 |
|
|
|
70 |
|
|
def get_minx(self): |
71 |
|
|
return self._rect.minx |
72 |
|
|
|
73 |
|
|
def get_miny(self): |
74 |
|
|
return self._rect.miny |
75 |
|
|
|
76 |
|
|
def get_maxx(self): |
77 |
|
|
return self._rect.maxx |
78 |
|
|
|
79 |
|
|
def get_maxy(self): |
80 |
|
|
return self._rect.maxy |
81 |
|
|
|
82 |
|
|
|
83 |
|
|
class MF_Color: |
84 |
|
|
""" |
85 |
|
|
The corresponding MapScript object contains also the |
86 |
|
|
attribute pen which defines the stroke of the feature. |
87 |
|
|
But this actually has nothing to do with the color and |
88 |
|
|
therefore is not support here. |
89 |
|
|
|
90 |
|
|
It needs to be discussed with the MapServer developers |
91 |
|
|
whether pen would better be moved to another class. |
92 |
|
|
|
93 |
|
|
The hex color definition which is also supported by |
94 |
|
|
mapscript and Thuban is not supported as it does |
95 |
|
|
not add any capability. |
96 |
|
|
|
97 |
|
|
color is definied as RGB 0..255 |
98 |
|
|
""" |
99 |
|
|
def __init__(self, mf_color): |
100 |
|
|
self._color = mf_color |
101 |
|
|
|
102 |
|
|
self._tbc_red = (float(self.get_red())/255) |
103 |
|
|
self._tbc_green = (float(self.get_green())/255) |
104 |
|
|
self._tbc_blue = (float(self.get_blue())/255) |
105 |
|
|
self._thubancolor = Color(self._tbc_red, self._tbc_green, self._tbc_blue) |
106 |
|
|
|
107 |
|
|
# TODO : Check if it is necessary to use rgb colors alone |
108 |
|
|
# or whether it is sufficient to only use the Thuban Color. |
109 |
|
|
# In some it is necessary as red == -1 indicates that no color |
110 |
|
|
# is set. |
111 |
|
|
def get_red(self): |
112 |
|
|
return self._color.red |
113 |
|
|
|
114 |
|
|
def get_green(self): |
115 |
|
|
return self._color.green |
116 |
|
|
|
117 |
|
|
def get_blue(self): |
118 |
|
|
return self._color.blue |
119 |
|
|
|
120 |
|
|
def get_thubancolor(self): |
121 |
|
|
return self._thubancolor |
122 |
|
|
|
123 |
|
|
def set_thubancolor(self, thuban_color): |
124 |
|
|
self._color.red = int(thuban_color.red * 255) |
125 |
|
|
self._color.green = int(thuban_color.green * 255) |
126 |
|
|
self._color.blue = int(thuban_color.blue * 255) |
127 |
|
|
self._thubancolor = thuban_color |
128 |
|
|
|
129 |
|
|
|
130 |
|
|
class MF_Size: |
131 |
|
|
""" |
132 |
|
|
Handle sizes. |
133 |
|
|
This is not implemented as a Class in mapscript but |
134 |
|
|
seems to be helpful. |
135 |
|
|
""" |
136 |
|
|
|
137 |
|
|
def __init__(self, mf_width, mf_height): |
138 |
|
|
self._width = mf_width |
139 |
|
|
self._height = mf_height |
140 |
|
|
|
141 |
|
|
def get_width(self): |
142 |
|
|
return self._width |
143 |
|
|
|
144 |
|
|
def get_height(self): |
145 |
|
|
return self._height |
146 |
|
|
|
147 |
|
|
|
148 |
|
|
class MF_Metadata: |
149 |
|
|
""" |
150 |
|
|
Metadata is not a Object in mapscript witch can be used |
151 |
|
|
by ease. Only the infos can get with the functions |
152 |
|
|
"getFirstMetaDataKey", "getNextMetaDataKey" and "getMetaData". |
153 |
|
|
To get some special Metadata you need a key. So the metadata will |
154 |
|
|
saved as an dictionary to geht the information with the key here. |
155 |
|
|
|
156 |
|
|
The metadata obj will be created and filled with infos like |
157 |
|
|
the following code sample: |
158 |
|
|
|
159 |
|
|
self.metadata = MF_Metadata() |
160 |
|
|
try: |
161 |
|
|
self.metafkey = varia.getFirstMetaDataKey() |
162 |
|
|
except: |
163 |
|
|
self.metadata = None |
164 |
|
|
else: |
165 |
|
|
while self.metafkey: |
166 |
|
|
self.metakeydata = varia.getMetaData(self.metafkey) |
167 |
|
|
self.metadata.add_metadata(self.metafkey,self.metakeydata) |
168 |
|
|
self.metafkey = varia.getNextMetaDataKey(self.metafkey) |
169 |
|
|
|
170 |
|
|
Metadata are not really needed at the moment. |
171 |
|
|
""" |
172 |
|
|
|
173 |
|
|
def __init__(self): |
174 |
|
|
self.data = {} |
175 |
|
|
|
176 |
|
|
def get_metadata(self): |
177 |
|
|
return self.data |
178 |
|
|
|
179 |
|
|
def get_metadatabykey(self, key): |
180 |
|
|
return self.data[key] |
181 |
|
|
|
182 |
|
|
def add_metadata(self, key, data): |
183 |
|
|
self.data[key] = data |
184 |
|
|
|
185 |
|
|
|
186 |
|
|
# ################################################## |
187 |
|
|
# Classes for MapServer Objects as they are |
188 |
|
|
# explicitly defined in a mapfile. |
189 |
|
|
|
190 |
|
|
class MF_Class: |
191 |
|
|
""" |
192 |
|
|
The following parameters and functions, which the mapscript style obj |
193 |
|
|
contains, are used: |
194 |
|
|
styles, numstyles, name, |
195 |
|
|
getExpressionString(), getMetaData(), getFirstMetaDataKey(), |
196 |
|
|
getNextMetaDataKey(), getStyle() |
197 |
|
|
|
198 |
|
|
The following parameters and functions are not used: |
199 |
|
|
status, label, title, template, type, minscale, maxscale, layer, |
200 |
|
|
debig, keyimage, |
201 |
|
|
setExpression(), setText(), setMetaData(), drawLegendIcon(), |
202 |
|
|
createLegendIcon(), insertStyle(), removeStyle(), moveStyleUp(), |
203 |
|
|
moveStyleDown() |
204 |
|
|
""" |
205 |
|
|
|
206 |
|
|
def __init__(self, mf_class): |
207 |
|
|
""" |
208 |
|
|
Initialized a class from them given mapscript Class Object |
209 |
|
|
with a list of the included styles. |
210 |
|
|
Metadata Object will be created from the Metadata informations |
211 |
|
|
wich are holt as a List i think. |
212 |
|
|
""" |
213 |
|
|
self._clazz = mf_class |
214 |
|
|
self._styles = [] |
215 |
|
|
self._numstyles = mf_class.numstyles |
216 |
|
|
for i in range(0,self._numstyles,1): |
217 |
|
|
self._styles.append(MF_Style(mf_class.getStyle(i))) |
218 |
|
|
|
219 |
|
|
|
220 |
|
|
if self._clazz.getExpressionString() == '"(null)"': |
221 |
|
|
self._expression = None |
222 |
|
|
else: |
223 |
|
|
self._expression = self._clazz.getExpressionString() |
224 |
|
|
|
225 |
|
|
self.metadata = MF_Metadata() |
226 |
|
|
try: |
227 |
|
|
self.metafkey = mf_class.getFirstMetaDataKey() |
228 |
|
|
except: |
229 |
|
|
self.metadata = None |
230 |
|
|
else: |
231 |
|
|
while self.metafkey: |
232 |
|
|
self.metakeydata = mf_class.getMetaData(self.metafkey) |
233 |
|
|
self.metadata.add_metadata(self.metafkey,self.metakeydata) |
234 |
|
|
self.metafkey = mf_class.getNextMetaDataKey(self.metafkey) |
235 |
|
|
|
236 |
|
|
def get_styles(self): |
237 |
|
|
return self._styles |
238 |
|
|
|
239 |
|
|
def get_name(self): |
240 |
|
|
return self._clazz.name |
241 |
|
|
|
242 |
|
|
def get_keyimage(self): |
243 |
|
|
return self._clazz.keyimage |
244 |
|
|
|
245 |
|
|
def get_expressionstring(self): |
246 |
|
|
return self._expression |
247 |
|
|
|
248 |
|
|
|
249 |
|
|
class MF_Layer: |
250 |
|
|
""" |
251 |
|
|
The following parameters and functions, which the mapscript style obj |
252 |
|
|
contains, are used: |
253 |
|
|
|
254 |
|
|
classitem, numclasses, name, data, type |
255 |
|
|
getClass(), getProjection(), getExtent(), getMetaData(), |
256 |
|
|
getFirstMetaDataKey(), getNextMetaDataKey() |
257 |
|
|
|
258 |
|
|
|
259 |
|
|
The following paramters and functions are not used: |
260 |
|
|
index, map, header, footer, template, groupe, status, tolerance, |
261 |
|
|
toleranceunits, symbolscale, minscale, maxscale, labelminscale |
262 |
|
|
labelmaxscale, sizeunits, maxfeatures, offsite, transform, labelcache |
263 |
|
|
postlabelcache, labelitem, labelsizeitem, labelangleitem, labelitemindex |
264 |
|
|
labelsizeitemindex, labelangleitemindex, tileitem, tileindex, units |
265 |
|
|
connection, connectiontype, numitems, filteritem, styleitem, requires |
266 |
|
|
labelrequires, transparency, dump, debug, numprocessing, numjoins, |
267 |
|
|
removeClass(), open(), close(), getShape(), getNumResults(), getResult() |
268 |
|
|
getItem(), promote(), demote(), draw(), drawQuery(), queryByAttributes() |
269 |
|
|
queryByPoint(), queryByRect(), queryByFeatures(), queryByShape(), |
270 |
|
|
setFilter(), setFilterString(), setWKTProjection(), setProjection() |
271 |
|
|
addFeature(), getNumFeatures(), setMetaData(), removeMetaData(), |
272 |
|
|
getWMSFeatureInfoURL(), executeWFSGetFeature(), applySLD(), applySLDURL() |
273 |
|
|
enerateSLD(), moveClassUp(), moveClassDown(), setProcessing(), |
274 |
|
|
getProcessing(), clearProcessing() |
275 |
|
|
""" |
276 |
|
|
|
277 |
|
|
def __init__(self, mf_layer): |
278 |
|
|
""" |
279 |
|
|
Creates the Layer Object from the mapscript Layer Object. |
280 |
|
|
the class objects in the layer object will be stored in |
281 |
|
|
an array. The metadata are created as a new object. |
282 |
|
|
""" |
283 |
|
|
|
284 |
|
|
self._mf_layer = mf_layer |
285 |
|
|
|
286 |
|
|
# Create Classes |
287 |
|
|
# there could be more then 1 |
288 |
|
|
self._numclasses = mf_layer.numclasses |
289 |
|
|
i = -1 |
290 |
|
|
self._classes = [] |
291 |
|
|
while i < self._numclasses-1: |
292 |
|
|
i += 1 |
293 |
|
|
self._classes.append(MF_Class(self._mf_layer.getClass(i))) |
294 |
|
|
|
295 |
|
|
self._projection = MF_Projection(self._mf_layer.getProjection()) |
296 |
|
|
|
297 |
|
|
# Variable extent will not used for RasterLayer |
298 |
|
|
# this variable is not necessary, because it comes directly |
299 |
|
|
# from the shp file |
300 |
|
|
try: |
301 |
|
|
self._extent = MF_Rectangle(self._mf_layer.getExtent()) |
302 |
|
|
except: |
303 |
|
|
self._extent = None |
304 |
|
|
|
305 |
|
|
# Create Metadata |
306 |
|
|
self._metadata = MF_Metadata() |
307 |
|
|
try: |
308 |
|
|
self._metafkey = self._mf_layer.getFirstMetaDataKey() |
309 |
|
|
except: |
310 |
|
|
self._metadata = None |
311 |
|
|
else: |
312 |
|
|
while self._metafkey: |
313 |
|
|
self._metakeydata = self._mf_layer.getMetaData(self._metafkey) |
314 |
|
|
self._metadata.add_metadata(self._metafkey,self._metakeydata) |
315 |
|
|
self._metafkey = self._mf_layer.getNextMetaDataKey(self._metafkey) |
316 |
|
|
|
317 |
|
|
def get_name(self): |
318 |
|
|
return self._mf_layer.name |
319 |
|
|
|
320 |
|
|
def get_data(self): |
321 |
|
|
return self._mf_layer.data |
322 |
|
|
|
323 |
|
|
def get_classes(self): |
324 |
|
|
return self._classes |
325 |
|
|
|
326 |
|
|
def get_type(self): |
327 |
|
|
return shp_type[self._mf_layer.type] |
328 |
|
|
|
329 |
|
|
def get_classitem(self): |
330 |
|
|
return self._mf_layer.classitem |
331 |
|
|
|
332 |
|
|
def get_projection(self): |
333 |
|
|
return self._projection |
334 |
|
|
|
335 |
|
|
class MF_Map: |
336 |
|
|
""" |
337 |
|
|
The following parameters and functions, which the mapscript style obj |
338 |
|
|
contains, are used: |
339 |
|
|
|
340 |
|
|
name, numlayers, extent, shapepath, imagecolor, imagetype, getLayer, |
341 |
|
|
getProjection, getMetaData, getFirstMetaDataKey, getNextMetaDataKey |
342 |
|
|
|
343 |
|
|
|
344 |
|
|
The following parameters and functions are not used: |
345 |
|
|
status, height, width, maxsize, layers, symbolset, fontset, labelcache, |
346 |
|
|
transparent, interlace, imagequality, cellsize, units, debug, datapattern, |
347 |
|
|
templatepattern, configoptions |
348 |
|
|
zoomPoint(), zoomRectangle(), zoomScale(), getLayerOrder(), setLayerOrder(), |
349 |
|
|
clone(), setExtent(), removeLayer(), getLayerByName(), getSymbolByName(), |
350 |
|
|
prepareQuery(), prepareImage(), setImageType(), setOutputFormat(), draw(), |
351 |
|
|
drawQuery(), drawLegend(), drawScalebar(), embedLegend(), drawLabelCache(), |
352 |
|
|
nextLabel(), queryByPoint(), queryByRecht(), queryByFeatures(), queryByShape(), |
353 |
|
|
setWKTProjection(), setProjection(), save(), saveQuery(), saveQueryASGML(), |
354 |
|
|
setMetaData(), removeMetaData(), setSymbolSet(), getNumSymbols(), setFontSet(), |
355 |
|
|
saveMapContext(), loadMapContext(), moveLayerUp(), moveLayerDown(), |
356 |
|
|
getLayersDrawingOrder(), setLayersDrawingOrder(), setConfigOption(), |
357 |
|
|
getConfigOption(), applyConfigOptions(), applySLD(), applySLDURL(), gernerateSLD(), |
358 |
|
|
procecssTemplate(), processLegemdTemplate(), processQueryTemplate(), |
359 |
|
|
getOutputFormatByName(), appendOutputFormat(), removeOutputFormat(), |
360 |
|
|
""" |
361 |
|
|
|
362 |
|
|
def __init__(self, mf_map): |
363 |
|
|
""" |
364 |
|
|
Create the map object from the mapfile mapobject witch is given. |
365 |
|
|
|
366 |
|
|
All layers in the mapfile will be written to an array. |
367 |
|
|
""" |
368 |
|
|
|
369 |
|
|
self._mf_map = mf_map |
370 |
|
|
self._extent = MF_Rectangle(self._mf_map.extent) |
371 |
|
|
self._imagecolor = MF_Color(self._mf_map.imagecolor) |
372 |
|
|
|
373 |
|
|
# if the map name is not set it will return a MS string. |
374 |
|
|
if self._mf_map.name != "MS": |
375 |
|
|
self._name = self._mf_map.name |
376 |
|
|
else: |
377 |
|
|
self._name = None |
378 |
|
|
|
379 |
|
|
self._projection = MF_Projection(self._mf_map.getProjection()) |
380 |
|
|
|
381 |
|
|
# Initial Layer List |
382 |
|
|
self._layers = [] |
383 |
|
|
self._numlayers = self._mf_map.numlayers |
384 |
|
|
self._i = 0 |
385 |
|
|
while self._i < self._numlayers: |
386 |
|
|
self._layers.append(MF_Layer(self._mf_map.getLayer(self._i))) |
387 |
|
|
self._i += 1 |
388 |
|
|
|
389 |
|
|
# Shapepath if not set, shapepath will be empty |
390 |
|
|
if self._mf_map.shapepath: |
391 |
|
|
self._shapepath = self._mf_map.shapepath |
392 |
|
|
else: |
393 |
|
|
self._shapepath = "" |
394 |
|
|
|
395 |
|
|
# Create Metadata |
396 |
|
|
self._metadata = MF_Metadata() |
397 |
|
|
try: |
398 |
|
|
self._metafkey = self._mf_map.getFirstMetaDataKey() |
399 |
|
|
except: |
400 |
|
|
self._metadata = None |
401 |
|
|
else: |
402 |
|
|
while self._metafkey: |
403 |
|
|
self._metakeydata = self._mf_map.getMetaData(self._metafkey) |
404 |
|
|
self._metadata.add_metadata(self._metafkey,self._metakeydata) |
405 |
|
|
self._metafkey = self._mf_map.getNextMetaDataKey(self._metafkey) |
406 |
|
|
|
407 |
|
|
|
408 |
|
|
def get_extent(self): |
409 |
|
|
return self._extent |
410 |
|
|
|
411 |
|
|
def get_layers(self): |
412 |
|
|
return self._layers |
413 |
|
|
|
414 |
|
|
def get_projection(self): |
415 |
|
|
return self._projection |
416 |
|
|
|
417 |
|
|
def get_name(self): |
418 |
|
|
return self._name |
419 |
|
|
|
420 |
|
|
def get_shapepath(self): |
421 |
|
|
return self._shapepath # where are the shape files located.. |
422 |
|
|
|
423 |
|
|
def get_imagetype(self): |
424 |
|
|
return self._imagetype |
425 |
|
|
|
426 |
|
|
def get_layerorder(self): |
427 |
|
|
# shows the order of layer as list |
428 |
|
|
return self._mf_map.getLayerOrder() |
429 |
|
|
|
430 |
|
|
|
431 |
|
|
class MF_Projection: |
432 |
|
|
""" |
433 |
|
|
The following parameter, which the mapscript style obj contains is used: |
434 |
|
|
|
435 |
|
|
numargs |
436 |
|
|
""" |
437 |
|
|
|
438 |
|
|
def __init__(self, mf_projection): |
439 |
|
|
""" |
440 |
|
|
Create a projection object from the given mapscript projection |
441 |
|
|
object. If it is a epsg code the extracted from the string |
442 |
|
|
(e.g."init=epsg:xxxx"), else the projection parameters will |
443 |
|
|
be splitted and an array with the parameters will be creaded. |
444 |
|
|
""" |
445 |
|
|
self._mfprojstring = mf_projection |
446 |
|
|
self._epsgcode = None |
447 |
|
|
self._params = None |
448 |
|
|
if self._mfprojstring: |
449 |
|
|
if self._mfprojstring.find("init=epsg:") != -1: |
450 |
|
|
self._initcode, self._epsgcode = self._mfprojstring.split(':') |
451 |
|
|
else: |
452 |
|
|
self._params = [] |
453 |
|
|
self._params = self._mfprojstring.split("+") |
454 |
|
|
if self._params[0] == "": |
455 |
|
|
self._params.remove("") |
456 |
|
|
|
457 |
|
|
def epsg_code_to_projection(self, epsg): |
458 |
|
|
""" |
459 |
|
|
Find the projection for the given epsg code. |
460 |
|
|
|
461 |
|
|
Copied from Extension/wms/layer.py |
462 |
|
|
|
463 |
|
|
epsg -- EPSG code as string |
464 |
|
|
""" |
465 |
|
|
#Needed only for this function |
466 |
|
|
from Thuban.Model.resource import get_system_proj_file, EPSG_PROJ_FILE, \ |
467 |
|
|
EPSG_DEPRECATED_PROJ_FILE |
468 |
|
|
|
469 |
|
|
proj_file, warnings = get_system_proj_file(EPSG_PROJ_FILE) |
470 |
|
|
|
471 |
|
|
for proj in proj_file.GetProjections(): |
472 |
|
|
if proj.EPSGCode() == epsg: |
473 |
|
|
return proj |
474 |
|
|
|
475 |
|
|
proj_file, warnings = get_system_proj_file(EPSG_DEPRECATED_PROJ_FILE) |
476 |
|
|
for proj in proj_file.GetProjections(): |
477 |
|
|
if proj.EPSGCode() == epsg: |
478 |
|
|
return proj |
479 |
|
|
return None |
480 |
|
|
|
481 |
|
|
def get_params(self): |
482 |
|
|
#Parameter from the mf_projectionstring as Array |
483 |
|
|
return self._params |
484 |
|
|
|
485 |
|
|
def get_epsgcode(self): |
486 |
|
|
# returnes the epsg number |
487 |
|
|
return self._epsgcode |
488 |
|
|
|
489 |
|
|
def get_epsgproj(self): |
490 |
|
|
# get an epsg projectionobject |
491 |
|
|
return self.epsg_code_to_projection(self._epsgcode) |
492 |
|
|
|
493 |
|
|
|
494 |
|
|
class MF_Style: |
495 |
|
|
""" |
496 |
|
|
The following parameters, which the mapscript style obj |
497 |
|
|
contains, are used: |
498 |
|
|
|
499 |
|
|
color, backgroundcolor, outlinecolor, size |
500 |
|
|
|
501 |
|
|
The following are not used: |
502 |
|
|
symbol, symbolname, sizescaled, minsize, maxsize, offsetx, offsety, |
503 |
|
|
antialias |
504 |
|
|
""" |
505 |
|
|
|
506 |
|
|
def __init__(self, mf_style): |
507 |
|
|
""" |
508 |
|
|
Create a style object from the given mapscript style object. |
509 |
|
|
The color Object from the color and the outlinecolor parameter |
510 |
|
|
will be created. if the color (red, green or blue) is -1 there |
511 |
|
|
is no definition in the mapfile and so there is no color object, |
512 |
|
|
it will set to 'None'. |
513 |
|
|
""" |
514 |
|
|
self._style = mf_style |
515 |
|
|
if self._style.color.red == -1: |
516 |
|
|
self._color = None |
517 |
|
|
else: |
518 |
|
|
self._color = MF_Color(self._style.color) |
519 |
|
|
self._backgroundcolor = MF_Color(self._style.backgroundcolor) |
520 |
|
|
if self._style.outlinecolor.red == -1: |
521 |
|
|
self._outlinecolor = None |
522 |
|
|
else: |
523 |
|
|
self._outlinecolor = MF_Color(self._style.outlinecolor) |
524 |
|
|
|
525 |
|
|
def get_color(self): |
526 |
|
|
return self._color |
527 |
|
|
|
528 |
|
|
def get_outlinecolor(self): |
529 |
|
|
return self._outlinecolor |
530 |
|
|
|
531 |
|
|
def get_size(self): |
532 |
|
|
return self._style.size |