def __init__(self, color=None, size=6, type='circle', opacity=1.0, rotation=0): Symbolizer.__init__(self) self.color = Color(color) if color else None self.size = Expression(size) self.type = type self.opacity = Expression(opacity) self.rotation = Expression(rotation) self._stroke = None
def _pointPlacement(self, anchor, displace, rotate): f = self.factory ap = f.createAnchorPoint( Expression(anchor[0]).expr, Expression(anchor[1]).expr) dp = f.createDisplacement( Expression(displace[0]).expr, Expression(displace[1]).expr) return f.createPointPlacement(ap, dp, Expression(rotate).expr)
def _colormap(self): f = self.factory map = f.createColorMap() map.setType(_type[self.interpolate]) for v in self.values: entry = f.createColorMapEntry() entry.setQuantity(Expression(v[0]).expr) col = Color(v[1]) entry.setColor(col.expr) entry.setOpacity(Expression(col._color.alpha / 255.0).expr) map.addColorMapEntry(entry) return map
def __init__(self, color='#000000', width=1, dash=None, cap=None, join=None, opacity=1.0): Symbolizer.__init__(self) self.color = Color(color) self.width = Expression(width) self.opacity = Expression(opacity) self.dash = dash self.cap = Expression(cap) if cap else None self.join = Expression(join) if join else None self._hatch = None self._icon = 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 __init__(self, fill=None, radius=1): Symbolizer.__init__(self) if fill: if not isinstance(fill, Fill): fill = Fill(Color(fill)) else: fill = Fill('#ffffff') self.fill = fill self.radius = Expression(radius)
def __init__(self, name, stroke=None, size=None): Symbolizer.__init__(self) self.name = name if not stroke: from geoscript.style.stroke import Stroke stroke = Stroke() self.stroke = stroke self.size = Expression(size if size else 8)
def line(self, offset=0, gap=None, igap=None, align=False, follow=False, group=False, displace=None, repeat=None): """ Sets the label placement relative to a line. The ``offset`` argument specifies the perpindicular distance from the line at which to position the label. The ``align`` argument specifies whether to align the label along the line. The ``follow`` argument specifies whether to curve the label in order to force it to follow the line. >>> label = Label('foo').linear(align=True, follow=True) """ f = self.factory lp = f.createLinePlacement(Expression(offset).expr) lp.setAligned(align) #lp.setRepeated(repeat) if gap: lp.setGap(Expression(gap).expr) if igap: lp.setInitialGap(Expression(igap).expr) self._placement = lp self.options['followLine'] = follow self.options['group'] = group if displace: self.options['maxDisplacement'] = displace if repeat: self.options['repeat'] = repeat return self
def __init__(self, value=1.0): Symbolizer.__init__(self) self.value = Expression(value)
def __init__(self, val): Expression.__init__(self, val)
def __init__(self, name): Expression.__init__(self, name)
class Stroke(Symbolizer): """ Symbolizer for linear geometries that consists of a ``color`` and a ``width``. >>> Stroke('#00ff00', 4) Stroke(color=(0,255,0),width=4) The ``color`` argument may also be specified as a well known name or as an rgb tuple. >>> stroke = Stroke('green', 4) >>> stroke = Stroke((0,255,0), 4) The ``dash`` argument specifies a dashed stroke pattern as a list of values. Oddly positioned elements specify the length in pixels of the dash. Evenly positioned elements specify the spaces. >>> stroke = Stroke('green', 4, [2,1,3,2]) The ``dash`` argument may also be specified as a tuple in which the first element is specifies the dash pattern described above, and the second element is an offset into the array which specifies where to begin the pattern from. >>> stroke = Stroke('green', 4, ([2,1,3,2], 2)) The ``cap`` argument specifies how lines should be capped. Supported values include "butt", "round", and "square". The ``join``argument specifies how two lines should be joined. Supported values include "miter", "round", and "bevel". The ``opacity`` argument is a float between 0 and 1 specifying the opaqueness of the stroke. """ def __init__(self, color='#000000', width=1, dash=None, cap=None, join=None, opacity=1.0): Symbolizer.__init__(self) self.color = Color(color) self.width = Expression(width) self.opacity = Expression(opacity) self.dash = dash self.cap = Expression(cap) if cap else None self.join = Expression(join) if join else None self._hatch = None self._icon = None def hatch(self, name, stroke=None, size=None): """ Composes the stroke with a hatched pattern. The ``name`` argument is the well known name of the hatch pattern. See :class:`Hatch <geoscript.style.hatch.Hatch>` for the list of supported names. The ``stroke`` and ``size`` argument specify the :class:`Stroke <geoscript.style.stroke.Stroke>` and size to use for the hatch pattern respectively. >>> stroke = Stroke().hatch('vertline') """ self._hatch = Hatch(name, stroke, size) return self def icon(self, url, format=None, size=None): """ Composes this stroke as an :class:`Icon <geoscript.style.icon.Icon>`. The ``url`` argument is the url/file containing the image. The ``format`` argument is the format or mime type of the image. """ self._icon = Icon(url, format, size) return self def interpolate(self, stroke, n=10): colors = self.color.interpolate(stroke.color, n) w1 = self.width.literal() w2 = stroke.width.literal() if w1 != None and w2 != None: widths = interpolate(w1, w2, n, 'linear') else: widths = [self.width] * n return map(lambda x: Stroke(x[0], x[1]), zip(colors, widths)) def _prepare(self, rule): sym = self.factory.createLineSymbolizer() self._apply(sym) rule.addSymbolizer(sym) def _apply(self, sym): Symbolizer._apply(self, sym) sym.setStroke(self._stroke()) if self._icon: self._icon._apply(sym) def _stroke(self): f = self.factory stroke = f.createStroke(self.color.expr, self.width.expr, self.opacity.expr) #stroke = f.createStroke(f.filter.literal(util.color(self.color)), # f.filter.literal(self.width)) if self.dash: if isinstance(self.dash, tuple): stroke.setDashArray(self.dash[0]) stroke.setDashOffset(f.filter.literal(self.dash[1])) else: stroke.setDashArray(self.dash) if self.cap: #stroke.setLineCap(f.filter.literal(self.cap)) stroke.setLineCap(self.cap.expr) if self.join: stroke.setLineJoin(self.join.expr) #stroke.setLineJoin(f.filter.literal(self.join)) if self._hatch: stroke.setGraphicStroke(self._hatch._hatch()) return stroke def __repr__(self): return self._repr('color', 'width')
class Stroke(Symbolizer): """ Symbolizer for linear geometries that consists of a ``color`` and a ``width``. >>> Stroke('#00ff00', 4) Stroke(color=(0,255,0),width=4) The ``color`` argument may also be specified as a well known name or as an rgb tuple. >>> stroke = Stroke('green', 4) >>> stroke = Stroke((0,255,0), 4) The ``dash`` argument specifies a dashed stroke pattern as a list of values. Oddly positioned elements specify the length in pixels of the dash. Evenly positioned elements specify the spaces. >>> stroke = Stroke('green', 4, [2,1,3,2]) The ``dash`` argument may also be specified as a tuple in which the first element is specifies the dash pattern described above, and the second element is an offset into the array which specifies where to begin the pattern from. >>> stroke = Stroke('green', 4, ([2,1,3,2], 2)) The ``cap`` argument specifies how lines should be capped. Supported values include "butt", "round", and "square". The ``join``argument specifies how two lines should be joined. Supported values include "miter", "round", and "bevel". The ``opacity`` argument is a float between 0 and 1 specifying the opaqueness of the stroke. """ def __init__(self, color='#000000', width=1, dash=None, cap=None, join=None, opacity=1.0): Symbolizer.__init__(self) self.color = Color(color) self.width = Expression(width) self.opacity = Expression(opacity) self.dash = dash self.cap = Expression(cap) if cap else None self.join = Expression(join) if join else None self._hatch = None self._icon = None def hatch(self, name, stroke=None, size=None): """ Composes the stroke with a hatched pattern. The ``name`` argument is the well known name of the hatch pattern. See :class:`Hatch <geoscript.style.hatch.Hatch>` for the list of supported names. The ``stroke`` and ``size`` argument specify the :class:`Stroke <geoscript.style.stroke.Stroke>` and size to use for the hatch pattern respectively. >>> stroke = Stroke().hatch('vertline') """ self._hatch = Hatch(name, stroke, size) return self def icon(self, url, format=None, size=None): """ Composes this stroke as an :class:`Icon <geoscript.style.icon.Icon>`. The ``url`` argument is the url/file containing the image. The ``format`` argument is the format or mime type of the image. """ self._icon = Icon(url, format, size) return self def interpolate(self, stroke, n=10, method='linear'): colors = self.color.interpolate(stroke.color, n, method) w1 = self.width.literal() w2 = stroke.width.literal() if w1 != None and w2 != None: widths = interpolate(w1, w2, n, method) else: widths = [self.width] * n return map(lambda x: Stroke(x[0], x[1]), zip(colors, widths)) def _prepare(self, rule): sym = self.factory.createLineSymbolizer() self._apply(sym) rule.addSymbolizer(sym) def _apply(self, sym): Symbolizer._apply(self, sym) sym.setStroke(self._stroke()) if self._icon: self._icon._apply(sym) def _stroke(self): f = self.factory stroke = f.createStroke(self.color.expr, self.width.expr, self.opacity.expr) #stroke = f.createStroke(f.filter.literal(util.color(self.color)), # f.filter.literal(self.width)) if self.dash: if isinstance(self.dash, tuple): stroke.setDashArray(self.dash[0]) stroke.setDashOffset(f.filter.literal(self.dash[1])) else: stroke.setDashArray(self.dash) if self.cap: #stroke.setLineCap(f.filter.literal(self.cap)) stroke.setLineCap(self.cap.expr) if self.join: stroke.setLineJoin(self.join.expr) #stroke.setLineJoin(f.filter.literal(self.join)) if self._hatch: stroke.setGraphicStroke(self._hatch._hatch()) return stroke def __repr__(self): return self._repr('color', 'width')
def __init__(self, color=None, opacity=1.0): Symbolizer.__init__(self) self.color = Color(color) if color else None self.opacity = Expression(opacity) self._icon = None self._hatch = None