fix up sequence of elements in Web Map Context 1.1 Format when writing, thanks trondmm for the catch and initial patch, r=tschaub (closes #2174)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@9614 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -641,15 +641,6 @@ OpenLayers.Format.WMC.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
|
|||||||
node.appendChild(this.write_wmc_MetadataURL(layer));
|
node.appendChild(this.write_wmc_MetadataURL(layer));
|
||||||
}
|
}
|
||||||
|
|
||||||
// optional FormatList element
|
|
||||||
node.appendChild(this.write_wmc_FormatList(layer));
|
|
||||||
|
|
||||||
// optional StyleList element
|
|
||||||
node.appendChild(this.write_wmc_StyleList(layer));
|
|
||||||
|
|
||||||
// OpenLayers specific properties go in an Extension element
|
|
||||||
node.appendChild(this.write_wmc_LayerExtension(layer));
|
|
||||||
|
|
||||||
return node;
|
return node;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,31 @@ OpenLayers.Format.WMC.v1_0_0 = OpenLayers.Class(
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: write_wmc_Layer
|
||||||
|
* Create a Layer node given a layer object.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* layer - {<OpenLayers.Layer.WMS>} Layer object.
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* {Element} A WMC Layer element node.
|
||||||
|
*/
|
||||||
|
write_wmc_Layer: function(layer) {
|
||||||
|
var node = OpenLayers.Format.WMC.v1.prototype.write_wmc_Layer.apply(
|
||||||
|
this, [layer]
|
||||||
|
);
|
||||||
|
|
||||||
|
// optional FormatList element
|
||||||
|
node.appendChild(this.write_wmc_FormatList(layer));
|
||||||
|
|
||||||
|
// optional StyleList element
|
||||||
|
node.appendChild(this.write_wmc_StyleList(layer));
|
||||||
|
|
||||||
|
// OpenLayers specific properties go in an Extension element
|
||||||
|
node.appendChild(this.write_wmc_LayerExtension(layer));
|
||||||
|
},
|
||||||
|
|
||||||
CLASS_NAME: "OpenLayers.Format.WMC.v1_0_0"
|
CLASS_NAME: "OpenLayers.Format.WMC.v1_0_0"
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -95,7 +95,7 @@ OpenLayers.Format.WMC.v1_1_0 = OpenLayers.Class(
|
|||||||
this.namespaces.sld, "sld:MinScaleDenominator"
|
this.namespaces.sld, "sld:MinScaleDenominator"
|
||||||
);
|
);
|
||||||
minSD.appendChild(this.createTextNode(layer.maxScale.toPrecision(10)));
|
minSD.appendChild(this.createTextNode(layer.maxScale.toPrecision(10)));
|
||||||
node.insertBefore(minSD, node.childNodes[3]);
|
node.appendChild(minSD);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(layer.options.resolutions || layer.options.scales ||
|
if(layer.options.resolutions || layer.options.scales ||
|
||||||
@@ -104,8 +104,17 @@ OpenLayers.Format.WMC.v1_1_0 = OpenLayers.Class(
|
|||||||
this.namespaces.sld, "sld:MaxScaleDenominator"
|
this.namespaces.sld, "sld:MaxScaleDenominator"
|
||||||
);
|
);
|
||||||
maxSD.appendChild(this.createTextNode(layer.minScale.toPrecision(10)));
|
maxSD.appendChild(this.createTextNode(layer.minScale.toPrecision(10)));
|
||||||
node.insertBefore(maxSD, node.childNodes[4]);
|
node.appendChild(maxSD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// optional FormatList element
|
||||||
|
node.appendChild(this.write_wmc_FormatList(layer));
|
||||||
|
|
||||||
|
// optional StyleList element
|
||||||
|
node.appendChild(this.write_wmc_StyleList(layer));
|
||||||
|
|
||||||
|
// OpenLayers specific properties go in an Extension element
|
||||||
|
node.appendChild(this.write_wmc_LayerExtension(layer));
|
||||||
|
|
||||||
return node;
|
return node;
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<script src="../../../lib/OpenLayers.js"></script>
|
<script src="../../../lib/OpenLayers.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
function test_write_wmc_Layer(t) {
|
function test_write_wmc_Layer(t) {
|
||||||
if (OpenLayers.Util.getBrowserName() == "safari") {
|
if (OpenLayers.Util.getBrowserName() == "safari") {
|
||||||
t.plan(0);
|
t.plan(0);
|
||||||
t.debug_print("Safari has wierd behavior with getElementsByTagNameNS: the result is that we can't run these tests there. Patches welcome.");
|
t.debug_print("Safari has wierd behavior with getElementsByTagNameNS: the result is that we can't run these tests there. Patches welcome.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
t.plan(10);
|
t.plan(12);
|
||||||
|
|
||||||
// direct construction of a parser for a unit test
|
// direct construction of a parser for a unit test
|
||||||
var wmc = new OpenLayers.Format.WMC.v1_1_0();
|
var wmc = new OpenLayers.Format.WMC.v1_1_0();
|
||||||
var sldNS = wmc.namespaces["sld"];
|
var sldNS = wmc.namespaces["sld"];
|
||||||
|
|
||||||
// test that Min/MaxScaleDenominator is not written out when no
|
// test that Min/MaxScaleDenominator is not written out when no
|
||||||
// resolution related options are set
|
// resolution related options are set
|
||||||
var layer = new OpenLayers.Layer.WMS(
|
var layer = new OpenLayers.Layer.WMS(
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
t.eq(maxList.length, 1, "(resolutions) node written with MaxScaleDenominator");
|
t.eq(maxList.length, 1, "(resolutions) node written with MaxScaleDenominator");
|
||||||
t.eq(layer.minScale.toPrecision(10), wmc.getChildValue(maxList[0]),
|
t.eq(layer.minScale.toPrecision(10), wmc.getChildValue(maxList[0]),
|
||||||
"(resolutions) node written with correct MaxScaleDenominator value");
|
"(resolutions) node written with correct MaxScaleDenominator value");
|
||||||
|
|
||||||
layer = new OpenLayers.Layer.WMS(
|
layer = new OpenLayers.Layer.WMS(
|
||||||
"test", "http://foo", {},
|
"test", "http://foo", {},
|
||||||
{scales: [4, 2, 1], maxExtent: new OpenLayers.Bounds(1, 2, 3, 4)}
|
{scales: [4, 2, 1], maxExtent: new OpenLayers.Bounds(1, 2, 3, 4)}
|
||||||
@@ -62,13 +62,20 @@
|
|||||||
t.eq(maxList.length, 1, "(scales) node written with MaxScaleDenominator");
|
t.eq(maxList.length, 1, "(scales) node written with MaxScaleDenominator");
|
||||||
t.eq(layer.minScale.toPrecision(10), wmc.getChildValue(maxList[0]),
|
t.eq(layer.minScale.toPrecision(10), wmc.getChildValue(maxList[0]),
|
||||||
"(scales) node written with correct MaxScaleDenominator value");
|
"(scales) node written with correct MaxScaleDenominator value");
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
layer.metadataURL = 'http://foo';
|
||||||
</head>
|
node = wmc.write_wmc_Layer(layer);
|
||||||
|
t.eq(node.childNodes[3].localName || node.childNodes[3].nodeName.split(":").pop(),
|
||||||
|
'MetadataURL', "MinScaleDenominator is written after MetadataURL, so third node should be MetadataURL");
|
||||||
|
t.eq(node.childNodes[4].localName || node.childNodes[4].nodeName.split(":").pop(),
|
||||||
|
'MinScaleDenominator', "MinScaleDenominator is written after MetadataURL, so fourth node should be MinScaleDenominator");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="map" style="width: 512px; height: 256px;"></div>
|
<div id="map" style="width: 512px; height: 256px;"></div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user