Example #1
0
def create_style(request, json_data, layer, gs, is_preview=False):
    name = json_data.get('name')
    if is_preview:
        name = name + '__tmp'
    is_default = json_data.get('is_default', False)
    is_default = utils.set_default_style(layer,
                                         gs,
                                         is_preview=is_preview,
                                         is_default=is_default)

    style = Style(name=name,
                  title=json_data.get('title'),
                  is_default=is_default,
                  minscale=json_data.get('minscale'),
                  maxscale=json_data.get('maxscale'),
                  type='US')
    style.save()
    style_layer = StyleLayer(style=style, layer=layer)
    style_layer.save()

    for r in json_data.get('rules'):
        json_rule = r.get('rule')

        filter_text = ""
        if json_rule.get('filter').__len__() != 0:
            filter_text = str(json.dumps(json_rule.get('filter')))

        rule = Rule(style=style,
                    name=json_rule.get('name'),
                    title=json_rule.get('title'),
                    abstract='',
                    filter=filter_text,
                    minscale=json_rule.get('minscale'),
                    maxscale=json_rule.get('maxscale'),
                    order=json_rule.get('order'))
        rule.save()

        for sym in r.get('symbolizers'):
            if sym.get('type') == 'PolygonSymbolizer':
                json_sym = json.loads(sym.get('json'))
                symbolizer = PolygonSymbolizer(
                    rule=rule,
                    order=int(sym.get('order')),
                    fill=json_sym.get('fill'),
                    fill_opacity=json_sym.get('fill_opacity'),
                    stroke=json_sym.get('stroke'),
                    stroke_width=json_sym.get('stroke_width'),
                    stroke_opacity=json_sym.get('stroke_opacity'),
                    stroke_dash_array=json_sym.get('stroke_dash_array'))
                symbolizer.save()

            elif sym.get('type') == 'LineSymbolizer':
                json_sym = json.loads(sym.get('json'))
                symbolizer = LineSymbolizer(
                    rule=rule,
                    order=int(sym.get('order')),
                    stroke=json_sym.get('stroke'),
                    stroke_width=json_sym.get('stroke_width'),
                    stroke_opacity=json_sym.get('stroke_opacity'),
                    stroke_dash_array=json_sym.get('stroke_dash_array'))
                symbolizer.save()

            elif sym.get('type') == 'MarkSymbolizer':
                json_sym = json.loads(sym.get('json'))
                symbolizer = MarkSymbolizer(
                    rule=rule,
                    order=int(sym.get('order')),
                    opacity=json_sym.get('opacity'),
                    size=json_sym.get('size'),
                    rotation=json_sym.get('rotation'),
                    well_known_name=json_sym.get('well_known_name'),
                    fill=json_sym.get('fill'),
                    fill_opacity=json_sym.get('fill_opacity'),
                    stroke=json_sym.get('stroke'),
                    stroke_width=json_sym.get('stroke_width'),
                    stroke_opacity=json_sym.get('stroke_opacity'),
                    stroke_dash_array=json_sym.get('stroke_dash_array'))
                symbolizer.save()

            elif sym.get('type') == 'ExternalGraphicSymbolizer':
                json_sym = json.loads(sym.get('json'))
                symbolizer = ExternalGraphicSymbolizer(
                    rule=rule,
                    order=int(sym.get('order')),
                    opacity=json_sym.get('opacity'),
                    size=json_sym.get('size'),
                    rotation=json_sym.get('rotation'),
                    online_resource=json_sym.get('online_resource'),
                    format=json_sym.get('format'))
                symbolizer.save()

            elif sym.get('type') == 'TextSymbolizer':
                json_sym = json.loads(sym.get('json'))
                symbolizer = TextSymbolizer(
                    rule=rule,
                    order=int(sym.get('order')),
                    label=json_sym.get('label'),
                    font_family=json_sym.get('font_family'),
                    font_size=json_sym.get('font_size'),
                    font_weight=json_sym.get('font_weight'),
                    font_style=json_sym.get('font_style'),
                    halo_fill=json_sym.get('halo_fill'),
                    halo_fill_opacity=json_sym.get('halo_fill_opacity'),
                    halo_radius=json_sym.get('halo_radius'),
                    fill=json_sym.get('fill'),
                    fill_opacity=json_sym.get('fill_opacity'),
                )
                symbolizer.save()

    sld_body = sld_builder.build_sld(layer, style)

    if is_preview:
        if gs.createOverwrittenStyle(style.name, sld_body, True):
            return style
    else:
        if gs.createStyle(style.name, sld_body):
            if not is_preview:
                gs.setLayerStyle(layer, style.name, style.is_default)
            return style
Example #2
0
def update_style(request, json_data, layer, gs, style, is_preview=False):
    is_default = json_data.get('is_default', False)
    is_default = utils.set_default_style(layer,
                                         gs,
                                         style=style,
                                         is_preview=is_preview,
                                         is_default=is_default)

    style.title = json_data.get('title')
    if json_data.get('minscale') != '':
        style.minscale = json_data.get('minscale')
    else:
        style.minscale = -1
    if json_data.get('maxscale') != '':
        style.maxscale = json_data.get('maxscale')
    else:
        style.maxscale = -1
    style.is_default = is_default
    style.save()

    rules = Rule.objects.filter(style=style)
    for ru in rules:
        symbolizers = Symbolizer.objects.filter(rule=ru)
        for symbolizer in symbolizers:
            symbolizer.delete()
        ru.delete()

    for r in json_data.get('rules'):
        json_rule = r.get('rule')

        filter_text = ""
        if json_rule.get('filter').__len__() != 0:
            filter_text = str(json.dumps(json_rule.get('filter')))

        if json_data.get('minscale') != '':
            minscale = json_rule.get('minscale')
        else:
            minscale = -1
        if json_data.get('maxscale') != '':
            maxscale = json_rule.get('maxscale')
        else:
            maxscale = -1

        rule = Rule(style=style,
                    name=json_rule.get('name'),
                    title=json_rule.get('title'),
                    abstract='',
                    filter=filter_text,
                    minscale=minscale,
                    maxscale=maxscale,
                    order=json_rule.get('order'))
        rule.save()

        for sym in r.get('symbolizers'):
            if sym.get('type') == 'PolygonSymbolizer':
                json_sym = json.loads(sym.get('json'))
                symbolizer = PolygonSymbolizer(
                    rule=rule,
                    order=int(sym.get('order')),
                    fill=json_sym.get('fill'),
                    fill_opacity=json_sym.get('fill_opacity'),
                    stroke=json_sym.get('stroke'),
                    stroke_width=json_sym.get('stroke_width'),
                    stroke_opacity=json_sym.get('stroke_opacity'),
                    stroke_dash_array=json_sym.get('stroke_dash_array'))
                symbolizer.save()

            elif sym.get('type') == 'LineSymbolizer':
                json_sym = json.loads(sym.get('json'))
                symbolizer = LineSymbolizer(
                    rule=rule,
                    order=int(sym.get('order')),
                    stroke=json_sym.get('stroke'),
                    stroke_width=json_sym.get('stroke_width'),
                    stroke_opacity=json_sym.get('stroke_opacity'),
                    stroke_dash_array=json_sym.get('stroke_dash_array'))
                symbolizer.save()

            elif sym.get('type') == 'MarkSymbolizer':
                json_sym = json.loads(sym.get('json'))
                symbolizer = MarkSymbolizer(
                    rule=rule,
                    order=int(sym.get('order')),
                    opacity=json_sym.get('opacity'),
                    size=json_sym.get('size'),
                    rotation=json_sym.get('rotation'),
                    well_known_name=json_sym.get('well_known_name'),
                    fill=json_sym.get('fill'),
                    fill_opacity=json_sym.get('fill_opacity'),
                    stroke=json_sym.get('stroke'),
                    stroke_width=json_sym.get('stroke_width'),
                    stroke_opacity=json_sym.get('stroke_opacity'),
                    stroke_dash_array=json_sym.get('stroke_dash_array'))
                symbolizer.save()

            elif sym.get('type') == 'ExternalGraphicSymbolizer':
                json_sym = json.loads(sym.get('json'))
                symbolizer = ExternalGraphicSymbolizer(
                    rule=rule,
                    order=int(sym.get('order')),
                    opacity=json_sym.get('opacity'),
                    size=json_sym.get('size'),
                    rotation=json_sym.get('rotation'),
                    online_resource=json_sym.get('online_resource'),
                    format=json_sym.get('format'))
                symbolizer.save()

            elif sym.get('type') == 'TextSymbolizer':
                json_sym = json.loads(sym.get('json'))
                symbolizer = TextSymbolizer(
                    rule=rule,
                    order=int(sym.get('order')),
                    label=json_sym.get('label'),
                    font_family=json_sym.get('font_family'),
                    font_size=json_sym.get('font_size'),
                    font_weight=json_sym.get('font_weight'),
                    font_style=json_sym.get('font_style'),
                    halo_fill=json_sym.get('halo_fill'),
                    halo_fill_opacity=json_sym.get('halo_fill_opacity'),
                    halo_radius=json_sym.get('halo_radius'),
                    fill=json_sym.get('fill'),
                    fill_opacity=json_sym.get('fill_opacity'),
                )
                symbolizer.save()

    sld_body = sld_builder.build_sld(layer, style)

    if is_preview:
        if gs.createOverwrittenStyle(style.name, sld_body, True):
            return style
    else:
        if gs.updateStyle(layer, style.name, sld_body):
            gs.setLayerStyle(layer, style.name, style.is_default)
            return style
        else:
            # try to recover from inconsistent gvsigol - geoserver status
            if utils.reset_geoserver_style(gs, layer, style):
                gs.setLayerStyle(layer, style.name, style.is_default)
                return style
def create_style(request, json_data, layer_id, is_preview=False):

    layer = Layer.objects.get(id=int(layer_id))
    datastore = layer.datastore
    workspace = datastore.workspace
    gs = geographic_servers.get_instance().get_server_by_id(
        workspace.server.id)

    layer_styles = StyleLayer.objects.filter(layer=layer)
    is_default = False
    if not is_preview:
        is_default = json_data.get('is_default')
    if is_default:
        for ls in layer_styles:
            s = Style.objects.get(id=ls.style.id)
            s.is_default = False
            s.save()
    else:
        has_default_style = False
        for ls in layer_styles:
            s = Style.objects.get(id=ls.style.id)
            if s.is_default:
                has_default_style = True
        if not has_default_style:
            is_default = True

    name = json_data.get('name')
    if is_preview:
        name = name + '__tmp'
        is_default = False

    style = Style(name=name,
                  title=json_data.get('title'),
                  is_default=is_default,
                  type='IN')
    if json_data.get('minscale') != '':
        style.minscale = json_data.get('minscale')
    else:
        style.minscale = -1
    if json_data.get('maxscale') != '':
        style.maxscale = json_data.get('maxscale')
    else:
        style.maxscale = -1

    style.save()
    style_layer = StyleLayer(style=style, layer=layer)
    style_layer.save()

    for r in json_data.get('rules'):
        json_rule = r.get('rule')

        filter_text = ""
        if json_rule.get('filter').__len__() != 0:
            filter_text = str(json.dumps(json_rule.get('filter')))

        rule = Rule(style=style,
                    name=json_rule.get('name'),
                    title=json_rule.get('title'),
                    abstract='',
                    filter=filter_text,
                    minscale=json_rule.get('minscale'),
                    maxscale=json_rule.get('maxscale'),
                    order=json_rule.get('order'))
        rule.save()

        for sym in r.get('symbolizers'):
            if sym.get('type') == 'PolygonSymbolizer':
                json_sym = json.loads(sym.get('json'))
                symbolizer = PolygonSymbolizer(
                    rule=rule,
                    order=int(sym.get('order')),
                    fill=json_sym.get('fill'),
                    fill_opacity=json_sym.get('fill_opacity'),
                    stroke=json_sym.get('stroke'),
                    stroke_width=json_sym.get('stroke_width'),
                    stroke_opacity=json_sym.get('stroke_opacity'),
                    stroke_dash_array=json_sym.get('stroke_dash_array'))
                symbolizer.save()

            elif sym.get('type') == 'LineSymbolizer':
                json_sym = json.loads(sym.get('json'))
                symbolizer = LineSymbolizer(
                    rule=rule,
                    order=int(sym.get('order')),
                    stroke=json_sym.get('stroke'),
                    stroke_width=json_sym.get('stroke_width'),
                    stroke_opacity=json_sym.get('stroke_opacity'),
                    stroke_dash_array=json_sym.get('stroke_dash_array'))
                symbolizer.save()

            elif sym.get('type') == 'MarkSymbolizer':
                json_sym = json.loads(sym.get('json'))
                symbolizer = MarkSymbolizer(
                    rule=rule,
                    order=int(sym.get('order')),
                    opacity=json_sym.get('opacity'),
                    size=json_sym.get('size'),
                    rotation=json_sym.get('rotation'),
                    well_known_name=json_sym.get('well_known_name'),
                    fill=json_sym.get('fill'),
                    fill_opacity=json_sym.get('fill_opacity'),
                    stroke=json_sym.get('stroke'),
                    stroke_width=json_sym.get('stroke_width'),
                    stroke_opacity=json_sym.get('stroke_opacity'),
                    stroke_dash_array=json_sym.get('stroke_dash_array'))
                symbolizer.save()

            elif sym.get('type') == 'ExternalGraphicSymbolizer':
                json_sym = json.loads(sym.get('json'))
                symbolizer = ExternalGraphicSymbolizer(
                    rule=rule,
                    order=int(sym.get('order')),
                    opacity=json_sym.get('opacity'),
                    size=json_sym.get('size'),
                    rotation=json_sym.get('rotation'),
                    online_resource=json_sym.get('online_resource'),
                    format=json_sym.get('format'))
                symbolizer.save()

            elif sym.get('type') == 'TextSymbolizer':
                json_sym = json.loads(sym.get('json'))
                symbolizer = TextSymbolizer(
                    rule=rule,
                    order=int(sym.get('order')),
                    label=json_sym.get('label'),
                    font_family=json_sym.get('font_family'),
                    font_size=json_sym.get('font_size'),
                    font_weight=json_sym.get('font_weight'),
                    font_style=json_sym.get('font_style'),
                    halo_fill=json_sym.get('halo_fill'),
                    halo_fill_opacity=json_sym.get('halo_fill_opacity'),
                    halo_radius=json_sym.get('halo_radius'),
                    fill=json_sym.get('fill'),
                    fill_opacity=json_sym.get('fill_opacity'),
                )
                symbolizer.save()

    sld_body = sld_builder.build_sld(layer, style)

    if is_preview:
        if gs.createOverwrittenStyle(style.name, sld_body, True):
            return True
        else:
            return False
    else:
        if gs.createStyle(style.name, sld_body):
            if not is_preview:
                gs.setLayerStyle(layer, style.name, style.is_default)
            return True

        else:
            return False
Example #4
0
def create_default_style(layer_id, style_name, style_type, geom_type, count):
    layer = Layer.objects.get(id=int(layer_id))

    minscaledenominator = -1
    maxscaledenominator = -1
    if count and count > 200000:
        minscaledenominator = 0
        maxscaledenominator = 50000

    style = Style(name=style_name,
                  title=_('Default style for: ') + layer.title,
                  is_default=True,
                  type=style_type,
                  minscale=minscaledenominator,
                  maxscale=maxscaledenominator)
    style.save()
    style_layer = StyleLayer(style=style, layer=layer)
    style_layer.save()

    if style.is_default:
        layer_styles = StyleLayer.objects.filter(layer=layer)
        for ls in layer_styles:
            s = Style.objects.get(id=ls.style.id)
            s.is_default = False

    symbol_type = None
    if geom.isPoint(geom_type):
        symbol_type = 'MarkSymbolizer'
    elif geom.isLine(geom_type):
        symbol_type = 'LineSymbolizer'
    elif geom.isPolygon(geom_type):
        symbol_type = 'PolygonSymbolizer'
    elif geom.isRaster(geom_type):
        symbol_type = 'RasterSymbolizer'

    rule = Rule(style=style,
                name='Default symbol',
                title=_('Default symbol'),
                abstract='',
                filter=str(""),
                minscale=minscaledenominator,
                maxscale=maxscaledenominator,
                order=0)
    rule.save()

    if symbol_type == 'PolygonSymbolizer':
        symbolizer = PolygonSymbolizer(rule=rule,
                                       order=0,
                                       fill='#383838',
                                       fill_opacity=0.6,
                                       stroke='#000000',
                                       stroke_width=1,
                                       stroke_opacity=1.0,
                                       stroke_dash_array='none')
        symbolizer.save()

    elif symbol_type == 'LineSymbolizer':
        symbolizer = LineSymbolizer(rule=rule,
                                    order=0,
                                    stroke='#000000',
                                    stroke_width=1,
                                    stroke_opacity=1.0,
                                    stroke_dash_array='none')
        symbolizer.save()

    elif symbol_type == 'MarkSymbolizer':
        symbolizer = MarkSymbolizer(rule=rule,
                                    order=0,
                                    opacity=1.0,
                                    size=8,
                                    rotation=0,
                                    well_known_name='circle',
                                    fill='#383838',
                                    fill_opacity=0.6,
                                    stroke='#000000',
                                    stroke_width=1,
                                    stroke_opacity=1.0,
                                    stroke_dash_array='none')
        symbolizer.save()

    elif symbol_type == 'RasterSymbolizer':
        color_map = ColorMap(type='ramp', extended=False)
        color_map.save()

        symbolizer = RasterSymbolizer(rule=rule,
                                      color_map=color_map,
                                      order=0,
                                      opacity=1.0)
        symbolizer.save()

    sld_body = sld_builder.build_sld(layer, style)
    return sld_body
def update_style(request, json_data, layer_id, style_id, is_preview=False):
    style = Style.objects.get(id=int(style_id))
    layer = Layer.objects.get(id=int(layer_id))

    layer_styles = StyleLayer.objects.filter(layer=layer)
    style_is_default = False
    if not is_preview:
        style_is_default = json_data.get('is_default')

    if style_is_default:
        for ls in layer_styles:
            s = Style.objects.get(id=ls.style.id)
            s.is_default = False
            s.save()
        datastore = layer.datastore
        workspace = datastore.workspace
        mapservice.setLayerStyle(layer, style.name, style.is_default)
    else:
        has_default_style = False
        for ls in layer_styles:
            s = Style.objects.get(id=ls.style.id)
            if s != style and s.is_default:
                has_default_style = True
        if not has_default_style:
            datastore = layer.datastore
            workspace = datastore.workspace
            style_is_default = True
            mapservice.setLayerStyle(layer, style.name, True)

    style.title = json_data.get('title')
    if json_data.get('minscale') != '':
        style.minscale = json_data.get('minscale')
    else:
        style.minscale = -1
    if json_data.get('maxscale') != '':
        style.maxscale = json_data.get('maxscale')
    else:
        style.maxscale = -1
    style.is_default = style_is_default
    style.save()

    rules = Rule.objects.filter(style=style)
    for ru in rules:
        symbolizers = Symbolizer.objects.filter(rule=ru)
        for symbolizer in symbolizers:
            symbolizer.delete()
        ru.delete()

    for r in json_data.get('rules'):
        json_rule = r.get('rule')

        filter_text = ""
        if json_rule.get('filter').__len__() != 0:
            filter_text = str(json.dumps(json_rule.get('filter')))

        if json_data.get('minscale') != '':
            minscale = json_rule.get('minscale')
        else:
            minscale = -1
        if json_data.get('maxscale') != '':
            maxscale = json_rule.get('maxscale')
        else:
            maxscale = -1

        rule = Rule(style=style,
                    name=json_rule.get('name'),
                    title=json_rule.get('title'),
                    abstract='',
                    filter=filter_text,
                    minscale=minscale,
                    maxscale=maxscale,
                    order=json_rule.get('order'))
        rule.save()

        for sym in r.get('symbolizers'):
            if sym.get('type') == 'PolygonSymbolizer':
                json_sym = json.loads(sym.get('json'))
                symbolizer = PolygonSymbolizer(
                    rule=rule,
                    order=int(sym.get('order')),
                    fill=json_sym.get('fill'),
                    fill_opacity=json_sym.get('fill_opacity'),
                    stroke=json_sym.get('stroke'),
                    stroke_width=json_sym.get('stroke_width'),
                    stroke_opacity=json_sym.get('stroke_opacity'),
                    stroke_dash_array=json_sym.get('stroke_dash_array'))
                symbolizer.save()

            elif sym.get('type') == 'LineSymbolizer':
                json_sym = json.loads(sym.get('json'))
                symbolizer = LineSymbolizer(
                    rule=rule,
                    order=int(sym.get('order')),
                    stroke=json_sym.get('stroke'),
                    stroke_width=json_sym.get('stroke_width'),
                    stroke_opacity=json_sym.get('stroke_opacity'),
                    stroke_dash_array=json_sym.get('stroke_dash_array'))
                symbolizer.save()

            elif sym.get('type') == 'MarkSymbolizer':
                json_sym = json.loads(sym.get('json'))
                symbolizer = MarkSymbolizer(
                    rule=rule,
                    order=int(sym.get('order')),
                    opacity=json_sym.get('opacity'),
                    size=json_sym.get('size'),
                    rotation=json_sym.get('rotation'),
                    well_known_name=json_sym.get('well_known_name'),
                    fill=json_sym.get('fill'),
                    fill_opacity=json_sym.get('fill_opacity'),
                    stroke=json_sym.get('stroke'),
                    stroke_width=json_sym.get('stroke_width'),
                    stroke_opacity=json_sym.get('stroke_opacity'),
                    stroke_dash_array=json_sym.get('stroke_dash_array'))
                symbolizer.save()

            elif sym.get('type') == 'ExternalGraphicSymbolizer':
                json_sym = json.loads(sym.get('json'))
                symbolizer = ExternalGraphicSymbolizer(
                    rule=rule,
                    order=int(sym.get('order')),
                    opacity=json_sym.get('opacity'),
                    size=json_sym.get('size'),
                    rotation=json_sym.get('rotation'),
                    online_resource=json_sym.get('online_resource'),
                    format=json_sym.get('format'))
                symbolizer.save()

            elif sym.get('type') == 'TextSymbolizer':
                json_sym = json.loads(sym.get('json'))
                symbolizer = TextSymbolizer(
                    rule=rule,
                    order=int(sym.get('order')),
                    label=json_sym.get('label'),
                    font_family=json_sym.get('font_family'),
                    font_size=json_sym.get('font_size'),
                    font_weight=json_sym.get('font_weight'),
                    font_style=json_sym.get('font_style'),
                    fill=json_sym.get('fill'),
                    fill_opacity=json_sym.get('fill_opacity'),
                    halo_fill=json_sym.get('halo_fill'),
                    halo_fill_opacity=json_sym.get('halo_fill_opacity'),
                    halo_radius=json_sym.get('halo_radius'),
                    anchor_point_x=json_sym.get('anchor_point_x'),
                    anchor_point_y=json_sym.get('anchor_point_y'),
                )
                symbolizer.save()

    sld_body = sld_builder.build_sld(layer, style)
    if is_preview:
        if mapservice.createOverwrittenStyle(style.name, sld_body, True):
            return True
        else:
            return False
    else:
        if mapservice.updateStyle(layer, style.name, sld_body):
            mapservice.setLayerStyle(layer, style.name, style.is_default)
            return True
        else:
            return False
Example #6
0
def get_sld(request, type, json_data, layer_id, single_symbol=False):

    layer = Layer.objects.get(id=layer_id)
    layer.name = layer.datastore.workspace.name + ':' + layer.name
    is_default = False
    if json_data.get('is_default'):
        is_default = json_data.get('is_default')
    style = Style(name=json_data.get('name'),
                  title=json_data.get('title'),
                  is_default=is_default,
                  type=type)
    style.save()

    for r in json_data.get('rules'):
        json_rule = r.get('rule')

        filter_text = ""
        if json_rule.get('filter').__len__() != 0:
            filter_text = str(json.dumps(json_rule.get('filter')))

        rule = Rule(style=style,
                    name=json_rule.get('name'),
                    title=json_rule.get('title'),
                    abstract='',
                    filter=filter_text,
                    minscale=json_rule.get('minscale'),
                    maxscale=json_rule.get('maxscale'),
                    order=json_rule.get('order'))
        rule.save()

        for sym in r.get('symbolizers'):
            if sym.get('type') == 'PolygonSymbolizer':
                json_sym = json.loads(sym.get('json'))
                symbolizer = PolygonSymbolizer(
                    rule=rule,
                    order=int(sym.get('order')),
                    fill=json_sym.get('fill'),
                    fill_opacity=json_sym.get('fill_opacity'),
                    stroke=json_sym.get('stroke'),
                    stroke_width=json_sym.get('stroke_width'),
                    stroke_opacity=json_sym.get('stroke_opacity'),
                    stroke_dash_array=json_sym.get('stroke_dash_array'))
                symbolizer.save()

            elif sym.get('type') == 'LineSymbolizer':
                json_sym = json.loads(sym.get('json'))
                symbolizer = LineSymbolizer(
                    rule=rule,
                    order=int(sym.get('order')),
                    stroke=json_sym.get('stroke'),
                    stroke_width=json_sym.get('stroke_width'),
                    stroke_opacity=json_sym.get('stroke_opacity'),
                    stroke_dash_array=json_sym.get('stroke_dash_array'))
                symbolizer.save()

            elif sym.get('type') == 'MarkSymbolizer':
                json_sym = json.loads(sym.get('json'))
                symbolizer = MarkSymbolizer(
                    rule=rule,
                    order=int(sym.get('order')),
                    opacity=json_sym.get('opacity'),
                    size=json_sym.get('size'),
                    rotation=json_sym.get('rotation'),
                    well_known_name=json_sym.get('well_known_name'),
                    fill=json_sym.get('fill'),
                    fill_opacity=json_sym.get('fill_opacity'),
                    stroke=json_sym.get('stroke'),
                    stroke_width=json_sym.get('stroke_width'),
                    stroke_opacity=json_sym.get('stroke_opacity'),
                    stroke_dash_array=json_sym.get('stroke_dash_array'))
                symbolizer.save()

            elif sym.get('type') == 'ExternalGraphicSymbolizer':
                json_sym = json.loads(sym.get('json'))
                symbolizer = ExternalGraphicSymbolizer(
                    rule=rule,
                    order=int(sym.get('order')),
                    opacity=json_sym.get('opacity'),
                    size=json_sym.get('size'),
                    rotation=json_sym.get('rotation'),
                    online_resource=json_sym.get('online_resource'),
                    format=json_sym.get('format'))
                symbolizer.save()

            elif sym.get('type') == 'TextSymbolizer':
                json_sym = json.loads(sym.get('json'))
                symbolizer = TextSymbolizer(
                    rule=rule,
                    order=int(sym.get('order')),
                    label=json_sym.get('label'),
                    font_family=json_sym.get('font_family'),
                    font_size=json_sym.get('font_size'),
                    font_weight=json_sym.get('font_weight'),
                    font_style=json_sym.get('font_style'),
                    halo_fill=json_sym.get('halo_fill'),
                    halo_fill_opacity=json_sym.get('halo_fill_opacity'),
                    halo_radius=json_sym.get('halo_radius'),
                    fill=json_sym.get('fill'),
                    fill_opacity=json_sym.get('fill_opacity'),
                    anchor_point_x=json_sym.get('anchor_point_x'),
                    anchor_point_y=json_sym.get('anchor_point_y'),
                )
                symbolizer.save()

    sld_body = sld_builder.build_sld(layer, style, single_symbol)

    style.delete()
    return sld_body