2
2
from geoscript .util import toURL
3
3
from geoscript .style import util
4
4
from geoscript .style .symbolizer import Symbolizer
5
+ from geoscript .style .expression import Expression
5
6
from org .geotools .styling import PointSymbolizer , PolygonSymbolizer
6
7
7
8
class Icon (Symbolizer ):
@@ -14,14 +15,15 @@ class Icon(Symbolizer):
14
15
>>> icon = Icon('tests/work/colorblocks.png', 'image/png')
15
16
>>> icon = Icon('http://v2.suite.opengeo.org/geoserver/styles/smileyface.png', 'image/png')
16
17
"""
17
- def __init__ (self , url , format = None ):
18
+ def __init__ (self , url , format = None , size = None ):
18
19
Symbolizer .__init__ (self )
19
20
self .url = toURL (url )
20
21
21
22
if not format :
22
23
format = mimetypes .guess_type (url )[0 ]
23
-
24
+
24
25
self .format = format
26
+ self .size = Expression (size ) if size else None
25
27
26
28
def _prepare (self , rule ):
27
29
syms = util .symbolizers (rule , PointSymbolizer )
@@ -32,6 +34,8 @@ def _apply(self, sym):
32
34
Symbolizer ._apply (self , sym )
33
35
eg = self .factory .createExternalGraphic (self .url , self .format )
34
36
g = util .graphic (sym )
37
+ if self .size :
38
+ g .size = self .size .expr
35
39
g .setMarks ([])
36
40
if g :
37
41
g .graphicalSymbols ().add (eg )
0 commit comments