Avoid VML rendering issues with zero area inner rings. We don't actually do an expensive area calculation, but just make sure that we have at least three distinct points. This version is slightly different from Tim's previous patch: it compares the VML path components rathter than the geometry components, which is less expensive and more reliable (because the VML path uses integers). p=tschaub,me r=me (closes #2876)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@10837 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -751,21 +751,43 @@ OpenLayers.Renderer.VML = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
||||
var resolution = this.getResolution();
|
||||
|
||||
var path = [];
|
||||
var linearRing, i, j, len, ilen, comp, x, y;
|
||||
for (j = 0, len=geometry.components.length; j<len; j++) {
|
||||
linearRing = geometry.components[j];
|
||||
|
||||
var j, jj, points, area, first, second, i, ii, comp, pathComp, x, y;
|
||||
for (j=0, jj=geometry.components.length; j<jj; j++) {
|
||||
path.push("m");
|
||||
for (i=0, ilen=linearRing.components.length; i<ilen; i++) {
|
||||
comp = linearRing.components[i];
|
||||
points = geometry.components[j].components;
|
||||
// we only close paths of interior rings with area
|
||||
area = (j === 0);
|
||||
first = null;
|
||||
second = null;
|
||||
for (i=0, ii=points.length; i<ii; i++) {
|
||||
comp = points[i];
|
||||
x = (comp.x / resolution - this.offset.x) | 0;
|
||||
y = (comp.y / resolution - this.offset.y) | 0;
|
||||
path.push(" " + x + "," + y);
|
||||
pathComp = " " + x + "," + y;
|
||||
path.push(pathComp)
|
||||
if (i==0) {
|
||||
path.push(" l");
|
||||
}
|
||||
if (!area) {
|
||||
// IE improperly renders sub-paths that have no area.
|
||||
// Instead of checking the area of every ring, we confirm
|
||||
// the ring has at least three distinct points. This does
|
||||
// not catch all non-zero area cases, but it greatly improves
|
||||
// interior ring digitizing and is a minor performance hit
|
||||
// when rendering rings with many points.
|
||||
if (!first) {
|
||||
first = pathComp;
|
||||
} else if (first != pathComp) {
|
||||
if (!second) {
|
||||
second = pathComp;
|
||||
} else if (second != pathComp) {
|
||||
// stop looking
|
||||
area = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
path.push(" x ");
|
||||
path.push(area ? " x " : " ");
|
||||
}
|
||||
path.push("e");
|
||||
node.path = path.join("");
|
||||
|
||||
Reference in New Issue
Block a user