Ejemplo n.º 1
0
def xml_shieldsymbolizer(path="",
                         width="",
                         height="",
                         text="name",
                         face=default_font_family,
                         size="10",
                         color="#000000",
                         halo_color="#ffffff",
                         halo_radius="0",
                         placement="line",
                         offset="0",
                         overlap="false",
                         distance="26",
                         wrap_width=256,
                         align="center",
                         opacity="1",
                         transform="none",
                         unlock_image='true',
                         spacing='500'):
    color = nicecolor(color)
    halo_color = nicecolor(halo_color)
    placement = {"center": "point"}.get(placement.lower(), placement)
    align = {"center": "middle"}.get(align.lower(), align)
    size = str(float(size.split(",")[0]) * text_scale)
    if width:
        width = ' width="%s" ' % width
    if height:
        height = ' height="%s" ' % height
    return """
      <ShieldSymbolizer file="%s%s" %s %s fontset-name="%s" size="%s" fill="%s" halo-fill= "%s" halo-radius="%s" placement="%s" dy="%s" allow-overlap="%s" wrap-width="%s" minimum-distance="%s" horizontal-alignment="%s" opacity="%s" text-transform="%s" unlock-image="%s" spacing="%s">[%s]</ShieldSymbolizer>
    """ % (icons_path, path, width, height, face, size, color, halo_color,
           halo_radius, placement, offset, overlap, wrap_width, distance,
           align, opacity, transform, unlock_image, spacing, text)
Ejemplo n.º 2
0
def xml_textsymbolizer(
    text="name",
    face="DejaVu Sans Book",
    size="10",
    color="#000000",
    halo_color="#ffffff",
    halo_radius="0",
    placement="line",
    offset="0",
    overlap="false",
    distance="26",
    wrap_width=256,
    align="center",
    opacity="1",
    pos="X",
    transform="none",
):
    color = nicecolor(color)
    halo_color = nicecolor(halo_color)
    pos = pos.replace("exact", "X").replace("any", "S, E, X, N, W, NE, SE, NW, SW").split(",")
    pos.extend([str(int(float(x))) for x in size.split(",")])
    pos = ",".join(pos)
    size = size.split(",")[0]

    placement = {"center": "point"}.get(placement.lower(), placement)
    align = {"center": "middle"}.get(align.lower(), align)
    dy = int(float(offset))
    dx = 0
    if align in ("right", "left"):
        dx = dy
        dy = 0

    return """
  <TextSymbolizer name="%s" fontset_name="%s" size="%s" fill="%s" halo_fill= "%s" halo_radius="%s" placement="%s" dx="%s" dy="%s" max_char_angle_delta="15" allow_overlap="%s" wrap_width="%s" min_distance="%s" vertical_alignment="middle" horizontal_alignment="%s" opacity="%s" placement-type="simple" placements="%s" text-transform="%s" />
  """ % (
        text,
        face,
        int(float(size)),
        color,
        halo_color,
        halo_radius,
        placement,
        dx,
        dy,
        overlap,
        wrap_width,
        distance,
        align,
        opacity,
        pos,
        transform,
    )
Ejemplo n.º 3
0
def xml_shieldsymbolizer(
    path="",
    width="",
    height="",
    text="name",
    face="DejaVu Sans Book",
    size="10",
    color="#000000",
    halo_color="#ffffff",
    halo_radius="0",
    placement="line",
    offset="0",
    overlap="false",
    distance="26",
    wrap_width=256,
    align="center",
    opacity="1",
    transform="none",
):
    color = nicecolor(color)
    halo_color = nicecolor(halo_color)
    placement = {"center": "point"}.get(placement.lower(), placement)
    align = {"center": "middle"}.get(align.lower(), align)
    size = size.split(",")[0]
    if width:
        width = ' width="%s" ' % width
    if height:
        height = ' height="%s" ' % height
    return """
    <ShieldSymbolizer file="%s%s" %s %s name="%s" fontset_name="%s" size="%s" fill="%s" halo_fill= "%s" halo_radius="%s" placement="%s" dy="%s" allow_overlap="%s" wrap_width="%s" min_distance="%s" horizontal_alignment="%s" opacity="%s" text-transform="%s" unlock-image="true" />
  """ % (
        icons_path,
        path,
        width,
        height,
        text,
        face,
        int(float(size)),
        color,
        halo_color,
        halo_radius,
        placement,
        offset,
        overlap,
        wrap_width,
        distance,
        align,
        opacity,
        transform,
    )
Ejemplo n.º 4
0
def xml_shieldsymbolizer(path="", width="", height="",
                        text="name",face="DejaVu Sans Book",size="10",color="#000000", halo_color="#ffffff", halo_radius="0", placement="line", offset="0", overlap="false", distance="26", wrap_width=256, align="center", opacity="1", transform="none", unlock_image='true', spacing='500'):
  color = nicecolor(color)
  halo_color = nicecolor(halo_color)
  placement = {"center": "point"}.get(placement.lower(), placement)
  align = {"center": "middle"}.get(align.lower(), align)
  size = size.split(",")[0]
  if width: 
    width =' width="%s" '%width
  if height:
    height =' height="%s" '%height
  return """
    <ShieldSymbolizer file="%s%s" %s %s fontset-name="%s" size="%s" fill="%s" halo-fill= "%s" halo-radius="%s" placement="%s" dy="%s" allow-overlap="%s" wrap-width="%s" minimum-distance="%s" horizontal-alignment="%s" opacity="%s" text-transform="%s" unlock-image="%s" spacing="%s">[%s]</ShieldSymbolizer>
  """%(icons_path, \
    path, width, height,face,int(float(size)*text_scale),color,halo_color,halo_radius,placement,offset,overlap,wrap_width,distance,align,opacity, transform, unlock_image, spacing,text )
Ejemplo n.º 5
0
def xml_start(bgcolor="transparent"):
  if bgcolor != "transparent":
    bgcolor = nicecolor(bgcolor)
  return """<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Map>
<Map bgcolor="%s" srs="%s" minimum_version="0.7.1" buffer_size="512" maximum-extent="-20037508.342789244,-20037508.342780735,20037508.342789244,20037508.342780709" >
"""%(bgcolor, map_proj)
Ejemplo n.º 6
0
def xml_linesymbolizer(color="#000000",
                       width="1",
                       opacity="1",
                       linecap="butt",
                       linejoin="round",
                       dashes="",
                       smooth=0,
                       zoom=200):
    color = nicecolor(color)
    linecap = {
        "none": "butt",
    }.get(linecap.lower(), linecap)

    if dashes:
        dashes = 'stroke-dasharray="' + str(dashes).strip('[]') + '"'
    else:
        dashes = ""

    if smooth:
        smooth = 'smooth="%s"' % (smooth)
    else:
        smooth = ""

    rasterizer = ""
    #  if float(width) < 4 and not dashes and zoom < 6:
    #    rasterizer = ' rasterizer="fast"'

    return """
    <LineSymbolizer %s %s stroke="%s" stroke-width="%s" stroke-opacity="%s" stroke-linejoin="%s" stroke-linecap="%s" %s/>""" % (
        rasterizer, smooth, color, float(width), float(opacity), linejoin,
        linecap, dashes)
Ejemplo n.º 7
0
def xml_start(bgcolor="transparent"):
    if bgcolor != "transparent":
        bgcolor = nicecolor(bgcolor)
    return """<?xml version="1.0" encoding="utf-8"?>
  <!DOCTYPE Map>
  <Map background-color="%s" srs="%s" minimum-version="0.7.1" buffer-size="512" maximum-extent="-20037508.342789244,-20037508.342780735,20037508.342789244,20037508.342780709" >
  """ % (bgcolor, map_proj)
Ejemplo n.º 8
0
def xml_linesymbolizer(color="#000000", width="1", opacity="1", linecap="butt", linejoin="round", dashes="", zoom=200):
    color = nicecolor(color)
    linecap = {"none": "butt"}.get(linecap.lower(), linecap)

    if dashes:
        dashes = '<CssParameter name="stroke-dasharray">%s</CssParameter>' % (dashes)
    else:
        dashes = ""
    rasterizer = ""
    #  if float(width) < 4 and not dashes and zoom < 6:
    #    rasterizer = ' rasterizer="fast"'

    return """
  <LineSymbolizer %s>
    <CssParameter name="stroke">%s</CssParameter>
    <CssParameter name="stroke-width">%s</CssParameter>
    <CssParameter name="stroke-opacity">%s</CssParameter>
    <CssParameter name="stroke-linejoin">%s</CssParameter>
    <CssParameter name="stroke-linecap">%s</CssParameter>
    %s
  </LineSymbolizer>""" % (
        rasterizer,
        color,
        float(width),
        float(opacity),
        linejoin,
        linecap,
        dashes,
    )
Ejemplo n.º 9
0
def xml_polygonsymbolizer(color="#000000", opacity="1", smooth='0'):
    color = nicecolor(color)
    if smooth:
        smooth = 'smooth="%s"' % (smooth)
    else:
        smooth = ""
    return """
    <PolygonSymbolizer fill="%s" fill-opacity="%s" gamma="0.73" %s />""" % (color, float(opacity), smooth)
Ejemplo n.º 10
0
def xml_polygonsymbolizer(color="#000000", opacity="1", smooth='0'):
    color = nicecolor(color)
    if smooth:
        smooth = 'smooth="%s"' % (smooth)
    else:
        smooth = ""
    return """
    <PolygonSymbolizer fill="%s" fill-opacity="%s" gamma="0.73" %s />""" % (
        color, float(opacity), smooth)
Ejemplo n.º 11
0
def xml_polygonsymbolizer(color="#000000", opacity="1"):
    color = nicecolor(color)

    return """
  <PolygonSymbolizer>
    <CssParameter name="fill">%s</CssParameter>
    <CssParameter name="fill-opacity">%s</CssParameter>
  </PolygonSymbolizer>""" % (
        color,
        float(opacity),
    )
Ejemplo n.º 12
0
def xml_textsymbolizer(
        text="name", face="DejaVu Sans Book", size="10", color="#000000", halo_color="#ffffff", halo_radius="0", placement="line", offset="0", overlap="false", distance="26", wrap_width=256, align="center", opacity="1", pos="X", transform="none", spacing="4096"):
    color = nicecolor(color)
    halo_color = nicecolor(halo_color)
    pos = pos.replace("exact", "X").replace("any", "S, E, X, N, W, NE, SE, NW, SW").split(",")
    pos.extend([str(int(float(x) * text_scale)) for x in size.split(",")])
    pos = ",".join(pos)
    size = str(int(float(size.split(",")[0]) * text_scale))

    placement = {"center": "interior"}.get(placement.lower(), placement)
    align = {"center": "middle"}.get(align.lower(), align)
    dy = int(float(offset))
    dx = 0
    if align in ("right", 'left'):
        dx = dy
        dy = 0

    return """
    <TextSymbolizer fontset-name="%s" size="%s" fill="%s" halo-fill= "%s" halo-radius="%s" placement="%s" dx="%s" dy="%s" max-char-angle-delta="17" allow-overlap="%s" wrap-width="%s" minimum-distance="%s" vertical-alignment="middle" horizontal-alignment="%s" opacity="%s" placement-type="simple" placements="%s" text-transform="%s" minimum-path-length="5" spacing="%s">[%s]</TextSymbolizer>
    """ % (face, int(float(size)), color, halo_color, halo_radius, placement, dx, dy, overlap, wrap_width, distance, align, opacity, pos, transform, spacing, text)
Ejemplo n.º 13
0
def xml_textsymbolizer(text="name",
                       face=default_font_family,
                       size="10",
                       color="#000000",
                       halo_color="#ffffff",
                       halo_radius="0",
                       character_spacing=font_tracking,
                       placement="line",
                       offset="0",
                       overlap="false",
                       distance="26",
                       wrap_width=256,
                       align="center",
                       opacity="1",
                       pos="X",
                       transform="none",
                       spacing="4096",
                       angle=max_char_angle_delta):
    color = nicecolor(color)
    halo_color = nicecolor(halo_color)
    pos = pos.replace("exact",
                      "X").replace("any",
                                   "S, E, X, N, W, NE, SE, NW, SW").split(",")
    pos.extend([str(int(float(x) * text_scale)) for x in size.split(",")])
    pos = ",".join(pos)
    size = str(float(size.split(",")[0]) * text_scale)
    angle = str(int(angle))

    placement = {"center": "interior"}.get(placement.lower(), placement)
    align = {"center": "middle"}.get(align.lower(), align)
    dy = int(float(offset))
    dx = 0
    if align in ("right", 'left'):
        dx = dy
        dy = 0

    return """
    <TextSymbolizer fontset-name="%s" size="%s" fill="%s" halo-fill= "%s" halo-radius="%s" halo-rasterizer="full" character-spacing="%s" placement="%s" dx="%s" dy="%s" max-char-angle-delta="%s" allow-overlap="%s" wrap-width="%s" minimum-distance="%s" vertical-alignment="middle" horizontal-alignment="%s" opacity="%s" placement-type="simple" placements="%s" text-transform="%s" minimum-path-length="5" clip="false" spacing="%s">[%s]</TextSymbolizer>
    """ % (face, size, color, halo_color, halo_radius, character_spacing,
           placement, dx, dy, angle, overlap, wrap_width, distance, align,
           opacity, pos, transform, spacing, text)
Ejemplo n.º 14
0
def xml_linesymbolizer(color="#000000", width="1", opacity="1", linecap="butt", linejoin="round", dashes="", smooth=0, zoom=200):
    color = nicecolor(color)
    linecap = {"none": "butt", }.get(linecap.lower(), linecap)

    if dashes:
        dashes = 'stroke-dasharray="%s"' % (dashes)
    else:
        dashes = ""

    if smooth:
        smooth = 'smooth="%s"' % (smooth)
    else:
        smooth = ""

    rasterizer = ""
#  if float(width) < 4 and not dashes and zoom < 6:
#    rasterizer = ' rasterizer="fast"'

    return """
    <LineSymbolizer %s %s stroke="%s" stroke-width="%s" stroke-opacity="%s" stroke-linejoin="%s" stroke-linecap="%s" %s/>""" % (rasterizer, smooth, color, float(width), float(opacity), linejoin, linecap, dashes)
Ejemplo n.º 15
0
def xml_polygonsymbolizer(color="#000000", opacity="1"):
  color = nicecolor(color)
  
  return """
  <PolygonSymbolizer fill="%s" fill-opacity="%s" gamma="0.73" />"""%(color, float(opacity))