From 8f93bf168b1b035a0a5fe3c45bba89ccef053b74 Mon Sep 17 00:00:00 2001 From: Jared Erickson Date: Sun, 5 Aug 2012 11:54:57 -0700 Subject: [PATCH] Fix issue #5, allow for specifying size in Icon --- geoscript/style/icon.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/geoscript/style/icon.py b/geoscript/style/icon.py index b0958ab..eb7f1a1 100644 --- a/geoscript/style/icon.py +++ b/geoscript/style/icon.py @@ -2,6 +2,7 @@ from geoscript.util import toURL from geoscript.style import util from geoscript.style.symbolizer import Symbolizer +from geoscript.style.expression import Expression from org.geotools.styling import PointSymbolizer, PolygonSymbolizer class Icon(Symbolizer): @@ -14,14 +15,15 @@ class Icon(Symbolizer): >>> icon = Icon('tests/work/colorblocks.png', 'image/png') >>> icon = Icon('http://v2.suite.opengeo.org/geoserver/styles/smileyface.png', 'image/png') """ - def __init__(self, url, format=None): + def __init__(self, url, format=None, size=None): Symbolizer.__init__(self) self.url = toURL(url) if not format: format = mimetypes.guess_type(url)[0] - + self.format = format + self.size = Expression(size) if size else None def _prepare(self, rule): syms = util.symbolizers(rule, PointSymbolizer) @@ -32,6 +34,8 @@ def _apply(self, sym): Symbolizer._apply(self, sym) eg = self.factory.createExternalGraphic(self.url, self.format) g = util.graphic(sym) + if self.size: + g.size = self.size.expr g.setMarks([]) if g: g.graphicalSymbols().add(eg)