[OpenLayers-Commits] r7349 - in sandbox/camptocamp/unhcr: build examples lib lib/OpenLayers lib/OpenLayers/Control lib/OpenLayers/Format lib/OpenLayers/Format/SLD lib/OpenLayers/Layer lib/OpenLayers/Renderer lib/OpenLayers/Tile tests tests/Format/SLD tests/Renderer tests/Request tests/Tile tests/manual
commits at openlayers.org
commits at openlayers.org
Wed Jun 11 09:48:50 EDT 2008
Author: elemoine
Date: 2008-06-11 09:48:50 -0400 (Wed, 11 Jun 2008)
New Revision: 7349
Added:
sandbox/camptocamp/unhcr/tests/Request.html
sandbox/camptocamp/unhcr/tests/Request/
sandbox/camptocamp/unhcr/tests/Request/XMLHttpRequest.html
Removed:
sandbox/camptocamp/unhcr/tests/Request/XMLHttpRequest.html
Modified:
sandbox/camptocamp/unhcr/build/full.cfg
sandbox/camptocamp/unhcr/build/library.cfg
sandbox/camptocamp/unhcr/build/license.txt
sandbox/camptocamp/unhcr/build/lite.cfg
sandbox/camptocamp/unhcr/examples/spherical-mercator.html
sandbox/camptocamp/unhcr/lib/OpenLayers.js
sandbox/camptocamp/unhcr/lib/OpenLayers/Ajax.js
sandbox/camptocamp/unhcr/lib/OpenLayers/Control/PanZoomBar.js
sandbox/camptocamp/unhcr/lib/OpenLayers/Format/KML.js
sandbox/camptocamp/unhcr/lib/OpenLayers/Format/SLD/v1.js
sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/GML.js
sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/GeoRSS.js
sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/KaMap.js
sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/MapGuide.js
sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/MapServer.js
sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/Text.js
sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/VirtualEarth.js
sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/WFS.js
sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/WorldWind.js
sandbox/camptocamp/unhcr/lib/OpenLayers/Map.js
sandbox/camptocamp/unhcr/lib/OpenLayers/Renderer/SVG.js
sandbox/camptocamp/unhcr/lib/OpenLayers/Renderer/VML.js
sandbox/camptocamp/unhcr/lib/OpenLayers/Request.js
sandbox/camptocamp/unhcr/lib/OpenLayers/Style.js
sandbox/camptocamp/unhcr/lib/OpenLayers/Tile/WFS.js
sandbox/camptocamp/unhcr/lib/OpenLayers/Util.js
sandbox/camptocamp/unhcr/tests/Ajax.html
sandbox/camptocamp/unhcr/tests/Format/SLD/v1_0_0.html
sandbox/camptocamp/unhcr/tests/Renderer/VML.html
sandbox/camptocamp/unhcr/tests/Tile/WFS.html
sandbox/camptocamp/unhcr/tests/Util.html
sandbox/camptocamp/unhcr/tests/list-tests.html
sandbox/camptocamp/unhcr/tests/manual/ajax.html
sandbox/camptocamp/unhcr/tests/xml_eq.js
Log:
sync with vector-behavior
Modified: sandbox/camptocamp/unhcr/build/full.cfg
===================================================================
--- sandbox/camptocamp/unhcr/build/full.cfg 2008-06-11 13:31:59 UTC (rev 7348)
+++ sandbox/camptocamp/unhcr/build/full.cfg 2008-06-11 13:48:50 UTC (rev 7349)
@@ -13,7 +13,10 @@
[exclude]
Firebug/firebug.js
Firebug/firebugx.js
+OpenLayers/Lang/cs-CZ.js
OpenLayers/Lang/de.js
OpenLayers/Lang/en-CA.js
OpenLayers/Lang/fr.js
-OpenLayers/Lang/cs-CZ.js
+OpenLayers/Lang/it.js
+OpenLayers/Lang/pt-BR.js
+OpenLayers/Lang/sv-SE.js
\ No newline at end of file
Modified: sandbox/camptocamp/unhcr/build/library.cfg
===================================================================
--- sandbox/camptocamp/unhcr/build/library.cfg 2008-06-11 13:31:59 UTC (rev 7348)
+++ sandbox/camptocamp/unhcr/build/library.cfg 2008-06-11 13:48:50 UTC (rev 7349)
@@ -46,9 +46,11 @@
OpenLayers/Renderer/SVG.js
OpenLayers/Renderer/VML.js
OpenLayers/Renderer.js
+OpenLayers/Lang/cs-CZ.js
OpenLayers/Lang/de.js
OpenLayers/Lang/en-CA.js
OpenLayers/Lang/fr.js
-OpenLayers/Lang/cs-CZ.js
+OpenLayers/Lang/it.js
+OpenLayers/Lang/pt-BR.js
+OpenLayers/Lang/sv-SE.js
-
Modified: sandbox/camptocamp/unhcr/build/license.txt
===================================================================
--- sandbox/camptocamp/unhcr/build/license.txt 2008-06-11 13:31:59 UTC (rev 7348)
+++ sandbox/camptocamp/unhcr/build/license.txt 2008-06-11 13:48:50 UTC (rev 7349)
@@ -72,3 +72,13 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
+
+/**
+ * Contains XMLHttpRequest.js <http://code.google.com/p/xmlhttprequest/>
+ * Copyright 2007 Sergey Ilinsky (http://www.ilinsky.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ */
Modified: sandbox/camptocamp/unhcr/build/lite.cfg
===================================================================
--- sandbox/camptocamp/unhcr/build/lite.cfg 2008-06-11 13:31:59 UTC (rev 7348)
+++ sandbox/camptocamp/unhcr/build/lite.cfg 2008-06-11 13:48:50 UTC (rev 7349)
@@ -21,8 +21,11 @@
[exclude]
Firebug/firebug.js
Firebug/firebugx.js
+OpenLayers/Lang/cs-CZ.js
OpenLayers/Lang/de.js
OpenLayers/Lang/en-CA.js
OpenLayers/Lang/fr.js
-OpenLayers/Lang/cs-CZ.js
+OpenLayers/Lang/it.js
+OpenLayers/Lang/pt-BR.js
+OpenLayers/Lang/sv-SE.js
Modified: sandbox/camptocamp/unhcr/examples/spherical-mercator.html
===================================================================
--- sandbox/camptocamp/unhcr/examples/spherical-mercator.html 2008-06-11 13:31:59 UTC (rev 7348)
+++ sandbox/camptocamp/unhcr/examples/spherical-mercator.html 2008-06-11 13:48:50 UTC (rev 7349)
@@ -4,6 +4,9 @@
<link rel="stylesheet" href="style.css" type="text/css" />
<style type="text/css">
.olControlAttribution { bottom: 0px!important }
+ #map {
+ height: 512px;
+ }
</style>
<script src='http://dev.virtualearth.net/mapcontrol/v3/mapcontrol.js'></script>
Modified: sandbox/camptocamp/unhcr/lib/OpenLayers/Ajax.js
===================================================================
--- sandbox/camptocamp/unhcr/lib/OpenLayers/Ajax.js 2008-06-11 13:31:59 UTC (rev 7348)
+++ sandbox/camptocamp/unhcr/lib/OpenLayers/Ajax.js 2008-06-11 13:48:50 UTC (rev 7349)
@@ -2,6 +2,9 @@
* license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
* full text of the license. */
+/**
+ * @requires OpenLayers/Request/XMLHttpRequest.js
+ */
OpenLayers.ProxyHost = "";
//OpenLayers.ProxyHost = "examples/proxy.cgi?url=";
@@ -30,16 +33,18 @@
*/
-/**
-* @param {} request
-*/
+/**
+ * Function: OpenLayers.nullHandler
+ * @param {} request
+ */
OpenLayers.nullHandler = function(request) {
alert(OpenLayers.i18n("unhandledRequest", {'statusText':request.statusText}));
};
/**
* Function: loadURL
- * Background load a document.
+ * Background load a document. For more flexibility in using XMLHttpRequest,
+ * see the <OpenLayers.Request> methods.
*
* Parameters:
* uri - {String} URI of source doc
@@ -49,35 +54,32 @@
* caller - {Object} object which gets callbacks
* onComplete - {Function} Optional callback for success. The callback
* will be called with this set to caller and will receive the request
- * object as an argument.
+ * object as an argument. Note that if you do not specify an onComplete
+ * function, <OpenLayers.nullHandler> will be called (which pops up an
+ * alert dialog).
* onFailure - {Function} Optional callback for failure. In the event of
* a failure, the callback will be called with this set to caller and will
- * receive the request object as an argument.
+ * receive the request object as an argument. Note that if you do not
+ * specify an onComplete function, <OpenLayers.nullHandler> will be called
+ * (which pops up an alert dialog).
*
* Returns:
- * {XMLHttpRequest} The request object. To abort loading, call
- * request.abort().
+ * {<OpenLayers.Request.XMLHttpRequest>} The request object. To abort loading,
+ * call request.abort().
*/
OpenLayers.loadURL = function(uri, params, caller,
onComplete, onFailure) {
-
- var success = (onComplete) ? OpenLayers.Function.bind(onComplete, caller)
- : OpenLayers.nullHandler;
-
- var failure = (onFailure) ? OpenLayers.Function.bind(onFailure, caller)
- : OpenLayers.nullHandler;
-
- // from prototype.js
- var request = new OpenLayers.Ajax.Request(
- uri,
- {
- method: 'get',
- parameters: params,
- onComplete: success,
- onFailure: failure
- }
- );
- return request.transport;
+
+ if(typeof params == 'string') {
+ params = OpenLayers.Util.getParameters(params);
+ }
+ var success = (onComplete) ? onComplete : OpenLayers.nullHandler;
+ var failure = (onFailure) ? onFailure : OpenLayers.nullHandler;
+
+ return OpenLayers.Request.GET({
+ url: uri, params: params,
+ success: success, failure: failure, scope: caller
+ });
};
/**
@@ -263,6 +265,7 @@
/**
* Class: OpenLayers.Ajax.Request
+ * *Deprecated*. Use <OpenLayers.Request> method instead.
*
* Inherit:
* - <OpenLayers.Ajax.Base>
Modified: sandbox/camptocamp/unhcr/lib/OpenLayers/Control/PanZoomBar.js
===================================================================
--- sandbox/camptocamp/unhcr/lib/OpenLayers/Control/PanZoomBar.js 2008-06-11 13:31:59 UTC (rev 7348)
+++ sandbox/camptocamp/unhcr/lib/OpenLayers/Control/PanZoomBar.js 2008-06-11 13:48:50 UTC (rev 7349)
@@ -186,7 +186,7 @@
this.zoomStopHeight),
imgLocation + "zoombar.png",
"absolute", null, "crop");
- div.style.height = sz.h;
+ div.style.height = sz.h + "px";
} else {
div = OpenLayers.Util.createDiv(
'OpenLayers_Control_PanZoomBar_Zoombar' + this.map.id,
Modified: sandbox/camptocamp/unhcr/lib/OpenLayers/Format/KML.js
===================================================================
--- sandbox/camptocamp/unhcr/lib/OpenLayers/Format/KML.js 2008-06-11 13:31:59 UTC (rev 7348)
+++ sandbox/camptocamp/unhcr/lib/OpenLayers/Format/KML.js 2008-06-11 13:48:50 UTC (rev 7349)
@@ -9,6 +9,7 @@
* @requires OpenLayers/Geometry/LineString.js
* @requires OpenLayers/Geometry/Polygon.js
* @requires OpenLayers/Geometry/Collection.js
+ * @requires OpenLayers/Request/XMLHttpRequest.js
*/
/**
@@ -249,11 +250,9 @@
*
*/
fetchLink: function(href) {
- var request = new OpenLayers.Ajax.Request(href,
- {method: 'get', asynchronous: false });
-
- if (request && request.transport) {
- return request.transport.responseText;
+ var request = OpenLayers.Request.GET({url: href, async: false});
+ if (request) {
+ return request.responseText;
}
},
@@ -550,9 +549,9 @@
if (inlineStyleNode) {
var inlineStyle= this.parseStyle(inlineStyleNode);
if (inlineStyle) {
- feature.style = OpenLayers.Util.extend({},
- feature.style);
- OpenLayers.Util.extend(feature.style, inlineStyle);
+ feature.style = OpenLayers.Util.extend(
+ feature.style, inlineStyle
+ );
}
}
Modified: sandbox/camptocamp/unhcr/lib/OpenLayers/Format/SLD/v1.js
===================================================================
--- sandbox/camptocamp/unhcr/lib/OpenLayers/Format/SLD/v1.js 2008-06-11 13:31:59 UTC (rev 7348)
+++ sandbox/camptocamp/unhcr/lib/OpenLayers/Format/SLD/v1.js 2008-06-11 13:48:50 UTC (rev 7349)
@@ -234,6 +234,9 @@
if(graphic.href != undefined) {
symbolizer.externalGraphic = graphic.href;
}
+ if(graphic.rotation != undefined) {
+ symbolizer.rotation = graphic.rotation;
+ }
},
"ExternalGraphic": function(node, graphic) {
this.readChildNodes(node, graphic);
@@ -290,7 +293,9 @@
"stroke-width": "strokeWidth",
"stroke-linecap": "strokeLinecap",
"fill": "fillColor",
- "fill-opacity": "fillOpacity"
+ "fill-opacity": "fillOpacity",
+ "font-family": "fontFamily",
+ "font-size": "fontSize"
},
/**
@@ -597,6 +602,68 @@
value: obj.symbolizer[obj.key]
});
},
+ "TextSymbolizer": function(symbolizer) {
+ var node = this.createElementNSPlus("TextSymbolizer");
+ // add in optional Label
+ if(symbolizer.label != null) {
+ this.writeNode(node, "Label", symbolizer.label);
+ }
+ // add in optional Font
+ if(symbolizer.fontFamily != null ||
+ symbolizer.fontSize != null) {
+ this.writeNode(node, "Font", symbolizer);
+ }
+ // add in optional Fill
+ if(symbolizer.fillColor != null ||
+ symbolizer.fillOpacity != null) {
+ this.writeNode(node, "Fill", symbolizer);
+ }
+ return node;
+ },
+ "Font": function(symbolizer) {
+ var node = this.createElementNSPlus("Font");
+ // add in CssParameters
+ if(symbolizer.fontFamily) {
+ this.writeNode(
+ node, "CssParameter",
+ {symbolizer: symbolizer, key: "fontFamily"}
+ );
+ }
+ if(symbolizer.fontSize) {
+ this.writeNode(
+ node, "CssParameter",
+ {symbolizer: symbolizer, key: "fontSize"}
+ );
+ }
+ return node;
+ },
+ "Label": function(label) {
+ // only the simplest of ogc:expression handled
+ // {label: "some text and a ${propertyName}"}
+ var node = this.createElementNSPlus("Label");
+ var tokens = label.split("${");
+ node.appendChild(this.createTextNode(tokens[0]));
+ var item, last;
+ for(var i=1; i<tokens.length; i++) {
+ item = tokens[i];
+ last = item.indexOf("}");
+ if(last > 0) {
+ this.writeNode(
+ node, "ogc:PropertyName",
+ {property: item.substring(0, last)}
+ );
+ node.appendChild(
+ this.createTextNode(item.substring(++last))
+ );
+ } else {
+ // no ending }, so this is a literal ${
+ node.appendChild(
+ this.createTextNode("${" + item)
+ );
+ }
+ }
+ return node;
+ },
"PolygonSymbolizer": function(symbolizer) {
var node = this.createElementNSPlus("PolygonSymbolizer");
this.writeNode(node, "Fill", symbolizer);
Modified: sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/GML.js
===================================================================
--- sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/GML.js 2008-06-11 13:31:59 UTC (rev 7348)
+++ sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/GML.js 2008-06-11 13:48:50 UTC (rev 7349)
@@ -4,7 +4,7 @@
/**
* @requires OpenLayers/Layer/Vector.js
- * @requires OpenLayers/Ajax.js
+ * @requires OpenLayers/Request/XMLHttpRequest.js
*/
/**
@@ -100,7 +100,12 @@
*/
loadGML: function() {
if (!this.loaded) {
- var results = OpenLayers.loadURL(this.url, null, this, this.requestSuccess, this.requestFailure);
+ OpenLayers.Request.GET({
+ url: this.url,
+ success: this.requestSuccess,
+ failure: this.requestFailure,
+ scope: this
+ });
this.loaded = true;
}
},
Modified: sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/GeoRSS.js
===================================================================
--- sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/GeoRSS.js 2008-06-11 13:31:59 UTC (rev 7348)
+++ sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/GeoRSS.js 2008-06-11 13:48:50 UTC (rev 7349)
@@ -5,7 +5,7 @@
/**
* @requires OpenLayers/Layer/Markers.js
- * @requires OpenLayers/Ajax.js
+ * @requires OpenLayers/Request/XMLHttpRequest.js
*/
/**
@@ -100,7 +100,11 @@
loadRSS: function() {
if (!this.loaded) {
this.events.triggerEvent("loadstart");
- OpenLayers.loadURL(this.location, null, this, this.parseData);
+ OpenLayers.Request.GET({
+ url: this.location,
+ success: this.parseData,
+ scope: this
+ });
this.loaded = true;
}
},
@@ -127,7 +131,7 @@
* Parse the data returned from the Events call.
*
* Parameters:
- * ajaxRequest - {XMLHttpRequest}
+ * ajaxRequest - {<OpenLayers.Request.XMLHttpRequest>}
*/
parseData: function(ajaxRequest) {
var doc = ajaxRequest.responseXML;
Modified: sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/KaMap.js
===================================================================
--- sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/KaMap.js 2008-06-11 13:31:59 UTC (rev 7348)
+++ sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/KaMap.js 2008-06-11 13:48:50 UTC (rev 7349)
@@ -64,13 +64,9 @@
var newArguments = [];
newArguments.push(name, url, params, options);
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
- this.params = (params ? params : {});
- if (params) {
- OpenLayers.Util.applyDefaults(
- this.params,
- this.DEFAULT_PARAMS
- );
- }
+ this.params = OpenLayers.Util.applyDefaults(
+ this.params, this.DEFAULT_PARAMS
+ );
},
/**
Modified: sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/MapGuide.js
===================================================================
--- sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/MapGuide.js 2008-06-11 13:31:59 UTC (rev 7348)
+++ sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/MapGuide.js 2008-06-11 13:48:50 UTC (rev 7349)
@@ -3,7 +3,7 @@
* full text of the license. */
/**
- * @requires OpenLayers/Ajax.js
+ * @requires OpenLayers/Request/XMLHttpRequest.js
* @requires OpenLayers/Layer/Grid.js
*/
@@ -202,12 +202,10 @@
getVisParams.mapName = this.params.mapName;
getVisParams.format = 'text/xml';
getVisParams = OpenLayers.Util.extend(getVisParams, params);
-
- new OpenLayers.Ajax.Request(this.url,
- { parameters: getVisParams,
- method: 'get',
- asynchronous: false //must be synchronous call to return control here
- });
+
+ OpenLayers.Request.GET({
+ url: this.url, params: getVisParams, async: false
+ });
}
//construct the full URL
Modified: sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/MapServer.js
===================================================================
--- sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/MapServer.js 2008-06-11 13:31:59 UTC (rev 7348)
+++ sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/MapServer.js 2008-06-11 13:48:50 UTC (rev 7349)
@@ -42,12 +42,9 @@
newArguments.push(name, url, params, options);
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
- if (arguments.length > 0) {
- OpenLayers.Util.applyDefaults(
- this.params,
- this.DEFAULT_PARAMS
- );
- }
+ this.params = OpenLayers.Util.applyDefaults(
+ this.params, this.DEFAULT_PARAMS
+ );
// unless explicitly set in options, if the layer is transparent,
// it will be an overlay
Modified: sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/Text.js
===================================================================
--- sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/Text.js 2008-06-11 13:31:59 UTC (rev 7348)
+++ sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/Text.js 2008-06-11 13:48:50 UTC (rev 7349)
@@ -5,7 +5,7 @@
/**
* @requires OpenLayers/Layer/Markers.js
- * @requires OpenLayers/Ajax.js
+ * @requires OpenLayers/Request/XMLHttpRequest.js
*/
/**
@@ -109,8 +109,12 @@
};
this.events.triggerEvent("loadstart");
- OpenLayers.loadURL(this.location, null,
- this, this.parseData, onFail);
+ OpenLayers.Request.GET({
+ url: this.location,
+ success: this.parseData,
+ failure: onFail,
+ scope: this
+ });
this.loaded = true;
}
}
@@ -137,7 +141,7 @@
* Method: parseData
*
* Parameters:
- * ajaxRequest - {XMLHttpRequest}
+ * ajaxRequest - {<OpenLayers.Request.XMLHttpRequest>}
*/
parseData: function(ajaxRequest) {
var text = ajaxRequest.responseText;
@@ -170,9 +174,19 @@
}
// FIXME: At the moment, we only use this if we have an
- // externalGraphic, because icon has no setOffset API Method.
- if (feature.style.graphicXOffset !== null
- && feature.style.graphicYOffset !== null) {
+ // externalGraphic, because icon has no setOffset API Method.
+ /**
+ * FIXME FIRST!!
+ * The Text format does all sorts of parseFloating
+ * The result of a parseFloat for a bogus string is NaN. That
+ * means the three possible values here are undefined, NaN, or a
+ * number. The previous check was an identity check for null. This
+ * means it was failing for all undefined or NaN. A slightly better
+ * check is for undefined. An even better check is to see if the
+ * value is a number (see #1441).
+ */
+ if (feature.style.graphicXOffset !== undefined
+ && feature.style.graphicYOffset !== undefined) {
iconOffset = new OpenLayers.Pixel(
feature.style.graphicXOffset,
feature.style.graphicYOffset);
Modified: sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/VirtualEarth.js
===================================================================
--- sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/VirtualEarth.js 2008-06-11 13:31:59 UTC (rev 7348)
+++ sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/VirtualEarth.js 2008-06-11 13:48:50 UTC (rev 7349)
@@ -95,8 +95,8 @@
// create div and set to same size as map
var veDiv = OpenLayers.Util.createDiv(this.name);
var sz = this.map.getSize();
- veDiv.style.width = sz.w;
- veDiv.style.height = sz.h;
+ veDiv.style.width = sz.w + "px";
+ veDiv.style.height = sz.h + "px";
this.div.appendChild(veDiv);
try { // crash prevention
Modified: sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/WFS.js
===================================================================
--- sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/WFS.js 2008-06-11 13:31:59 UTC (rev 7348)
+++ sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/WFS.js 2008-06-11 13:48:50 UTC (rev 7349)
@@ -138,11 +138,10 @@
this.options.geometry_column = "the_geom";
}
- this.params = params;
- OpenLayers.Util.applyDefaults(
- this.params,
- OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS)
- );
+ this.params = OpenLayers.Util.applyDefaults(
+ params,
+ OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS)
+ );
this.url = url;
},
@@ -456,21 +455,14 @@
}
var data = this.writer.write(this.features);
-
- var url = this.url;
- var success = OpenLayers.Function.bind(this.commitSuccess, this);
-
- var failure = OpenLayers.Function.bind(this.commitFailure, this);
-
- // from prototype.js
- new OpenLayers.Ajax.Request(url,
- { method: 'post',
- postBody: data,
- onComplete: success,
- onFailure: failure
- }
- );
+ OpenLayers.Request.POST({
+ url: this.url,
+ data: data,
+ success: this.commitSuccess,
+ failure: this.commitFailure,
+ scope: this
+ });
},
/**
Modified: sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/WorldWind.js
===================================================================
--- sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/WorldWind.js 2008-06-11 13:31:59 UTC (rev 7348)
+++ sandbox/camptocamp/unhcr/lib/OpenLayers/Layer/WorldWind.js 2008-06-11 13:48:50 UTC (rev 7349)
@@ -54,13 +54,9 @@
var newArguments = [];
newArguments.push(name, url, params, options);
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
- this.params = (params ? params : {});
- if (params) {
- OpenLayers.Util.applyDefaults(
- this.params,
- this.DEFAULT_PARAMS
- );
- }
+ this.params = OpenLayers.Util.applyDefaults(
+ this.params, this.DEFAULT_PARAMS
+ );
},
/**
* Method: addTile
Modified: sandbox/camptocamp/unhcr/lib/OpenLayers/Map.js
===================================================================
--- sandbox/camptocamp/unhcr/lib/OpenLayers/Map.js 2008-06-11 13:31:59 UTC (rev 7348)
+++ sandbox/camptocamp/unhcr/lib/OpenLayers/Map.js 2008-06-11 13:48:50 UTC (rev 7349)
@@ -1335,11 +1335,7 @@
* false.
*/
pan: function(dx, dy, options) {
- // this should be pushed to applyDefaults and extend
- if (!options) {
- options = {};
- }
- OpenLayers.Util.applyDefaults(options, {
+ options = OpenLayers.Util.applyDefaults(options, {
animate: true,
dragging: false
});
Modified: sandbox/camptocamp/unhcr/lib/OpenLayers/Renderer/SVG.js
===================================================================
--- sandbox/camptocamp/unhcr/lib/OpenLayers/Renderer/SVG.js 2008-06-11 13:31:59 UTC (rev 7348)
+++ sandbox/camptocamp/unhcr/lib/OpenLayers/Renderer/SVG.js 2008-06-11 13:48:50 UTC (rev 7349)
@@ -222,6 +222,12 @@
} else {
node.setAttributeNS(null, "r", style.pointRadius);
}
+
+ if (style.rotation) {
+ var rotation = OpenLayers.String.format(
+ "rotate(${0} ${1} ${2})", [style.rotation, x, y]);
+ node.setAttributeNS(null, "transform", rotation);
+ }
}
if (options.isFilled) {
Modified: sandbox/camptocamp/unhcr/lib/OpenLayers/Renderer/VML.js
===================================================================
--- sandbox/camptocamp/unhcr/lib/OpenLayers/Renderer/VML.js 2008-06-11 13:31:59 UTC (rev 7348)
+++ sandbox/camptocamp/unhcr/lib/OpenLayers/Renderer/VML.js 2008-06-11 13:48:50 UTC (rev 7349)
@@ -98,11 +98,11 @@
setSize: function(size) {
OpenLayers.Renderer.prototype.setSize.apply(this, arguments);
- this.rendererRoot.style.width = this.size.w;
- this.rendererRoot.style.height = this.size.h;
+ this.rendererRoot.style.width = this.size.w + "px";
+ this.rendererRoot.style.height = this.size.h + "px";
- this.root.style.width = this.size.w;
- this.root.style.height = this.size.h;
+ this.root.style.width = this.size.w + "px";
+ this.root.style.height = this.size.h + "px";
},
/**
@@ -169,8 +169,9 @@
node.style.left = ((geometry.x/resolution)+xOffset).toFixed();
node.style.top = ((geometry.y/resolution)-(yOffset+height)).toFixed();
- node.style.width = width;
- node.style.height = height;
+ node.style.width = width + "px";
+ node.style.height = height + "px";
+ node.style.flip = "y";
// modify style/options for fill and stroke styling below
style.fillColor = "none";
@@ -209,11 +210,20 @@
fill.setAttribute("src", style.externalGraphic);
fill.setAttribute("type", "frame");
- node.style.flip = "y";
if (!(style.graphicWidth && style.graphicHeight)) {
fill.aspect = "atmost";
}
+
+ // additional rendering for rotated graphics
+ if (style.rotation) {
+ this.graphicRotate(node, xOffset, yOffset);
+ // make the fill fully transparent, because we now have
+ // the graphic as imagedata element. We cannot just remove
+ // the fill, because this is part of the hack described
+ // in graphicRotate
+ fill.setAttribute("opacity", 0);
+ }
}
if (fill.parentNode != node) {
node.appendChild(fill);
@@ -250,6 +260,112 @@
},
/**
+ * Method: graphicRotate
+ * If a point is to be styled with externalGraphic and rotation, VML fills
+ * cannot be used to display the graphic, because rotation of graphic
+ * fills is not supported by the VML implementation of Internet Explorer.
+ * This method creates a olv:imagedata element inside the VML node,
+ * DXImageTransform.Matrix and BasicImage filters for rotation and
+ * opacity, and a 3-step hack to remove rendering artefacts from the
+ * graphic and preserve the ability of graphics to trigger events.
+ * Finally, OpenLayers methods are used to determine the correct
+ * insertion point of the rotated image, because DXImageTransform.Matrix
+ * does the rotation without the ability to specify a rotation center
+ * point.
+ *
+ * Parameters:
+ * node - {DOMElement}
+ * xOffset - {Number} rotation center relative to image, x coordinate
+ * yOffset - {Number} rotation center relative to image, y coordinate
+ */
+ graphicRotate: function(node, xOffset, yOffset) {
+ var style = style || node._style;
+ var options = node._options;
+
+ var aspectRatio, size;
+ if (!(style.graphicWidth && style.graphicHeight)) {
+ // load the image to determine its size
+ var img = new Image();
+ img.onreadystatechange = OpenLayers.Function.bind(function() {
+ if(img.readyState == "complete" ||
+ img.readyState == "interactive") {
+ aspectRatio = img.width / img.height;
+ size = Math.max(style.pointRadius * 2,
+ style.graphicWidth || 0,
+ style.graphicHeight || 0);
+ xOffset = xOffset * aspectRatio;
+ style.graphicWidth = size * aspectRatio;
+ style.graphicHeight = size;
+ this.graphicRotate(node, xOffset, yOffset)
+ }
+ }, this);
+ img.src = style.externalGraphic;
+
+ // will be called again by the onreadystate handler
+ return;
+ } else {
+ size = Math.max(style.graphicWidth, style.graphicHeight);
+ aspectRatio = style.graphicWidth / style.graphicHeight;
+ }
+
+ var width = Math.round(style.graphicWidth || size * aspectRatio);
+ var height = Math.round(style.graphicHeight || size);
+ node.style.width = width + "px";
+ node.style.height = height + "px";
+
+ // Three steps are required to remove artefacts for images with
+ // transparent backgrounds (resulting from using DXImageTransform
+ // filters on svg objects), while preserving awareness for browser
+ // events on images:
+ // - Use the fill as usual (like for unrotated images) to handle
+ // events
+ // - specify an imagedata element with the same src as the fill
+ // - style the imagedata element with an AlphaImageLoader filter
+ // with empty src
+ var image = document.getElementById(node.id + "_image");
+ if (!image) {
+ image = this.createNode("olv:imagedata", node.id + "_image");
+ node.appendChild(image);
+ }
+ image.style.width = width + "px";
+ image.style.height = height + "px";
+ image.src = style.externalGraphic;
+ image.style.filter =
+ "progid:DXImageTransform.Microsoft.AlphaImageLoader(" +
+ "src='', sizingMethod='scale')";
+
+ var rotation = style.rotation * Math.PI / 180;
+ var sintheta = Math.sin(rotation);
+ var costheta = Math.cos(rotation);
+
+ // do the rotation on the image
+ var filter =
+ "progid:DXImageTransform.Microsoft.Matrix(M11=" + costheta +
+ ",M12=" + (-sintheta) + ",M21=" + sintheta + ",M22=" + costheta +
+ ",SizingMethod='auto expand')\n"
+
+ // set the opacity (needed for the imagedata)
+ var opacity = style.graphicOpacity || style.fillOpacity;
+ if (opacity && opacity != 1) {
+ filter +=
+ "progid:DXImageTransform.Microsoft.BasicImage(opacity=" +
+ opacity+")\n";
+ }
+ node.style.filter = filter;
+
+ // do the rotation again on a box, so we know the insertion point
+ var centerPoint = new OpenLayers.Geometry.Point(-xOffset, -yOffset);
+ var imgBox = new OpenLayers.Bounds(0, 0, width, height).toGeometry();
+ imgBox.rotate(style.rotation, centerPoint);
+ var imgBounds = imgBox.getBounds();
+
+ node.style.left = Math.round(
+ parseInt(node.style.left) + imgBounds.left) + "px";
+ node.style.top = Math.round(
+ parseInt(node.style.top) - imgBounds.bottom) + "px";
+ },
+
+ /**
* Method: postDraw
* Some versions of Internet Explorer seem to be unable to set fillcolor
* and strokecolor to "none" correctly before the fill node is appended to
@@ -295,10 +411,10 @@
(bbox.top/resolution).toFixed());
// Set the internal coordinate system to draw the path
- node.style.left = scaledBox.left;
- node.style.top = scaledBox.top;
- node.style.width = scaledBox.getWidth();
- node.style.height = scaledBox.getHeight();
+ node.style.left = scaledBox.left + "px";
+ node.style.top = scaledBox.top + "px";
+ node.style.width = scaledBox.getWidth() + "px";
+ node.style.height = scaledBox.getHeight() + "px";
node.coordorigin = scaledBox.left + " " + scaledBox.top;
node.coordsize = scaledBox.getWidth()+ " " + scaledBox.getHeight();
@@ -414,13 +530,13 @@
if(!isNaN(geometry.x)&& !isNaN(geometry.y)) {
var resolution = this.getResolution();
- node.style.left = (geometry.x /resolution).toFixed() - radius;
- node.style.top = (geometry.y /resolution).toFixed() - radius;
+ node.style.left = ((geometry.x /resolution).toFixed() - radius) + "px";
+ node.style.top = ((geometry.y /resolution).toFixed() - radius) + "px";
var diameter = radius * 2;
- node.style.width = diameter;
- node.style.height = diameter;
+ node.style.width = diameter + "px";
+ node.style.height = diameter + "px";
}
},
@@ -522,10 +638,10 @@
drawRectangle: function(node, geometry) {
var resolution = this.getResolution();
- node.style.left = geometry.x/resolution;
- node.style.top = geometry.y/resolution;
- node.style.width = geometry.width/resolution;
- node.style.height = geometry.height/resolution;
+ node.style.left = geometry.x/resolution + "px";
+ node.style.top = geometry.y/resolution + "px";
+ node.style.width = geometry.width/resolution + "px";
+ node.style.height = geometry.height/resolution + "px";
},
/**
Modified: sandbox/camptocamp/unhcr/lib/OpenLayers/Request.js
===================================================================
--- sandbox/camptocamp/unhcr/lib/OpenLayers/Request.js 2008-06-11 13:31:59 UTC (rev 7348)
+++ sandbox/camptocamp/unhcr/lib/OpenLayers/Request.js 2008-06-11 13:48:50 UTC (rev 7349)
@@ -25,6 +25,8 @@
headers: {},
data: null,
callback: function() {},
+ success: null,
+ failure: null,
scope: null
},
@@ -36,8 +38,9 @@
* Parameters:
* config - {Object} Object containing properties for configuring the
* request. Allowed configuration properties are described below.
+ * This object is modified and should not be reused.
*
- * Properties of the config object:
+ * Allowed config properties:
* method - {String} One of GET, POST, PUT, DELETE, HEAD, or
* OPTIONS. Default is GET.
* url - {String} URL for the request.
@@ -59,6 +62,12 @@
* callback - {Function} Function to call when request is done.
* To determine if the request failed, check request.status (200
* indicates success).
+ * success - {Function} Optional function to call if request status is in
+ * the 200s. This will be called in addition to callback above and
+ * would typically only be used as an alternative.
+ * failure - {Function} Optional function to call if request status is not
+ * in the 200s. This will be called in addition to callback above and
+ * would typically only be used as an alternative.
* scope - {Object} If callback is a public method on some object,
* set the scope to that object.
*
@@ -90,18 +99,36 @@
request.setRequestHeader(header, config.headers[header]);
}
- // bind callback to readyState 4 (done)
+ // bind callbacks to readyState 4 (done)
var complete = (config.scope) ?
OpenLayers.Function.bind(config.callback, config.scope) :
config.callback;
+
+ // optional success callback
+ var success;
+ if(config.success) {
+ success = (config.scope) ?
+ OpenLayers.Function.bind(config.success, config.scope) :
+ config.success;
+ }
+
+ // optional failure callback
+ var failure;
+ if(config.failure) {
+ failure = (config.scope) ?
+ OpenLayers.Function.bind(config.failure, config.scope) :
+ config.failure;
+ }
+
request.onreadystatechange = function() {
if(request.readyState == OpenLayers.Request.XMLHttpRequest.DONE) {
- try {
- complete(request);
- } catch(exception) {
- OpenLayers.Console.error(exception);
- throw exception;
+ complete(request);
+ if(success && request.status >= 200 && request.status < 300) {
+ success(request);
}
+ if(failure && (request.status < 200 || request.status >= 300)) {
+ failure(request);
+ }
}
}
@@ -119,6 +146,7 @@
* Parameters:
* config - {Object} Object with properties for configuring the request.
* See the <issue> method for documentation of allowed properties.
+ * This object is modified and should not be reused.
*
* Returns:
* {XMLHttpRequest} Request object.
@@ -138,7 +166,7 @@
* config - {Object} Object with properties for configuring the request.
* See the <issue> method for documentation of allowed properties. The
* default "Content-Type" header will be set to "application-xml" if
- * none is provided.
+ * none is provided. This object is modified and should not be reused.
*
* Returns:
* {XMLHttpRequest} Request object.
@@ -163,7 +191,7 @@
* config - {Object} Object with properties for configuring the request.
* See the <issue> method for documentation of allowed properties. The
* default "Content-Type" header will be set to "application-xml" if
- * none is provided.
+ * none is provided. This object is modified and should not be reused.
*
* Returns:
* {XMLHttpRequest} Request object.
@@ -187,6 +215,7 @@
* Parameters:
* config - {Object} Object with properties for configuring the request.
* See the <issue> method for documentation of allowed properties.
+ * This object is modified and should not be reused.
*
* Returns:
* {XMLHttpRequest} Request object.
@@ -205,6 +234,7 @@
* Parameters:
* config - {Object} Object with properties for configuring the request.
* See the <issue> method for documentation of allowed properties.
+ * This object is modified and should not be reused.
*
* Returns:
* {XMLHttpRequest} Request object.
@@ -223,6 +253,7 @@
* Parameters:
* config - {Object} Object with properties for configuring the request.
* See the <issue> method for documentation of allowed properties.
+ * This object is modified and should not be reused.
*
* Returns:
* {XMLHttpRequest} Request object.
@@ -232,4 +263,4 @@
return OpenLayers.Request.issue(config);
}
-};
\ No newline at end of file
+};
Modified: sandbox/camptocamp/unhcr/lib/OpenLayers/Style.js
===================================================================
--- sandbox/camptocamp/unhcr/lib/OpenLayers/Style.js 2008-06-11 13:31:59 UTC (rev 7348)
+++ sandbox/camptocamp/unhcr/lib/OpenLayers/Style.js 2008-06-11 13:48:50 UTC (rev 7349)
@@ -353,4 +353,4 @@
* {Array} prefixes of the sld symbolizers. These are the
* same as the main geometry types
*/
-OpenLayers.Style.SYMBOLIZER_PREFIXES = ['Point', 'Line', 'Polygon'];
+OpenLayers.Style.SYMBOLIZER_PREFIXES = ['Point', 'Line', 'Polygon', 'Text'];
Modified: sandbox/camptocamp/unhcr/lib/OpenLayers/Tile/WFS.js
===================================================================
--- sandbox/camptocamp/unhcr/lib/OpenLayers/Tile/WFS.js 2008-06-11 13:31:59 UTC (rev 7348)
+++ sandbox/camptocamp/unhcr/lib/OpenLayers/Tile/WFS.js 2008-06-11 13:48:50 UTC (rev 7349)
@@ -5,6 +5,7 @@
/**
* @requires OpenLayers/Tile.js
+ * @requires OpenLayers/Request/XMLHttpRequest.js
*/
/**
@@ -32,7 +33,7 @@
/**
* Property: request
- * {OpenLayers.Ajax.Request}
+ * {<OpenLayers.Request.XMLHttpRequest>}
*/
request: null,
@@ -100,8 +101,7 @@
/**
* Method: loadFeaturesForRegion
- * get the full request string from the ds and the tile params
- * and call the AJAX loadURL().
+ * Abort any pending requests and issue another request for data.
*
* Input are function pointers for what to do on success and failure.
*
@@ -113,7 +113,12 @@
if(this.request) {
this.request.abort();
}
- this.request = OpenLayers.loadURL(this.url, null, this, success);
+ this.request = OpenLayers.Request.GET({
+ url: this.url,
+ success: success,
+ failure: failure,
+ scope: this
+ });
},
/**
@@ -122,7 +127,7 @@
* layer.addFeatures in vector mode, addResults otherwise.
*
* Parameters:
- * request - {XMLHttpRequest}
+ * request - {<OpenLayers.Request.XMLHttpRequest>}
*/
requestSuccess:function(request) {
if (this.features) {
Modified: sandbox/camptocamp/unhcr/lib/OpenLayers/Util.js
===================================================================
--- sandbox/camptocamp/unhcr/lib/OpenLayers/Util.js 2008-06-11 13:31:59 UTC (rev 7348)
+++ sandbox/camptocamp/unhcr/lib/OpenLayers/Util.js 2008-06-11 13:48:50 UTC (rev 7349)
@@ -49,7 +49,8 @@
* {Object} The destination object.
*/
OpenLayers.Util.extend = function(destination, source) {
- if(destination && source) {
+ destination = destination || {};
+ if(source) {
for(var property in source) {
var value = source[property];
if(value !== undefined) {
@@ -522,7 +523,7 @@
* in place and returned by this function.
*/
OpenLayers.Util.applyDefaults = function (to, from) {
-
+ to = to || {};
/*
* FF/Windows < 2.0.0.13 reports "Illegal operation on WrappedNative
* prototype object" when calling hawOwnProperty if the source object is an
@@ -1364,7 +1365,7 @@
*/
OpenLayers.Util.getRenderedDimensions = function(contentHTML, size) {
- var w = h = null;
+ var w, h;
// create temp container div with restricted size
var container = document.createElement("div");
@@ -1375,9 +1376,11 @@
//fix a dimension, if specified.
if (size) {
if (size.w) {
- w = container.style.width = size.w;
+ w = size.w;
+ container.style.width = w + "px";
} else if (size.h) {
- h = container.style.height = size.h;
+ h = size.h
+ container.style.height = h + "px";
}
}
Modified: sandbox/camptocamp/unhcr/lib/OpenLayers.js
===================================================================
--- sandbox/camptocamp/unhcr/lib/OpenLayers.js 2008-06-11 13:31:59 UTC (rev 7348)
+++ sandbox/camptocamp/unhcr/lib/OpenLayers.js 2008-06-11 13:48:50 UTC (rev 7349)
@@ -84,9 +84,9 @@
"OpenLayers/Tween.js",
"Rico/Corner.js",
"Rico/Color.js",
+ "OpenLayers/Ajax.js",
"OpenLayers/Request.js",
"OpenLayers/Request/XMLHttpRequest.js",
- "OpenLayers/Ajax.js",
"OpenLayers/Events.js",
"OpenLayers/Projection.js",
"OpenLayers/Map.js",
Modified: sandbox/camptocamp/unhcr/tests/Ajax.html
===================================================================
--- sandbox/camptocamp/unhcr/tests/Ajax.html 2008-06-11 13:31:59 UTC (rev 7348)
+++ sandbox/camptocamp/unhcr/tests/Ajax.html 2008-06-11 13:48:50 UTC (rev 7349)
@@ -4,13 +4,21 @@
<script type="text/javascript">
function test_Ajax_loadUrl(t) {
- t.plan(1);
- var req = OpenLayers.Ajax.Request;
- OpenLayers.ProxyHost = "/?url=";
- OpenLayers.Ajax.Request.prototype.request = function(uri) {
- t.eq(uri, "/?url=http%3A%2F%2Fexample.com%2F%3Fformat%3Dimage%2Bkml", "URI matches what we expect from loadurl");
- }
- OpenLayers.loadURL("http://example.com/?format=image+kml");
+ t.plan(5);
+ var _get = OpenLayers.Request.GET;
+ var caller = {};
+ var onComplete = function() {};
+ var onFailure = function() {};
+ var params = {};
+ OpenLayers.Request.GET = function(config) {
+ t.eq(config.url, "http://example.com/?format=image+kml", "correct url")
+ t.eq(config.params, params, "correct params");
+ t.eq(config.scope, caller, "correct scope");
+ t.ok(config.success === onComplete, "correct success callback");
+ t.ok(config.failure === onFailure, "correct failure callback");
+ };
+ OpenLayers.loadURL("http://example.com/?format=image+kml", params, caller, onComplete, onFailure);
+ OpenLayers.Request.GET = _get;
}
</script>
</head>
Modified: sandbox/camptocamp/unhcr/tests/Format/SLD/v1_0_0.html
===================================================================
--- sandbox/camptocamp/unhcr/tests/Format/SLD/v1_0_0.html 2008-06-11 13:31:59 UTC (rev 7348)
+++ sandbox/camptocamp/unhcr/tests/Format/SLD/v1_0_0.html 2008-06-11 13:48:50 UTC (rev 7349)
@@ -150,6 +150,42 @@
}
+ function test_writeTextSymbolizer(t) {
+ t.plan(1);
+ var parser = new OpenLayers.Format.SLD.v1_0_0();
+ var symbolizer = {
+ "Text": {
+ "label": "This is the ${city} in ${state}.",
+ "fontFamily": "Arial",
+ "fontSize": 10,
+ "fillColor": "blue"
+ }
+ };
+ var node = parser.writers["sld"]["TextSymbolizer"].apply(
+ parser, [symbolizer["Text"]]
+ );
+
+ var expected =
+ '<TextSymbolizer xmlns="http://www.opengis.net/sld">' +
+ '<Label>' +
+ 'This is the ' +
+ '<ogc:PropertyName xmlns:ogc="http://www.opengis.net/ogc">city</ogc:PropertyName>' +
+ ' in ' +
+ '<ogc:PropertyName xmlns:ogc="http://www.opengis.net/ogc">state</ogc:PropertyName>' +
+ '.' +
+ '</Label>' +
+ '<Font>' +
+ '<CssParameter name="font-family">Arial</CssParameter>' +
+ '<CssParameter name="font-size">10</CssParameter>' +
+ '</Font>' +
+ '<Fill>' +
+ '<CssParameter name="fill">blue</CssParameter>' +
+ '</Fill>' +
+ '</TextSymbolizer>';
+
+ t.xml_eq(node, expected, "TextSymbolizer correctly written");
+
+ }
</script>
</head>
Modified: sandbox/camptocamp/unhcr/tests/Renderer/VML.html
===================================================================
--- sandbox/camptocamp/unhcr/tests/Renderer/VML.html 2008-06-11 13:31:59 UTC (rev 7348)
+++ sandbox/camptocamp/unhcr/tests/Renderer/VML.html 2008-06-11 13:48:50 UTC (rev 7349)
@@ -143,7 +143,48 @@
t.eq(node.style.width, (2 * radius) + "px", "width is correct");
t.eq(node.style.height, (2 * radius) + "px", "height is correct");
}
+
+ function test_VML_drawGraphic(t) {
+ if (!OpenLayers.Renderer.VML.prototype.supported()) {
+ t.plan(0);
+ return;
+ }
+
+ t.plan(6);
+
+ var r = new OpenLayers.Renderer.VML(document.body);
+ r.resolution = 1;
+
+ var node = document.createElement('div');
+ node.id = "test"
+ node._geometryClass = "OpenLayers.Geometry.Point";
+
+ var geometry = {
+ x: 1,
+ y: 2
+ }
+
+ var style = {
+ externalGraphic: "foo.png",
+ graphicWidth: 7,
+ graphicHeight: 10
+ }
+
+ r.drawGeometryNode(node, geometry, style);
+ t.eq(node.childNodes[0].id, "test_fill", "fill child node correctly created");
+ t.eq(node.style.left, "-3px", "x of insertion point with calculated xOffset correct");
+ t.eq(node.style.top, "-3px", "y of insertion point with calculated yOffset correct");
+
+ style.rotation = 90;
+
+ r.drawGeometryNode(node, geometry, style);
+
+ t.eq(node.childNodes[1].id, "test_image", "image child node correctly created");
+ t.eq(node.style.left, "-4px", "x of insertion point of rotated image correct");
+ t.eq(node.style.top, "-4px", "y of insertion point of rotated image correct");
+ }
+
function test_VML_drawlinestring(t) {
if (!OpenLayers.Renderer.VML.prototype.supported()) {
t.plan(0);
Copied: sandbox/camptocamp/unhcr/tests/Request (from rev 7348, sandbox/vector-behavior/tests/Request)
Deleted: sandbox/camptocamp/unhcr/tests/Request/XMLHttpRequest.html
===================================================================
--- sandbox/vector-behavior/tests/Request/XMLHttpRequest.html 2008-06-11 13:31:59 UTC (rev 7348)
+++ sandbox/camptocamp/unhcr/tests/Request/XMLHttpRequest.html 2008-06-11 13:48:50 UTC (rev 7349)
@@ -1,14 +0,0 @@
-<html>
-<head>
- <script src="../../lib/OpenLayers.js"></script>
- <script type="text/javascript">
- function test_constructor(t) {
- t.plan(1);
- t.ok(new OpenLayers.Request.XMLHttpRequest(),
- "constructor didn't fail and we trust the code is well tested in OpenLayers.Request methods");
- }
- </script>
-</head>
-<body>
-</body>
-</html>
Copied: sandbox/camptocamp/unhcr/tests/Request/XMLHttpRequest.html (from rev 7348, sandbox/vector-behavior/tests/Request/XMLHttpRequest.html)
===================================================================
--- sandbox/camptocamp/unhcr/tests/Request/XMLHttpRequest.html (rev 0)
+++ sandbox/camptocamp/unhcr/tests/Request/XMLHttpRequest.html 2008-06-11 13:48:50 UTC (rev 7349)
@@ -0,0 +1,14 @@
+<html>
+<head>
+ <script src="../../lib/OpenLayers.js"></script>
+ <script type="text/javascript">
+ function test_constructor(t) {
+ t.plan(1);
+ t.ok(new OpenLayers.Request.XMLHttpRequest(),
+ "constructor didn't fail and we trust the code is well tested in OpenLayers.Request methods");
+ }
+ </script>
+</head>
+<body>
+</body>
+</html>
Copied: sandbox/camptocamp/unhcr/tests/Request.html (from rev 7348, sandbox/vector-behavior/tests/Request.html)
===================================================================
--- sandbox/camptocamp/unhcr/tests/Request.html (rev 0)
+++ sandbox/camptocamp/unhcr/tests/Request.html 2008-06-11 13:48:50 UTC (rev 7349)
@@ -0,0 +1,204 @@
+<html>
+<head>
+ <script src="../lib/OpenLayers.js"></script>
+ <script type="text/javascript">
+ function setup() {
+ window._xhr = OpenLayers.Request.XMLHttpRequest;
+ var anon = new Function();
+ OpenLayers.Request.XMLHttpRequest = function() {};
+ OpenLayers.Request.XMLHttpRequest.prototype = {
+ open: anon,
+ setRequestHeader: anon,
+ send: anon
+ };
+ OpenLayers.Request.XMLHttpRequest.DONE = 4;
+ }
+ function teardown() {
+ OpenLayers.Request.XMLHttpRequest = window._xhr;
+ }
+
+ function test_issue(t) {
+ setup();
+
+ t.plan(18);
+ var request, config;
+ var proto = OpenLayers.Request.XMLHttpRequest.prototype;
+ var issue = OpenLayers.Function.bind(OpenLayers.Request.issue,
+ OpenLayers.Request);
+
+ // test that issue returns a new XMLHttpRequest - 1 test
+ request = issue();
+ t.ok(request instanceof OpenLayers.Request.XMLHttpRequest,
+ "returns an XMLHttpRequest instance");
+
+ // test that issue calls xhr.open with correct args from config - 5 tests
+ var _open = proto.open;
+ config = {
+ method: "foo",
+ url: "http://nowhere",
+ async: "bar",
+ user: "uncle",
+ password: "sam"
+ };
+ proto.open = function(method, url, async, user, password) {
+ t.eq(method, config.method, "open called with correct method");
+ t.eq(url, config.url, "open called with correct url");
+ t.eq(async, config.async, "open called with correct async");
+ t.eq(user, config.user, "open called with correct user");
+ t.eq(password, config.password, "open called with correct password");
+ }
+ request = issue(config);
+ proto.open = _open;
+
+ // test that headers are correctly set - 4 tests
+ var _setRequestHeader = proto.setRequestHeader;
+ config = {
+ headers: {
+ foo: "bar",
+ chicken: "soup"
+ }
+ };
+ proto.setRequestHeader = function(key, value) {
+ t.ok(key in config.headers, "setRequestHeader called with key: " + key);
+ t.eq(value, config.headers[key], "setRequestHeader called with correct value: " + value);
+ }
+ request = issue(config);
+ proto.setRequestHeader = _setRequestHeader;
+
+ // test that callback is called (no scope) - 1 test
+ var unbound = function(request) {
+ t.ok(request instanceof OpenLayers.Request.XMLHttpRequest,
+ "unbound callback called with xhr instance");
+ }
+ config = {
+ callback: unbound
+ };
+ request = issue(config);
+ request.readyState = OpenLayers.Request.XMLHttpRequest.DONE;
+ request.onreadystatechange();
+
+ // test that callback is called (with scope) - 2 tests
+ var obj = {};
+ var bound = function(request) {
+ t.ok(this === obj, "bound callback has correct scope");
+ t.ok(request instanceof OpenLayers.Request.XMLHttpRequest,
+ "bound callback called with xhr instance");
+ }
+ config = {
+ callback: bound,
+ scope: obj
+ };
+ request = issue(config);
+ request.readyState = 4;
+ request.onreadystatechange();
+
+ // test that send is called with data - 1 test
+ var _send = proto.send;
+ config = {
+ method: "PUT",
+ data: "bling"
+ };
+ proto.send = function(data) {
+ t.eq(data, config.data, "send called with correct data");
+ }
+ request = issue(config);
+ proto.send = _send;
+
+ // test that optional success callback is only called with 200s and
+ // failure is only called with non-200s
+ var _send = proto.send;
+ proto.send = function() {};
+
+ config = {
+ success: function(req) {
+ t.ok(req.status >= 200 && req.status < 300,
+ "success callback called with " + req.status + " status");
+ },
+ failure: function(req) {
+ t.ok(req.status < 200 || req.status >= 300,
+ "failure callback called with " + req.status + " status");
+ }
+ };
+ request = issue(config);
+ request.readyState = 4;
+
+ // mock up status 200 (1 test)
+ request.status = 200;
+ request.onreadystatechange();
+
+ // mock up status 299 (1 test)
+ request.status = 299;
+ request.onreadystatechange();
+
+ // mock up status 100 (1 test)
+ request.status = 100;
+ request.onreadystatechange();
+
+ // mock up status 300 (1 test)
+ request.status = 300;
+ request.onreadystatechange();
+
+ proto.send = _send;
+
+ teardown();
+ }
+
+ function test_GET(t) {
+ t.plan(1);
+ var _issue = OpenLayers.Request.issue;
+ OpenLayers.Request.issue = function(config) {
+ t.eq(config.method, "GET", "calls issue with correct method");
+ }
+ OpenLayers.Request.GET();
+ OpenLayers.Request.issue = _issue;
+ }
+ function test_POST(t) {
+ t.plan(1);
+ var _issue = OpenLayers.Request.issue;
+ OpenLayers.Request.issue = function(config) {
+ t.eq(config.method, "POST", "calls issue with correct method");
+ }
+ OpenLayers.Request.POST();
+ OpenLayers.Request.issue = _issue;
+ }
+ function test_PUT(t) {
+ t.plan(1);
+ var _issue = OpenLayers.Request.issue;
+ OpenLayers.Request.issue = function(config) {
+ t.eq(config.method, "PUT", "calls issue with correct method");
+ }
+ OpenLayers.Request.PUT();
+ OpenLayers.Request.issue = _issue;
+ }
+ function test_DELETE(t) {
+ t.plan(1);
+ var _issue = OpenLayers.Request.issue;
+ OpenLayers.Request.issue = function(config) {
+ t.eq(config.method, "DELETE", "calls issue with correct method");
+ }
+ OpenLayers.Request.DELETE();
+ OpenLayers.Request.issue = _issue;
+ }
+ function test_HEAD(t) {
+ t.plan(1);
+ var _issue = OpenLayers.Request.issue;
+ OpenLayers.Request.issue = function(config) {
+ t.eq(config.method, "HEAD", "calls issue with correct method");
+ }
+ OpenLayers.Request.HEAD();
+ OpenLayers.Request.issue = _issue;
+ }
+ function test_OPTIONS(t) {
+ t.plan(1);
+ var _issue = OpenLayers.Request.issue;
+ OpenLayers.Request.issue = function(config) {
+ t.eq(config.method, "OPTIONS", "calls issue with correct method");
+ }
+ OpenLayers.Request.OPTIONS();
+ OpenLayers.Request.issue = _issue;
+ }
+ </script>
+</head>
+<body>
+</body>
+</html>
Modified: sandbox/camptocamp/unhcr/tests/Tile/WFS.html
===================================================================
--- sandbox/camptocamp/unhcr/tests/Tile/WFS.html 2008-06-11 13:31:59 UTC (rev 7348)
+++ sandbox/camptocamp/unhcr/tests/Tile/WFS.html 2008-06-11 13:48:50 UTC (rev 7349)
@@ -64,12 +64,12 @@
var g_Success = {};
- var tLoadURL = OpenLayers.loadURL;
- OpenLayers.loadURL = function(url, params, caller, onComplete) {
- t.ok(url == tile.url, "tile's url correctly passed as 1st param to loadURL");
- t.ok(params == null, "null passed as 2nd param to loadURL");
- t.ok(caller == tile, "tile passed as 3rd param to loadURL");
- t.ok(onComplete == g_Success, "success param from loadFeaturesForRegion() passed as 4th param to loadURL");
+ var _get = OpenLayers.Request.GET;
+ OpenLayers.Request.GET = function(config) {
+ t.ok(config.url == tile.url, "tile's url correctly passed");
+ t.ok(config.params == null, "null params");
+ t.ok(config.scope == tile, "tile passed as scope");
+ t.ok(config.success == g_Success, "success passed");
};
//no running request -- 4 tests
@@ -82,8 +82,8 @@
}
};
OpenLayers.Tile.WFS.prototype.loadFeaturesForRegion.apply(tile, [g_Success]);
-
- OpenLayers.loadURL = tLoadURL;
+
+ OpenLayers.Request.GET = _get;
}
function test_Tile_WFS_destroy(t) {
Modified: sandbox/camptocamp/unhcr/tests/Util.html
===================================================================
--- sandbox/camptocamp/unhcr/tests/Util.html 2008-06-11 13:31:59 UTC (rev 7348)
+++ sandbox/camptocamp/unhcr/tests/Util.html 2008-06-11 13:48:50 UTC (rev 7349)
@@ -169,7 +169,7 @@
function test_Util_applyDefaults(t) {
- t.plan(10);
+ t.plan(11);
var to = {
'a': "abra",
@@ -198,6 +198,12 @@
t.eq( ret["c"], "press", "key present in from and not ret successfully copied to ret");
t.eq(to.toString(), "works", "correctly applies custom toString");
t.eq(to.n, null, "correctly preserves null");
+
+ var to;
+ var from = {rand: Math.random()};
+
+ var ret = OpenLayers.Util.applyDefaults(to, from);
+ t.eq(ret.rand, from.rand, "works with undefined to");
}
function test_Util_getParameterString(t) {
@@ -400,7 +406,7 @@
}
function test_Util_modifyAlphaImageDiv(t) {
- t.plan( 20 );
+ t.plan( 21 );
var imageDiv = OpenLayers.Util.createAlphaImageDiv();
@@ -484,7 +490,11 @@
var display = "block";
imageDiv.style.display = display;
OpenLayers.Util.modifyAlphaImageDiv(imageDiv, id, xy, sz, img, position, border, sizing, opacity);
- t.eq(imageDiv.style.display, "inline-block", "imageDiv.style.display set correctly, if not 'none'");
+ if(OpenLayers.Util.alphaHack()) {
+ t.eq(imageDiv.style.display, "inline-block", "imageDiv.style.display set correctly, if not 'none'");
+ } else {
+ t.ok(true, "inline-block is not part of CSS2 and is not supported by Firefox 2");
+ }
@@ -705,7 +715,7 @@
}
function tests_Util_extend(t) {
- t.plan(6);
+ t.plan(7);
var source = {
num: Math.random(),
@@ -732,6 +742,12 @@
t.eq(destination.nada, "untouched",
"undefined source properties don't clobber existing properties");
t.eq(window.property, undefined, "Property variable not clobbered.");
+
+ var destination;
+ var source = {rand: Math.random()};
+ var ret = OpenLayers.Util.extend(destination, source);
+ t.eq(destination.rand, source.rand, "works with undefined destination");
+
}
function test_XX_Util_Try(t) {
@@ -766,6 +782,20 @@
t.ok(ret == g_TestVal3, "try returns first sucessfully executed function's return");
}
+
+ function test_getRenderedDimensions(t) {
+ t.plan(2);
+ var content = (new Array(100)).join("foo ");
+
+ // test with fixed width
+ var fw = OpenLayers.Util.getRenderedDimensions(content, {w: 20});
+ t.eq(fw.w, 20, "got the fixed width");
+
+ // test with fixed height
+ var fh = OpenLayers.Util.getRenderedDimensions(content, {h: 15});
+ t.eq(fh.h, 15, "got the fixed height");
+
+ }
</script>
</head>
Modified: sandbox/camptocamp/unhcr/tests/list-tests.html
===================================================================
--- sandbox/camptocamp/unhcr/tests/list-tests.html 2008-06-11 13:31:59 UTC (rev 7348)
+++ sandbox/camptocamp/unhcr/tests/list-tests.html 2008-06-11 13:48:50 UTC (rev 7349)
@@ -61,6 +61,8 @@
<li>Lang.html</li>
<li>Layer.html</li>
<li>Renderer.html</li>
+ <li>Request.html</li>
+ <li>Request/XMLHttpRequest.html</li>
<li>Strategy/Save.html</li>
<li>Layer/EventPane.html</li>
<li>Layer/FixedZoomLevels.html</li>
Modified: sandbox/camptocamp/unhcr/tests/manual/ajax.html
===================================================================
--- sandbox/camptocamp/unhcr/tests/manual/ajax.html 2008-06-11 13:31:59 UTC (rev 7348)
+++ sandbox/camptocamp/unhcr/tests/manual/ajax.html 2008-06-11 13:48:50 UTC (rev 7349)
@@ -1,70 +1,49 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
- <title>Ajax Acceptance Test</title>
- <style type="text/css">
-
- body {
- font-size: 0.8em;
- }
- p {
- padding-top: 1em;
- }
-
- .buttons {
- margin: 1em;
- float: left;
- }
-
- </style>
-
+ <title>XHR Acceptance Test</title>
<script src="../../lib/OpenLayers.js"></script>
<script type="text/javascript">
var url = "ajax.txt";
function sendSynchronous(){
- var request = new OpenLayers.Ajax.Request(url, {
- 'asynchronous': false,
- onComplete: function() {
+ var request = OpenLayers.Request.GET({
+ url: url,
+ async: false,
+ callback: function() {
document.getElementById('send_sync').value += 'request completed\n';
}
});
document.getElementById('send_sync').value += 'other processing\n';
}
function sendAsynchronous(){
- var request = new OpenLayers.Ajax.Request(url, {
- onComplete: function() {
+ var request = OpenLayers.Request.GET({
+ url: url,
+ callback: function() {
document.getElementById('send_sync').value += 'request completed\n';
}
});
document.getElementById('send_sync').value += 'other processing\n';
}
function sendAndAbort(){
- var request = new OpenLayers.Ajax.Request(url, {
- onComplete: function(request) {
- if (request.responseText == '') {
- document.getElementById('send_sync').value += 'request aborted\n';
- }
+ var request = OpenLayers.Request.GET({
+ url: url,
+ callback: function() {
+ document.getElementById('send_sync').value += 'never called\n';
}
});
- request.transport.abort();
+ request.abort();
document.getElementById('send_sync').value += 'other processing\n';
}
- </script>
- </head>
- <body >
- <div class="buttons">
- <button onclick="sendSynchronous()">Send an synchronous Ajax request</button><br />
- <button onclick="sendAsynchronous()">Send an asynchronous Ajax request</button><br />
- <button onclick="sendAndAbort()">Send a request and abort it</button><br />
+ </script>
+ </head>
+ <body >
+ <button onclick="sendSynchronous()">synchronous</button>
+ expected output: "request completed" then "other processing"<br />
+ <button onclick="sendAsynchronous()">asynchronous</button>
+ expected output: "other processing" then "request completed"<br />
+ <button onclick="sendAndAbort()">send and abort</button>
+ expected output: "other processing" (and not "never called")<br />
<textarea id="send_sync" rows="6"></textarea><br />
<button onclick="document.getElementById('send_sync').value = ''">Clear</button>
- </div>
- <p><b></b></p>
- <p>Clicking on the different buttons should give the following results in the textarea below :</p>
- <ul>
- <li>synchronous: "request completed" then "other processing"</li>
- <li>asynchronous: "other processing" then "request completed"</li>
- <li>abort: "request aborted" then "other processing" (note that real XHR behavior would not call onComplete with abort - meaning "request aborted" would not be displayed here)</li>
- </ul>
</body>
</html>
Modified: sandbox/camptocamp/unhcr/tests/xml_eq.js
===================================================================
--- sandbox/camptocamp/unhcr/tests/xml_eq.js 2008-06-11 13:31:59 UTC (rev 7348)
+++ sandbox/camptocamp/unhcr/tests/xml_eq.js 2008-06-11 13:48:50 UTC (rev 7349)
@@ -83,7 +83,7 @@
expected = "null";
}
if(got != expected) {
- throw msg + ": got " + got + " but expected " + expected;
+ throw msg + ": got '" + got + "' but expected '" + expected + "'";
}
}
More information about the Commits
mailing list