From e8af06e6ae805bee7cf3acacca869fddb96dd561 Mon Sep 17 00:00:00 2001 From: Peter Robins Date: Tue, 6 Mar 2012 11:30:28 +0000 Subject: [PATCH 1/7] Improve docs for bounds/lonlat as array --- lib/OpenLayers/BaseTypes/Bounds.js | 8 +++- lib/OpenLayers/BaseTypes/LonLat.js | 8 +++- lib/OpenLayers/Layer.js | 10 ++++- lib/OpenLayers/Map.js | 64 +++++++++++++++++++++--------- 4 files changed, 66 insertions(+), 24 deletions(-) diff --git a/lib/OpenLayers/BaseTypes/Bounds.js b/lib/OpenLayers/BaseTypes/Bounds.js index 5dd6d2c906..a4fee70554 100644 --- a/lib/OpenLayers/BaseTypes/Bounds.js +++ b/lib/OpenLayers/BaseTypes/Bounds.js @@ -56,15 +56,19 @@ OpenLayers.Bounds = OpenLayers.Class({ /** * Constructor: OpenLayers.Bounds - * Construct a new bounds object. + * Construct a new bounds object. Coordinates can either be passed as four + * arguments, or as a single argument. * - * Parameters: + * Parameters (four arguments): * left - {Number} The left bounds of the box. Note that for width * calculations, this is assumed to be less than the right value. * bottom - {Number} The bottom bounds of the box. Note that for height * calculations, this is assumed to be more than the top value. * right - {Number} The right bounds. * top - {Number} The top bounds. + * + * Parameters (single argument): + * bounds - {Array(Number)} [left, bottom, right, top] */ initialize: function(left, bottom, right, top) { if (OpenLayers.Util.isArray(left)) { diff --git a/lib/OpenLayers/BaseTypes/LonLat.js b/lib/OpenLayers/BaseTypes/LonLat.js index 243e75338d..ed274225c4 100644 --- a/lib/OpenLayers/BaseTypes/LonLat.js +++ b/lib/OpenLayers/BaseTypes/LonLat.js @@ -27,15 +27,19 @@ OpenLayers.LonLat = OpenLayers.Class({ /** * Constructor: OpenLayers.LonLat - * Create a new map location. + * Create a new map location. Coordinates can be passed either as two + * arguments, or as a single argument. * - * Parameters: + * Parameters (two arguments): * lon - {Number} The x-axis coordinate in map units. If your map is in * a geographic projection, this will be the Longitude. Otherwise, * it will be the x coordinate of the map location in your map units. * lat - {Number} The y-axis coordinate in map units. If your map is in * a geographic projection, this will be the Latitude. Otherwise, * it will be the y coordinate of the map location in your map units. + * + * Parameters (single argument): + * location - {Array(Float)} [lon, lat] */ initialize: function(lon, lat) { if (OpenLayers.Util.isArray(lon)) { diff --git a/lib/OpenLayers/Layer.js b/lib/OpenLayers/Layer.js index 788b6e7633..cbaf8e5c16 100644 --- a/lib/OpenLayers/Layer.js +++ b/lib/OpenLayers/Layer.js @@ -229,7 +229,11 @@ OpenLayers.Layer = OpenLayers.Class({ /** * APIProperty: maxExtent - * {} The center of these bounds will not stray outside + * {|Array} If provided as an array, the array + * should consist of four values (left, bottom, right, top). + * The maximum extent for the layer. Defaults to null. + * + * The center of these bounds will not stray outside * of the viewport extent during panning. In addition, if * is set to false, data will not be * requested that falls completely outside of these bounds. @@ -238,7 +242,9 @@ OpenLayers.Layer = OpenLayers.Class({ /** * APIProperty: minExtent - * {} + * {|Array} If provided as an array, the array + * should consist of four values (left, bottom, right, top). + * The minimum extent for the layer. Defaults to null. */ minExtent: null, diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index 016c4110b8..2203e65428 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -307,7 +307,9 @@ OpenLayers.Map = OpenLayers.Class({ /** * APIProperty: maxExtent - * {} The maximum extent for the map. Defaults to the + * {|Array} If provided as an array, the array + * should consist of four values (left, bottom, right, top). + * The maximum extent for the map. Defaults to the * whole world in decimal degrees (-180, -90, 180, 90). Specify a * different extent in the map options if you are not using a geographic * projection and displaying the whole world. To restrict user panning @@ -318,13 +320,17 @@ OpenLayers.Map = OpenLayers.Class({ /** * APIProperty: minExtent - * {} + * {|Array} If provided as an array, the array + * should consist of four values (left, bottom, right, top). + * The minimum extent for the map. Defaults to null. */ minExtent: null, /** * APIProperty: restrictedExtent - * {} Limit map navigation to this extent where possible. + * {|Array} If provided as an array, the array + * should consist of four values (left, bottom, right, top). + * Limit map navigation to this extent where possible. * If a non-null restrictedExtent is set, panning will be restricted * to the given bounds. In addition, zooming to a resolution that * displays more than the restricted extent will center the map @@ -436,6 +442,24 @@ OpenLayers.Map = OpenLayers.Class({ * provided or if you intend to call the method later. * options - {Object} Optional object with properties to tag onto the map. * + * Valid options (in addition to the listed API properties): + * center - {|Array} The default initial center of the map. + * If provided as array, the first value is the x coordinate, + * and the 2nd value is the y coordinate. + * Only specify if is provided. + * Note that if an ArgParser/Permalink control is present, + * and the querystring contains coordinates, center will be set + * by that, and this option will be ignored. + * zoom - {Number} The initial zoom level for the map. Only specify if + * is provided. + * Note that if an ArgParser/Permalink control is present, + * and the querystring contains a zoom level, zoom will be set + * by that, and this option will be ignored. + * extent - {|Array} The initial extent of the map. + * If provided as an array, the array should consist of + * four values (left, bottom, right, top). + * Only specify if
and are not provided. + * * Examples: * (code) * // create a map with default options in an element with the id "map1" @@ -443,28 +467,26 @@ OpenLayers.Map = OpenLayers.Class({ * * // create a map with non-default options in an element with id "map2" * var options = { + * projection: "EPSG:3857", * maxExtent: new OpenLayers.Bounds(-200000, -200000, 200000, 200000), - * maxResolution: 156543, - * units: 'm', - * projection: "EPSG:41001" + * center: new OpenLayers.LonLat(-12356463.476333, 5621521.4854095) * }; * var map = new OpenLayers.Map("map2", options); * - * // map with non-default options - same as above but with a single argument + * // map with non-default options - same as above but with a single argument, + * // a restricted extent, and using arrays for bounds and center * var map = new OpenLayers.Map({ * div: "map_id", - * maxExtent: new OpenLayers.Bounds(-200000, -200000, 200000, 200000), - * maxResolution: 156543, - * units: 'm', - * projection: "EPSG:41001" + * projection: "EPSG:3857", + * maxExtent: [-18924313.432222, -15538711.094146, 18924313.432222, 15538711.094146], + * restrictedExtent: [-13358338.893333, -9608371.5085962, 13358338.893333, 9608371.5085962], + * center: [-12356463.476333, 5621521.4854095] * }); * * // create a map without a reference to a container - call render later * var map = new OpenLayers.Map({ - * maxExtent: new OpenLayers.Bounds(-200000, -200000, 200000, 200000), - * maxResolution: 156543, - * units: 'm', - * projection: "EPSG:41001" + * projection: "EPSG:3857", + * maxExtent: new OpenLayers.Bounds(-200000, -200000, 200000, 200000) * }); * (end) */ @@ -500,6 +522,9 @@ OpenLayers.Map = OpenLayers.Class({ if (this.maxExtent && !(this.maxExtent instanceof OpenLayers.Bounds)) { this.maxExtent = new OpenLayers.Bounds(this.maxExtent); } + if (this.minExtent && !(this.minExtent instanceof OpenLayers.Bounds)) { + this.minExtent = new OpenLayers.Bounds(this.minExtent); + } if (this.restrictedExtent && !(this.restrictedExtent instanceof OpenLayers.Bounds)) { this.restrictedExtent = new OpenLayers.Bounds(this.restrictedExtent); } @@ -622,7 +647,7 @@ OpenLayers.Map = OpenLayers.Class({ if (options && options.layers) { /** * If you have set options.center, the map center property will be - * set at this point. However, since setCenter has not been caleld, + * set at this point. However, since setCenter has not been called, * addLayers gets confused. So we delete the map center in this * case. Because the check below uses options.center, it will * be properly set below. @@ -1659,7 +1684,9 @@ OpenLayers.Map = OpenLayers.Class({ * Set the map center (and optionally, the zoom level). * * Parameters: - * lonlat - {} The new center location. + * lonlat - {|Array} The new center location. + * If provided as array, the first value is the x coordinate, + * and the 2nd value is the y coordinate. * zoom - {Integer} Optional zoom level. * dragging - {Boolean} Specifies whether or not to trigger * movestart/end events @@ -2279,7 +2306,8 @@ OpenLayers.Map = OpenLayers.Class({ * Zoom to the passed in bounds, recenter * * Parameters: - * bounds - {} + * bounds - {|Array} If provided as an array, the array + * should consist of four values (left, bottom, right, top). * closest - {Boolean} Find the zoom level that most closely fits the * specified bounds. Note that this may result in a zoom that does * not exactly contain the entire extent. From 5d9791133eea42c5a2edb5542d3a72737b0bb9ee Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Thu, 8 Mar 2012 15:47:43 +0100 Subject: [PATCH 2/7] do not output graphic inside of textsymbolizer if graphic is set to false --- lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js | 2 +- tests/Format/SLD/v1_0_0_GeoServer.html | 68 ++++++++++++++++++- 2 files changed, 67 insertions(+), 3 deletions(-) diff --git a/lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js b/lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js index bee661311b..ed3b958a1b 100644 --- a/lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js +++ b/lib/OpenLayers/Format/SLD/v1_0_0_GeoServer.js @@ -87,7 +87,7 @@ OpenLayers.Format.SLD.v1_0_0_GeoServer = OpenLayers.Class( "TextSymbolizer": function(symbolizer) { var writers = OpenLayers.Format.SLD.v1_0_0.prototype.writers; var node = writers["sld"]["TextSymbolizer"].apply(this, arguments); - if (symbolizer.externalGraphic || symbolizer.graphicName) { + if (symbolizer.graphic !== false && (symbolizer.externalGraphic || symbolizer.graphicName)) { this.writeNode("Graphic", symbolizer, node); } if ("priority" in symbolizer) { diff --git a/tests/Format/SLD/v1_0_0_GeoServer.html b/tests/Format/SLD/v1_0_0_GeoServer.html index bfe9b3ec4a..4eecb7195d 100644 --- a/tests/Format/SLD/v1_0_0_GeoServer.html +++ b/tests/Format/SLD/v1_0_0_GeoServer.html @@ -14,7 +14,7 @@ "poly_label.sld" ]; var len = cases.length; - t.plan(len); + t.plan(len+1); var format = new OpenLayers.Format.SLD({ profile: "GeoServer", @@ -31,7 +31,11 @@ out = format.write(data); t.xml_eq(out, doc.documentElement, "round-tripped " + c); } - + doc = readXML("poly_label.sld"); + data = format.read(doc); + data.namedLayers[0].userStyles[0].rules[0].symbolizers[1].graphic = false; + out = format.write(data); + t.xml_eq(out, readXML("poly_label_nographic.sld").documentElement, "If graphic if false no Graphic is outputted"); } @@ -110,5 +114,65 @@ --> +
From 9707a388c357f086df643ba412d1a1441cedf113 Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Thu, 8 Mar 2012 15:52:03 +0100 Subject: [PATCH 3/7] typo --- tests/Format/SLD/v1_0_0_GeoServer.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Format/SLD/v1_0_0_GeoServer.html b/tests/Format/SLD/v1_0_0_GeoServer.html index 4eecb7195d..8793d59f14 100644 --- a/tests/Format/SLD/v1_0_0_GeoServer.html +++ b/tests/Format/SLD/v1_0_0_GeoServer.html @@ -35,7 +35,7 @@ data = format.read(doc); data.namedLayers[0].userStyles[0].rules[0].symbolizers[1].graphic = false; out = format.write(data); - t.xml_eq(out, readXML("poly_label_nographic.sld").documentElement, "If graphic if false no Graphic is outputted"); + t.xml_eq(out, readXML("poly_label_nographic.sld").documentElement, "If graphic is false no Graphic is outputted"); } From 636ac640ca78fb3077e189b770622d3dc71e2951 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Thu, 8 Mar 2012 16:26:26 +0100 Subject: [PATCH 4/7] Don't test VML if SVG is also supported. The VML renderer does not work in IE9 standards mode, and SVG takes precedence over VML. So it is safe to skip these tests if both VML and SVG report "supported". See #285 --- tests/Renderer/VML.html | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/Renderer/VML.html b/tests/Renderer/VML.html index f383848cf4..2bdc876dfc 100644 --- a/tests/Renderer/VML.html +++ b/tests/Renderer/VML.html @@ -6,7 +6,7 @@ var geometry = null, node = null; function test_VML_constructor(t) { - if (!OpenLayers.Renderer.VML.prototype.supported()) { + if (!OpenLayers.Renderer.VML.prototype.supported() || OpenLayers.Renderer.SVG.prototype.supported()) { t.plan(0); return; } @@ -17,7 +17,7 @@ } function test_VML_destroy(t) { - if (!OpenLayers.Renderer.VML.prototype.supported()) { + if (!OpenLayers.Renderer.VML.prototype.supported() || OpenLayers.Renderer.SVG.prototype.supported()) { t.plan(0); return; } @@ -43,7 +43,7 @@ } function test_VML_setextent(t) { - if (!OpenLayers.Renderer.VML.prototype.supported()) { + if (!OpenLayers.Renderer.VML.prototype.supported() || OpenLayers.Renderer.SVG.prototype.supported()) { t.plan(0); return; } @@ -80,7 +80,7 @@ } function test_VML_setsize(t) { - if (!OpenLayers.Renderer.VML.prototype.supported()) { + if (!OpenLayers.Renderer.VML.prototype.supported() || OpenLayers.Renderer.SVG.prototype.supported()) { t.plan(0); return; } @@ -99,7 +99,7 @@ } function test_VML_drawText(t) { - if (!OpenLayers.Renderer.VML.prototype.supported()) { + if (!OpenLayers.Renderer.VML.prototype.supported() || OpenLayers.Renderer.SVG.prototype.supported()) { t.plan(0); return; } @@ -128,7 +128,7 @@ } function test_VML_drawpoint(t) { - if (!OpenLayers.Renderer.VML.prototype.supported()) { + if (!OpenLayers.Renderer.VML.prototype.supported() || OpenLayers.Renderer.SVG.prototype.supported()) { t.plan(0); return; } @@ -149,7 +149,7 @@ } function test_VML_drawcircle(t) { - if (!OpenLayers.Renderer.VML.prototype.supported()) { + if (!OpenLayers.Renderer.VML.prototype.supported() || OpenLayers.Renderer.SVG.prototype.supported()) { t.plan(0); return; } @@ -177,7 +177,7 @@ } function test_VML_drawGraphic(t) { - if (!OpenLayers.Renderer.VML.prototype.supported()) { + if (!OpenLayers.Renderer.VML.prototype.supported() || OpenLayers.Renderer.SVG.prototype.supported()) { t.plan(0); return; } @@ -219,7 +219,7 @@ } function test_VML_drawlinestring(t) { - if (!OpenLayers.Renderer.VML.prototype.supported()) { + if (!OpenLayers.Renderer.VML.prototype.supported() || OpenLayers.Renderer.SVG.prototype.supported()) { t.plan(0); return; } @@ -239,7 +239,7 @@ } function test_VML_drawlinearring(t) { - if (!OpenLayers.Renderer.VML.prototype.supported()) { + if (!OpenLayers.Renderer.VML.prototype.supported() || OpenLayers.Renderer.SVG.prototype.supported()) { t.plan(0); return; } @@ -259,7 +259,7 @@ } function test_VML_drawline(t) { - if (!OpenLayers.Renderer.VML.prototype.supported()) { + if (!OpenLayers.Renderer.VML.prototype.supported() || OpenLayers.Renderer.SVG.prototype.supported()) { t.plan(0); return; } @@ -300,7 +300,7 @@ } function test_VML_drawpolygon(t) { - if (!OpenLayers.Renderer.VML.prototype.supported()) { + if (!OpenLayers.Renderer.VML.prototype.supported() || OpenLayers.Renderer.SVG.prototype.supported()) { t.plan(0); return; } @@ -331,7 +331,7 @@ } function test_VML_drawrectangle(t) { - if (!OpenLayers.Renderer.VML.prototype.supported()) { + if (!OpenLayers.Renderer.VML.prototype.supported() || OpenLayers.Renderer.SVG.prototype.supported()) { t.plan(0); return; } @@ -360,7 +360,7 @@ } function test_vml_getnodetype(t) { - if (!OpenLayers.Renderer.VML.prototype.supported()) { + if (!OpenLayers.Renderer.VML.prototype.supported() || OpenLayers.Renderer.SVG.prototype.supported()) { t.plan(0); return; } @@ -376,7 +376,7 @@ } function test_vml_importsymbol(t) { - if (!OpenLayers.Renderer.VML.prototype.supported()) { + if (!OpenLayers.Renderer.VML.prototype.supported() || OpenLayers.Renderer.SVG.prototype.supported()) { t.plan(0); return; } @@ -405,7 +405,7 @@ } function test_vml_dashstyle(t) { - if (!OpenLayers.Renderer.VML.prototype.supported()) { + if (!OpenLayers.Renderer.VML.prototype.supported() || OpenLayers.Renderer.SVG.prototype.supported()) { t.plan(0); return; } @@ -422,7 +422,7 @@ } function test_vml_moveRoot(t) { - if (!OpenLayers.Renderer.VML.prototype.supported()) { + if (!OpenLayers.Renderer.VML.prototype.supported() || OpenLayers.Renderer.SVG.prototype.supported()) { t.plan(0); return; } From 89cf93d994d3fc42d1161d0ba1a50843ede6906a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Thu, 8 Mar 2012 17:52:44 +0100 Subject: [PATCH 5/7] fix the Grid tests that fail in slow browsers, suggested by @ahocevar (refs #299) --- tests/Layer/Grid.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Layer/Grid.html b/tests/Layer/Grid.html index 34abdea092..841993eb5a 100644 --- a/tests/Layer/Grid.html +++ b/tests/Layer/Grid.html @@ -230,17 +230,17 @@ layer.deferMoveGriddedTiles = function() { log.push("deferMoveGriddedTiles"); origDeferMoveGriddedTiles.apply(this, arguments); - } + }; layer.moveGriddedTiles = function() { log.push("moveGriddedTiles"); OpenLayers.Layer.WMS.prototype.moveGriddedTiles.apply(this, arguments); - } + }; map.moveTo([5, 0]); t.eq(log[0], "moveGriddedTiles", "deferred after moveTo"); map.moveTo([0, 0]); t.eq(log[1], "moveGriddedTiles", "deferred again after another moveTo"); t.eq(log.length, 2, "no tiles loaded yet"); - t.delay_call(0.1, function() { + t.delay_call(1, function() { t.eq(log[2], "deferMoveGriddedTiles", "tiles moved after tileLoadingDelay"); }); From 46191897cba4c84be3f89a4c1bde633d01d3a36b Mon Sep 17 00:00:00 2001 From: Emanuele Ziglioli Date: Fri, 9 Mar 2012 08:54:51 +1300 Subject: [PATCH 6/7] Added missing dependency --- lib/OpenLayers/Control/Graticule.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/OpenLayers/Control/Graticule.js b/lib/OpenLayers/Control/Graticule.js index 142b4f3af1..8cc66385b2 100644 --- a/lib/OpenLayers/Control/Graticule.js +++ b/lib/OpenLayers/Control/Graticule.js @@ -6,6 +6,7 @@ /** * @requires OpenLayers/Control.js * @requires OpenLayers/Lang.js + * @requires OpenLayers/Rule.js */ /** From 197c8053facf0f68aaa697143d57da1d371be2f9 Mon Sep 17 00:00:00 2001 From: Emanuele Ziglioli Date: Fri, 9 Mar 2012 09:51:24 +1300 Subject: [PATCH 7/7] Added extra dependencies: StyleMap.js and Layer/Vector.js. See: https://github.com/openlayers/openlayers/pull/303#issuecomment-4401757 --- lib/OpenLayers/Control/Graticule.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/OpenLayers/Control/Graticule.js b/lib/OpenLayers/Control/Graticule.js index 8cc66385b2..1566f7e7fc 100644 --- a/lib/OpenLayers/Control/Graticule.js +++ b/lib/OpenLayers/Control/Graticule.js @@ -7,6 +7,8 @@ * @requires OpenLayers/Control.js * @requires OpenLayers/Lang.js * @requires OpenLayers/Rule.js + * @requires OpenLayers/StyleMap.js + * @requires OpenLayers/Layer/Vector.js */ /**