[Commits] r1281 - in sandbox/camptocamp/geobretagne: lib/GeoExt/data tests/lib/GeoExt/data
commits at geoext.org
commits at geoext.org
Thu Jul 23 08:51:28 CEST 2009
Author: elemoine
Date: 2009-07-23 08:51:27 +0200 (Thu, 23 Jul 2009)
New Revision: 1281
Modified:
sandbox/camptocamp/geobretagne/lib/GeoExt/data/WMSCapabilitiesReader.js
sandbox/camptocamp/geobretagne/tests/lib/GeoExt/data/WMSCapabilitiesReader.html
sandbox/camptocamp/geobretagne/tests/lib/GeoExt/data/WMSCapabilitiesReader.js
Log:
svn merge -r1274:HEAD http://svn.geoext.org/core/trunk/geoext .
Modified: sandbox/camptocamp/geobretagne/lib/GeoExt/data/WMSCapabilitiesReader.js
===================================================================
--- sandbox/camptocamp/geobretagne/lib/GeoExt/data/WMSCapabilitiesReader.js 2009-07-20 20:37:06 UTC (rev 1280)
+++ sandbox/camptocamp/geobretagne/lib/GeoExt/data/WMSCapabilitiesReader.js 2009-07-23 06:51:27 UTC (rev 1281)
@@ -69,6 +69,14 @@
Ext.extend(GeoExt.data.WMSCapabilitiesReader, Ext.data.DataReader, {
+
+ /** api: config[attributionCls]
+ * ``String`` CSS class name for the attribution DOM elements.
+ * Element class names append "-link", "-image", and "-title" as
+ * appropriate. Default is "gx-attribution".
+ */
+ attributionCls: "gx-attribution",
+
/** private: method[read]
* :param request: ``Object`` The XHR object which contains the parsed XML
* document.
@@ -138,15 +146,16 @@
data = this.meta.format.read(data);
}
var capability = data.capability;
+ var url = capability.request.getmap.href;
var records = [], layer;
+
for(var i=0, len=capability.layers.length; i<len; i++){
layer = capability.layers[i];
if(layer.name) {
records.push(new this.recordType(Ext.apply(layer, {
layer: new OpenLayers.Layer.WMS(
layer.title || layer.name,
- capability.request.getmap.href,
- {
+ url, {
layers: layer.name,
exceptions: this.serviceExceptionFormat(
capability.exception.formats
@@ -154,21 +163,62 @@
format: this.imageFormat(layer),
version: data.version
}, {
- minScale: (typeof(layer.minScale)!='undefined') ?
- layer.minScale : null,
- maxScale: (typeof(layer.maxScale)!='undefined') ?
- layer.maxScale : null
+ minScale: layer.minScale != undefined ?
+ layer.minScale : undefined,
+ maxScale: layer.maxScale != undefined ?
+ layer.maxScale : undefined,
+ attribution: layer.attribution ?
+ this.attributionMarkup(layer.attribution) :
+ undefined
}
)
})));
}
}
-
+
return {
totalRecords: records.length,
success: true,
records: records
};
+ },
+
+ /** private: method[attributionMarkup]
+ * :param attribution: ``Object`` The attribution property of the layer
+ * object as parsed from a WMS Capabilities document
+ * :return: ``String`` HTML markup to display attribution
+ * information.
+ *
+ * Generates attribution markup using the Attribution metadata
+ * from WMS Capabilities
+ */
+ attributionMarkup : function(attribution){
+ var markup = [];
+
+ if (attribution.logo){
+ markup.push("<img class='"+this.attributionCls+"-image' "
+ + "src='" + attribution.logo.href + "' />");
+ }
+
+ if (attribution.title) {
+ markup.push("<span class='"+ this.attributionCls + "-title'>"
+ + attribution.title
+ + "</span>");
+ }
+
+ if(attribution.href){
+ for(var i = 0; i < markup.length; i++){
+ markup[i] = "<a class='"
+ + this.attributionCls + "-link' "
+ + "href="
+ + attribution.href
+ + ">"
+ + markup[i]
+ + "</a>";
+ }
+ }
+
+ return markup.join(" ");
}
});
Modified: sandbox/camptocamp/geobretagne/tests/lib/GeoExt/data/WMSCapabilitiesReader.html
===================================================================
--- sandbox/camptocamp/geobretagne/tests/lib/GeoExt/data/WMSCapabilitiesReader.html 2009-07-20 20:37:06 UTC (rev 1280)
+++ sandbox/camptocamp/geobretagne/tests/lib/GeoExt/data/WMSCapabilitiesReader.html 2009-07-23 06:51:27 UTC (rev 1281)
@@ -33,7 +33,7 @@
'field values set from configuration are correct');
}
function test_read(t) {
- t.plan(29);
+ t.plan(32);
var reader = new GeoExt.data.WMSCapabilitiesReader();
@@ -93,6 +93,12 @@
t.eq(layer.name, "Manhattan (NY) roads","[2] layer field has correct name");
t.eq(typeof(layer.minScale), "number","[2] layer minScale has been set");
t.eq(typeof(layer.maxScale), "number","[2] layer maxScale has been set");
+
+ // 3 tests -- attribution markup
+ var attribution = layer.attribution;
+ t.ok(attribution.indexOf("http://foo/logo.png") !== -1, "attribution markup has a logo");
+ t.ok(attribution.indexOf("Foo Authority") !== -1, "attribution markup has a title");
+ t.ok(attribution.indexOf("http://foo/about/") !== -1, "attribution has a link");
}
</script>
<body>
Modified: sandbox/camptocamp/geobretagne/tests/lib/GeoExt/data/WMSCapabilitiesReader.js
===================================================================
--- sandbox/camptocamp/geobretagne/tests/lib/GeoExt/data/WMSCapabilitiesReader.js 2009-07-20 20:37:06 UTC (rev 1280)
+++ sandbox/camptocamp/geobretagne/tests/lib/GeoExt/data/WMSCapabilitiesReader.js 2009-07-23 06:51:27 UTC (rev 1281)
@@ -4134,6 +4134,14 @@
'AUTHORITY["EPSG","4326"]]-->' +
'<LatLonBoundingBox minx="-74.08769307536667" miny="40.660618924633326" maxx="-73.84653192463333" maxy="40.90178007536667"/>' +
'<BoundingBox SRS="EPSG:4326" minx="-74.02722" miny="40.684221" maxx="-73.907005" maxy="40.878178"/>' +
+ '<Attribution>' +
+ '<Title>Foo Authority</Title>' +
+ '<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="http://foo/about/" />' +
+ '<LogoURL width="24" height="24">' +
+ '<Format>image/png</Format>' +
+ '<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="http://foo/logo.png" />' +
+ '</LogoURL>' +
+ '</Attribution>' +
'<Style>' +
'<Name>tiger_roads</Name>' +
'<Title>Default Styler</Title>' +
More information about the Commits
mailing list