Add clipping back

This commit is contained in:
John Firebaugh
2013-10-17 17:41:22 -04:00
parent 4cce2e8d3a
commit f9eaed7fb9
3 changed files with 11 additions and 3 deletions
+8 -1
View File
@@ -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]);
+1 -1
View File
@@ -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();
+2 -1
View File
@@ -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) {