Skip to content
Permalink
Browse files
mapscript: add an optional version parameter for map.generateSLD()
  • Loading branch information
rouault committed Oct 24, 2019
1 parent 6dbece4 commit 1681765bf82c61a5f981889ca756cda2cb00a35b
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 40 deletions.
@@ -332,16 +332,16 @@ class MapRunSubTestCase(MapTestCase):

def testDefaultSubstitutions(self):
s = """
MAP
WEB
VALIDATION
'key1' '.*'
'default_key1' 'Test Title'
END
METADATA
"wms_title" "%key1%"
END
END
MAP
WEB
VALIDATION
'key1' '.*'
'default_key1' 'Test Title'
END
METADATA
"wms_title" "%key1%"
END
END
END
"""
map = mapscript.fromstring(s)
@@ -353,33 +353,44 @@ def testRuntimeSubstitutions(self):
For supported parameters see https://mapserver.org/cgi/runsub.html#parameters-supported
"""
s = """
MAP
WEB
VALIDATION
'key1' '.*'
'default_key1' 'Test Title'
END
METADATA
"wms_title" "%key1%"
END
END
LAYER
TYPE POINT
FILTER ([size]<%my_filter%)
VALIDATION
'my_filter' '^[0-9]$'
END
END
MAP
WEB
VALIDATION
'key1' '.*'
'default_key1' 'Test Title'
END
METADATA
"wms_title" "%key1%"
END
END
LAYER
TYPE POINT
FILTER ([size]<%my_filter%)
VALIDATION
'my_filter' '^[0-9]$'
END
END
END
"""
map = mapscript.fromstring(s)

d = {"key1": "New Title", "my_filter": "3"}
d = {"key1": "New Title", "my_filter": "3"}
map.applySubstitutions(d)

assert map.web.metadata["wms_title"] == "New Title"
assert map.getLayer(0).getFilterString() == "([size]<3)"


class MapSLDTestCase(MapTestCase):
def test(self):

test_map = mapscript.mapObj(TESTMAPFILE)
result = test_map.generateSLD()
assert result.startswith('<StyledLayerDescriptor version="1.0.0"'), result

result = test_map.generateSLD("1.1.0")
assert result.startswith('<StyledLayerDescriptor version="1.1.0"'), result


if __name__ == '__main__':
unittest.main()
@@ -458,8 +458,8 @@
}

%newobject generateSLD;
char *generateSLD() {
return (char *) msSLDGenerateSLD(self, -1, NULL);
char *generateSLD(char *sldVersion=NULL) {
return (char *) msSLDGenerateSLD(self, -1, sldVersion);
}


@@ -513,20 +513,20 @@
%feature("docstring") applyDefaultSubstitutions
"Apply any default values
defined in a VALIDATION block used for runtime substitutions"
void applyDefaultSubstitutions()
{
msApplyDefaultSubstitutions(self);
}

void applyDefaultSubstitutions()
{
msApplyDefaultSubstitutions(self);
}

%feature("autodoc", "3");
%feature("docstring") applySubstitutions
"Pass in runtime substitution
keys and values and apply them to the map.
**Note** This method is currently enabled for Python only.
Typemaps are needed for other mapscript languages."
void applySubstitutions(char **names, char **values, int npairs)
{
msApplySubstitutions(self, names, values, npairs);
**Note** This method is currently enabled for Python only.
Typemaps are needed for other mapscript languages."
void applySubstitutions(char **names, char **values, int npairs)
{
msApplySubstitutions(self, names, values, npairs);
}
}

0 comments on commit 1681765

Please sign in to comment.