mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-15 13:38:26 +02:00
Custom d3 3.1 build (fixes #1232)
This commit is contained in:
@@ -87,3 +87,22 @@ clean:
|
||||
|
||||
translations:
|
||||
node data/update_locales
|
||||
|
||||
D3_FILES = \
|
||||
node_modules/d3/src/start.js \
|
||||
node_modules/d3/src/arrays/index.js \
|
||||
node_modules/d3/src/behavior/behavior.js \
|
||||
node_modules/d3/src/behavior/zoom.js \
|
||||
node_modules/d3/src/core/index.js \
|
||||
node_modules/d3/src/event/index.js \
|
||||
node_modules/d3/src/geo/mercator.js \
|
||||
node_modules/d3/src/geo/path.js \
|
||||
node_modules/d3/src/geo/stream.js \
|
||||
node_modules/d3/src/geom/polygon.js \
|
||||
node_modules/d3/src/selection/index.js \
|
||||
node_modules/d3/src/transition/index.js \
|
||||
node_modules/d3/src/xhr/index.js \
|
||||
node_modules/d3/src/end.js
|
||||
|
||||
js/lib/d3.v3.js: $(D3_FILES)
|
||||
node_modules/.bin/smash $(D3_FILES) > $@
|
||||
|
||||
+1
-1
@@ -246,7 +246,7 @@ iD.Connection = function(context) {
|
||||
if (off) return;
|
||||
|
||||
var scaleExtent = [16, 16],
|
||||
s = projection.scale(),
|
||||
s = projection.scale() * 2 * Math.PI,
|
||||
tiles = d3.geo.tile()
|
||||
.scaleExtent(scaleExtent)
|
||||
.scale(s)
|
||||
|
||||
@@ -49,14 +49,14 @@ iD.Background = function(backgroundType) {
|
||||
|
||||
// Update tiles based on current state of `projection`.
|
||||
function background(selection) {
|
||||
tile.scale(projection.scale())
|
||||
tile.scale(projection.scale() * 2 * Math.PI)
|
||||
.translate(projection.translate());
|
||||
|
||||
tileOrigin = [
|
||||
projection.scale() / 2 - projection.translate()[0],
|
||||
projection.scale() / 2 - projection.translate()[1]];
|
||||
projection.scale() * Math.PI - projection.translate()[0],
|
||||
projection.scale() * Math.PI - projection.translate()[1]];
|
||||
|
||||
z = Math.max(Math.log(projection.scale()) / Math.log(2) - 8, 0);
|
||||
z = Math.max(Math.log(projection.scale() * 2 * Math.PI) / Math.log(2) - 8, 0);
|
||||
|
||||
render(selection);
|
||||
}
|
||||
|
||||
+10
-10
@@ -1,11 +1,11 @@
|
||||
iD.Map = function(context) {
|
||||
var dimensions = [1, 1],
|
||||
dispatch = d3.dispatch('move', 'drawn'),
|
||||
projection = d3.geo.mercator().scale(1024),
|
||||
projection = d3.geo.mercator().scale(512 / Math.PI),
|
||||
roundedProjection = iD.svg.RoundProjection(projection),
|
||||
zoom = d3.behavior.zoom()
|
||||
.translate(projection.translate())
|
||||
.scale(projection.scale())
|
||||
.scale(projection.scale() * 2 * Math.PI)
|
||||
.scaleExtent([1024, 256 * Math.pow(2, 24)])
|
||||
.on('zoom', zoomPan),
|
||||
dblclickEnabled = true,
|
||||
@@ -118,7 +118,7 @@ iD.Map = function(context) {
|
||||
function zoomPan() {
|
||||
if (d3.event && d3.event.sourceEvent.type === 'dblclick') {
|
||||
if (!dblclickEnabled) {
|
||||
zoom.scale(projection.scale())
|
||||
zoom.scale(projection.scale() * 2 * Math.PI)
|
||||
.translate(projection.translate());
|
||||
return d3.event.sourceEvent.preventDefault();
|
||||
}
|
||||
@@ -133,7 +133,7 @@ iD.Map = function(context) {
|
||||
|
||||
projection
|
||||
.translate(d3.event.translate)
|
||||
.scale(d3.event.scale);
|
||||
.scale(d3.event.scale / (2 * Math.PI));
|
||||
|
||||
var ascale = d3.event.scale;
|
||||
var bscale = transformStart[0];
|
||||
@@ -202,7 +202,7 @@ iD.Map = function(context) {
|
||||
}
|
||||
|
||||
transformStart = [
|
||||
projection.scale(),
|
||||
projection.scale() * 2 * Math.PI,
|
||||
projection.translate().slice()];
|
||||
|
||||
return map;
|
||||
@@ -216,13 +216,13 @@ iD.Map = function(context) {
|
||||
|
||||
function pointLocation(p) {
|
||||
var translate = projection.translate(),
|
||||
scale = projection.scale();
|
||||
scale = projection.scale() * 2 * Math.PI;
|
||||
return [(p[0] - translate[0]) / scale, (p[1] - translate[1]) / scale];
|
||||
}
|
||||
|
||||
function locationPoint(l) {
|
||||
var translate = projection.translate(),
|
||||
scale = projection.scale();
|
||||
scale = projection.scale() * 2 * Math.PI;
|
||||
return [l[0] * scale + translate[0], l[1] * scale + translate[1]];
|
||||
}
|
||||
|
||||
@@ -248,8 +248,8 @@ iD.Map = function(context) {
|
||||
center = pxCenter(),
|
||||
l = pointLocation(center);
|
||||
scale = Math.max(1024, Math.min(256 * Math.pow(2, 24), scale));
|
||||
projection.scale(scale);
|
||||
zoom.scale(projection.scale());
|
||||
projection.scale(scale / (2 * Math.PI));
|
||||
zoom.scale(scale);
|
||||
var t = projection.translate();
|
||||
l = locationPoint(l);
|
||||
t[0] += center[0] - l[0];
|
||||
@@ -312,7 +312,7 @@ iD.Map = function(context) {
|
||||
|
||||
map.zoom = function(z) {
|
||||
if (!arguments.length) {
|
||||
return Math.max(Math.log(projection.scale()) / Math.LN2 - 8, 0);
|
||||
return Math.max(Math.log(projection.scale() * 2 * Math.PI) / Math.LN2 - 8, 0);
|
||||
}
|
||||
|
||||
if (setZoom(z)) {
|
||||
|
||||
Vendored
+4901
-7971
File diff suppressed because it is too large
Load Diff
@@ -20,6 +20,8 @@
|
||||
],
|
||||
"license": "WTFPL",
|
||||
"devDependencies": {
|
||||
"d3": "3",
|
||||
"smash": "0.0",
|
||||
"uglify-js": "~2.2.5",
|
||||
"mocha-phantomjs": "~1.1.1",
|
||||
"glob": "~3.1.21",
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
describe("iD.actions.Move", function() {
|
||||
var projection = d3.geo.mercator().scale(250 / Math.PI);
|
||||
|
||||
describe("#disabled", function() {
|
||||
it("returns falsy by default", function() {
|
||||
var node = iD.Node({loc: [0, 0]}),
|
||||
action = iD.actions.Move([node.id], [0, 0], d3.geo.mercator()),
|
||||
action = iD.actions.Move([node.id], [0, 0], projection),
|
||||
graph = iD.Graph([node]);
|
||||
expect(action.disabled(graph)).not.to.be.ok;
|
||||
});
|
||||
|
||||
it("returns 'incomplete_relation' for an incomplete relation", function() {
|
||||
var relation = iD.Relation({members: [{id: 1}]}),
|
||||
action = iD.actions.Move([relation.id], [0, 0], d3.geo.mercator()),
|
||||
action = iD.actions.Move([relation.id], [0, 0], projection),
|
||||
graph = iD.Graph([relation]);
|
||||
expect(action.disabled(graph)).to.equal('incomplete_relation');
|
||||
});
|
||||
@@ -17,7 +19,7 @@ describe("iD.actions.Move", function() {
|
||||
it("returns falsy for a complete relation", function() {
|
||||
var node = iD.Node({loc: [0, 0]}),
|
||||
relation = iD.Relation({members: [{id: node.id}]}),
|
||||
action = iD.actions.Move([relation.id], [0, 0], d3.geo.mercator()),
|
||||
action = iD.actions.Move([relation.id], [0, 0], projection),
|
||||
graph = iD.Graph([node, relation]);
|
||||
expect(action.disabled(graph)).not.to.be.ok;
|
||||
});
|
||||
@@ -28,7 +30,6 @@ describe("iD.actions.Move", function() {
|
||||
node2 = iD.Node({loc: [5, 10]}),
|
||||
way = iD.Way({nodes: [node1.id, node2.id]}),
|
||||
delta = [2, 3],
|
||||
projection = d3.geo.mercator(),
|
||||
graph = iD.actions.Move([way.id], delta, projection)(iD.Graph([node1, node2, way])),
|
||||
loc1 = graph.entity(node1.id).loc,
|
||||
loc2 = graph.entity(node2.id).loc;
|
||||
@@ -42,7 +43,6 @@ describe("iD.actions.Move", function() {
|
||||
var node = iD.Node({loc: [0, 0]}),
|
||||
way = iD.Way({nodes: [node.id, node.id]}),
|
||||
delta = [2, 3],
|
||||
projection = d3.geo.mercator(),
|
||||
graph = iD.actions.Move([way.id], delta, projection)(iD.Graph([node, way])),
|
||||
loc = graph.entity(node.id).loc;
|
||||
expect(loc[0]).to.be.closeTo( 1.440, 0.001);
|
||||
@@ -54,7 +54,6 @@ describe("iD.actions.Move", function() {
|
||||
way1 = iD.Way({nodes: [node.id]}),
|
||||
way2 = iD.Way({nodes: [node.id]}),
|
||||
delta = [2, 3],
|
||||
projection = d3.geo.mercator(),
|
||||
graph = iD.actions.Move([way1.id, way2.id], delta, projection)(iD.Graph([node, way1, way2])),
|
||||
loc = graph.entity(node.id).loc;
|
||||
expect(loc[0]).to.be.closeTo( 1.440, 0.001);
|
||||
@@ -66,7 +65,6 @@ describe("iD.actions.Move", function() {
|
||||
way = iD.Way({nodes: [node.id]}),
|
||||
relation = iD.Relation({members: [{id: way.id}]}),
|
||||
delta = [2, 3],
|
||||
projection = d3.geo.mercator(),
|
||||
graph = iD.actions.Move([relation.id], delta, projection)(iD.Graph([node, way, relation])),
|
||||
loc = graph.entity(node.id).loc;
|
||||
expect(loc[0]).to.be.closeTo( 1.440, 0.001);
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
describe("iD.svg.LineString", function () {
|
||||
var projection = d3.geo.mercator();
|
||||
var projection = d3.geo.mercator().scale(250 / Math.PI);
|
||||
|
||||
it("returns an SVG path description for the entity's nodes", function () {
|
||||
var a = iD.Node({loc: [0, 0]}),
|
||||
|
||||
Reference in New Issue
Block a user