Skip to content
Permalink
Browse files
Allow both <LineSymbolizer> and <PolygonSymbolizer> in same Rule
  • Loading branch information
jbo-ads committed Feb 28, 2020
1 parent b79ced1 commit 9167d8af2cd606c73b7f1fea907b422bca576d32
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 18 deletions.
@@ -30,6 +30,7 @@
#include "mapogcfilter.h"
#include "mapserver.h"
#include "mapows.h"
#include "mapcopy.h"
#include "cpl_string.h"

#if defined(USE_CURL)
@@ -928,26 +929,11 @@ int msSLDParseRule(CPLXMLNode *psRoot, layerObj *psLayer, const char* pszUserSty
return MS_FAILURE;

/* TODO : parse name of the rule */
/* -------------------------------------------------------------------- */
/* The SLD specs assumes here that a certain FeatureType can only have*/
/* rules for only one type of symbolizer. */
/* -------------------------------------------------------------------- */
/* ==================================================================== */
/* For each rule a new class is created. If there are more than */
/* one symbolizer of the same type, a style is added in the */
/* same class. */
/* one symbolizer, a style is added in the same class. */
/* ==================================================================== */

/* line symbolizer */
LOOP_ON_CHILD_ELEMENT(psRoot, psLineSymbolizer, "LineSymbolizer")
{
const int bNewClass = (nSymbolizer == 0);
msSLDParseLineSymbolizer(psLineSymbolizer, psLayer, bNewClass,
pszUserStyleName);
psLayer->type = MS_LAYER_LINE;
nSymbolizer++;
}

/* Polygon symbolizer */
LOOP_ON_CHILD_ELEMENT(psRoot, psPolygonSymbolizer, "PolygonSymbolizer")
{
@@ -957,15 +943,53 @@ int msSLDParseRule(CPLXMLNode *psRoot, layerObj *psLayer, const char* pszUserSty
psLayer->type = MS_LAYER_POLYGON;
nSymbolizer++;
}

/* line symbolizer */
LOOP_ON_CHILD_ELEMENT(psRoot, psLineSymbolizer, "LineSymbolizer")
{
const int bNewClass = (nSymbolizer == 0);
msSLDParseLineSymbolizer(psLineSymbolizer, psLayer, bNewClass,
pszUserStyleName);
if (bNewClass)
{
psLayer->type = MS_LAYER_LINE;
}
if (psLayer->type == MS_LAYER_POLYGON)
{
const int nClassId = psLayer->numclasses - 1;
if (nClassId >= 0)
{
const int nStyleId = psLayer->class[nClassId]->numstyles - 1;
if (nStyleId >= 0)
{
styleObj * psStyle = psLayer->class[nClassId]->styles[nStyleId];
psStyle->outlinecolor = psStyle->color;
MS_INIT_COLOR(psStyle->color,-1,-1,-1,255);
MS_COPYSTRING(psStyle->exprBindings[MS_STYLE_BINDING_OUTLINECOLOR].string,
psStyle->exprBindings[MS_STYLE_BINDING_COLOR].string);
psStyle->exprBindings[MS_STYLE_BINDING_OUTLINECOLOR].type =
psStyle->exprBindings[MS_STYLE_BINDING_COLOR].type;
msFreeExpression(&(psStyle->exprBindings[MS_STYLE_BINDING_COLOR]));
msInitExpression(&(psStyle->exprBindings[MS_STYLE_BINDING_COLOR]));
}
}
}
nSymbolizer++;
}

/* Point Symbolizer */
LOOP_ON_CHILD_ELEMENT(psRoot, psPointSymbolizer, "PointSymbolizer")
{
const int bNewClass = (nSymbolizer == 0);
msSLDParsePointSymbolizer(psPointSymbolizer, psLayer, bNewClass,
pszUserStyleName);
psLayer->type = MS_LAYER_POINT;
if (bNewClass)
{
psLayer->type = MS_LAYER_POINT;
}
nSymbolizer++;
}

/* Text symbolizer */
/* ==================================================================== */
/* For text symbolizer, here is how it is translated into */
@@ -988,7 +1012,10 @@ int msSLDParseRule(CPLXMLNode *psRoot, layerObj *psLayer, const char* pszUserSty
LOOP_ON_CHILD_ELEMENT(psRoot, psRasterSymbolizer, "RasterSymbolizer")
{
msSLDParseRasterSymbolizer(psRasterSymbolizer, psLayer, pszUserStyleName);
psLayer->type = MS_LAYER_RASTER;
if (nSymbolizer == 0)
{
psLayer->type = MS_LAYER_RASTER;
}
}

return MS_SUCCESS;
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,47 @@
#
#
# RUN_PARMS: map_symbolizers.png [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WMS&VERSION=1.3&REQUEST=GetMap&CRS=EPSG:4326&BBOX=42,-5,52,9&FORMAT=image/png&WIDTH=200&HEIGHT=200&LAYERS=main" > [RESULT_DEMIME]
#
#
# RUN_PARMS: sld_stroke_fill.png [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WMS&VERSION=1.3&REQUEST=GetMap&CRS=EPSG:4326&BBOX=42,-5,52,9&FORMAT=image/png&WIDTH=200&HEIGHT=200&LAYERS=main&SLD_BODY=<StyledLayerDescriptor version=%221.1.0%22><NamedLayer><Name>main</Name><UserStyle><FeatureTypeStyle><Rule><PolygonSymbolizer><Stroke><SvgParameter name=%22stroke%22><Literal>#FFFF00</Literal></SvgParameter><SvgParameter name=%22stroke-width%22><Literal>3</Literal></SvgParameter></Stroke><Fill><SvgParameter name=%22fill%22><Literal>#0000FF</Literal></SvgParameter></Fill></PolygonSymbolizer></Rule></FeatureTypeStyle></UserStyle></NamedLayer></StyledLayerDescriptor>" > [RESULT_DEMIME]
#
#
# RUN_PARMS: sld_symbolizers.png [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WMS&VERSION=1.3&REQUEST=GetMap&CRS=EPSG:4326&BBOX=42,-5,52,9&FORMAT=image/png&WIDTH=200&HEIGHT=200&LAYERS=main&SLD_BODY=<StyledLayerDescriptor version=%221.1.0%22><NamedLayer><Name>main</Name><UserStyle><FeatureTypeStyle><Rule><PolygonSymbolizer><Fill><SvgParameter name=%22fill%22><Literal>#0000FF</Literal></SvgParameter></Fill></PolygonSymbolizer><LineSymbolizer><Stroke><SvgParameter name=%22stroke%22><Literal>#FFFF00</Literal></SvgParameter><SvgParameter name=%22stroke-width%22><Add><PropertyName>w1</PropertyName><Literal>2</Literal></Add></SvgParameter></Stroke></LineSymbolizer></Rule></FeatureTypeStyle></UserStyle></NamedLayer></StyledLayerDescriptor>" > [RESULT_DEMIME]
#

MAP
NAME SYMBOLIZERS
SIZE 300 300
IMAGECOLOR 100 100 100
PROJECTION
"init=epsg:4326"
END
WEB
IMAGEPATH "/tmp/ms_tmp/"
IMAGEURL "/ms_tmp/"
METADATA
"wms_title" "Test SLD"
"wms_onlineresource" "http://localhost/path/to/wms_simple?"
"wms_srs" "EPSG:4326"
"ows_schemas_location" "http://ogc.dmsolutions.ca"
"ows_enable_request" "*"
"ows_sld_enabled" "true"
END
END

LAYER
NAME main
CONNECTIONTYPE OGR
CONNECTION data/inner.json
TYPE POLYGON
STATUS ON
SIZEUNITS pixels
CLASS
STYLE
COLOR 0 0 255
OUTLINECOLOR 255 255 0
WIDTH 3
END
END
END
END

0 comments on commit 9167d8a

Please sign in to comment.