From 6be48e9ef9841989a6aa536a7d7cd623f0cba067 Mon Sep 17 00:00:00 2001 From: Antoine Abt Date: Wed, 4 Jan 2012 10:59:51 +0100 Subject: [PATCH 01/16] Basic support for canvas only (patch from trac #3503) --- lib/OpenLayers/Feature/Vector.js | 2 ++ lib/OpenLayers/Renderer/Canvas.js | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/OpenLayers/Feature/Vector.js b/lib/OpenLayers/Feature/Vector.js index 4aec61de30..40afe9ccc7 100644 --- a/lib/OpenLayers/Feature/Vector.js +++ b/lib/OpenLayers/Feature/Vector.js @@ -419,6 +419,8 @@ OpenLayers.Feature.Vector = OpenLayers.Class(OpenLayers.Feature, { * labelYOffset - {Number} Pixel offset along the positive y axis for displacing the label. Not supported by the canvas renderer. * labelSelect - {Boolean} If set to true, labels will be selectable using SelectFeature or similar controls. * Default is false. + * labelOutlineColor - {String} The color of the label outline. Default is 'white'. Only supported by the canvas renderer. + * labelOutlineWidth - {Number} The width of the label outline. Default is 3, set to 0 or null to disable. Only supported by the canvas renderer. * fontColor - {String} The font color for the label, to be provided like CSS. * fontOpacity - {Number} Opacity (0-1) for the label * fontFamily - {String} The font family for the label, to be provided like in CSS. diff --git a/lib/OpenLayers/Renderer/Canvas.js b/lib/OpenLayers/Renderer/Canvas.js index e6883a86ca..cffecad5e9 100644 --- a/lib/OpenLayers/Renderer/Canvas.js +++ b/lib/OpenLayers/Renderer/Canvas.js @@ -527,7 +527,9 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, { drawText: function(location, style) { style = OpenLayers.Util.extend({ fontColor: "#000000", - labelAlign: "cm" + labelAlign: "cm", + labelOutlineColor: "white", + labelOutlineWidth: 3 }, style); var pt = this.getLocalXY(location); @@ -560,6 +562,13 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, { this.canvas.measureText('xx').width; pt[1] += lineHeight*vfactor*(numRows-1); for (var i = 0; i < numRows; i++) { + if (style.labelOutlineWidth) { + this.canvas.save(); + this.canvas.strokeStyle = style.labelOutlineColor; + this.canvas.lineWidth = style.labelOutlineWidth; + this.canvas.strokeText(labelRows[i], pt[0], pt[1] + (lineHeight*i)); + this.canvas.restore(); + } this.canvas.fillText(labelRows[i], pt[0], pt[1] + (lineHeight*i)); } } else if (this.canvas.mozDrawText) { From 0ff9d54d5c16d65144eece4722b4285e672c4153 Mon Sep 17 00:00:00 2001 From: Antoine Abt Date: Wed, 4 Jan 2012 11:00:29 +0100 Subject: [PATCH 02/16] better alignment --- lib/OpenLayers/Renderer/Canvas.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/OpenLayers/Renderer/Canvas.js b/lib/OpenLayers/Renderer/Canvas.js index cffecad5e9..2fd620c11e 100644 --- a/lib/OpenLayers/Renderer/Canvas.js +++ b/lib/OpenLayers/Renderer/Canvas.js @@ -566,7 +566,7 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, { this.canvas.save(); this.canvas.strokeStyle = style.labelOutlineColor; this.canvas.lineWidth = style.labelOutlineWidth; - this.canvas.strokeText(labelRows[i], pt[0], pt[1] + (lineHeight*i)); + this.canvas.strokeText(labelRows[i], pt[0], pt[1] + (lineHeight*i) + 1); this.canvas.restore(); } this.canvas.fillText(labelRows[i], pt[0], pt[1] + (lineHeight*i)); From 5be7e7f8442d8ccac48885bb51388b3ba441f45f Mon Sep 17 00:00:00 2001 From: Antoine Abt Date: Thu, 5 Jan 2012 10:26:05 +0100 Subject: [PATCH 03/16] =?UTF-8?q?don=E2=80=99t=20duplicate=20defaults=20in?= =?UTF-8?q?=20renderers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/vector-features-with-text.html | 5 ++++- lib/OpenLayers/Feature/Vector.js | 20 +++++++++++++++++--- lib/OpenLayers/Renderer/Canvas.js | 6 ------ lib/OpenLayers/Renderer/SVG.js | 2 +- lib/OpenLayers/Renderer/SVG2.js | 2 +- 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/examples/vector-features-with-text.html b/examples/vector-features-with-text.html index cbdba665ab..e2eb1df5e8 100644 --- a/examples/vector-features-with-text.html +++ b/examples/vector-features-with-text.html @@ -39,7 +39,10 @@ fontWeight: "bold", labelAlign: "${align}", labelXOffset: "${xOffset}", - labelYOffset: "${yOffset}" + labelYOffset: "${yOffset}", + labelAlign: "cm", + labelOutlineColor: "white", + labelOutlineWidth: 3 }}), renderers: renderer }); diff --git a/lib/OpenLayers/Feature/Vector.js b/lib/OpenLayers/Feature/Vector.js index 40afe9ccc7..d18cba3aeb 100644 --- a/lib/OpenLayers/Feature/Vector.js +++ b/lib/OpenLayers/Feature/Vector.js @@ -447,7 +447,11 @@ OpenLayers.Feature.Vector.style = { hoverPointRadius: 1, hoverPointUnit: "%", pointerEvents: "visiblePainted", - cursor: "inherit" + cursor: "inherit", + fontColor: "#000000", + labelAlign: "cm", + labelOutlineColor: "white", + labelOutlineWidth: 3 }, 'select': { fillColor: "blue", @@ -466,7 +470,12 @@ OpenLayers.Feature.Vector.style = { hoverPointRadius: 1, hoverPointUnit: "%", pointerEvents: "visiblePainted", - cursor: "pointer" + cursor: "pointer", + fontColor: "#000000", + labelAlign: "cm", + labelOutlineColor: "white", + labelOutlineWidth: 3 + }, 'temporary': { fillColor: "#66cccc", @@ -485,7 +494,12 @@ OpenLayers.Feature.Vector.style = { hoverPointRadius: 1, hoverPointUnit: "%", pointerEvents: "visiblePainted", - cursor: "inherit" + cursor: "inherit", + fontColor: "#000000", + labelAlign: "cm", + labelOutlineColor: "white", + labelOutlineWidth: 3 + }, 'delete': { display: "none" diff --git a/lib/OpenLayers/Renderer/Canvas.js b/lib/OpenLayers/Renderer/Canvas.js index 2fd620c11e..1448bfb585 100644 --- a/lib/OpenLayers/Renderer/Canvas.js +++ b/lib/OpenLayers/Renderer/Canvas.js @@ -525,12 +525,6 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, { * style - {Object} */ drawText: function(location, style) { - style = OpenLayers.Util.extend({ - fontColor: "#000000", - labelAlign: "cm", - labelOutlineColor: "white", - labelOutlineWidth: 3 - }, style); var pt = this.getLocalXY(location); this.setCanvasStyle("reset"); diff --git a/lib/OpenLayers/Renderer/SVG.js b/lib/OpenLayers/Renderer/SVG.js index 5d445093bf..d74233d0c7 100644 --- a/lib/OpenLayers/Renderer/SVG.js +++ b/lib/OpenLayers/Renderer/SVG.js @@ -677,7 +677,7 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, { } else { label.setAttributeNS(null, "pointer-events", "none"); } - var align = style.labelAlign || "cm"; + var align = style.labelAlign; label.setAttributeNS(null, "text-anchor", OpenLayers.Renderer.SVG.LABEL_ALIGN[align[0]] || "middle"); diff --git a/lib/OpenLayers/Renderer/SVG2.js b/lib/OpenLayers/Renderer/SVG2.js index 4743ea2690..8e398636c4 100644 --- a/lib/OpenLayers/Renderer/SVG2.js +++ b/lib/OpenLayers/Renderer/SVG2.js @@ -584,7 +584,7 @@ OpenLayers.Renderer.SVG2 = OpenLayers.Class(OpenLayers.Renderer.NG, { } else { text.setAttributeNS(null, "pointer-events", "none"); } - var align = style.labelAlign || "cm"; + var align = style.labelAlign; text.setAttributeNS(null, "text-anchor", OpenLayers.Renderer.SVG2.LABEL_ALIGN[align[0]] || "middle"); From be585c5f232bde95a8f54da8048c00bf1ac392c2 Mon Sep 17 00:00:00 2001 From: Antoine Abt Date: Thu, 5 Jan 2012 17:32:00 +0100 Subject: [PATCH 04/16] =?UTF-8?q?Add=20support=20for=20SVG=C2=A0renderer?= =?UTF-8?q?=20(=20Heavily=20inspired=20from=20rdewit=E2=80=99s=20patch=20h?= =?UTF-8?q?ttp://trac.osgeo.org/openlayers/ticket/2965=20)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/OpenLayers/Renderer/Elements.js | 6 ++++++ lib/OpenLayers/Renderer/SVG.js | 23 +++++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Renderer/Elements.js b/lib/OpenLayers/Renderer/Elements.js index 9ebab760fc..cb07666cd7 100644 --- a/lib/OpenLayers/Renderer/Elements.js +++ b/lib/OpenLayers/Renderer/Elements.js @@ -415,6 +415,12 @@ OpenLayers.Renderer.Elements = OpenLayers.Class(OpenLayers.Renderer, { */ LABEL_ID_SUFFIX: "_label", + /** + * Constant: LABEL_OUTLINE_SUFFIX + * {String} + */ + LABEL_OUTLINE_SUFFIX: "_outline", + /** * Constructor: OpenLayers.Renderer.Elements * diff --git a/lib/OpenLayers/Renderer/SVG.js b/lib/OpenLayers/Renderer/SVG.js index d74233d0c7..a453a4c5a0 100644 --- a/lib/OpenLayers/Renderer/SVG.js +++ b/lib/OpenLayers/Renderer/SVG.js @@ -643,12 +643,25 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, { * location - {} */ drawText: function(featureId, style, location) { + var drawOutline = (!!style.labelOutlineWidth); + // First draw text in halo color and size and overlay the + // normal text afterwards + if (drawOutline) { + var outlineStyle = OpenLayers.Util.extend({}, style); + outlineStyle.fontColor = outlineStyle.labelOutlineColor; + outlineStyle.fontStrokeColor = outlineStyle.labelOutlineColor; + outlineStyle.fontStrokeWidth = style.labelOutlineWidth; + delete outlineStyle.labelOutlineWidth; + this.drawText(featureId, outlineStyle, location); + } + var resolution = this.getResolution(); var x = ((location.x - this.featureDx) / resolution + this.left); var y = (location.y / resolution - this.top); - var label = this.nodeFactory(featureId + this.LABEL_ID_SUFFIX, "text"); + var suffix = (drawOutline)?this.LABEL_OUTLINE_SUFFIX:this.LABEL_ID_SUFFIX; + label = this.nodeFactory(featureId + suffix, "text"); label.setAttributeNS(null, "x", x); label.setAttributeNS(null, "y", -y); @@ -656,6 +669,12 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, { if (style.fontColor) { label.setAttributeNS(null, "fill", style.fontColor); } + if (style.fontStrokeColor) { + label.setAttributeNS(null, "stroke", style.fontStrokeColor); + } + if (style.fontStrokeWidth) { + label.setAttributeNS(null, "stroke-width", style.fontStrokeWidth); + } if (style.fontOpacity) { label.setAttributeNS(null, "opacity", style.fontOpacity); } @@ -692,7 +711,7 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, { label.removeChild(label.lastChild); } for (var i = 0; i < numRows; i++) { - var tspan = this.nodeFactory(featureId + this.LABEL_ID_SUFFIX + "_tspan_" + i, "tspan"); + var tspan = this.nodeFactory(featureId + suffix + "_tspan_" + i, "tspan"); if (style.labelSelect === true) { tspan._featureId = featureId; tspan._geometry = location; From 241162a4bc2b7e144a480fa28129ed6f2a8d97b4 Mon Sep 17 00:00:00 2001 From: Antoine Abt Date: Fri, 6 Jan 2012 10:32:28 +0100 Subject: [PATCH 05/16] update comments for supported renderers --- lib/OpenLayers/Feature/Vector.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Feature/Vector.js b/lib/OpenLayers/Feature/Vector.js index d18cba3aeb..a938865feb 100644 --- a/lib/OpenLayers/Feature/Vector.js +++ b/lib/OpenLayers/Feature/Vector.js @@ -419,8 +419,8 @@ OpenLayers.Feature.Vector = OpenLayers.Class(OpenLayers.Feature, { * labelYOffset - {Number} Pixel offset along the positive y axis for displacing the label. Not supported by the canvas renderer. * labelSelect - {Boolean} If set to true, labels will be selectable using SelectFeature or similar controls. * Default is false. - * labelOutlineColor - {String} The color of the label outline. Default is 'white'. Only supported by the canvas renderer. - * labelOutlineWidth - {Number} The width of the label outline. Default is 3, set to 0 or null to disable. Only supported by the canvas renderer. + * labelOutlineColor - {String} The color of the label outline. Default is 'white'. Only supported by the canvas & SVG renderers. + * labelOutlineWidth - {Number} The width of the label outline. Default is 3, set to 0 or null to disable. Only supported by the canvas & SVG renderers. * fontColor - {String} The font color for the label, to be provided like CSS. * fontOpacity - {Number} Opacity (0-1) for the label * fontFamily - {String} The font family for the label, to be provided like in CSS. From 71d9d36266ca193b68cb4949585e27008e30f754 Mon Sep 17 00:00:00 2001 From: Antoine Abt Date: Thu, 12 Jan 2012 10:41:34 +0100 Subject: [PATCH 06/16] when removeText, remove its outline too --- lib/OpenLayers/Renderer/Elements.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/OpenLayers/Renderer/Elements.js b/lib/OpenLayers/Renderer/Elements.js index cb07666cd7..8325fd327a 100644 --- a/lib/OpenLayers/Renderer/Elements.js +++ b/lib/OpenLayers/Renderer/Elements.js @@ -883,6 +883,10 @@ OpenLayers.Renderer.Elements = OpenLayers.Class(OpenLayers.Renderer, { if (label) { this.textRoot.removeChild(label); } + var outline = document.getElementById(featureId + this.LABEL_OUTLINE_SUFFIX); + if (outline) { + this.textRoot.removeChild(outline); + } }, /** From 3cbd7b4b40ceba50ee3ae58b383a958f556976de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Thu, 12 Jan 2012 21:22:58 +0100 Subject: [PATCH 07/16] move Layer.OSM in its own script file --- apidoc_config/Menu.txt | 1 + lib/OpenLayers.js | 1 + lib/OpenLayers/Layer/OSM.js | 41 +++++++++++++++++++++++++++++++++++++ lib/OpenLayers/Layer/XYZ.js | 34 ------------------------------ notes/2.12.md | 4 ++++ tests/Layer/OSM.html | 16 +++++++++++++++ tests/Layer/XYZ.html | 10 ++------- tests/list-tests.html | 1 + 8 files changed, 66 insertions(+), 42 deletions(-) create mode 100644 lib/OpenLayers/Layer/OSM.js create mode 100644 tests/Layer/OSM.html diff --git a/apidoc_config/Menu.txt b/apidoc_config/Menu.txt index 9d23a1a7aa..16dd487956 100644 --- a/apidoc_config/Menu.txt +++ b/apidoc_config/Menu.txt @@ -362,6 +362,7 @@ Group: OpenLayers { File: MapServer.Untiled (no auto-title, OpenLayers/Layer/MapServer/Untiled.js) File: Markers (no auto-title, OpenLayers/Layer/Markers.js) File: MultiMap (no auto-title, OpenLayers/Layer/MultiMap.js) + File: OSM (no auto-title, OpenLayers/Layer/OSM.js) File: PointGrid (no auto-title, OpenLayers/Layer/PointGrid.js) File: PointTrack (no auto-title, OpenLayers/Layer/PointTrack.js) File: SphericalMercator (no auto-title, OpenLayers/Layer/SphericalMercator.js) diff --git a/lib/OpenLayers.js b/lib/OpenLayers.js index ff302535e4..040570e13c 100644 --- a/lib/OpenLayers.js +++ b/lib/OpenLayers.js @@ -144,6 +144,7 @@ "OpenLayers/Layer/GeoRSS.js", "OpenLayers/Layer/Boxes.js", "OpenLayers/Layer/XYZ.js", + "OpenLayers/Layer/OSM.js", "OpenLayers/Layer/Bing.js", "OpenLayers/Layer/TMS.js", "OpenLayers/Layer/TileCache.js", diff --git a/lib/OpenLayers/Layer/OSM.js b/lib/OpenLayers/Layer/OSM.js new file mode 100644 index 0000000000..0531a9a7a8 --- /dev/null +++ b/lib/OpenLayers/Layer/OSM.js @@ -0,0 +1,41 @@ +/* Copyright (c) 2006-2012 by OpenLayers Contributors (see authors.txt for + * full list of contributors). Published under the Clear BSD license. + * See http://svn.openlayers.org/trunk/openlayers/license.txt for the + * full text of the license. */ + +/** + * @requires OpenLayers/Layer/XYZ.js + */ + +/** + * Class: OpenLayers.Layer.OSM + * A class to access OpenStreetMap tiles. By default, uses the OpenStreetMap + * hosted tile.openstreetmap.org 'Mapnik' tileset. If you wish to use + * tiles@home / osmarender layer instead, you can pass a layer like: + * + * (code) + * new OpenLayers.Layer.OSM("t@h", + * "http://tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png"); + * (end) + * + * This layer defaults to Spherical Mercator. + * + * Inherits from: + * - + */ +OpenLayers.Layer.OSM = OpenLayers.Class(OpenLayers.Layer.XYZ, { + name: "OpenStreetMap", + attribution: "Data CC-By-SA by OpenStreetMap", + sphericalMercator: true, + url: 'http://tile.openstreetmap.org/${z}/${x}/${y}.png', + clone: function(obj) { + if (obj == null) { + obj = new OpenLayers.Layer.OSM( + this.name, this.url, this.getOptions()); + } + obj = OpenLayers.Layer.XYZ.prototype.clone.apply(this, [obj]); + return obj; + }, + wrapDateLine: true, + CLASS_NAME: "OpenLayers.Layer.OSM" +}); diff --git a/lib/OpenLayers/Layer/XYZ.js b/lib/OpenLayers/Layer/XYZ.js index 84855f95be..7977a3255f 100644 --- a/lib/OpenLayers/Layer/XYZ.js +++ b/lib/OpenLayers/Layer/XYZ.js @@ -183,37 +183,3 @@ OpenLayers.Layer.XYZ = OpenLayers.Class(OpenLayers.Layer.Grid, { CLASS_NAME: "OpenLayers.Layer.XYZ" }); - - -/** - * Class: OpenLayers.Layer.OSM - * A class to access OpenStreetMap tiles. By default, uses the OpenStreetMap - * hosted tile.openstreetmap.org 'Mapnik' tileset. If you wish to use - * tiles@home / osmarender layer instead, you can pass a layer like: - * - * (code) - * new OpenLayers.Layer.OSM("t@h", - * "http://tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png"); - * (end) - * - * This layer defaults to Spherical Mercator. - * - * Inherits from: - * - - */ -OpenLayers.Layer.OSM = OpenLayers.Class(OpenLayers.Layer.XYZ, { - name: "OpenStreetMap", - attribution: "Data CC-By-SA by OpenStreetMap", - sphericalMercator: true, - url: 'http://tile.openstreetmap.org/${z}/${x}/${y}.png', - clone: function(obj) { - if (obj == null) { - obj = new OpenLayers.Layer.OSM( - this.name, this.url, this.getOptions()); - } - obj = OpenLayers.Layer.XYZ.prototype.clone.apply(this, [obj]); - return obj; - }, - wrapDateLine: true, - CLASS_NAME: "OpenLayers.Layer.OSM" -}); diff --git a/notes/2.12.md b/notes/2.12.md index d57ce08859..6fa1f42310 100644 --- a/notes/2.12.md +++ b/notes/2.12.md @@ -50,6 +50,10 @@ The base `OpenLayers.Geometry` class no longer depends on `OpenLayers.Format.WKT Without the WKT format included (by default), the `OpenLayers.Geometry::toString` method now returns "[object Object]." Previously, it returned the Well-Known Text representation of the geometry. To maintain the previous behavior, include the OpenLayers/Format/WKT.js file in your build. +## OSM Layer + +`Layer.OSM` is now defined in its own script file, namely `OpenLayers/Layer/OSM.js`. So people using `Layer.OSM` should now include `OpenLayers/Layer/OSM.js`, as opposed to `OpenLayers/Layer/XYZ.js`, in their OpenLayers builds. (See https://github.com/openlayers/openlayers/issues/138) + ## Deprecated Components A number of properties, methods, and constructors have been marked as deprecated for multiple releases in the 2.x series. For the 2.12 release this deprecated functionality has been moved to a separate deprecated.js file. If you use any of the constructors or methods below, you will have to explicitly include the deprecated.js file in your build (or add it in a separate ` + + + +
+ + diff --git a/tests/Layer/XYZ.html b/tests/Layer/XYZ.html index d6685c05b5..8b8a7cbf31 100644 --- a/tests/Layer/XYZ.html +++ b/tests/Layer/XYZ.html @@ -251,17 +251,11 @@ } function test_clone(t) { - t.plan(2); - - var clone; + t.plan(1); layer = new OpenLayers.Layer.XYZ(name, url, options); - clone = layer.clone(); + var clone = layer.clone(); t.ok(clone instanceof OpenLayers.Layer.XYZ, "clone is a Layer.XYZ instance"); - - layer = new OpenLayers.Layer.OSM(); - clone = layer.clone(); - t.ok(clone instanceof OpenLayers.Layer.OSM, "clone is a Layer.OSM instance"); } diff --git a/tests/list-tests.html b/tests/list-tests.html index a3a3023463..7daa933355 100644 --- a/tests/list-tests.html +++ b/tests/list-tests.html @@ -167,6 +167,7 @@
  • Layer/WMTS.html
  • Layer/WrapDateLine.html
  • Layer/XYZ.html
  • +
  • Layer/OSM.html
  • Map.html
  • Marker.html
  • Marker/Box.html
  • From 7a0336a9efb4f52e8cc0224af9ac653e97c4498e Mon Sep 17 00:00:00 2001 From: Pierre GIRAUD Date: Fri, 13 Jan 2012 17:36:23 +0100 Subject: [PATCH 08/16] Fixing a wrong calculation in LinearRing::containsPoint --- lib/OpenLayers/Geometry/LinearRing.js | 2 +- tests/Geometry/LinearRing.html | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/OpenLayers/Geometry/LinearRing.js b/lib/OpenLayers/Geometry/LinearRing.js index c8b960915c..bcb9ea4c4b 100644 --- a/lib/OpenLayers/Geometry/LinearRing.js +++ b/lib/OpenLayers/Geometry/LinearRing.js @@ -294,7 +294,7 @@ OpenLayers.Geometry.LinearRing = OpenLayers.Class( var px = approx(point.x, digs); var py = approx(point.y, digs); function getX(y, x1, y1, x2, y2) { - return (((x1 - x2) * y) + ((x2 * y1) - (x1 * y2))) / (y1 - y2); + return (y-y2)*((x2-x1)/(y2-y1)) + x2; } var numSeg = this.components.length - 1; var start, end, x1, y1, x2, y2, cx, cy; diff --git a/tests/Geometry/LinearRing.html b/tests/Geometry/LinearRing.html index 5cacd89eb7..20ef87efdd 100644 --- a/tests/Geometry/LinearRing.html +++ b/tests/Geometry/LinearRing.html @@ -250,6 +250,22 @@ "resize correctly adjusts y of component 4"); } + function test_LinearRing_containsPoint(t) { + t.plan(1); + + var components = [ + new OpenLayers.Geometry.Point(-10812863.417266,3923827.912779), + new OpenLayers.Geometry.Point(-10812863.417264,3923951.5257855), + new OpenLayers.Geometry.Point(-10812309.24881,3923990.9386282), + new OpenLayers.Geometry.Point(-10812751.15038,3923798.0545649) + ]; + + var ring = new OpenLayers.Geometry.LinearRing(components); + var point = new OpenLayers.Geometry.Point(-10812964.078829, 3923856.9524225); + + t.ok(!ring.containsPoint(point), + "containsPoint correctly returns false for point outside"); + } From 3eee019fca354de270c8d4d9d31da841cb497d41 Mon Sep 17 00:00:00 2001 From: Peter Robins Date: Sat, 14 Jan 2012 14:51:03 +0000 Subject: [PATCH 09/16] Remove QueryStringFilter requires from Protocol/HTTP --- lib/OpenLayers/Protocol/HTTP.js | 5 ----- notes/2.12.md | 4 ++++ 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/OpenLayers/Protocol/HTTP.js b/lib/OpenLayers/Protocol/HTTP.js index 37768fbac0..2fbec736fc 100644 --- a/lib/OpenLayers/Protocol/HTTP.js +++ b/lib/OpenLayers/Protocol/HTTP.js @@ -8,11 +8,6 @@ * @requires OpenLayers/Request/XMLHttpRequest.js */ -/** - * TODO: remove this dependency in 3.0 - * @requires OpenLayers/Format/QueryStringFilter.js - */ - /** * Class: OpenLayers.Protocol.HTTP * A basic HTTP protocol for vector layers. Create a new instance with the diff --git a/notes/2.12.md b/notes/2.12.md index d57ce08859..06a2f0ec16 100644 --- a/notes/2.12.md +++ b/notes/2.12.md @@ -50,6 +50,10 @@ The base `OpenLayers.Geometry` class no longer depends on `OpenLayers.Format.WKT Without the WKT format included (by default), the `OpenLayers.Geometry::toString` method now returns "[object Object]." Previously, it returned the Well-Known Text representation of the geometry. To maintain the previous behavior, include the OpenLayers/Format/WKT.js file in your build. +## QueryStringFilter + +`OpenLayers.Protocol.HTTP` no longer requires `OpenLayers.Format.QueryStringFilter`. It you need this, make sure it is included in your build config file. + ## Deprecated Components A number of properties, methods, and constructors have been marked as deprecated for multiple releases in the 2.x series. For the 2.12 release this deprecated functionality has been moved to a separate deprecated.js file. If you use any of the constructors or methods below, you will have to explicitly include the deprecated.js file in your build (or add it in a separate ` From 58468c28501ca0f7d884575e57ffef6fc1b8e89b Mon Sep 17 00:00:00 2001 From: Antoine Abt Date: Tue, 17 Jan 2012 11:38:54 +0100 Subject: [PATCH 14/16] =?UTF-8?q?don=E2=80=99t=20set=20labelAlign=20twice?= =?UTF-8?q?=20in=20example?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/vector-features-with-text.html | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/vector-features-with-text.html b/examples/vector-features-with-text.html index e2eb1df5e8..d32fd89e15 100644 --- a/examples/vector-features-with-text.html +++ b/examples/vector-features-with-text.html @@ -40,7 +40,6 @@ labelAlign: "${align}", labelXOffset: "${xOffset}", labelYOffset: "${yOffset}", - labelAlign: "cm", labelOutlineColor: "white", labelOutlineWidth: 3 }}), From 4c22ceee4a61fb4d33bab14d171fade090781413 Mon Sep 17 00:00:00 2001 From: Antoine Abt Date: Tue, 17 Jan 2012 12:24:02 +0100 Subject: [PATCH 15/16] Document default labelAlign --- lib/OpenLayers/Feature/Vector.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/OpenLayers/Feature/Vector.js b/lib/OpenLayers/Feature/Vector.js index a938865feb..ca4c533647 100644 --- a/lib/OpenLayers/Feature/Vector.js +++ b/lib/OpenLayers/Feature/Vector.js @@ -414,7 +414,7 @@ OpenLayers.Feature.Vector = OpenLayers.Class(OpenLayers.Feature, { * labelAlign - {String} Label alignment. This specifies the insertion point relative to the text. It is a string * composed of two characters. The first character is for the horizontal alignment, the second for the vertical * alignment. Valid values for horizontal alignment: "l"=left, "c"=center, "r"=right. Valid values for vertical - * alignment: "t"=top, "m"=middle, "b"=bottom. Example values: "lt", "cm", "rb". + * alignment: "t"=top, "m"=middle, "b"=bottom. Example values: "lt", "cm", "rb". Default is "cm". * labelXOffset - {Number} Pixel offset along the positive x axis for displacing the label. Not supported by the canvas renderer. * labelYOffset - {Number} Pixel offset along the positive y axis for displacing the label. Not supported by the canvas renderer. * labelSelect - {Boolean} If set to true, labels will be selectable using SelectFeature or similar controls. From ca6d93712a2f6fe25e718e314618d16b8d744bc3 Mon Sep 17 00:00:00 2001 From: Peter Robins Date: Tue, 17 Jan 2012 11:41:22 +0000 Subject: [PATCH 16/16] Suggested addition to Kinetic documentation --- lib/OpenLayers/Control/DragPan.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/OpenLayers/Control/DragPan.js b/lib/OpenLayers/Control/DragPan.js index 34e31be905..233e7ab377 100644 --- a/lib/OpenLayers/Control/DragPan.js +++ b/lib/OpenLayers/Control/DragPan.js @@ -57,6 +57,8 @@ OpenLayers.Control.DragPan = OpenLayers.Class(OpenLayers.Control, { * set to true or to an object. If set to an object this * object will be passed to the {} * constructor. Defaults to false. + * If you set this property, you should ensure that + * OpenLayers/Kinetic.js is included in your build config */ enableKinetic: false,