Begin d3 v4 update

This commit is contained in:
Tom MacWright
2016-08-12 10:29:00 -04:00
parent 36a90b4f86
commit cdb533fa84
137 changed files with 842 additions and 6691 deletions
+14 -10
View File
@@ -1,3 +1,7 @@
import { rebind } from '../util/rebind';
import { functor } from '../util/index';
import { d3geoTile } from '../../js/lib/d3.geo.tile';
import * as d3 from 'd3';
import _ from 'lodash';
import { Detect } from '../util/detect';
import { Entity } from './entity';
@@ -102,11 +106,11 @@ export function Connection(useHttps) {
};
function authenticating() {
event.authenticating();
event.call("authenticating");
}
function authenticated() {
event.authenticated();
event.call("authenticated");
}
function getLoc(attrs) {
@@ -298,7 +302,7 @@ export function Connection(useHttps) {
method: 'PUT',
path: '/api/0.6/changeset/' + changeset_id + '/close',
options: { header: { 'Content-Type': 'text/xml' } }
}, d3.functor(true));
}, functor(true));
});
});
};
@@ -378,7 +382,7 @@ export function Connection(useHttps) {
s / 2 - projection.translate()[0],
s / 2 - projection.translate()[1]];
var tiles = d3.geo.tile()
var tiles = d3geoTile()
.scaleExtent([tileZoom, tileZoom])
.scale(s)
.size(dimensions)
@@ -413,7 +417,7 @@ export function Connection(useHttps) {
if (loadedTiles[id] || inflight[id]) return;
if (_.isEmpty(inflight)) {
event.loading();
event.call("loading");
}
inflight[id] = connection.loadFromURL(bboxUrl(tile), function(err, parsed) {
@@ -423,7 +427,7 @@ export function Connection(useHttps) {
if (callback) callback(err, _.extend({data: parsed}, tile));
if (_.isEmpty(inflight)) {
event.loaded();
event.call("loaded");
}
});
});
@@ -435,7 +439,7 @@ export function Connection(useHttps) {
loading: authenticating,
done: authenticated
}, options));
event.auth();
event.call("auth");
connection.flush();
return connection;
};
@@ -462,18 +466,18 @@ export function Connection(useHttps) {
connection.logout = function() {
userDetails = undefined;
oauth.logout();
event.auth();
event.call("auth");
return connection;
};
connection.authenticate = function(callback) {
userDetails = undefined;
function done(err, res) {
event.auth();
event.call("auth");
if (callback) callback(err, res);
}
return oauth.authenticate(done);
};
return d3.rebind(connection, event, 'on');
return rebind(connection, event, 'on');
}
+6 -4
View File
@@ -1,3 +1,5 @@
import { rebind } from '../util/rebind';
import * as d3 from 'd3';
import { t, addTranslation, setLocale } from '../util/locale';
import _ from 'lodash';
import { Background } from '../renderer/background';
@@ -170,12 +172,12 @@ export function Context(root) {
context.enter = function(newMode) {
if (mode) {
mode.exit();
dispatch.exit(mode);
dispatch.call("exit", this, mode);
}
mode = newMode;
mode.enter();
dispatch.enter(mode);
dispatch.call("enter", this, mode);
};
context.selectedIDs = function() {
@@ -251,7 +253,7 @@ export function Context(root) {
context.setDebug = function(flag, val) {
if (arguments.length === 1) val = true;
debugFlags[flag] = val;
dispatch.change();
dispatch.call("change");
return context;
};
context.getDebug = function(flag) {
@@ -399,6 +401,6 @@ export function Context(root) {
presets = presetsInit();
return d3.rebind(context, dispatch, 'on');
return rebind(context, dispatch, 'on');
}
+1
View File
@@ -1,3 +1,4 @@
import * as d3 from 'd3';
import _ from 'lodash';
/*
iD.Difference represents the difference between two graphs.
+1
View File
@@ -1,3 +1,4 @@
import * as d3 from 'd3';
import _ from 'lodash';
import { debug } from '../index';
import { interestingTag } from './tags';
+10 -8
View File
@@ -1,3 +1,5 @@
import { rebind } from '../util/rebind';
import * as d3 from 'd3';
import _ from 'lodash';
import * as Validations from '../validations/index';
import { Difference } from './difference';
@@ -36,7 +38,7 @@ export function History(context) {
function change(previous) {
var difference = Difference(previous, history.graph());
dispatch.change(difference);
dispatch.call("change", this, difference);
return difference;
}
@@ -58,7 +60,7 @@ export function History(context) {
stack[0].graph.rebase(entities, _.map(stack, 'graph'), false);
tree.rebase(entities, false);
dispatch.change(undefined, extent);
dispatch.call("change", this, undefined, extent);
},
perform: function() {
@@ -114,7 +116,7 @@ export function History(context) {
if (stack[index].annotation) break;
}
dispatch.undone();
dispatch.call("undone");
return change(previous);
},
@@ -126,7 +128,7 @@ export function History(context) {
if (stack[index].annotation) break;
}
dispatch.redone();
dispatch.call("redone");
return change(previous);
},
@@ -202,7 +204,7 @@ export function History(context) {
stack = [{graph: Graph()}];
index = 0;
tree = Tree(stack[0].graph);
dispatch.change();
dispatch.call("change");
return history;
},
@@ -317,7 +319,7 @@ export function History(context) {
if (err || _.isEmpty(missing)) {
loading.close();
context.redrawEnable(true);
dispatch.change();
dispatch.call("change");
}
};
@@ -364,7 +366,7 @@ export function History(context) {
}
if (loadComplete) {
dispatch.change();
dispatch.call("change");
}
return history;
@@ -409,5 +411,5 @@ export function History(context) {
history.reset();
return d3.rebind(history, dispatch, 'on');
return rebind(history, dispatch, 'on');
}
+4 -3
View File
@@ -1,3 +1,4 @@
import * as d3 from 'd3';
import _ from 'lodash';
import { Extent, joinWays, polygonContainsPolygon, polygonIntersectsPolygon } from '../geo/index';
import { Entity } from './entity';
@@ -191,7 +192,7 @@ _.extend(Relation.prototype, {
area: function(resolver) {
return resolver.transient(this, 'area', function() {
return d3.geo.area(this.asGeoJSON(resolver));
return d3.geoArea(this.asGeoJSON(resolver));
});
},
@@ -235,7 +236,7 @@ _.extend(Relation.prototype, {
var result = outers.map(function(o) {
// Heuristic for detecting counterclockwise winding order. Assumes
// that OpenStreetMap polygons are not hemisphere-spanning.
return [d3.geo.area({type: 'Polygon', coordinates: [o]}) > 2 * Math.PI ? o.reverse() : o];
return [d3.geoArea({type: 'Polygon', coordinates: [o]}) > 2 * Math.PI ? o.reverse() : o];
});
function findOuter(inner) {
@@ -257,7 +258,7 @@ _.extend(Relation.prototype, {
for (var i = 0; i < inners.length; i++) {
var inner = inners[i];
if (d3.geo.area({type: 'Polygon', coordinates: [inner]}) < 2 * Math.PI) {
if (d3.geoArea({type: 'Polygon', coordinates: [inner]}) < 2 * Math.PI) {
inner = inner.reverse();
}
+3 -2
View File
@@ -1,3 +1,4 @@
import * as d3 from 'd3';
import _ from 'lodash';
import { Extent, cross } from '../geo/index';
import { Entity } from './entity';
@@ -336,13 +337,13 @@ _.extend(Way.prototype, {
json.coordinates[0].push(nodes[0].loc);
}
var area = d3.geo.area(json);
var area = d3.geoArea(json);
// Heuristic for detecting counterclockwise winding order. Assumes
// that OpenStreetMap polygons are not hemisphere-spanning.
if (area > 2 * Math.PI) {
json.coordinates[0] = json.coordinates[0].reverse();
area = d3.geo.area(json);
area = d3.geoArea(json);
}
return isNaN(area) ? 0 : area;