diff --git a/dist/index.html b/dist/index.html
index 530e57539..d3b539eaf 100644
--- a/dist/index.html
+++ b/dist/index.html
@@ -34,6 +34,7 @@
} else {
var context = iD.coreContext();
+ context.init();
// disable boundaries (unless we have an explicit disable_features list)
var q = iD.utilStringQs(window.location.hash.substring(1));
diff --git a/index.html b/index.html
index 6273832b3..1d6f99187 100644
--- a/index.html
+++ b/index.html
@@ -34,6 +34,7 @@
} else {
var context = iD.coreContext().assetPath('dist/');
window.context = window.id = context; // for debugging
+ context.init();
// disable boundaries (unless we have an explicit disable_features list)
var q = iD.utilStringQs(window.location.hash.substring(1));
diff --git a/modules/core/context.js b/modules/core/context.js
index 7f3c482b3..5a54985a1 100644
--- a/modules/core/context.js
+++ b/modules/core/context.js
@@ -472,103 +472,106 @@ export function coreContext() {
/* Init */
+ context.init = () => {
+ context.projection = geoRawMercator();
+ context.curtainProjection = geoRawMercator();
- context.projection = geoRawMercator();
- context.curtainProjection = geoRawMercator();
-
- _locale = utilDetect().locale;
- if (_locale && !dataLocales.hasOwnProperty(_locale)) {
- _locale = _locale.split('-')[0];
- }
-
- _data = coreData(context);
- _history = coreHistory(context);
- _validator = coreValidator(context);
-
- context.graph = _history.graph;
- context.changes = _history.changes;
- context.intersects = _history.intersects;
- context.pauseChangeDispatch = _history.pauseChangeDispatch;
- context.resumeChangeDispatch = _history.resumeChangeDispatch;
-
- // Debounce save, since it's a synchronous localStorage write,
- // and history changes can happen frequently (e.g. when dragging).
- context.debouncedSave = _debounce(context.save, 350);
- function withDebouncedSave(fn) {
- return function() {
- const result = fn.apply(_history, arguments);
- context.debouncedSave();
- return result;
- };
- }
-
- context.perform = withDebouncedSave(_history.perform);
- context.replace = withDebouncedSave(_history.replace);
- context.pop = withDebouncedSave(_history.pop);
- context.overwrite = withDebouncedSave(_history.overwrite);
- context.undo = withDebouncedSave(_history.undo);
- context.redo = withDebouncedSave(_history.redo);
-
- _ui = uiInit(context);
-
- _connection = services.osm;
- _background = rendererBackground(context);
- _features = rendererFeatures(context);
- _photos = rendererPhotos(context);
- _presets = presetIndex(context);
-
- const hash = utilStringQs(window.location.hash);
-
- if (services.maprules && hash.maprules) {
- d3_json(hash.maprules)
- .then(mapcss => {
- services.maprules.init();
- mapcss.forEach(mapcssSelector => services.maprules.addRule(mapcssSelector));
- })
- .catch(() => { /* ignore */ });
- }
-
- _map = rendererMap(context);
- context.mouse = _map.mouse;
- context.extent = _map.extent;
- context.pan = _map.pan;
- context.zoomIn = _map.zoomIn;
- context.zoomOut = _map.zoomOut;
- context.zoomInFurther = _map.zoomInFurther;
- context.zoomOutFurther = _map.zoomOutFurther;
- context.redrawEnable = _map.redrawEnable;
-
- Object.values(services).forEach(service => {
- if (service && typeof service.init === 'function') {
- service.init(context);
+ _locale = utilDetect().locale;
+ if (_locale && !dataLocales.hasOwnProperty(_locale)) {
+ _locale = _locale.split('-')[0];
}
- });
- _validator.init();
- _background.init();
- _features.init();
- _photos.init();
+ _data = coreData(context);
+ _history = coreHistory(context);
+ _validator = coreValidator(context);
- let presetsParameter = hash.presets;
- if (presetsParameter && presetsParameter.indexOf('://') !== -1) {
- // a URL of external presets file
- _presets.fromExternal(external, (externalPresets) => {
- context.presets = () => externalPresets; // default + external presets...
+ context.graph = _history.graph;
+ context.changes = _history.changes;
+ context.intersects = _history.intersects;
+ context.pauseChangeDispatch = _history.pauseChangeDispatch;
+ context.resumeChangeDispatch = _history.resumeChangeDispatch;
+
+ // Debounce save, since it's a synchronous localStorage write,
+ // and history changes can happen frequently (e.g. when dragging).
+ context.debouncedSave = _debounce(context.save, 350);
+ function withDebouncedSave(fn) {
+ return function() {
+ const result = fn.apply(_history, arguments);
+ context.debouncedSave();
+ return result;
+ };
+ }
+
+ context.perform = withDebouncedSave(_history.perform);
+ context.replace = withDebouncedSave(_history.replace);
+ context.pop = withDebouncedSave(_history.pop);
+ context.overwrite = withDebouncedSave(_history.overwrite);
+ context.undo = withDebouncedSave(_history.undo);
+ context.redo = withDebouncedSave(_history.redo);
+
+ _ui = uiInit(context);
+
+ _connection = services.osm;
+ _background = rendererBackground(context);
+ _features = rendererFeatures(context);
+ _photos = rendererPhotos(context);
+ _presets = presetIndex(context);
+
+ const hash = utilStringQs(window.location.hash);
+
+ if (services.maprules && hash.maprules) {
+ d3_json(hash.maprules)
+ .then(mapcss => {
+ services.maprules.init();
+ mapcss.forEach(mapcssSelector => services.maprules.addRule(mapcssSelector));
+ })
+ .catch(() => { /* ignore */ });
+ }
+
+ _map = rendererMap(context);
+ context.mouse = _map.mouse;
+ context.extent = _map.extent;
+ context.pan = _map.pan;
+ context.zoomIn = _map.zoomIn;
+ context.zoomOut = _map.zoomOut;
+ context.zoomInFurther = _map.zoomInFurther;
+ context.zoomOutFurther = _map.zoomOutFurther;
+ context.redrawEnable = _map.redrawEnable;
+
+ Object.values(services).forEach(service => {
+ if (service && typeof service.init === 'function') {
+ service.init(context);
+ }
+ });
+
+ _validator.init();
+ _background.init();
+ _features.init();
+ _photos.init();
+
+ let presetsParameter = hash.presets;
+ if (presetsParameter && presetsParameter.indexOf('://') !== -1) {
+ // a URL of external presets file
+ _presets.fromExternal(external, (externalPresets) => {
+ context.presets = () => externalPresets; // default + external presets...
+ osmSetAreaKeys(_presets.areaKeys());
+ osmSetPointTags(_presets.pointTags());
+ osmSetVertexTags(_presets.vertexTags());
+ });
+ } else {
+ let addablePresetIDs;
+ if (presetsParameter) {
+ // a list of allowed preset IDs
+ addablePresetIDs = presetsParameter.split(',');
+ }
+ _presets.init(addablePresetIDs);
osmSetAreaKeys(_presets.areaKeys());
osmSetPointTags(_presets.pointTags());
osmSetVertexTags(_presets.vertexTags());
- });
- } else {
- let addablePresetIDs;
- if (presetsParameter) {
- // a list of allowed preset IDs
- addablePresetIDs = presetsParameter.split(',');
}
- _presets.init(addablePresetIDs);
- osmSetAreaKeys(_presets.areaKeys());
- osmSetPointTags(_presets.pointTags());
- osmSetVertexTags(_presets.vertexTags());
- }
+ return context;
+ };
+
return context;
}
diff --git a/test/spec/actions/split.js b/test/spec/actions/split.js
index d37fe81de..419ee765f 100644
--- a/test/spec/actions/split.js
+++ b/test/spec/actions/split.js
@@ -1,7 +1,7 @@
describe('iD.actionSplit', function () {
beforeEach(function () {
- iD.areaKeys = iD.coreContext().presets().areaKeys();
+ iD.areaKeys = iD.coreContext().init().presets().areaKeys();
});
diff --git a/test/spec/behavior/hash.js b/test/spec/behavior/hash.js
index 683ec0b69..46bb9a4c9 100644
--- a/test/spec/behavior/hash.js
+++ b/test/spec/behavior/hash.js
@@ -4,7 +4,7 @@ describe('iD.behaviorHash', function () {
var hash, context;
beforeEach(function () {
- context = iD.coreContext();
+ context = iD.coreContext().init();
var container = d3.select(document.createElement('div'));
context.container(container);
container.call(context.map());
diff --git a/test/spec/behavior/lasso.js b/test/spec/behavior/lasso.js
index 56b4be6e6..5a3847423 100644
--- a/test/spec/behavior/lasso.js
+++ b/test/spec/behavior/lasso.js
@@ -2,7 +2,7 @@ describe('iD.behaviorLasso', function () {
var context, lasso;
beforeEach(function () {
- context = iD.coreContext();
+ context = iD.coreContext().init();
d3.select(document.createElement('div'))
.attr('id', 'map')
.call(context.map());
diff --git a/test/spec/behavior/select.js b/test/spec/behavior/select.js
index ef42baa0e..e3ffcfd45 100644
--- a/test/spec/behavior/select.js
+++ b/test/spec/behavior/select.js
@@ -3,7 +3,7 @@ describe('iD.behaviorSelect', function() {
beforeEach(function() {
container = d3.select('body').append('div');
- context = iD.coreContext().container(container);
+ context = iD.coreContext().container(container).init();
a = iD.osmNode({loc: [0, 0]});
b = iD.osmNode({loc: [0, 0]});
diff --git a/test/spec/core/context.js b/test/spec/core/context.js
index 0e55ad0be..6b603aafd 100644
--- a/test/spec/core/context.js
+++ b/test/spec/core/context.js
@@ -5,7 +5,7 @@ describe('iD.coreContext', function() {
describe('#assetPath', function() {
it('sets and gets assetPath', function() {
- var context = iD.coreContext();
+ var context = iD.coreContext().init();
expect(context.assetPath()).to.eql('');
context.assetPath('iD/');
@@ -15,7 +15,7 @@ describe('iD.coreContext', function() {
describe('#assetMap', function() {
it('sets and gets assetMap', function() {
- var context = iD.coreContext();
+ var context = iD.coreContext().init();
expect(context.assetMap()).to.eql({});
context.assetMap(assets);
@@ -26,7 +26,7 @@ describe('iD.coreContext', function() {
describe('#asset', function() {
var context;
beforeEach(function() {
- context = iD.coreContext().assetPath('iD/').assetMap(assets);
+ context = iD.coreContext().assetPath('iD/').assetMap(assets).init();
});
it('ignores absolute urls', function() {
@@ -44,7 +44,7 @@ describe('iD.coreContext', function() {
describe('#imagePath', function() {
var context;
beforeEach(function() {
- context = iD.coreContext().assetPath('iD/').assetMap(assets);
+ context = iD.coreContext().assetPath('iD/').assetMap(assets).init();
});
it('looks first in assetMap', function() {
@@ -57,7 +57,7 @@ describe('iD.coreContext', function() {
describe('#debug', function() {
it('sets and gets debug flags', function() {
- var context = iD.coreContext();
+ var context = iD.coreContext().init();
var flags = {
tile: false,
collision: false,
diff --git a/test/spec/core/data.js b/test/spec/core/data.js
index b9443c60d..bd26f8f5d 100644
--- a/test/spec/core/data.js
+++ b/test/spec/core/data.js
@@ -10,7 +10,7 @@ describe('iD.coreData', function() {
});
beforeEach(function() {
- _context = iD.coreContext();
+ _context = iD.coreContext().init();
});
diff --git a/test/spec/core/history.js b/test/spec/core/history.js
index d355961f7..517bed1c8 100644
--- a/test/spec/core/history.js
+++ b/test/spec/core/history.js
@@ -8,7 +8,7 @@ describe('iD.coreHistory', function () {
};
beforeEach(function () {
- context = iD.coreContext();
+ context = iD.coreContext().init();
history = context.history();
spy = sinon.spy();
// clear lock
diff --git a/test/spec/core/tree.js b/test/spec/core/tree.js
index 7f0522d8b..970bba212 100644
--- a/test/spec/core/tree.js
+++ b/test/spec/core/tree.js
@@ -1,8 +1,8 @@
-describe('iD.Tree', function() {
+describe('iD.coreTree', function() {
describe('#rebase', function() {
it('adds entities to the tree', function() {
var graph = iD.coreGraph(),
- tree = iD.Tree(graph),
+ tree = iD.coreTree(graph),
node = iD.osmNode({id: 'n', loc: [1, 1]});
graph.rebase([node], [graph]);
@@ -13,7 +13,7 @@ describe('iD.Tree', function() {
it('is idempotent', function() {
var graph = iD.coreGraph(),
- tree = iD.Tree(graph),
+ tree = iD.coreTree(graph),
node = iD.osmNode({id: 'n', loc: [1, 1]}),
extent = iD.geoExtent([0, 0], [2, 2]);
@@ -28,7 +28,7 @@ describe('iD.Tree', function() {
it('does not insert if entity has a modified version', function() {
var graph = iD.coreGraph(),
- tree = iD.Tree(graph),
+ tree = iD.coreTree(graph),
node = iD.osmNode({id: 'n', loc: [1, 1]}),
node_ = node.update({loc: [10, 10]}),
g = graph.replace(node_);
@@ -44,7 +44,7 @@ describe('iD.Tree', function() {
it('does not error on self-referencing relations', function() {
var graph = iD.coreGraph(),
- tree = iD.Tree(graph),
+ tree = iD.coreTree(graph),
node = iD.osmNode({id: 'n', loc: [1, 1]}),
relation = iD.osmRelation();
@@ -59,7 +59,7 @@ describe('iD.Tree', function() {
it('adjusts entities that are force-rebased', function() {
var graph = iD.coreGraph(),
- tree = iD.Tree(graph),
+ tree = iD.coreTree(graph),
node = iD.osmNode({id: 'n', loc: [1, 1]});
graph.rebase([node], [graph]);
@@ -76,7 +76,7 @@ describe('iD.Tree', function() {
describe('#intersects', function() {
it('includes entities within extent, excludes those without', function() {
var graph = iD.coreGraph(),
- tree = iD.Tree(graph),
+ tree = iD.coreTree(graph),
n1 = iD.osmNode({loc: [1, 1]}),
n2 = iD.osmNode({loc: [3, 3]}),
extent = iD.geoExtent([0, 0], [2, 2]);
@@ -87,7 +87,7 @@ describe('iD.Tree', function() {
it('includes intersecting relations after incomplete members are loaded', function() {
var graph = iD.coreGraph(),
- tree = iD.Tree(graph),
+ tree = iD.coreTree(graph),
n1 = iD.osmNode({id: 'n1', loc: [0, 0]}),
n2 = iD.osmNode({id: 'n2', loc: [1, 1]}),
relation = iD.osmRelation({id: 'r', members: [{id: 'n1'}, {id: 'n2'}]}),
@@ -105,7 +105,7 @@ describe('iD.Tree', function() {
// This happens when local storage includes a changed way but not its nodes.
it('includes intersecting ways after missing nodes are loaded', function() {
var base = iD.coreGraph(),
- tree = iD.Tree(base),
+ tree = iD.coreTree(base),
node = iD.osmNode({id: 'n', loc: [0.5, 0.5]}),
way = iD.osmWay({nodes: ['n']}),
graph = base.replace(way),
@@ -120,7 +120,7 @@ describe('iD.Tree', function() {
it('adjusts parent ways when a member node is moved', function() {
var graph = iD.coreGraph(),
- tree = iD.Tree(graph),
+ tree = iD.coreTree(graph),
node = iD.osmNode({id: 'n', loc: [1, 1]}),
way = iD.osmWay({nodes: ['n']}),
extent = iD.geoExtent([0, 0], [2, 2]);
@@ -134,7 +134,7 @@ describe('iD.Tree', function() {
it('adjusts parent relations when a member node is moved', function() {
var graph = iD.coreGraph(),
- tree = iD.Tree(graph),
+ tree = iD.coreTree(graph),
node = iD.osmNode({id: 'n', loc: [1, 1]}),
relation = iD.osmRelation({members: [{type: 'node', id: 'n'}]}),
extent = iD.geoExtent([0, 0], [2, 2]);
@@ -148,7 +148,7 @@ describe('iD.Tree', function() {
it('adjusts parent relations of parent ways when a member node is moved', function() {
var graph = iD.coreGraph(),
- tree = iD.Tree(graph),
+ tree = iD.coreTree(graph),
node = iD.osmNode({id: 'n', loc: [1, 1]}),
way = iD.osmWay({id: 'w', nodes: ['n']}),
relation = iD.osmRelation({members: [{type: 'multipolygon', id: 'w'}]}),
@@ -163,7 +163,7 @@ describe('iD.Tree', function() {
it('adjusts parent ways when a member node is removed', function() {
var graph = iD.coreGraph(),
- tree = iD.Tree(graph),
+ tree = iD.coreTree(graph),
n1 = iD.osmNode({id: 'n1', loc: [1, 1]}),
n2 = iD.osmNode({id: 'n2', loc: [3, 3]}),
way = iD.osmWay({nodes: ['n1', 'n2']}),
@@ -179,7 +179,7 @@ describe('iD.Tree', function() {
it('don\'t include parent way multiple times when multiple child nodes are moved', function() {
// checks against the following regression: https://github.com/openstreetmap/iD/issues/1978
var graph = iD.coreGraph(),
- tree = iD.Tree(graph),
+ tree = iD.coreTree(graph),
n1 = iD.osmNode({id: 'n1', loc: [1, 1]}),
n2 = iD.osmNode({id: 'n2', loc: [3, 3]}),
way = iD.osmWay({id: 'w1', nodes: ['n1', 'n2']}),
@@ -195,7 +195,7 @@ describe('iD.Tree', function() {
it('doesn\'t include removed entities', function() {
var graph = iD.coreGraph(),
- tree = iD.Tree(graph),
+ tree = iD.coreTree(graph),
node = iD.osmNode({loc: [1, 1]}),
extent = iD.geoExtent([0, 0], [2, 2]);
@@ -208,7 +208,7 @@ describe('iD.Tree', function() {
it('doesn\'t include removed entities after rebase', function() {
var base = iD.coreGraph(),
- tree = iD.Tree(base),
+ tree = iD.coreTree(base),
node = iD.osmNode({id: 'n', loc: [1, 1]}),
extent = iD.geoExtent([0, 0], [2, 2]);
@@ -222,7 +222,7 @@ describe('iD.Tree', function() {
it('handles recursive relations', function() {
var base = iD.coreGraph(),
- tree = iD.Tree(base),
+ tree = iD.coreTree(base),
node = iD.osmNode({id: 'n', loc: [1, 1]}),
r1 = iD.osmRelation({id: 'r1', members: [{id: 'n'}]}),
r2 = iD.osmRelation({id: 'r2', members: [{id: 'r1'}]}),
diff --git a/test/spec/core/validator.js b/test/spec/core/validator.js
index 36cfb814a..5592a2c13 100644
--- a/test/spec/core/validator.js
+++ b/test/spec/core/validator.js
@@ -2,7 +2,7 @@ describe('iD.coreValidator', function () {
var context;
beforeEach(function() {
- context = iD.coreContext();
+ context = iD.coreContext().init();
});
function createInvalidWay() {
diff --git a/test/spec/modes/add_note.js b/test/spec/modes/add_note.js
index da25a8e09..b4ddc9113 100644
--- a/test/spec/modes/add_note.js
+++ b/test/spec/modes/add_note.js
@@ -11,9 +11,9 @@ describe('iD.modeAddNote', function() {
beforeEach(function() {
var container = d3.select(document.createElement('div'));
-
context = iD.coreContext()
- .container(container);
+ .container(container)
+ .init();
context.loadTiles = function () {};
diff --git a/test/spec/modes/add_point.js b/test/spec/modes/add_point.js
index d46cdea98..0b728e870 100644
--- a/test/spec/modes/add_point.js
+++ b/test/spec/modes/add_point.js
@@ -5,7 +5,8 @@ describe.skip('iD.modeAddPoint', function() {
var container = d3.select(document.createElement('div'));
context = iD.coreContext()
- .container(container);
+ .container(container)
+ .init();
context.loadTiles = function () {};
diff --git a/test/spec/osm/way.js b/test/spec/osm/way.js
index ad272a6c4..c0789f192 100644
--- a/test/spec/osm/way.js
+++ b/test/spec/osm/way.js
@@ -406,7 +406,7 @@ describe('iD.osmWay', function() {
describe('#isArea', function() {
before(function() {
- iD.coreContext();
+ iD.coreContext().init();
});
it('returns false when the way has no tags', function() {
diff --git a/test/spec/presets/index.js b/test/spec/presets/index.js
index d6707cdee..0db203444 100644
--- a/test/spec/presets/index.js
+++ b/test/spec/presets/index.js
@@ -24,7 +24,7 @@ describe('iD.presetIndex', function () {
it('returns a collection containing presets matching a geometry and tags', function () {
iD.data.presets = testPresets;
- var presets = iD.coreContext().presets();
+ var presets = iD.coreContext().init().presets();
var way = iD.osmWay({ tags: { highway: 'residential' } });
var graph = iD.coreGraph([way]);
@@ -33,7 +33,7 @@ describe('iD.presetIndex', function () {
it('returns the appropriate fallback preset when no tags match', function () {
iD.data.presets = testPresets;
- var presets = iD.coreContext().presets();
+ var presets = iD.coreContext().init().presets();
var point = iD.osmNode();
var line = iD.osmWay({ tags: { foo: 'bar' } });
var graph = iD.coreGraph([point, line]);
@@ -44,7 +44,7 @@ describe('iD.presetIndex', function () {
it('matches vertices on a line as points', function () {
iD.data.presets = testPresets;
- var presets = iD.coreContext().presets();
+ var presets = iD.coreContext().init().presets();
var point = iD.osmNode({ tags: { leisure: 'park' } });
var line = iD.osmWay({ nodes: [point.id], tags: { 'highway': 'residential' } });
var graph = iD.coreGraph([point, line]);
@@ -54,7 +54,7 @@ describe('iD.presetIndex', function () {
it('matches vertices on an addr:interpolation line as points', function () {
iD.data.presets = testPresets;
- var presets = iD.coreContext().presets();
+ var presets = iD.coreContext().init().presets();
var point = iD.osmNode({ tags: { leisure: 'park' } });
var line = iD.osmWay({ nodes: [point.id], tags: { 'addr:interpolation': 'even' } });
var graph = iD.coreGraph([point, line]);
@@ -79,44 +79,44 @@ describe('iD.presetIndex', function () {
it('whitelists keys for presets with area geometry', function () {
iD.data.presets = testPresets;
- var presets = iD.coreContext().presets();
+ var presets = iD.coreContext().init().presets();
expect(presets.areaKeys()).to.include.keys('natural');
});
it('blacklists key-values for presets with a line geometry', function () {
iD.data.presets = testPresets;
- var presets = iD.coreContext().presets();
+ var presets = iD.coreContext().init().presets();
expect(presets.areaKeys().natural).to.include.keys('tree_row');
expect(presets.areaKeys().natural.tree_row).to.be.true;
});
it('blacklists key-values for presets with both area and line geometry', function () {
iD.data.presets = testPresets;
- var presets = iD.coreContext().presets();
+ var presets = iD.coreContext().init().presets();
expect(presets.areaKeys().leisure).to.include.keys('track');
});
it('does not blacklist key-values for presets with neither area nor line geometry', function () {
iD.data.presets = testPresets;
- var presets = iD.coreContext().presets();
+ var presets = iD.coreContext().init().presets();
expect(presets.areaKeys().natural).not.to.include.keys('peak');
});
it('does not blacklist generic \'*\' key-values', function () {
iD.data.presets = testPresets;
- var presets = iD.coreContext().presets();
+ var presets = iD.coreContext().init().presets();
expect(presets.areaKeys().natural).not.to.include.keys('natural');
});
it('ignores keys like \'highway\' that are assumed to be lines', function () {
iD.data.presets = testPresets;
- var presets = iD.coreContext().presets();
+ var presets = iD.coreContext().init().presets();
expect(presets.areaKeys()).not.to.include.keys('highway');
});
it('ignores suggestion presets', function () {
iD.data.presets = testPresets;
- var presets = iD.coreContext().presets();
+ var presets = iD.coreContext().init().presets();
expect(presets.areaKeys()).not.to.include.keys('amenity');
});
});
@@ -125,7 +125,7 @@ describe('iD.presetIndex', function () {
it('builds presets from provided', function () {
var surfShop = iD.osmNode({ tags: { amenity: 'shop', 'shop:type': 'surf' } });
var graph = iD.coreGraph([surfShop]);
- var presets = iD.coreContext().presets();
+ var presets = iD.coreContext().init().presets();
var morePresets = {
presets: {
'amenity/shop/surf': {
@@ -145,7 +145,7 @@ describe('iD.presetIndex', function () {
var firstStreetJetty = iD.osmNode({ tags: { man_made: 'jetty' } });
var entities = [surfShop, firstStreetJetty];
var graph = iD.coreGraph(entities);
- var presets = iD.coreContext().presets();
+ var presets = iD.coreContext().init().presets();
var morePresets = {
presets: {
'amenity/shop/surf': {
@@ -199,7 +199,7 @@ describe('iD.presetIndex', function () {
it('prefers building to multipolygon', function () {
iD.data.presets = testPresets;
- var presets = iD.coreContext().presets();
+ var presets = iD.coreContext().init().presets();
var relation = iD.osmRelation({ tags: { type: 'multipolygon', building: 'yes' } });
var graph = iD.coreGraph([relation]);
expect(presets.match(relation, graph).id).to.eql('building');
@@ -207,7 +207,7 @@ describe('iD.presetIndex', function () {
it('prefers building to address', function () {
iD.data.presets = testPresets;
- var presets = iD.coreContext().presets();
+ var presets = iD.coreContext().init().presets();
var way = iD.osmWay({ tags: { area: 'yes', building: 'yes', 'addr:housenumber': '1234' } });
var graph = iD.coreGraph([way]);
expect(presets.match(way, graph).id).to.eql('building');
@@ -215,7 +215,7 @@ describe('iD.presetIndex', function () {
it('prefers pedestrian to area', function () {
iD.data.presets = testPresets;
- var presets = iD.coreContext().presets();
+ var presets = iD.coreContext().init().presets();
var way = iD.osmWay({ tags: { area: 'yes', highway: 'pedestrian' } });
var graph = iD.coreGraph([way]);
expect(presets.match(way, graph).id).to.eql('highway/pedestrian_area');
@@ -258,13 +258,13 @@ describe('iD.presetIndex', function () {
var url = 'https://fakemaprules.io/fake.json';
// no exernal presets yet
- expect(iD.coreContext().presets().match(surfShop, graph).id).to.eql('point');
+ expect(iD.coreContext().init().presets().match(surfShop, graph).id).to.eql('point');
// reset graph...
graph = iD.coreGraph([surfShop]);
// add the validations query param...
- iD.coreContext().presets().fromExternal(url, function (externalPresets) {
+ iD.coreContext().init().presets().fromExternal(url, function (externalPresets) {
expect(externalPresets.match(surfShop, graph).id).to.eql('8bc64d6d');
});
@@ -277,7 +277,7 @@ describe('iD.presetIndex', function () {
it('makes only the external presets initially addable', function () {
var url = 'https://fakemaprules.io/fake.json';
- iD.coreContext().presets().fromExternal(url, function(externalPresets) {
+ iD.coreContext().init().presets().fromExternal(url, function(externalPresets) {
var external = externalPresets.collection.reduce(function(presets, preset) {
if (!preset.hasOwnProperty('members') && preset.addable()) {
presets.push(preset.id);
diff --git a/test/spec/renderer/features.js b/test/spec/renderer/features.js
index 7afb66746..7476d141d 100644
--- a/test/spec/renderer/features.js
+++ b/test/spec/renderer/features.js
@@ -3,7 +3,7 @@ describe('iD.rendererFeatures', function() {
var context, features;
beforeEach(function() {
- context = iD.coreContext();
+ context = iD.coreContext().init();
d3.select(document.createElement('div'))
.attr('id', 'map')
.call(context.map());
diff --git a/test/spec/renderer/map.js b/test/spec/renderer/map.js
index ccb1dee2e..c2a5a59e6 100644
--- a/test/spec/renderer/map.js
+++ b/test/spec/renderer/map.js
@@ -3,7 +3,7 @@ describe('iD.Map', function() {
beforeEach(function() {
content = d3.select('body').append('div');
- context = iD.coreContext();
+ context = iD.coreContext().init();
map = context.map();
content.call(map);
});
diff --git a/test/spec/renderer/tile_layer.js b/test/spec/renderer/tile_layer.js
index 750df1d60..0196ee11f 100644
--- a/test/spec/renderer/tile_layer.js
+++ b/test/spec/renderer/tile_layer.js
@@ -2,7 +2,7 @@ describe('iD.TileLayer', function() {
var context, d, c;
beforeEach(function() {
- context = iD.coreContext();
+ context = iD.coreContext().init();
d = d3.select(document.createElement('div'));
c = iD.TileLayer(context).projection(d3.geoMercator());
});
@@ -11,14 +11,12 @@ describe('iD.TileLayer', function() {
d.remove();
});
- describe('iD.TileLayer', function() {
- it('is instantiated', function() {
- expect(c).to.be.ok;
- });
+ it('is instantiated', function() {
+ expect(c).to.be.ok;
+ });
- it('#dimensions', function() {
- expect(c.dimensions([100, 100])).to.equal(c);
- expect(c.dimensions()).to.eql([100,100]);
- });
+ it('#dimensions', function() {
+ expect(c.dimensions([100, 100])).to.equal(c);
+ expect(c.dimensions()).to.eql([100,100]);
});
});
diff --git a/test/spec/services/mapillary.js b/test/spec/services/mapillary.js
index e5ab0c3e7..8ff8c5fdd 100644
--- a/test/spec/services/mapillary.js
+++ b/test/spec/services/mapillary.js
@@ -12,7 +12,7 @@ describe('iD.serviceMapillary', function() {
});
beforeEach(function() {
- context = iD.coreContext().assetPath('../dist/');
+ context = iD.coreContext().assetPath('../dist/').init();
context.projection
.scale(iD.geoZoomToScale(14))
.translate([-116508, 0]) // 10,0
diff --git a/test/spec/services/openstreetcam.js b/test/spec/services/openstreetcam.js
index 5553c4a49..e53218fdf 100644
--- a/test/spec/services/openstreetcam.js
+++ b/test/spec/services/openstreetcam.js
@@ -11,7 +11,7 @@ describe('iD.serviceOpenstreetcam', function() {
});
beforeEach(function() {
- context = iD.coreContext().assetPath('../dist/');
+ context = iD.coreContext().assetPath('../dist/').init();
context.projection
.scale(iD.geoZoomToScale(14))
.translate([-116508, 0]) // 10,0
diff --git a/test/spec/services/osm.js b/test/spec/services/osm.js
index 61625a15b..2832c15b5 100644
--- a/test/spec/services/osm.js
+++ b/test/spec/services/osm.js
@@ -27,7 +27,7 @@ describe('iD.serviceOsm', function () {
beforeEach(function () {
serverFetch = window.fakeFetch().create(); // unauthenticated calls use d3-fetch
serverXHR = sinon.fakeServer.create(); // authenticated calls use XHR via osm-auth
- context = iD.coreContext();
+ context = iD.coreContext().init();
connection = context.connection();
connection.switch({ urlroot: 'http://www.openstreetmap.org' });
connection.reset();
diff --git a/test/spec/services/streetside.js b/test/spec/services/streetside.js
index 9231f0a31..be7b299eb 100644
--- a/test/spec/services/streetside.js
+++ b/test/spec/services/streetside.js
@@ -11,7 +11,7 @@ describe('iD.serviceStreetside', function() {
});
beforeEach(function() {
- context = iD.coreContext().assetPath('../dist/');
+ context = iD.coreContext().assetPath('../dist/').init();
context.projection
.scale(iD.geoZoomToScale(14))
.translate([-116508, 0]) // 10,0
diff --git a/test/spec/svg/areas.js b/test/spec/svg/areas.js
index b4241bd57..a08fbf5d2 100644
--- a/test/spec/svg/areas.js
+++ b/test/spec/svg/areas.js
@@ -9,7 +9,7 @@ describe('iD.svgAreas', function () {
beforeEach(function () {
- context = iD.coreContext();
+ context = iD.coreContext().init();
d3.select(document.createElement('div'))
.attr('id', 'map')
.call(context.map().centerZoom([0, 0], 17));
diff --git a/test/spec/svg/data.js b/test/spec/svg/data.js
index 426854409..340a3a60f 100644
--- a/test/spec/svg/data.js
+++ b/test/spec/svg/data.js
@@ -81,7 +81,7 @@ describe('iD.svgData', function () {
}
beforeEach(function () {
- context = iD.coreContext();
+ context = iD.coreContext().init();
d3.select(document.createElement('div'))
.attr('id', 'map')
.call(context.map().centerZoom([-74.389286, 40.1502754], 17));
diff --git a/test/spec/svg/layers.js b/test/spec/svg/layers.js
index 5ac4d8bc2..09b2b85ce 100644
--- a/test/spec/svg/layers.js
+++ b/test/spec/svg/layers.js
@@ -6,7 +6,7 @@ describe('iD.svgLayers', function () {
.clipExtent([[0, 0], [Infinity, Infinity]]);
beforeEach(function () {
- context = iD.coreContext();
+ context = iD.coreContext().init();
container = d3.select(document.createElement('div'));
});
diff --git a/test/spec/svg/lines.js b/test/spec/svg/lines.js
index 1edce33ef..cd1224d89 100644
--- a/test/spec/svg/lines.js
+++ b/test/spec/svg/lines.js
@@ -9,7 +9,7 @@ describe('iD.svgLines', function () {
beforeEach(function () {
- context = iD.coreContext();
+ context = iD.coreContext().init();
d3.select(document.createElement('div'))
.attr('id', 'map')
.call(context.map().centerZoom([0, 0], 17));
diff --git a/test/spec/svg/midpoints.js b/test/spec/svg/midpoints.js
index c30530fae..6339ee0ae 100644
--- a/test/spec/svg/midpoints.js
+++ b/test/spec/svg/midpoints.js
@@ -9,7 +9,7 @@ describe('iD.svgMidpoints', function () {
beforeEach(function () {
- context = iD.coreContext();
+ context = iD.coreContext().init();
context.enter({
id: 'select',
enter: function() { },
diff --git a/test/spec/svg/points.js b/test/spec/svg/points.js
index c1012a7cd..9acea2758 100644
--- a/test/spec/svg/points.js
+++ b/test/spec/svg/points.js
@@ -6,7 +6,7 @@ describe('iD.svgPoints', function () {
.clipExtent([[0, 0], [Infinity, Infinity]]);
beforeEach(function () {
- context = iD.coreContext();
+ context = iD.coreContext().init();
d3.select(document.createElement('div'))
.attr('id', 'map')
.call(context.map().centerZoom([0, 0], 17));
diff --git a/test/spec/svg/vertices.js b/test/spec/svg/vertices.js
index 1c29ca70d..d6fa5d297 100644
--- a/test/spec/svg/vertices.js
+++ b/test/spec/svg/vertices.js
@@ -8,7 +8,7 @@ describe('iD.svgVertices', function () {
beforeEach(function () {
- context = iD.coreContext();
+ context = iD.coreContext().init();
d3.select(document.createElement('div'))
.attr('id', 'map')
.call(context.map().centerZoom([0, 0], 17));
diff --git a/test/spec/ui/combobox.js b/test/spec/ui/combobox.js
index 978ff62c8..86eab1884 100644
--- a/test/spec/ui/combobox.js
+++ b/test/spec/ui/combobox.js
@@ -66,7 +66,7 @@ describe('uiCombobox', function() {
beforeEach(function() {
body = d3.select('body');
container = body.append('div').attr('class', 'id-container');
- context = iD.coreContext().container(container);
+ context = iD.coreContext().container(container).init();
content = container.append('div');
input = content.append('input');
combobox = iD.uiCombobox(context);
diff --git a/test/spec/ui/fields/access.js b/test/spec/ui/fields/access.js
index 81a7c8a6c..f629d4482 100644
--- a/test/spec/ui/fields/access.js
+++ b/test/spec/ui/fields/access.js
@@ -2,7 +2,7 @@ describe('iD.uiFieldAccess', function() {
var context, selection, field;
beforeEach(function() {
- context = iD.coreContext();
+ context = iD.coreContext().init();
selection = d3.select(document.createElement('div'));
field = iD.presetField('access', {
keys: ['access', 'foot', 'motor_vehicle', 'bicycle', 'horse'],
diff --git a/test/spec/ui/fields/localized.js b/test/spec/ui/fields/localized.js
index fbc815ac9..b2f07a90b 100644
--- a/test/spec/ui/fields/localized.js
+++ b/test/spec/ui/fields/localized.js
@@ -15,7 +15,7 @@ describe('iD.uiFieldLocalized', function() {
});
beforeEach(function() {
- context = iD.coreContext();
+ context = iD.coreContext().init();
selection = d3.select(document.createElement('div'));
field = iD.presetField('name', { key: 'name', type: 'localized' });
field.locked = function() { return false; };
diff --git a/test/spec/ui/fields/wikipedia.js b/test/spec/ui/fields/wikipedia.js
index 01bb4ff35..e3aa6aa2f 100644
--- a/test/spec/ui/fields/wikipedia.js
+++ b/test/spec/ui/fields/wikipedia.js
@@ -51,7 +51,7 @@ describe('iD.uiFieldWikipedia', function() {
beforeEach(function() {
entity = iD.osmNode({id: 'n12345'});
- context = iD.coreContext();
+ context = iD.coreContext().init();
context.history().merge([entity]);
selection = d3.select(document.createElement('div'));
field = iD.presetField('wikipedia', {
diff --git a/test/spec/ui/raw_tag_editor.js b/test/spec/ui/raw_tag_editor.js
index f0f3bc526..a6b6885d6 100644
--- a/test/spec/ui/raw_tag_editor.js
+++ b/test/spec/ui/raw_tag_editor.js
@@ -16,7 +16,7 @@ describe('iD.uiRawTagEditor', function() {
beforeEach(function () {
entity = iD.osmNode({id: 'n12345'});
- context = iD.coreContext();
+ context = iD.coreContext().init();
context.history().merge([entity]);
render({highway: 'residential'});
});
diff --git a/test/spec/validations/almost_junction.js b/test/spec/validations/almost_junction.js
index 378665029..83cef265e 100644
--- a/test/spec/validations/almost_junction.js
+++ b/test/spec/validations/almost_junction.js
@@ -2,7 +2,7 @@ describe('iD.validations.almost_junction', function () {
var context;
beforeEach(function() {
- context = iD.coreContext();
+ context = iD.coreContext().init();
});
function horizontalVertialCloserThanThd() {
diff --git a/test/spec/validations/crossing_ways.js b/test/spec/validations/crossing_ways.js
index 5d719edac..639aa2b61 100644
--- a/test/spec/validations/crossing_ways.js
+++ b/test/spec/validations/crossing_ways.js
@@ -2,7 +2,7 @@ describe('iD.validations.crossing_ways', function () {
var context;
beforeEach(function() {
- context = iD.coreContext();
+ context = iD.coreContext().init();
});
function createWaysWithOneCrossingPoint(tags1, tags2) {
diff --git a/test/spec/validations/disconnected_way.js b/test/spec/validations/disconnected_way.js
index f6b63dd48..e10eab331 100644
--- a/test/spec/validations/disconnected_way.js
+++ b/test/spec/validations/disconnected_way.js
@@ -2,7 +2,7 @@ describe('iD.validations.disconnected_way', function () {
var context;
beforeEach(function() {
- context = iD.coreContext();
+ context = iD.coreContext().init();
});
function createWay(tags) {
diff --git a/test/spec/validations/incompatible_source.js b/test/spec/validations/incompatible_source.js
index c4f4cd9cf..e80d224fc 100644
--- a/test/spec/validations/incompatible_source.js
+++ b/test/spec/validations/incompatible_source.js
@@ -2,7 +2,7 @@ describe('iD.validations.incompatible_source', function () {
var context;
beforeEach(function() {
- context = iD.coreContext();
+ context = iD.coreContext().init();
});
function createWay(tags) {
diff --git a/test/spec/validations/mismatched_geometry.js b/test/spec/validations/mismatched_geometry.js
index 2970ae23f..b7279b522 100644
--- a/test/spec/validations/mismatched_geometry.js
+++ b/test/spec/validations/mismatched_geometry.js
@@ -2,7 +2,7 @@ describe('iD.validations.mismatched_geometry', function () {
var context;
beforeEach(function() {
- context = iD.Context();
+ context = iD.coreContext().init();
});
function createPoint(tags) {
diff --git a/test/spec/validations/missing_role.js b/test/spec/validations/missing_role.js
index 8aa02cf2b..de63a4ecd 100644
--- a/test/spec/validations/missing_role.js
+++ b/test/spec/validations/missing_role.js
@@ -2,7 +2,7 @@ describe('iD.validations.missing_role', function () {
var context;
beforeEach(function() {
- context = iD.coreContext();
+ context = iD.coreContext().init();
});
function createWay(tags) {
diff --git a/test/spec/validations/missing_tag.js b/test/spec/validations/missing_tag.js
index 43655541f..94aa7fe76 100644
--- a/test/spec/validations/missing_tag.js
+++ b/test/spec/validations/missing_tag.js
@@ -2,7 +2,7 @@ describe('iD.validations.missing_tag', function () {
var context;
beforeEach(function() {
- context = iD.coreContext();
+ context = iD.coreContext().init();
});
function createWay(tags) {
diff --git a/test/spec/validations/outdated_tags.js b/test/spec/validations/outdated_tags.js
index 26aa3392d..e8e9faa1b 100644
--- a/test/spec/validations/outdated_tags.js
+++ b/test/spec/validations/outdated_tags.js
@@ -13,7 +13,7 @@ describe('iD.validations.outdated_tags', function () {
});
beforeEach(function() {
- context = iD.coreContext();
+ context = iD.coreContext().init();
});
diff --git a/test/spec/validations/private_data.js b/test/spec/validations/private_data.js
index 93a935597..bafbe0300 100644
--- a/test/spec/validations/private_data.js
+++ b/test/spec/validations/private_data.js
@@ -2,7 +2,7 @@ describe('iD.validations.private_data', function () {
var context;
beforeEach(function() {
- context = iD.coreContext();
+ context = iD.coreContext().init();
});
function createWay(tags) {
diff --git a/test/spec/validations/suspicious_name.js b/test/spec/validations/suspicious_name.js
index ba2fb186e..1a51983d1 100644
--- a/test/spec/validations/suspicious_name.js
+++ b/test/spec/validations/suspicious_name.js
@@ -2,7 +2,7 @@ describe('iD.validations.suspicious_name', function () {
var context;
beforeEach(function() {
- context = iD.coreContext();
+ context = iD.coreContext().init();
});
function createWay(tags) {