From f9eaed7fb9374d76ff6a35e8d5c0d6c315ad55a5 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Thu, 17 Oct 2013 17:41:22 -0400 Subject: [PATCH] Add clipping back --- js/id/id.js | 9 ++++++++- js/id/renderer/map.js | 2 +- js/id/svg.js | 3 ++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/js/id/id.js b/js/id/id.js index 1726d3834..8415b6975 100644 --- a/js/id/id.js +++ b/js/id/id.js @@ -198,7 +198,8 @@ window.iD = function () { function rawMercator() { var project = d3.geo.mercator.raw, k = 512 / Math.PI, // scale - x = 0, y = 0; // translate + x = 0, y = 0, // translate + clipExtent = [[0, 0], [0, 0]]; function projection(point) { point = project(point[0] * Math.PI / 180, point[1] * Math.PI / 180); @@ -223,6 +224,12 @@ window.iD = function () { return projection; }; + projection.clipExtent = function(_) { + if (!arguments.length) return clipExtent; + clipExtent = _; + return projection; + }; + projection.stream = d3.geo.transform({ point: function(x, y) { x = projection([x, y]); diff --git a/js/id/renderer/map.js b/js/id/renderer/map.js index 3c58e3838..531469de5 100644 --- a/js/id/renderer/map.js +++ b/js/id/renderer/map.js @@ -317,7 +317,7 @@ iD.Map = function(context) { dimensions = _; surface.dimensions(dimensions); context.background().dimensions(dimensions); -// projection.clipExtent([[0, 0], dimensions]); + projection.clipExtent([[0, 0], dimensions]); mouse = iD.util.fastMouse(supersurface.node()); setCenter(center); return redraw(); diff --git a/js/id/svg.js b/js/id/svg.js index 54d70b85b..623828b0b 100644 --- a/js/id/svg.js +++ b/js/id/svg.js @@ -22,9 +22,10 @@ iD.svg = { Path: function(projection, graph, polygon) { var cache = {}, round = iD.svg.Round().stream, + clip = d3.geo.clipExtent().extent(projection.clipExtent()).stream, project = projection.stream, path = d3.geo.path() - .projection({stream: function(output) { return project(round(output)); }}); + .projection({stream: function(output) { return polygon ? project(round(output)) : project(clip(round(output))); }}); return function(entity) { if (entity.id in cache) {