From 4a713d406d6af3e5fbe7c8d09dee1dfe96fb4d2f Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Thu, 11 Feb 2016 15:55:41 -0800 Subject: [PATCH] round points created during bucket creation fix #2067 --- js/data/line_bucket.js | 4 ++-- js/symbol/clip_line.js | 16 ++++++++-------- js/symbol/get_anchors.js | 4 +--- package.json | 2 +- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/js/data/line_bucket.js b/js/data/line_bucket.js index 84f5a7ec4be..a86e25fe14e 100644 --- a/js/data/line_bucket.js +++ b/js/data/line_bucket.js @@ -174,7 +174,7 @@ LineBucket.prototype.addLine = function(vertices, join, cap, miterLimit, roundLi if (isSharpCorner && i > 0) { var prevSegmentLength = currentVertex.dist(prevVertex); if (prevSegmentLength > 2 * sharpCornerOffset) { - var newPrevVertex = currentVertex.sub(currentVertex.sub(prevVertex)._mult(sharpCornerOffset / prevSegmentLength)); + var newPrevVertex = currentVertex.sub(currentVertex.sub(prevVertex)._mult(sharpCornerOffset / prevSegmentLength)._round()); distance += newPrevVertex.dist(prevVertex); this.addCurrentVertex(newPrevVertex, flip, distance, prevNormal.mult(1), 0, 0, false); prevVertex = newPrevVertex; @@ -329,7 +329,7 @@ LineBucket.prototype.addLine = function(vertices, join, cap, miterLimit, roundLi if (isSharpCorner && i < len - 1) { var nextSegmentLength = currentVertex.dist(nextVertex); if (nextSegmentLength > 2 * sharpCornerOffset) { - var newCurrentVertex = currentVertex.add(nextVertex.sub(currentVertex)._mult(sharpCornerOffset / nextSegmentLength)); + var newCurrentVertex = currentVertex.add(nextVertex.sub(currentVertex)._mult(sharpCornerOffset / nextSegmentLength)._round()); distance += newCurrentVertex.dist(currentVertex); this.addCurrentVertex(newCurrentVertex, flip, distance, nextNormal.mult(1), 0, 0, false); currentVertex = newCurrentVertex; diff --git a/js/symbol/clip_line.js b/js/symbol/clip_line.js index 13c446239cd..2f409b17bd4 100644 --- a/js/symbol/clip_line.js +++ b/js/symbol/clip_line.js @@ -30,33 +30,33 @@ function clipLine(lines, x1, y1, x2, y2) { if (p0.x < x1 && p1.x < x1) { continue; } else if (p0.x < x1) { - p0 = new Point(x1, p0.y + (p1.y - p0.y) * ((x1 - p0.x) / (p1.x - p0.x))); + p0 = new Point(x1, p0.y + (p1.y - p0.y) * ((x1 - p0.x) / (p1.x - p0.x)))._round(); } else if (p1.x < x1) { - p1 = new Point(x1, p0.y + (p1.y - p0.y) * ((x1 - p0.x) / (p1.x - p0.x))); + p1 = new Point(x1, p0.y + (p1.y - p0.y) * ((x1 - p0.x) / (p1.x - p0.x)))._round(); } if (p0.y < y1 && p1.y < y1) { continue; } else if (p0.y < y1) { - p0 = new Point(p0.x + (p1.x - p0.x) * ((y1 - p0.y) / (p1.y - p0.y)), y1); + p0 = new Point(p0.x + (p1.x - p0.x) * ((y1 - p0.y) / (p1.y - p0.y)), y1)._round(); } else if (p1.y < y1) { - p1 = new Point(p0.x + (p1.x - p0.x) * ((y1 - p0.y) / (p1.y - p0.y)), y1); + p1 = new Point(p0.x + (p1.x - p0.x) * ((y1 - p0.y) / (p1.y - p0.y)), y1)._round(); } if (p0.x >= x2 && p1.x >= x2) { continue; } else if (p0.x >= x2) { - p0 = new Point(x2, p0.y + (p1.y - p0.y) * ((x2 - p0.x) / (p1.x - p0.x))); + p0 = new Point(x2, p0.y + (p1.y - p0.y) * ((x2 - p0.x) / (p1.x - p0.x)))._round(); } else if (p1.x >= x2) { - p1 = new Point(x2, p0.y + (p1.y - p0.y) * ((x2 - p0.x) / (p1.x - p0.x))); + p1 = new Point(x2, p0.y + (p1.y - p0.y) * ((x2 - p0.x) / (p1.x - p0.x)))._round(); } if (p0.y >= y2 && p1.y >= y2) { continue; } else if (p0.y >= y2) { - p0 = new Point(p0.x + (p1.x - p0.x) * ((y2 - p0.y) / (p1.y - p0.y)), y2); + p0 = new Point(p0.x + (p1.x - p0.x) * ((y2 - p0.y) / (p1.y - p0.y)), y2)._round(); } else if (p1.y >= y2) { - p1 = new Point(p0.x + (p1.x - p0.x) * ((y2 - p0.y) / (p1.y - p0.y)), y2); + p1 = new Point(p0.x + (p1.x - p0.x) * ((y2 - p0.y) / (p1.y - p0.y)), y2)._round(); } if (!clippedLine || !p0.equals(clippedLine[clippedLine.length - 1])) { diff --git a/js/symbol/get_anchors.js b/js/symbol/get_anchors.js index 55a632c7b7f..51bb0a1d823 100644 --- a/js/symbol/get_anchors.js +++ b/js/symbol/get_anchors.js @@ -78,9 +78,7 @@ function resample(line, offset, spacing, angleWindowSize, maxAngle, labelLength, if (x >= 0 && x < tileExtent && y >= 0 && y < tileExtent && markedDistance - halfLabelLength >= 0 && markedDistance + halfLabelLength <= lineLength) { - x = Math.round(x); - y = Math.round(y); - var anchor = new Anchor(x, y, angle, i); + var anchor = new Anchor(x, y, angle, i)._round(); if (!angleWindowSize || checkMaxAngle(line, anchor, labelLength, angleWindowSize, maxAngle)) { anchors.push(anchor); diff --git a/package.json b/package.json index 6844c2f8c5c..f9e8a7b9862 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "eslint": "^1.5.0", "eslint-config-mourner": "^1.0.0", "istanbul": "^0.4.1", - "mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#c896d35640872d61cbae2dc681a27d405e610b4e", + "mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#8859b504ef241bca49d4c2f9a79ff4d0bfdf81a1", "prova": "^2.1.2", "sinon": "^1.15.4", "st": "^1.0.0",