1 |
# -*- 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, lineObj, |
17 |
markerCacheMembet, msTiledSHPLayerInfo, OutputFormat, pointObj, queryMapObj, |
18 |
referenzMapObj, resultCacheMemberObj, resultCacheObj, scalebarObj, |
19 |
shapefileObj, shapeObj, 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 |
import os |
34 |
|
35 |
from Thuban.Model.color import Color, Transparent |
36 |
|
37 |
from mapscript import layerObj, classObj, colorObj, styleObj, rectObj, symbolObj, \ |
38 |
pointObj, lineObj |
39 |
|
40 |
|
41 |
# ################################### |
42 |
# |
43 |
# Definition of dictionaries |
44 |
# |
45 |
# ################################### |
46 |
|
47 |
shp_type = { 0:'point', |
48 |
1:'line', |
49 |
2:'polygon', |
50 |
3:'raster', |
51 |
4:'annotation', |
52 |
5:'circle', |
53 |
6:'query'} |
54 |
|
55 |
unit_type = { 0:"inches", |
56 |
1:"feet", |
57 |
2:"miles", |
58 |
3:"meters", |
59 |
4:"kilometers", |
60 |
5:"dd"} |
61 |
|
62 |
# TODO: generate the list dynamical by alle supported formats. |
63 |
# At the moment outputformat only get by name. |
64 |
image_type = ["png","jpeg","wbmp","GTiff"] |
65 |
|
66 |
legend_status_type = { 0:"OFF", |
67 |
1:"ON", |
68 |
3:"embed" } |
69 |
# 2 = Default but will not be imported because |
70 |
# mapscript dont support it and its not allowed |
71 |
|
72 |
scalebar_status_type = { 0:"OFF", |
73 |
1:"ON", |
74 |
3:"embed" } |
75 |
# 2 = Default but will not be imported because |
76 |
# mapscript dont support it and its not allowed |
77 |
|
78 |
scalebar_style_type = { 0:"0", |
79 |
1:"1" } |
80 |
|
81 |
scalebar_position_type = { 0:"ul", |
82 |
1:"lr", |
83 |
2:"ur", |
84 |
3:"ll", |
85 |
6:"uc", |
86 |
7:"lc"} |
87 |
|
88 |
layer_status_type = { 0:"OFF", |
89 |
1:"ON", |
90 |
2:"default"} |
91 |
|
92 |
legend_position_type = { 0:"ul", |
93 |
1:"lr", |
94 |
2:"ur", |
95 |
3:"ll", |
96 |
6:"uc", |
97 |
7:"lc"} |
98 |
|
99 |
label_size_type = { 0:"tiny", |
100 |
1:"small", |
101 |
2:"medium", |
102 |
3:"large", |
103 |
4:"giant" } |
104 |
|
105 |
#TODO: build in truetype (0:"truetype") support |
106 |
label_font_type = { 1:"bitmap" } |
107 |
|
108 |
label_position_type = { 0:"ul", |
109 |
1:"lr", |
110 |
2:"ur", |
111 |
3:"ll", |
112 |
4:"cr", |
113 |
5:"cl", |
114 |
6:"uc", |
115 |
7:"lc", |
116 |
8:"cc", |
117 |
10:"auto"} |
118 |
|
119 |
|
120 |
# ################################################## |
121 |
# |
122 |
# Class Definition |
123 |
# |
124 |
# ################################################## |
125 |
|
126 |
# ################################################## |
127 |
# General Classes that are not all explicitly defined through |
128 |
# a mapfile, but rather some helper-classes. |
129 |
|
130 |
class MF_Rectangle: |
131 |
""" |
132 |
Represents an rectanle with the bottom left |
133 |
and top right corner. |
134 |
""" |
135 |
def __init__(self,mf_rect): |
136 |
self._rect = mf_rect |
137 |
|
138 |
def get_minx(self): |
139 |
return self._rect.minx |
140 |
|
141 |
def get_miny(self): |
142 |
return self._rect.miny |
143 |
|
144 |
def get_maxx(self): |
145 |
return self._rect.maxx |
146 |
|
147 |
def get_maxy(self): |
148 |
return self._rect.maxy |
149 |
|
150 |
def get_rect(self): |
151 |
return (self._rect.minx,self._rect.miny,self._rect.maxx,self._rect.maxy) |
152 |
|
153 |
def set_rect(self, minx, miny, maxx, maxy): |
154 |
self._rect.minx = minx |
155 |
self._rect.miny = miny |
156 |
self._rect.maxx = maxx |
157 |
self._rect.maxy = maxy |
158 |
|
159 |
class MF_Color: |
160 |
""" |
161 |
The corresponding MapScript object contains also the |
162 |
attribute pen which defines the stroke of the feature. |
163 |
But this actually has nothing to do with the color and |
164 |
therefore is not support here. |
165 |
|
166 |
It needs to be discussed with the MapServer developers |
167 |
whether pen would better be moved to another class. |
168 |
|
169 |
The hex color definition which is also supported by |
170 |
mapscript and Thuban is not supported as it does |
171 |
not add any capability. |
172 |
|
173 |
color is definied as RGB 0..255 |
174 |
""" |
175 |
def __init__(self, mf_color): |
176 |
self._color = mf_color |
177 |
|
178 |
self._tbc_red = (float(self.get_red())/255) |
179 |
self._tbc_green = (float(self.get_green())/255) |
180 |
self._tbc_blue = (float(self.get_blue())/255) |
181 |
self._thubancolor = Color(self._tbc_red, self._tbc_green, self._tbc_blue) |
182 |
|
183 |
# TODO : Check if it is necessary to use rgb colors alone |
184 |
# or whether it is sufficient to only use the Thuban Color. |
185 |
# In some it is necessary as red == -1 indicates that no color |
186 |
# is set. |
187 |
def get_red(self): |
188 |
return self._color.red |
189 |
|
190 |
def get_green(self): |
191 |
return self._color.green |
192 |
|
193 |
def get_blue(self): |
194 |
return self._color.blue |
195 |
|
196 |
def set_rgbcolor(self, red, green, blue): |
197 |
self._color.red = red |
198 |
self._color.green = green |
199 |
self._color.blue = blue |
200 |
|
201 |
self._tbc_red = (float(self.get_red())/255) |
202 |
self._tbc_green = (float(self.get_green())/255) |
203 |
self._tbc_blue = (float(self.get_blue())/255) |
204 |
self._thubancolor = Color(self._tbc_red, self._tbc_green, self._tbc_blue) |
205 |
|
206 |
def get_mfcolor(self): |
207 |
return self._color |
208 |
|
209 |
def get_thubancolor(self): |
210 |
return self._thubancolor |
211 |
|
212 |
def set_thubancolor(self, thuban_color): |
213 |
if thuban_color != Transparent: |
214 |
self._color.red = int(thuban_color.red * 255) |
215 |
self._color.green = int(thuban_color.green * 255) |
216 |
self._color.blue = int(thuban_color.blue * 255) |
217 |
self._thubancolor = thuban_color |
218 |
|
219 |
|
220 |
class MF_Metadata: |
221 |
""" |
222 |
Metadata is not a Object in mapscript witch can be used |
223 |
by ease. Only the infos can get with the functions |
224 |
"getFirstMetaDataKey", "getNextMetaDataKey" and "getMetaData". |
225 |
To get some special Metadata you need a key. So the metadata will |
226 |
saved as an dictionary to geht the information with the key here. |
227 |
|
228 |
The metadata obj will be created and filled with infos like |
229 |
the following code sample: |
230 |
|
231 |
self.metadata = MF_Metadata() |
232 |
try: |
233 |
self.metafkey = varia.getFirstMetaDataKey() |
234 |
except: |
235 |
self.metadata = None |
236 |
else: |
237 |
while self.metafkey: |
238 |
self.metakeydata = varia.getMetaData(self.metafkey) |
239 |
self.metadata.add_metadata(self.metafkey,self.metakeydata) |
240 |
self.metafkey = varia.getNextMetaDataKey(self.metafkey) |
241 |
|
242 |
Metadata are not really needed at the moment. |
243 |
""" |
244 |
|
245 |
def __init__(self): |
246 |
self.data = {} |
247 |
|
248 |
def get_metadata(self): |
249 |
return self.data |
250 |
|
251 |
def get_metadatabykey(self, key): |
252 |
return self.data[key] |
253 |
|
254 |
def add_metadata(self, key, data): |
255 |
self.data[key] = data |
256 |
|
257 |
# ################################################## |
258 |
# Classes for MapServer Objects as they are |
259 |
# explicitly defined in a mapfile |
260 |
class MF_Outputformat: |
261 |
|
262 |
def __init__(self, mf_outputformat): |
263 |
self._outputformat = mf_outputformat |
264 |
|
265 |
def get_name(self): |
266 |
return self._outputformat.name |
267 |
|
268 |
|
269 |
|
270 |
class MF_Symbol: |
271 |
""" |
272 |
defines a single symbol which is used in the Symbolset |
273 |
|
274 |
name, type, sizex, sizey, points, numpoints, filled, stylelength, |
275 |
style, imagepath, transparent, transparentcolor, character, antialias, |
276 |
font, gap, position, linecap, linejoin, linejoinmaxsize, setPoints(), |
277 |
getPoints(), setStyle() |
278 |
""" |
279 |
|
280 |
def __init__(self, mf_symbol = "newone"): |
281 |
# create a circle Object like shown in Thuban |
282 |
# because Thuban don't support other symbols |
283 |
if mf_symbol == "newone": |
284 |
mf_symbol = symbolObj("") |
285 |
newpoint = pointObj() |
286 |
newpoint.x = 1 |
287 |
newpoint.y = 1 |
288 |
newline = lineObj() |
289 |
newline.add(newpoint) |
290 |
mf_symbol.setPoints(newline) |
291 |
|
292 |
self._symbol = mf_symbol |
293 |
|
294 |
def get_symbolObj(self): |
295 |
return self._symbol |
296 |
|
297 |
def get_name(self): |
298 |
return self._symbol.name |
299 |
|
300 |
def set_name(self, new_name): |
301 |
self._symbol.name = new_name |
302 |
|
303 |
def set_type(self, new_type): |
304 |
# TODO include a function to set the type by a string |
305 |
self._symbol.type = new_type |
306 |
|
307 |
def set_filled(self, new_filled): |
308 |
if new_filled: |
309 |
self._symbol.filled = 1 |
310 |
else: |
311 |
self._symbol.filled = 0 |
312 |
|
313 |
|
314 |
|
315 |
class MF_SymbolSet: |
316 |
""" |
317 |
defines a set of symbols, may be there can only be one |
318 |
|
319 |
filename, imagecachesize, numsymbols, symbol, getSymbol(), |
320 |
getSymbolByName(), index(), appendSymbol(), removeSymbol(), |
321 |
save() |
322 |
""" |
323 |
|
324 |
# TODO: include the symbolset, but found only the possibility to |
325 |
# create an extra symbol file and not to include it direct to the |
326 |
# mapfile itself |
327 |
def __init__(self, mf_symbolset): |
328 |
self._symbolset = mf_symbolset |
329 |
|
330 |
# Initial Symbol List |
331 |
self._symbols = [] |
332 |
self._numsymbols = self._symbolset.numsymbols |
333 |
self._i = 1 |
334 |
while self._i < self._numsymbols: |
335 |
self._symbols.append(MF_Symbol(self._symbolset.getSymbol(self._i))) |
336 |
self._i += 1 |
337 |
|
338 |
# POINT |
339 |
# 1 1 |
340 |
# END |
341 |
|
342 |
def add_symbol(self, new_symbol): |
343 |
self._symbolset.appendSymbol(new_symbol.get_symbolObj()) |
344 |
self._symbols.append(new_symbol) |
345 |
# the save function must be run to set the symbols to the |
346 |
# mapfile. I don't know why this ist so but it must be. |
347 |
self._symbolset.save("tempsymbol") |
348 |
os.remove("tempsymbol") |
349 |
|
350 |
def get_symbol(self, symbolnr): |
351 |
if symbolnr < self._numsymbols: |
352 |
return self._symbols[symbolnr-1] |
353 |
else: |
354 |
return None |
355 |
|
356 |
class MF_Class: |
357 |
""" |
358 |
The following parameters and functions, which the mapscript style obj |
359 |
contains, are used: |
360 |
styles, numstyles, name, |
361 |
getExpressionString(), setExpression(), getMetaData(), getFirstMetaDataKey(), |
362 |
getNextMetaDataKey(), getStyle() |
363 |
|
364 |
The following parameters and functions are not used: |
365 |
status, label, title, template, type, minscale, maxscale, layer, |
366 |
debig, keyimage, |
367 |
setExpression(), setText(), setMetaData(), drawLegendIcon(), |
368 |
createLegendIcon(), insertStyle(), removeStyle(), moveStyleUp(), |
369 |
moveStyleDown() |
370 |
""" |
371 |
def __init__(self, mf_class): |
372 |
""" |
373 |
Initialized a class from them given mapscript Class Object |
374 |
with a list of the included styles. |
375 |
Metadata Object will be created from the Metadata informations |
376 |
wich are holt as a List i think. |
377 |
""" |
378 |
self._clazz = mf_class |
379 |
self._styles = [] |
380 |
self._numstyles = mf_class.numstyles |
381 |
for i in range(0,self._numstyles,1): |
382 |
self._styles.append(MF_Style(mf_class.getStyle(i))) |
383 |
|
384 |
if self._clazz.getExpressionString() == '"(null)"': |
385 |
self._expression = None |
386 |
else: |
387 |
self._expression = self._clazz.getExpressionString() |
388 |
|
389 |
self.metadata = MF_Metadata() |
390 |
try: |
391 |
self.metafkey = mf_class.getFirstMetaDataKey() |
392 |
except: |
393 |
self.metadata = None |
394 |
else: |
395 |
while self.metafkey: |
396 |
self.metakeydata = mf_class.getMetaData(self.metafkey) |
397 |
self.metadata.add_metadata(self.metafkey,self.metakeydata) |
398 |
self.metafkey = mf_class.getNextMetaDataKey(self.metafkey) |
399 |
|
400 |
def get_styles(self): |
401 |
return self._styles |
402 |
|
403 |
def get_name(self): |
404 |
return self._clazz.name |
405 |
|
406 |
def get_keyimage(self): |
407 |
return self._clazz.keyimage |
408 |
|
409 |
def get_expressionstring(self): |
410 |
return self._expression |
411 |
|
412 |
def set_name(self, newname): |
413 |
self._clazz.name = newname |
414 |
|
415 |
def set_expressionstring(self, newstring): |
416 |
self._clazz.setExpression(newstring) |
417 |
self._expression = self._clazz.getExpressionString() |
418 |
|
419 |
def get_status(self): |
420 |
if self._clazz.status == 1: |
421 |
return True |
422 |
else: |
423 |
return False |
424 |
|
425 |
def set_status(self, new_status): |
426 |
if new_status: |
427 |
self._clazz.status = 1 |
428 |
else: |
429 |
self._clazz.status = 0 |
430 |
|
431 |
def add_thubanstyle(self, tb_style, type="default"): |
432 |
""" |
433 |
added a thuban style object to the mapobject |
434 |
""" |
435 |
new_styleobj = MF_Style(styleObj(self._clazz)) |
436 |
if type == "line": |
437 |
new_styleobj.set_color(tb_style.GetLineColor()) |
438 |
elif type == "point": |
439 |
# set a default symbol to show circles not only a small dot |
440 |
# symbol "circle" must create before |
441 |
# TODO: create a Symbol (more see MF_SymbolSet) |
442 |
# first the default symbol circle will be created and the size 8 |
443 |
new_styleobj.set_symbolname('circle') |
444 |
new_styleobj.set_size(8) |
445 |
if tb_style.GetLineColor() != Transparent: |
446 |
new_styleobj.set_linecolor(tb_style.GetLineColor()) |
447 |
new_styleobj.set_color(tb_style.GetFill()) |
448 |
else: |
449 |
new_styleobj.set_size(tb_style.GetLineWidth()) |
450 |
new_styleobj.set_linecolor(tb_style.GetLineColor()) |
451 |
new_styleobj.set_color(tb_style.GetFill()) |
452 |
|
453 |
|
454 |
|
455 |
class MF_Layer: |
456 |
""" |
457 |
The following parameters and functions, which the mapscript style obj |
458 |
contains, are used: |
459 |
|
460 |
classitem, numclasses, name, data, type |
461 |
getClass(), getProjection(), getExtent(), getMetaData(), |
462 |
getFirstMetaDataKey(), getNextMetaDataKey(), status, |
463 |
|
464 |
|
465 |
The following paramters and functions are not used: |
466 |
index, map, header, footer, template, groupe, tolerance, |
467 |
toleranceunits, symbolscale, minscale, maxscale, labelminscale |
468 |
labelmaxscale, sizeunits, maxfeatures, offsite, transform, labelcache |
469 |
postlabelcache, labelitem, labelsizeitem, labelangleitem, labelitemindex |
470 |
labelsizeitemindex, labelangleitemindex, tileitem, tileindex, units |
471 |
connection, connectiontype, numitems, filteritem, styleitem, requires |
472 |
labelrequires, transparency, dump, debug, numprocessing, numjoins, |
473 |
removeClass(), open(), close(), getShape(), getNumResults(), getResult() |
474 |
getItem(), promote(), demote(), draw(), drawQuery(), queryByAttributes() |
475 |
queryByPoint(), queryByRect(), queryByFeatures(), queryByShape(), |
476 |
setFilter(), setFilterString(), setWKTProjection(), setProjection() |
477 |
addFeature(), getNumFeatures(), setMetaData(), removeMetaData(), |
478 |
getWMSFeatureInfoURL(), executeWFSGetFeature(), applySLD(), applySLDURL() |
479 |
enerateSLD(), moveClassUp(), moveClassDown(), setProcessing(), |
480 |
getProcessing(), clearProcessing() |
481 |
""" |
482 |
|
483 |
def __init__(self, mf_layer): |
484 |
""" |
485 |
Creates the Layer Object from the mapscript Layer Object. |
486 |
the class objects in the layer object will be stored in |
487 |
an array. The metadata are created as a new object. |
488 |
""" |
489 |
|
490 |
self._mf_layer = mf_layer |
491 |
|
492 |
# Create Classes |
493 |
# there could be more then 1 |
494 |
self._numclasses = mf_layer.numclasses |
495 |
i = -1 |
496 |
self._classes = [] |
497 |
while i < self._numclasses-1: |
498 |
i += 1 |
499 |
self._classes.append(MF_Class(self._mf_layer.getClass(i))) |
500 |
|
501 |
self._projection = MF_Projection(self._mf_layer.getProjection()) |
502 |
|
503 |
# Variable extent will not used for RasterLayer |
504 |
# this variable is not necessary, because it comes directly |
505 |
# from the shp file |
506 |
try: |
507 |
self._extent = MF_Rectangle(self._mf_layer.getExtent()) |
508 |
except: |
509 |
self._extent = None |
510 |
|
511 |
# Create Metadata |
512 |
self._metadata = MF_Metadata() |
513 |
try: |
514 |
self._metafkey = self._mf_layer.getFirstMetaDataKey() |
515 |
except: |
516 |
self._metadata = None |
517 |
else: |
518 |
while self._metafkey: |
519 |
self._metakeydata = self._mf_layer.getMetaData(self._metafkey) |
520 |
self._metadata.add_metadata(self._metafkey,self._metakeydata) |
521 |
self._metafkey = self._mf_layer.getNextMetaDataKey(self._metafkey) |
522 |
|
523 |
def get_name(self): |
524 |
return self._mf_layer.name |
525 |
|
526 |
def get_data(self): |
527 |
return self._mf_layer.data |
528 |
|
529 |
def get_classes(self): |
530 |
return self._classes |
531 |
|
532 |
def get_type(self): |
533 |
return shp_type[self._mf_layer.type] |
534 |
|
535 |
def get_classitem(self): |
536 |
return self._mf_layer.classitem |
537 |
|
538 |
def get_projection(self): |
539 |
return self._projection |
540 |
|
541 |
def get_status(self): |
542 |
# returns a integer value |
543 |
# 0 = off, 1 = on, 2 = default(always on) |
544 |
if self._mf_layer.status == 0: |
545 |
return False |
546 |
else: |
547 |
return True |
548 |
#return self._mf_layer.status |
549 |
|
550 |
def set_name(self, newname): |
551 |
self._mf_layer.name = newname |
552 |
|
553 |
def set_data(self, newdata, type="shape"): |
554 |
if type == "raster": |
555 |
self._mf_layer.data = newdata |
556 |
else: |
557 |
self._mf_layer.data = newdata[:-4] |
558 |
|
559 |
|
560 |
def set_status(self, newstatus): |
561 |
# status can set to true or false from thuban. |
562 |
# but mapserver supports the default value |
563 |
self._mf_layer.status = newstatus |
564 |
|
565 |
def set_classitem(self, tb_field): |
566 |
self._mf_layer.classitem = tb_field |
567 |
|
568 |
def set_type(self, tb_type): |
569 |
# if type = arc its a in shapetype line |
570 |
if tb_type == "arc": |
571 |
self._mf_layer.type = 1 |
572 |
if tb_type == "raster": |
573 |
self._mf_layer.type = 3 |
574 |
if shp_type.has_key(tb_type): |
575 |
self._mf_layer.type = tb_type |
576 |
else: |
577 |
for shp_paar_nr in shp_type: |
578 |
if shp_type[shp_paar_nr] == tb_type: |
579 |
self._mf_layer.type = shp_paar_nr |
580 |
return |
581 |
|
582 |
def set_projection(self, newprojection): |
583 |
self._mfnewprojstring = "" |
584 |
if newprojection: |
585 |
self._newparams = newprojection.GetAllParameters() |
586 |
for field in self._newparams: |
587 |
self._mfnewprojstring = self._mfnewprojstring+ "," + field |
588 |
self._mf_layer.setProjection(self._mfnewprojstring[1:]) |
589 |
self._projection.set_projection(newprojection) |
590 |
|
591 |
def add_thubanclass(self, tb_class, type=""): |
592 |
""" |
593 |
Add a thuban class object |
594 |
""" |
595 |
new_class = MF_Class(classObj(self._mf_layer)) |
596 |
new_class.set_name(tb_class.GetLabel()) |
597 |
if self.get_type() == "line": |
598 |
new_class.add_thubanstyle(tb_class.GetProperties(), type="line") |
599 |
elif self.get_type() == "point": |
600 |
new_class.add_thubanstyle(tb_class.GetProperties(), type="point") |
601 |
else: |
602 |
new_class.add_thubanstyle(tb_class.GetProperties()) |
603 |
if (type == "default"): |
604 |
return |
605 |
elif (tb_class.Matches("DEFAULT")): |
606 |
new_class.set_expressionstring('/./') |
607 |
else: |
608 |
new_class.set_expressionstring(str(tb_class.GetValue())) |
609 |
new_class.set_status(tb_class.IsVisible()) |
610 |
self._classes.append(new_class) |
611 |
|
612 |
class MF_Scalebar: |
613 |
""" |
614 |
The following settings are (not) used: |
615 |
imagecolor, height, width, style, intervals, label, color, backgroundcolor, |
616 |
outlinecolor, units, status, position, postlabelcache |
617 |
""" |
618 |
def __init__(self, mf_scalebar): |
619 |
self._scalebar = mf_scalebar |
620 |
self._color = MF_Color(self._scalebar.color) |
621 |
self._imagecolor = MF_Color(self._scalebar.imagecolor) |
622 |
self._label = MF_Label(self._scalebar.label) |
623 |
|
624 |
def get_label(self): |
625 |
return self._label |
626 |
|
627 |
def get_color(self): |
628 |
return self._color |
629 |
|
630 |
def get_imagecolor(self): |
631 |
return self._imagecolor |
632 |
|
633 |
def get_style(self): |
634 |
return self._scalebar.style |
635 |
|
636 |
def set_style(self, new_style): |
637 |
self._scalebar.style = new_style |
638 |
|
639 |
def get_size(self): |
640 |
#returns the size |
641 |
return (self._scalebar.width, self._scalebar.height) |
642 |
|
643 |
def set_size(self, new_width, new_height): |
644 |
self._scalebar.width = new_width |
645 |
self._scalebar.height = new_height |
646 |
|
647 |
def get_intervals(self): |
648 |
return self._scalebar.intervals |
649 |
|
650 |
def set_intervals(self, new_intervals): |
651 |
self._scalebar.intervals = new_intervals |
652 |
|
653 |
def get_units(self): |
654 |
#returns the unittype |
655 |
return unit_type[self._scalebar.units] |
656 |
|
657 |
def set_units(self, units): |
658 |
if unit_type.has_key(units): |
659 |
self._scalebar.units = units |
660 |
else: |
661 |
for unit_paar_nr in unit_type: |
662 |
if unit_type[unit_paar_nr] == units: |
663 |
self._scalebar.units = unit_paar_nr |
664 |
|
665 |
def get_status(self, art="integer"): |
666 |
if art == "string": |
667 |
return scalebar_status_type[self._scalebar.status] |
668 |
else: |
669 |
return self._scalebar.status |
670 |
|
671 |
def set_status(self, new_status): |
672 |
if scalebar_status_type.has_key(new_status): |
673 |
self._scalebar.status = new_status |
674 |
else: |
675 |
for scalebar_status_type_nr in scalebar_status_type: |
676 |
if scalebar_status_type[scalebar_status_type_nr] == new_status: |
677 |
self._scalebar.status = scalebar_status_type_nr |
678 |
|
679 |
def get_position(self, art="integer"): |
680 |
if art == "string": |
681 |
return scalebar_position_type[self._scalebar.position] |
682 |
else: |
683 |
return self._scalebar.position |
684 |
|
685 |
def set_position(self, new_position): |
686 |
if scalebar_position_type.has_key(new_position): |
687 |
self._scalebar.position = new_position |
688 |
else: |
689 |
for scalebar_position_type_nr in legend_position_type: |
690 |
if scalebar_position_type[scalebar_position_type_nr] == new_position: |
691 |
self._scalebar.position = scalebar_position_type_nr |
692 |
|
693 |
class MF_Map: |
694 |
""" |
695 |
The following parameters and functions, which the mapscript style obj |
696 |
contains, are used: |
697 |
|
698 |
name, numlayers, extent, shapepath, imagecolor, imagetype, units, getLayer, |
699 |
status, getProjection, getMetaData, getFirstMetaDataKey, getNextMetaDataKey, |
700 |
save(), setExtent(), height, width, setProjection() |
701 |
|
702 |
|
703 |
The following parameters and functions are not used: |
704 |
maxsize, layers, symbolset, fontset, labelcache, |
705 |
transparent, interlace, imagequality, cellsize, debug, datapattern, |
706 |
templatepattern, configoptions |
707 |
zoomPoint(), zoomRectangle(), zoomScale(), getLayerOrder(), setLayerOrder(), |
708 |
clone(), removeLayer(), getLayerByName(), getSymbolByName(), |
709 |
prepareQuery(), prepareImage(), setImageType(), setOutputFormat(), draw(), |
710 |
drawQuery(), drawLegend(), drawScalebar(), embedLegend(), drawLabelCache(), |
711 |
nextLabel(), queryByPoint(), queryByRecht(), queryByFeatures(), queryByShape(), |
712 |
setWKTProjection(), saveQuery(), saveQueryASGML(), |
713 |
setMetaData(), removeMetaData(), setSymbolSet(), getNumSymbols(), setFontSet(), |
714 |
saveMapContext(), loadMapContext(), moveLayerUp(), moveLayerDown(), |
715 |
getLayersDrawingOrder(), setLayersDrawingOrder(), setConfigOption(), |
716 |
getConfigOption(), applyConfigOptions(), applySLD(), applySLDURL(), gernerateSLD(), |
717 |
procecssTemplate(), processLegemdTemplate(), processQueryTemplate(), |
718 |
getOutputFormatByName(), appendOutputFormat(), removeOutputFormat(), |
719 |
""" |
720 |
|
721 |
def __init__(self, mf_map): |
722 |
""" |
723 |
Create the map object from the mapfile mapobject which is given. |
724 |
|
725 |
All layers in the mapfile will be written to an array. |
726 |
""" |
727 |
|
728 |
self._mf_map = mf_map |
729 |
self._extent = MF_Rectangle(self._mf_map.extent) |
730 |
self._imagecolor = MF_Color(self._mf_map.imagecolor) |
731 |
self._web = MF_Web(self._mf_map.web) |
732 |
self._legend = MF_Legend(self._mf_map.legend) |
733 |
self._scalebar = MF_Scalebar(self._mf_map.scalebar) |
734 |
self._outputformat = MF_Outputformat(self._mf_map.outputformat) |
735 |
|
736 |
# symbols |
737 |
self._symbolset = MF_SymbolSet(self._mf_map.symbolset) |
738 |
|
739 |
# if the map name is not set it will return a MS string. |
740 |
if self._mf_map.name != "MS": |
741 |
self._name = self._mf_map.name |
742 |
else: |
743 |
self._name = None |
744 |
|
745 |
self._projection = MF_Projection(self._mf_map.getProjection()) |
746 |
|
747 |
# Initial Layer List |
748 |
self._layers = [] |
749 |
self._numlayers = self._mf_map.numlayers |
750 |
self._i = 0 |
751 |
while self._i < self._numlayers: |
752 |
self._layers.append(MF_Layer(self._mf_map.getLayer(self._i))) |
753 |
self._i += 1 |
754 |
|
755 |
# Shapepath if not set, shapepath will be empty |
756 |
if self._mf_map.shapepath: |
757 |
self._shapepath = self._mf_map.shapepath |
758 |
else: |
759 |
self._shapepath = "" |
760 |
|
761 |
# Create Metadata |
762 |
self._metadata = MF_Metadata() |
763 |
try: |
764 |
self._metafkey = self._mf_map.getFirstMetaDataKey() |
765 |
except: |
766 |
self._metadata = None |
767 |
else: |
768 |
while self._metafkey: |
769 |
self._metakeydata = self._mf_map.getMetaData(self._metafkey) |
770 |
self._metadata.add_metadata(self._metafkey,self._metakeydata) |
771 |
self._metafkey = self._mf_map.getNextMetaDataKey(self._metafkey) |
772 |
|
773 |
def get_outputformat(self): |
774 |
return self._outputformat |
775 |
|
776 |
def get_imagetype(self): |
777 |
return self._mf_map.imagetype |
778 |
|
779 |
def set_imagetype(self, new_imagetype): |
780 |
self._mf_map.setImageType(new_imagetype) |
781 |
|
782 |
def get_symbolset(self): |
783 |
return self._symbolset |
784 |
|
785 |
def get_status(self): |
786 |
if self._mf_map.status == 1: |
787 |
return True |
788 |
else: |
789 |
return False |
790 |
|
791 |
def set_status(self, new_status): |
792 |
if new_status: |
793 |
self._mf_map.status = 1 |
794 |
else: |
795 |
self._mf_map.status = 0 |
796 |
|
797 |
def get_scalebar(self): |
798 |
return self._scalebar |
799 |
|
800 |
def get_web(self): |
801 |
return self._web |
802 |
|
803 |
def get_legend(self): |
804 |
return self._legend |
805 |
|
806 |
def get_extent(self): |
807 |
return self._extent |
808 |
|
809 |
def get_layers(self): |
810 |
return self._layers |
811 |
|
812 |
def get_projection(self): |
813 |
return self._projection |
814 |
|
815 |
def get_name(self): |
816 |
return self._name |
817 |
|
818 |
def get_shapepath(self): |
819 |
return self._shapepath # where are the shape files located.. |
820 |
|
821 |
def get_imagetype(self): |
822 |
return self._mf_map.imagetype |
823 |
|
824 |
def get_layerorder(self): |
825 |
# shows the order of layer as list |
826 |
return self._mf_map.getLayerOrder() |
827 |
|
828 |
def get_size(self): |
829 |
#returns the size |
830 |
return (self._mf_map.width, self._mf_map.height) |
831 |
|
832 |
def get_units(self): |
833 |
#returns the unittype |
834 |
return unit_type[self._mf_map.units] |
835 |
|
836 |
def get_imagecolor(self): |
837 |
return self._imagecolor |
838 |
|
839 |
def set_name(self, newname): |
840 |
# whitespace musst be replaced, either no |
841 |
# mapfile will be shown in the mapserver |
842 |
newname = newname.replace(" ","_") |
843 |
self._name = newname |
844 |
self._mf_map.name = newname |
845 |
|
846 |
def set_extent(self, newextent): |
847 |
# TODO: add the shown extend here instead of the total |
848 |
self._newrect = MF_Rectangle(rectObj()) |
849 |
try: |
850 |
self._newrect.set_rect(newextent[0],newextent[1],newextent[2],newextent[3]) |
851 |
self._mf_map.setExtent(newextent[0],newextent[1],newextent[2],newextent[3]) |
852 |
except: |
853 |
return |
854 |
|
855 |
def set_size(self, newwidth, newheight): |
856 |
self._mf_map.width = newwidth |
857 |
self._mf_map.height = newheight |
858 |
|
859 |
def set_projection(self, projection): |
860 |
self._mfnewprojstring = "" |
861 |
self._newparams = projection.GetAllParameters() |
862 |
for field in self._newparams: |
863 |
self._mfnewprojstring = self._mfnewprojstring+ "," + field |
864 |
self._mf_map.setProjection(self._mfnewprojstring[1:]) |
865 |
self._projection.set_projection(projection) |
866 |
|
867 |
def set_units(self, units): |
868 |
if unit_type.has_key(units): |
869 |
self._mf_map.units = units |
870 |
else: |
871 |
for unit_paar_nr in unit_type: |
872 |
if unit_type[unit_paar_nr] == units: |
873 |
self._mf_map.units = unit_paar_nr |
874 |
|
875 |
def add_thubanlayer(self, tb_layer): |
876 |
""" |
877 |
Add a thuban layer |
878 |
""" |
879 |
new_layer = MF_Layer(layerObj(self._mf_map)) |
880 |
new_layer.set_name(tb_layer.Title()) |
881 |
|
882 |
# TODO: implement relative pathnames |
883 |
# yet only absolute pathnames in the LayerObj are set |
884 |
try: |
885 |
new_layer.set_data(tb_layer.ShapeStore().FileName()) |
886 |
except: |
887 |
new_layer.set_data(tb_layer.GetImageFilename(), type="raster") |
888 |
new_layer.set_type("raster") |
889 |
new_layer.set_status(tb_layer.Visible()) |
890 |
else: |
891 |
new_layer.set_status(tb_layer.Visible()) |
892 |
new_layer.set_type(tb_layer.ShapeType()) |
893 |
|
894 |
if tb_layer.GetClassificationColumn(): |
895 |
new_layer.set_classitem(tb_layer.GetClassificationColumn()) |
896 |
if tb_layer.GetProjection(): |
897 |
new_layer.set_projection(tb_layer.GetProjection()) |
898 |
if tb_layer.GetClassification().GetNumGroups() > 0: |
899 |
for group in range(0, tb_layer.GetClassification().GetNumGroups(), 1): |
900 |
new_layer.add_thubanclass(tb_layer.GetClassification().GetGroup(group)) |
901 |
new_layer.add_thubanclass(tb_layer.GetClassification().GetDefaultGroup()) |
902 |
else: |
903 |
new_layer.add_thubanclass(tb_layer.GetClassification().GetDefaultGroup(), type="default") |
904 |
|
905 |
# set the projection to the layer. |
906 |
# if the layer has its own definition use is, else use the main projection |
907 |
if tb_layer.GetProjection(): |
908 |
new_layer.set_projection(tb_layer.GetProjection()) |
909 |
else: |
910 |
new_layer.set_projection(self._projection.get_projection()) |
911 |
self._layers.append(new_layer) |
912 |
|
913 |
def remove_layer(self, nr): |
914 |
self._mf_map.removeLayer(nr) |
915 |
self._numlayers -= 1 |
916 |
self._layers.remove(self._layers[nr]) |
917 |
|
918 |
def save_map(self, filepath): |
919 |
# save the Map |
920 |
# maybe an own saver can implement here |
921 |
self._mf_map.save(filepath) |
922 |
|
923 |
|
924 |
class MF_Web: |
925 |
""" |
926 |
Save the Web settings |
927 |
|
928 |
The following parametes are used: |
929 |
imagepath, imageurl |
930 |
|
931 |
The following parameters are not used: |
932 |
log, map, template, queryformat, header, footer, empty, error, extent, |
933 |
minscale, maxscale, mintemplate, maxtemplate |
934 |
""" |
935 |
def __init__(self, mf_web): |
936 |
self._mf_web = mf_web |
937 |
|
938 |
def get_imagepath(self): |
939 |
return self._mf_web.imagepath |
940 |
|
941 |
def set_imagepath(self, new_imagepath): |
942 |
self._mf_web.imagepath = new_imagepath |
943 |
|
944 |
def get_imageurl(self): |
945 |
return self._mf_web.imageurl |
946 |
|
947 |
def set_imageurl(self, new_imageurl): |
948 |
self._mf_web.imagepath = new_imageurl |
949 |
|
950 |
def get_queryformat(self): |
951 |
return self._mf_web.queryformat |
952 |
|
953 |
def set_queryformat(self, new_queryformat): |
954 |
self._mf_web.imagepath = new_queryformat |
955 |
|
956 |
|
957 |
class MF_Label: |
958 |
""" |
959 |
The following parameters from mapscript are used: |
960 |
type, color, size, offsetx, offsety, |
961 |
|
962 |
The following parameters are not used: |
963 |
font, outlinecolor, shadowcolor, shadowsizex, shadowsizey, |
964 |
backgroundcolor, backgroundshadowcolor, backgroundshadowsizex, |
965 |
backgroundshadowsizey, sizescaled, minsize, maxsize, position, angle, |
966 |
autoangle, buffer, antialias, wrap, minfeaturesize, |
967 |
autominfeaturesize, mindistance, partials, force |
968 |
""" |
969 |
def __init__(self, mf_label): |
970 |
""" |
971 |
Create a legend obj from the existing mapfile |
972 |
""" |
973 |
self._label = mf_label |
974 |
self._color = MF_Color(self._label.color) |
975 |
|
976 |
def get_size(self): |
977 |
return self._label.size |
978 |
|
979 |
def set_size(self, new_size): |
980 |
if label_size_type.has_key(new_size): |
981 |
self._label.size = new_size |
982 |
for label_size_type_nr in label_size_type: |
983 |
if label_size_type[label_size_type_nr] == new_size: |
984 |
self._label.size = label_size_type_nr |
985 |
else: |
986 |
self._label.size = new_size |
987 |
|
988 |
def get_color(self): |
989 |
return self._color |
990 |
|
991 |
def get_partials(self): |
992 |
if self._label.partials == 1: |
993 |
return True |
994 |
else: |
995 |
return False |
996 |
|
997 |
def set_partials(self, new_partials): |
998 |
# if partials = True |
999 |
if new_partials: |
1000 |
self._label.partials = 1 |
1001 |
elif new_partials == False: |
1002 |
self._label.partials = 0 |
1003 |
else: |
1004 |
print "Boolean exspected" |
1005 |
|
1006 |
def get_buffer(self): |
1007 |
return self._label.buffer |
1008 |
|
1009 |
def set_buffer(self, new_buffer): |
1010 |
self._label.buffer = new_buffer |
1011 |
|
1012 |
def get_mindistance(self): |
1013 |
return self._label.mindistance |
1014 |
|
1015 |
def set_mindistance(self, new_mindistance): |
1016 |
self._label.mindistance = new_mindistance |
1017 |
|
1018 |
def get_minfeaturesize(self): |
1019 |
return self._label.minfeaturesize |
1020 |
|
1021 |
def set_minfeaturesize(self, new_minfeaturesize): |
1022 |
self._label.minfeaturesize = new_minfeaturesize |
1023 |
|
1024 |
def get_position(self, art="integer"): |
1025 |
if art == "string": |
1026 |
return label_position_type[self._label.position] |
1027 |
else: |
1028 |
return self._label.position |
1029 |
|
1030 |
def set_position(self, new_position): |
1031 |
if label_position_type.has_key(new_position): |
1032 |
self._label.position = new_position |
1033 |
else: |
1034 |
for label_position_type_nr in label_position_type: |
1035 |
if label_position_type[label_position_type_nr] == new_position: |
1036 |
self._label.position = label_position_type_nr |
1037 |
|
1038 |
def get_force(self): |
1039 |
if self._label.force == 1: |
1040 |
return True |
1041 |
else: |
1042 |
return False |
1043 |
|
1044 |
def set_force(self, new_force): |
1045 |
if new_force: |
1046 |
self._label.force = 1 |
1047 |
else: |
1048 |
self._label.force = 0 |
1049 |
|
1050 |
def get_type(self): |
1051 |
return label_font_type[self._label.type] |
1052 |
|
1053 |
def set_type(self, new_type): |
1054 |
if label_font_type.has_key(new_type): |
1055 |
self._label.type = new_type |
1056 |
else: |
1057 |
for label_font_type_nr in label_font_type: |
1058 |
if label_font_type[label_font_type_nr] == new_type: |
1059 |
self._label.type = label_font_type_nr |
1060 |
|
1061 |
def get_offset(self): |
1062 |
return (self._label.offsetx, self._label.offsety) |
1063 |
|
1064 |
def set_offset(self, new_offsetx, new_offsety): |
1065 |
self._label.offsetx = new_offsetx |
1066 |
self._label.offsety = new_offsety |
1067 |
|
1068 |
|
1069 |
class MF_Legend: |
1070 |
""" |
1071 |
The following parameters are (not) used: |
1072 |
imagecolor, label, keysizex, keysizey, status, position, |
1073 |
|
1074 |
The following parameters are not used: |
1075 |
keyspacingx, keyspacingy, |
1076 |
outlinecolor, height, width, postlabelcache, template, map |
1077 |
""" |
1078 |
def __init__(self, mf_legend): |
1079 |
""" |
1080 |
Create a legend obj from the existing mapfile |
1081 |
""" |
1082 |
self._mf_legend = mf_legend |
1083 |
self._imagecolor = MF_Color(self._mf_legend.imagecolor) |
1084 |
self._label = MF_Label(self._mf_legend.label) |
1085 |
|
1086 |
def get_imagecolor(self): |
1087 |
return self._imagecolor |
1088 |
|
1089 |
def get_label(self): |
1090 |
return self._label |
1091 |
|
1092 |
def get_keysize(self): |
1093 |
return (self._mf_legend.keysizex, self._mf_legend.keysizey) |
1094 |
|
1095 |
def set_keysize(self, new_keysizex, new_keysizey): |
1096 |
self._mf_legend.keysizex = new_keysizex |
1097 |
self._mf_legend.keysizey = new_keysizey |
1098 |
|
1099 |
def get_keyspacing(self): |
1100 |
return (self._mf_legend.keyspacingx, self._mf_legend.keyspacingy) |
1101 |
|
1102 |
def set_keyspacing(self, new_keyspacingx, new_keyspacingy): |
1103 |
self._mf_legend.keyspacingx = new_keyspacingx |
1104 |
self._mf_legend.keyspacingy = new_keyspacingy |
1105 |
|
1106 |
def get_status(self, art="integer"): |
1107 |
if art == "string": |
1108 |
return legend_status_type[self._mf_legend.status] |
1109 |
else: |
1110 |
return self._mf_legend.status |
1111 |
|
1112 |
def set_status(self, new_status): |
1113 |
if legend_status_type.has_key(new_status): |
1114 |
self._mf_legend.status = new_status |
1115 |
else: |
1116 |
for legend_status_type_nr in legend_status_type: |
1117 |
if legend_status_type[legend_status_type_nr] == new_status: |
1118 |
self._mf_legend.status = legend_status_type_nr |
1119 |
|
1120 |
def get_position(self, art="integer"): |
1121 |
if art == "string": |
1122 |
return legend_position_type[self._mf_legend.position] |
1123 |
else: |
1124 |
return self._mf_legend.position |
1125 |
|
1126 |
def set_position(self, new_position): |
1127 |
if legend_position_type.has_key(new_position): |
1128 |
self._mf_legend.position = new_position |
1129 |
else: |
1130 |
for legend_position_type_nr in legend_position_type: |
1131 |
if legend_position_type[legend_position_type_nr] == new_position: |
1132 |
self._mf_legend.position = legend_position_type_nr |
1133 |
|
1134 |
class MF_Projection: |
1135 |
""" |
1136 |
The following parameter, which the mapscript style obj contains is used: |
1137 |
|
1138 |
numargs |
1139 |
""" |
1140 |
|
1141 |
def __init__(self, mf_projection): |
1142 |
""" |
1143 |
Create a projection object from the given mapscript projection |
1144 |
object. If it is a epsg code the extracted from the string |
1145 |
(e.g."init=epsg:xxxx"), else the projection parameters will |
1146 |
be splitted and an array with the parameters will be creaded. |
1147 |
""" |
1148 |
self._mfprojstring = mf_projection |
1149 |
self._projstring = self._mfprojstring |
1150 |
self._epsgcode = None |
1151 |
self._params = None |
1152 |
if self._mfprojstring: |
1153 |
if self._mfprojstring.find("init=epsg:") != -1: |
1154 |
self._initcode, self._epsgcode = self._mfprojstring.split(':') |
1155 |
else: |
1156 |
self._params = [] |
1157 |
self._params = self._mfprojstring.split("+") |
1158 |
if self._params[0] == "": |
1159 |
self._params.remove("") |
1160 |
|
1161 |
def epsg_code_to_projection(self, epsg): |
1162 |
""" |
1163 |
Find the projection for the given epsg code. |
1164 |
|
1165 |
Copied from Extension/wms/layer.py |
1166 |
|
1167 |
epsg -- EPSG code as string |
1168 |
""" |
1169 |
#Needed only for this function |
1170 |
from Thuban.Model.resource import get_system_proj_file, EPSG_PROJ_FILE, \ |
1171 |
EPSG_DEPRECATED_PROJ_FILE |
1172 |
|
1173 |
proj_file, warnings = get_system_proj_file(EPSG_PROJ_FILE) |
1174 |
|
1175 |
for proj in proj_file.GetProjections(): |
1176 |
if proj.EPSGCode() == epsg: |
1177 |
return proj |
1178 |
|
1179 |
proj_file, warnings = get_system_proj_file(EPSG_DEPRECATED_PROJ_FILE) |
1180 |
for proj in proj_file.GetProjections(): |
1181 |
if proj.EPSGCode() == epsg: |
1182 |
return proj |
1183 |
return None |
1184 |
|
1185 |
def get_params(self): |
1186 |
#Parameter from the mf_projectionstring as Array |
1187 |
return self._params |
1188 |
|
1189 |
def get_epsgcode(self): |
1190 |
# returnes the epsg number |
1191 |
return self._epsgcode |
1192 |
|
1193 |
def get_epsgproj(self): |
1194 |
# get an epsg projectionobject |
1195 |
return self.epsg_code_to_projection(self._epsgcode) |
1196 |
|
1197 |
def get_projection(self): |
1198 |
return self._projstring |
1199 |
|
1200 |
def set_projection(self, newprojection): |
1201 |
self._projstring = newprojection |
1202 |
self._params = newprojection.GetAllParameters() |
1203 |
self._mfnewprojstring = "" |
1204 |
for field in self._params: |
1205 |
self._mfnewprojstring = self._mfnewprojstring+ "+" + field |
1206 |
self._mfprojstring = self._mfnewprojstring |
1207 |
|
1208 |
|
1209 |
class MF_Style: |
1210 |
""" |
1211 |
The following parameters, which the mapscript style obj |
1212 |
contains, are used: |
1213 |
color, backgroundcolor, outlinecolor, size, symbolname |
1214 |
|
1215 |
The following are not used: |
1216 |
symbol, sizescaled, minsize, maxsize, offsetx, offsety, |
1217 |
antialias |
1218 |
""" |
1219 |
|
1220 |
def __init__(self, mf_style): |
1221 |
""" |
1222 |
Create a style object from the given mapscript style object. |
1223 |
The color Object from the color and the outlinecolor parameter |
1224 |
will be created. if the color (red, green or blue) is -1 there |
1225 |
is no definition in the mapfile and so there is no color object, |
1226 |
it will set to 'None'. |
1227 |
""" |
1228 |
self._style = mf_style |
1229 |
if self._style.color.red == -1: |
1230 |
self._color = None |
1231 |
else: |
1232 |
self._color = MF_Color(self._style.color) |
1233 |
if self._style.outlinecolor.red == -1: |
1234 |
self._outlinecolor = None |
1235 |
else: |
1236 |
self._outlinecolor = MF_Color(self._style.outlinecolor) |
1237 |
|
1238 |
def get_color(self): |
1239 |
return self._color |
1240 |
|
1241 |
def get_outlinecolor(self): |
1242 |
return self._outlinecolor |
1243 |
|
1244 |
def get_size(self): |
1245 |
return self._style.size |
1246 |
|
1247 |
def set_linecolor(self, tb_color): |
1248 |
self._color = tb_color |
1249 |
new_linecolor = MF_Color(colorObj()) |
1250 |
new_linecolor.set_thubancolor(tb_color) |
1251 |
self._outlinecolor = new_linecolor |
1252 |
self._style.outlinecolor = new_linecolor.get_mfcolor() |
1253 |
|
1254 |
def set_color(self, tb_color): |
1255 |
self._color = tb_color |
1256 |
new_color = MF_Color(colorObj()) |
1257 |
new_color.set_thubancolor(tb_color) |
1258 |
self._color = new_color |
1259 |
self._style.color = new_color.get_mfcolor() |
1260 |
|
1261 |
def set_size(self, newsize): |
1262 |
self._style.size = newsize |
1263 |
|
1264 |
def set_symbolname(self, newsymbol): |
1265 |
# its possible to use stringnames instead of numbers |
1266 |
self._style.symbolname = newsymbol |
1267 |
|