mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-17 22:24:49 +02:00
Replace coreContext.geometry function with a more explicit coreGraph.geometry function
This commit is contained in:
@@ -25,7 +25,7 @@ export function behaviorDrawWay(context, wayID, index, mode, startGraph) {
|
||||
|
||||
var _annotation = t((_origWay.isDegenerate() ?
|
||||
'operations.start.annotation.' :
|
||||
'operations.continue.annotation.') + context.geometry(wayID)
|
||||
'operations.continue.annotation.') + _origWay.geometry(context.graph())
|
||||
);
|
||||
|
||||
var behavior = behaviorDraw(context);
|
||||
|
||||
@@ -247,7 +247,6 @@ export function coreContext() {
|
||||
/* Graph */
|
||||
context.hasEntity = (id) => _history.graph().hasEntity(id);
|
||||
context.entity = (id) => _history.graph().entity(id);
|
||||
context.geometry = (id) => context.entity(id).geometry(_history.graph());
|
||||
|
||||
|
||||
/* Modes */
|
||||
|
||||
@@ -46,6 +46,11 @@ coreGraph.prototype = {
|
||||
},
|
||||
|
||||
|
||||
geometry: function(id) {
|
||||
return this.entity(id).geometry(this);
|
||||
},
|
||||
|
||||
|
||||
transient: function(entity, key, fn) {
|
||||
var id = entity.id;
|
||||
var transients = this.transients[id] || (this.transients[id] = {});
|
||||
|
||||
@@ -38,7 +38,7 @@ export function modeMove(context, entityIDs, baseGraph) {
|
||||
operationRotate(entityIDs, context).behavior
|
||||
];
|
||||
var annotation = entityIDs.length === 1 ?
|
||||
t('operations.move.annotation.' + context.geometry(entityIDs[0])) :
|
||||
t('operations.move.annotation.' + context.graph().geometry(entityIDs[0])) :
|
||||
t('operations.move.annotation.multiple');
|
||||
|
||||
var _prevGraph;
|
||||
|
||||
@@ -42,7 +42,7 @@ export function modeRotate(context, entityIDs) {
|
||||
operationReflectShort(entityIDs, context).behavior
|
||||
];
|
||||
var annotation = entityIDs.length === 1 ?
|
||||
t('operations.rotate.annotation.' + context.geometry(entityIDs[0])) :
|
||||
t('operations.rotate.annotation.' + context.graph().geometry(entityIDs[0])) :
|
||||
t('operations.rotate.annotation.multiple');
|
||||
|
||||
var _prevGraph;
|
||||
|
||||
@@ -156,7 +156,7 @@ export function modeSelect(context, selectedIDs) {
|
||||
if (!editMenu) return;
|
||||
|
||||
var entity = singular();
|
||||
if (entity && context.geometry(entity.id) === 'relation') {
|
||||
if (entity && entity.geometry(context.graph()) === 'relation') {
|
||||
_suppressMenu = true;
|
||||
} else {
|
||||
var point = context.mouse();
|
||||
@@ -377,7 +377,7 @@ export function modeSelect(context, selectedIDs) {
|
||||
var surface = context.surface();
|
||||
var entity = singular();
|
||||
|
||||
if (entity && context.geometry(entity.id) === 'relation') {
|
||||
if (entity && entity.geometry(context.graph()) === 'relation') {
|
||||
_suppressMenu = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ export function operationDelete(selectedIDs, context) {
|
||||
if (selectedIDs.length === 1) {
|
||||
var id = selectedIDs[0];
|
||||
var entity = context.entity(id);
|
||||
var geometry = context.geometry(id);
|
||||
var geometry = entity.geometry(context.graph());
|
||||
var parents = context.graph().parentWays(entity);
|
||||
var parent = parents[0];
|
||||
|
||||
@@ -140,7 +140,7 @@ export function operationDelete(selectedIDs, context) {
|
||||
|
||||
operation.annotation = function() {
|
||||
return selectedIDs.length === 1 ?
|
||||
t('operations.delete.annotation.' + context.geometry(selectedIDs[0])) :
|
||||
t('operations.delete.annotation.' + context.graph().geometry(selectedIDs[0])) :
|
||||
t('operations.delete.annotation.multiple', { n: selectedIDs.length });
|
||||
};
|
||||
|
||||
|
||||
@@ -11,16 +11,17 @@ export function operationDisconnect(selectedIDs, context) {
|
||||
var actions = [];
|
||||
|
||||
selectedIDs.forEach(function(id) {
|
||||
if (context.geometry(id) === 'vertex') {
|
||||
var entity = context.entity(id);
|
||||
if (entity.geometry(context.graph()) === 'vertex') {
|
||||
vertexIDs.push(id);
|
||||
} else if (context.entity(id).type === 'way'){
|
||||
} else if (entity.type === 'way'){
|
||||
wayIDs.push(id);
|
||||
} else {
|
||||
otherIDs.push(id);
|
||||
}
|
||||
});
|
||||
|
||||
var disconnectingWayID = (vertexIDs.length === 0 && wayIDs.length === 1 && wayIDs[0]);
|
||||
var disconnectingWayID = vertexIDs.length === 0 && wayIDs.length === 1 && wayIDs[0];
|
||||
var extent, nodes, coords;
|
||||
|
||||
if (disconnectingWayID) { // disconnecting a way
|
||||
@@ -115,7 +116,7 @@ export function operationDisconnect(selectedIDs, context) {
|
||||
return t('operations.disconnect.' + disable);
|
||||
}
|
||||
if (disconnectingWayID) {
|
||||
return t('operations.disconnect.' + context.geometry(disconnectingWayID) + '.description');
|
||||
return t('operations.disconnect.' + context.graph().geometry(disconnectingWayID) + '.description');
|
||||
}
|
||||
return t('operations.disconnect.description');
|
||||
};
|
||||
|
||||
@@ -9,7 +9,7 @@ export function operationExtract(selectedIDs, context) {
|
||||
var entityID = selectedIDs.length && selectedIDs[0];
|
||||
var action = actionExtract(entityID, context.projection);
|
||||
|
||||
var geometry = entityID && context.geometry(entityID);
|
||||
var geometry = entityID && context.graph().geometry(entityID);
|
||||
var extent = geometry === 'area' && context.entity(entityID).extent(context.graph());
|
||||
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ export function operationMove(selectedIDs, context) {
|
||||
|
||||
operation.annotation = function() {
|
||||
return selectedIDs.length === 1 ?
|
||||
t('operations.move.annotation.' + context.geometry(selectedIDs[0])) :
|
||||
t('operations.move.annotation.' + context.graph().geometry(selectedIDs[0])) :
|
||||
t('operations.move.annotation.multiple');
|
||||
};
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ export function operationOrthogonalize(selectedIDs, context) {
|
||||
function chooseAction(entityID) {
|
||||
|
||||
var entity = context.entity(entityID);
|
||||
var geometry = context.geometry(entityID);
|
||||
var geometry = entity.geometry(context.graph());
|
||||
|
||||
if (!_extent) {
|
||||
_extent = entity.extent(context.graph());
|
||||
|
||||
@@ -69,7 +69,7 @@ export function operationRotate(selectedIDs, context) {
|
||||
|
||||
operation.annotation = function() {
|
||||
return selectedIDs.length === 1 ?
|
||||
t('operations.rotate.annotation.' + context.geometry(selectedIDs[0])) :
|
||||
t('operations.rotate.annotation.' + context.graph().geometry(selectedIDs[0])) :
|
||||
t('operations.rotate.annotation.multiple');
|
||||
};
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import { modeSelect } from '../modes/select';
|
||||
|
||||
export function operationSplit(selectedIDs, context) {
|
||||
var vertices = selectedIDs
|
||||
.filter(function(id) { return context.geometry(id) === 'vertex'; });
|
||||
.filter(function(id) { return context.graph().geometry(id) === 'vertex'; });
|
||||
var entityID = vertices[0];
|
||||
var action = actionSplit(entityID);
|
||||
var ways = [];
|
||||
@@ -48,7 +48,7 @@ export function operationSplit(selectedIDs, context) {
|
||||
if (disable) {
|
||||
return t('operations.split.' + disable);
|
||||
} else if (ways.length === 1) {
|
||||
return t('operations.split.description.' + context.geometry(ways[0].id));
|
||||
return t('operations.split.description.' + context.graph().geometry(ways[0].id));
|
||||
} else {
|
||||
return t('operations.split.description.multiple');
|
||||
}
|
||||
@@ -57,7 +57,7 @@ export function operationSplit(selectedIDs, context) {
|
||||
|
||||
operation.annotation = function() {
|
||||
return ways.length === 1 ?
|
||||
t('operations.split.annotation.' + context.geometry(ways[0].id)) :
|
||||
t('operations.split.annotation.' + context.graph().geometry(ways[0].id)) :
|
||||
t('operations.split.annotation.multiple', { n: ways.length });
|
||||
};
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@ export function uiFeatureList(context) {
|
||||
localResults.push({
|
||||
id: entity.id,
|
||||
entity: entity,
|
||||
geometry: context.geometry(entity.id),
|
||||
geometry: entity.geometry(graph),
|
||||
type: type,
|
||||
name: name,
|
||||
distance: distance
|
||||
|
||||
@@ -188,7 +188,7 @@ export function uiFieldCombo(field, context) {
|
||||
};
|
||||
|
||||
if (_entityIDs.length) {
|
||||
params.geometry = context.geometry(_entityIDs[0]);
|
||||
params.geometry = context.graph().geometry(_entityIDs[0]);
|
||||
}
|
||||
|
||||
taginfo[fn](params, function(err, data) {
|
||||
|
||||
@@ -495,7 +495,7 @@ export function uiPresetList(context) {
|
||||
for (var i in _entityIDs) {
|
||||
var entityID = _entityIDs[i];
|
||||
var entity = context.entity(entityID);
|
||||
var geometry = context.geometry(entityID);
|
||||
var geometry = entity.geometry(context.graph());
|
||||
|
||||
// Treat entities on addr:interpolation lines as points, not vertices (#3241)
|
||||
if (geometry === 'vertex' && entity.isOnAddressLine(context.graph())) {
|
||||
|
||||
@@ -143,7 +143,7 @@ export function uiSectionFeatureType(context) {
|
||||
var counts = {};
|
||||
|
||||
for (var i in _entityIDs) {
|
||||
var geometry = context.geometry(_entityIDs[i]);
|
||||
var geometry = context.graph().geometry(_entityIDs[i]);
|
||||
if (!counts[geometry]) counts[geometry] = 0;
|
||||
counts[geometry] += 1;
|
||||
}
|
||||
|
||||
@@ -346,7 +346,7 @@ export function uiSectionRawMemberEditor(context) {
|
||||
// not yet downloaded, it's ok to guess based on type.
|
||||
var geometry;
|
||||
if (d.member) {
|
||||
geometry = context.geometry(d.member.id);
|
||||
geometry = context.graph().geometry(d.member.id);
|
||||
} else if (d.type === 'relation') {
|
||||
geometry = 'relation';
|
||||
} else if (d.type === 'way') {
|
||||
|
||||
@@ -414,7 +414,7 @@ export function uiSectionRawMembershipEditor(context) {
|
||||
taginfo.roles({
|
||||
debounce: true,
|
||||
rtype: rtype || '',
|
||||
geometry: context.geometry(entityID),
|
||||
geometry: context.graph().geometry(entityID),
|
||||
query: role
|
||||
}, function(err, data) {
|
||||
if (!err) callback(sort(role, data));
|
||||
|
||||
@@ -403,7 +403,7 @@ export function uiSectionRawTagEditor(id, context) {
|
||||
return;
|
||||
}
|
||||
|
||||
var geometry = context.geometry(_entityIDs[0]);
|
||||
var geometry = context.graph().geometry(_entityIDs[0]);
|
||||
|
||||
key.call(uiCombobox(context, 'tag-key')
|
||||
.fetcher(function(value, callback) {
|
||||
|
||||
@@ -114,7 +114,7 @@ export function uiSectionSelectionList(context) {
|
||||
items.selectAll('.entity-geom-icon use')
|
||||
.attr('href', function() {
|
||||
var entity = this.parentNode.parentNode.__data__;
|
||||
return '#iD-icon-' + context.geometry(entity.id);
|
||||
return '#iD-icon-' + entity.geometry(context.graph());
|
||||
});
|
||||
|
||||
items.selectAll('.entity-type')
|
||||
|
||||
@@ -6,7 +6,6 @@ describe('iD.operationExtract', function () {
|
||||
fakeContext = {};
|
||||
fakeContext.graph = function () { return graph; };
|
||||
fakeContext.hasHiddenConnections = function () { return false; };
|
||||
fakeContext.geometry = function () { return 'vertex'; };
|
||||
|
||||
var fakeTags = { 'name': 'fake' };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user