diff --git a/src/mra.py b/src/mra.py index 476d5e4c865eca8965f04c29b3257f278cf8bb16..667c68c5319aafc881f2b4aa7f3b9faa7644425d 100644 --- a/src/mra.py +++ b/src/mra.py @@ -207,6 +207,9 @@ class Layer(MetadataMixin): else: raise KeyError(s_name) + if self.ms.classgroup == s_name: + self.ms.classgroup = None # Should never be 'None' + class LayerGroup(object): def __init__(self, name, mapfile): diff --git a/src/server.py b/src/server.py index e2a4a824f726e3efd127179ee38ea14e1e267c46..93b0fae6db9bfd590f3efe2da6fd3f1cc3a6d319 100755 --- a/src/server.py +++ b/src/server.py @@ -632,7 +632,7 @@ class coverage(object): class files(object): """ http://hostname/mra/workspaces/<ws>/datastores/<cs>/file.<extension> - + http://hostname/mra/workspaces/<ws>/coveragestores/<cs>/file.<extension> """ @@ -805,7 +805,7 @@ class layers(object): @HTTPCompatible() def POST(self, format): - """Create a new layers.""" + """Create a new layer.""" data = get_data(name="layer", mandatory=["name", "resource"], @@ -818,7 +818,7 @@ class layers(object): try: ws_name, st_type, st_name, r_type, r_name = mra.href_parse(href, 5) except ValueError: - raise webapp.NotFound(message="resource '%s' was not found." % href) + raise webapp.NotFound(message="resource \"%s\" was not found." % href) st_type, r_type = st_type[:-1], r_type[:-1] # Remove trailing s. @@ -841,6 +841,11 @@ class layers(object): layer = mf.get_layer(l_name) layer.add_style_sld(mf, s_name, style) + # Remove the automatic default style. + for s_name in layer.iter_styles(): + if s_name in ("default_polygon", "default_line", "default_point"): + layer.remove_style(s_name) + mf.save() webapp.Created("%s/layers/%s.%s" % (web.ctx.home, l_name, format)) @@ -867,13 +872,21 @@ class layer(object): "coverage": ("coverage", "coveragestore") }[layer.get_mra_metadata("type")] + # Check CLASSGROUP + dflt_style = layer.ms.classgroup + if dflt_style == None: + # If is 'None': take the first style as would MapServer. + for s_name in layer.iter_styles(): + dflt_style = s_name + break + return {"layer" : { "name": l_name, "path": "/", # TODO "type": layer.get_type_name(), "defaultStyle": { - "name": layer.ms.classgroup, - "href": "%s/styles/%s.%s" % (web.ctx.home, layer.ms.classgroup, format), + "name": dflt_style, + "href": "%s/styles/%s.%s" % (web.ctx.home, dflt_style, format), }, "styles": [{ # TODO: Add attr class="linked-hash-set" "name": s_name, @@ -939,6 +952,11 @@ class layer(object): with webapp.mightNotFound(): style = mra.get_style(s_name) layer.add_style_sld(mf, s_name, style) + + # Remove the automatic default style. + for s_name in layer.iter_styles(): + if s_name in ("default_polygon", "default_line", "default_point"): + layer.remove_style(s_name) mf.save()