diff --git a/Makefile b/Makefile
index 53294aae3..88c0d4853 100644
--- a/Makefile
+++ b/Makefile
@@ -44,7 +44,6 @@ $(BUILDJS_TARGETS): $(BUILDJS_SOURCES) build.js
MODULE_TARGETS = \
js/lib/id/index.js \
- js/lib/id/operations.js \
js/lib/id/presets.js \
js/lib/id/renderer.js \
js/lib/id/services.js \
@@ -62,10 +61,6 @@ js/lib/id/modes.js: $(shell find modules/modes -type f)
@rm -f $@
node_modules/.bin/rollup -f umd -n iD.modes modules/modes/index.js --no-strict -o $@
-js/lib/id/operations.js: $(shell find modules/operations -type f)
- @rm -f $@
- node_modules/.bin/rollup -f umd -n iD.operations modules/operations/index.js --no-strict -o $@
-
js/lib/id/presets.js: $(shell find modules/presets -type f)
@rm -f $@
node_modules/.bin/rollup -f umd -n iD.presets modules/presets/index.js --no-strict -o $@
diff --git a/index.html b/index.html
index adfa1485e..555552818 100644
--- a/index.html
+++ b/index.html
@@ -37,7 +37,6 @@
-
diff --git a/js/lib/id/index.js b/js/lib/id/index.js
index c8b5b2d41..fbdfd4f6d 100644
--- a/js/lib/id/index.js
+++ b/js/lib/id/index.js
@@ -4397,7 +4397,7 @@
};
}
- function Circularize(wayId
+ function CircularizeAction(wayId
, projection, maxAngle) {
maxAngle = (maxAngle || 20) * Math.PI / 180;
@@ -4874,7 +4874,7 @@
};
}
- function Disconnect(nodeId, newNodeId) {
+ function DisconnectAction(nodeId, newNodeId) {
var wayIds;
var action = function(graph) {
@@ -5039,7 +5039,7 @@
return action;
}
- function Merge(ids) {
+ function MergeAction(ids) {
function groupEntitiesByGeometry(graph) {
var entities = ids.map(function(id) { return graph.entity(id); });
return _.extend({point: [], area: [], line: [], relation: []},
@@ -5745,7 +5745,7 @@
* Based on https://github.com/openstreetmap/potlatch2/blob/master/net/systemeD/potlatch2/tools/Quadrilateralise.as
*/
- function Orthogonalize(wayId, projection) {
+ function OrthogonalizeAction(wayId, projection) {
var threshold = 12, // degrees within right or straight to alter
lowerThreshold = Math.cos((90 - threshold) * Math.PI / 180),
upperThreshold = Math.cos(threshold * Math.PI / 180);
@@ -5928,7 +5928,7 @@
// Reference:
// https://github.com/systemed/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/SplitWayAction.as
//
- function Split(nodeId, newWayIds) {
+ function SplitAction(nodeId, newWayIds) {
var wayIds;
// if the way is closed, we need to search for a partner node
@@ -6138,7 +6138,7 @@
function split(toOrFrom) {
var newID = toOrFrom.newID || Way().id;
- graph = Split(via.id, [newID])
+ graph = SplitAction(via.id, [newID])
.limitWays([toOrFrom.way])(graph);
var a = graph.entity(newID),
@@ -6222,7 +6222,7 @@
http://wiki.openstreetmap.org/wiki/Route#Members
http://josm.openstreetmap.de/browser/josm/trunk/src/org/openstreetmap/josm/corrector/ReverseWayTagCorrector.java
*/
- function Reverse(wayId, options) {
+ function ReverseAction(wayId, options) {
var replacements = [
[/:right$/, ':left'], [/:left$/, ':right'],
[/:forward$/, ':backward'], [/:backward$/, ':forward']
@@ -6348,7 +6348,7 @@
* Based on https://github.com/openstreetmap/potlatch2/net/systemeD/potlatch2/tools/Straighten.as
*/
- function Straighten(wayId, projection) {
+ function StraightenAction(wayId, projection) {
function positionAlongWay(n, s, e) {
return ((n[0] - s[0]) * (e[0] - s[0]) + (n[1] - s[1]) * (e[1] - s[1]))/
(Math.pow(e[0] - s[0], 2) + Math.pow(e[1] - s[1], 2));
@@ -6457,7 +6457,7 @@
ChangeMember: ChangeMember,
ChangePreset: ChangePreset,
ChangeTags: ChangeTags,
- Circularize: Circularize,
+ Circularize: CircularizeAction,
Connect: Connect,
CopyEntities: CopyEntities,
DeleteMember: DeleteMember,
@@ -6467,21 +6467,21 @@
DeleteWay: DeleteWay,
DeprecateTags: DeprecateTags,
DiscardTags: DiscardTags,
- Disconnect: Disconnect,
+ Disconnect: DisconnectAction,
Join: Join,
- Merge: Merge,
+ Merge: MergeAction,
MergePolygon: MergePolygon,
MergeRemoteChanges: MergeRemoteChanges,
Move: MoveAction,
MoveNode: MoveNode,
Noop: Noop,
- Orthogonalize: Orthogonalize,
+ Orthogonalize: OrthogonalizeAction,
RestrictTurn: RestrictTurn,
- Reverse: Reverse,
+ Reverse: ReverseAction,
Revert: Revert,
RotateWay: RotateWayAction,
- Split: Split,
- Straighten: Straighten,
+ Split: SplitAction,
+ Straighten: StraightenAction,
UnrestrictTurn: UnrestrictTurn
});
@@ -10177,12 +10177,12 @@
return mode;
}
- function Circularize$1(selectedIDs, context) {
+ function Circularize(selectedIDs, context) {
var entityId = selectedIDs[0],
entity = context.entity(entityId),
extent = entity.extent(context.graph()),
geometry = context.geometry(entityId),
- action = iD.actions.Circularize(entityId, context.projection);
+ action = CircularizeAction(entityId, context.projection);
var operation = function() {
var annotation = t('operations.circularize.annotation.' + geometry);
@@ -10236,7 +10236,7 @@
var operation = function() {
var candidate = candidateWays()[0];
- context.enter(iD.modes.DrawLine(
+ context.enter(DrawLine(
context,
candidate.id,
context.graph(),
@@ -10271,7 +10271,7 @@
}
function Delete(selectedIDs, context) {
- var action = iD.actions.DeleteMultiple(selectedIDs);
+ var action = DeleteMultiple(selectedIDs);
var operation = function() {
var annotation,
@@ -10299,8 +10299,8 @@
} else if (i === nodes.length - 1) {
i--;
} else {
- var a = iD.geo.sphericalDistance(entity.loc, context.entity(nodes[i - 1]).loc),
- b = iD.geo.sphericalDistance(entity.loc, context.entity(nodes[i + 1]).loc);
+ var a = sphericalDistance(entity.loc, context.entity(nodes[i - 1]).loc),
+ b = sphericalDistance(entity.loc, context.entity(nodes[i + 1]).loc);
i = a < b ? i - 1 : i + 1;
}
@@ -10309,9 +10309,9 @@
}
if (nextSelectedID && context.hasEntity(nextSelectedID)) {
- context.enter(iD.modes.Select(context, [nextSelectedID]));
+ context.enter(SelectMode(context, [nextSelectedID]));
} else {
- context.enter(iD.modes.Browse(context));
+ context.enter(Browse(context));
}
context.perform(
@@ -10345,13 +10345,13 @@
return operation;
}
- function Disconnect$1(selectedIDs, context) {
+ function Disconnect(selectedIDs, context) {
var vertices = _.filter(selectedIDs, function vertex(entityId) {
return context.geometry(entityId) === 'vertex';
});
var entityId = vertices[0],
- action = iD.actions.Disconnect(entityId);
+ action = DisconnectAction(entityId);
if (selectedIDs.length > 1) {
action.limitWays(_.without(selectedIDs, entityId));
@@ -10387,10 +10387,10 @@
return operation;
}
- function Merge$1(selectedIDs, context) {
- var join = iD.actions.Join(selectedIDs),
- merge = iD.actions.Merge(selectedIDs),
- mergePolygon = iD.actions.MergePolygon(selectedIDs);
+ function Merge(selectedIDs, context) {
+ var join = Join(selectedIDs),
+ merge = MergeAction(selectedIDs),
+ mergePolygon = MergePolygon(selectedIDs);
var operation = function() {
var annotation = t('operations.merge.annotation', {n: selectedIDs.length}),
@@ -10405,7 +10405,7 @@
}
context.perform(action, annotation);
- context.enter(iD.modes.Select(context, selectedIDs.filter(function(id) { return context.hasEntity(id); }))
+ context.enter(SelectMode(context, selectedIDs.filter(function(id) { return context.hasEntity(id); }))
.suppressMenu(true));
};
@@ -10446,10 +10446,10 @@
function Move(selectedIDs, context) {
var extent = selectedIDs.reduce(function(extent, id) {
return extent.extend(context.entity(id).extent(context.graph()));
- }, iD.geo.Extent());
+ }, Extent());
var operation = function() {
- context.enter(iD.modes.Move(context, selectedIDs));
+ context.enter(MoveMode(context, selectedIDs));
};
operation.available = function() {
@@ -10464,7 +10464,7 @@
} else if (_.some(selectedIDs, context.hasHiddenConnections)) {
reason = 'connected_to_hidden';
}
- return iD.actions.Move(selectedIDs).disabled(context.graph()) || reason;
+ return MoveAction(selectedIDs).disabled(context.graph()) || reason;
};
operation.tooltip = function() {
@@ -10481,12 +10481,12 @@
return operation;
}
- function Orthogonalize$1(selectedIDs, context) {
+ function Orthogonalize(selectedIDs, context) {
var entityId = selectedIDs[0],
entity = context.entity(entityId),
extent = entity.extent(context.graph()),
geometry = context.geometry(entityId),
- action = iD.actions.Orthogonalize(entityId, context.projection);
+ action = OrthogonalizeAction(entityId, context.projection);
var operation = function() {
var annotation = t('operations.orthogonalize.annotation.' + geometry);
@@ -10524,12 +10524,12 @@
return operation;
}
- function Reverse$1(selectedIDs, context) {
+ function Reverse(selectedIDs, context) {
var entityId = selectedIDs[0];
var operation = function() {
context.perform(
- iD.actions.Reverse(entityId),
+ ReverseAction(entityId),
t('operations.reverse.annotation'));
};
@@ -10560,7 +10560,7 @@
geometry = context.geometry(entityId);
var operation = function() {
- context.enter(iD.modes.RotateWay(context, entityId));
+ context.enter(RotateWay(context, entityId));
};
operation.available = function() {
@@ -10598,13 +10598,13 @@
return operation;
}
- function Split$1(selectedIDs, context) {
+ function Split(selectedIDs, context) {
var vertices = _.filter(selectedIDs, function vertex(entityId) {
return context.geometry(entityId) === 'vertex';
});
var entityId = vertices[0],
- action = iD.actions.Split(entityId);
+ action = SplitAction(entityId);
if (selectedIDs.length > 1) {
action.limitWays(_.without(selectedIDs, entityId));
@@ -10621,7 +10621,7 @@
}
var difference = context.perform(action, annotation);
- context.enter(iD.modes.Select(context, difference.extantIDs()));
+ context.enter(SelectMode(context, difference.extantIDs()));
};
operation.available = function() {
@@ -10657,9 +10657,9 @@
return operation;
}
- function Straighten$1(selectedIDs, context) {
+ function Straighten(selectedIDs, context) {
var entityId = selectedIDs[0],
- action = iD.actions.Straighten(entityId, context.projection);
+ action = StraightenAction(entityId, context.projection);
function operation() {
var annotation = t('operations.straighten.annotation');
@@ -10699,17 +10699,17 @@
var Operations = Object.freeze({
- Circularize: Circularize$1,
+ Circularize: Circularize,
Continue: Continue,
Delete: Delete,
- Disconnect: Disconnect$1,
- Merge: Merge$1,
+ Disconnect: Disconnect,
+ Merge: Merge,
Move: Move,
- Orthogonalize: Orthogonalize$1,
- Reverse: Reverse$1,
+ Orthogonalize: Orthogonalize,
+ Reverse: Reverse,
Rotate: Rotate,
- Split: Split$1,
- Straighten: Straighten$1
+ Split: Split,
+ Straighten: Straighten
});
function SelectMode(context, selectedIDs) {
@@ -12373,8 +12373,12 @@
=======
exports.modes = modes;
<<<<<<< HEAD
+<<<<<<< HEAD
>>>>>>> 75901f6... external modules for modes
=======
+=======
+ exports.operations = Operations;
+>>>>>>> 422ffee... external modules for operations
exports.util = util;
>>>>>>> 42ce4cf... external modules for util
exports.Connection = Connection;
diff --git a/modules/index.js b/modules/index.js
index 45a40edd2..62fb9f382 100644
--- a/modules/index.js
+++ b/modules/index.js
@@ -3,6 +3,7 @@ import * as geo from './geo/index';
import * as behavior from './behavior/index';
import * as modes from './modes/index';
import * as util from './util/index';
+import * as operations from './operations/index';
export { Connection } from './core/connection';
export { Difference } from './core/difference';
@@ -20,5 +21,6 @@ export {
geo,
behavior,
modes,
+ operations,
util
};
diff --git a/modules/operations/circularize.js b/modules/operations/circularize.js
index e614fbafd..662675304 100644
--- a/modules/operations/circularize.js
+++ b/modules/operations/circularize.js
@@ -1,9 +1,10 @@
+import { Circularize as CircularizeAction } from '../actions/index';
export function Circularize(selectedIDs, context) {
var entityId = selectedIDs[0],
entity = context.entity(entityId),
extent = entity.extent(context.graph()),
geometry = context.geometry(entityId),
- action = iD.actions.Circularize(entityId, context.projection);
+ action = CircularizeAction(entityId, context.projection);
var operation = function() {
var annotation = t('operations.circularize.annotation.' + geometry);
diff --git a/modules/operations/continue.js b/modules/operations/continue.js
index bd412eedc..a4bc75c9f 100644
--- a/modules/operations/continue.js
+++ b/modules/operations/continue.js
@@ -1,3 +1,4 @@
+import { DrawLine } from '../modes/index';
export function Continue(selectedIDs, context) {
var graph = context.graph(),
entities = selectedIDs.map(function(id) { return graph.entity(id); }),
@@ -15,7 +16,7 @@ export function Continue(selectedIDs, context) {
var operation = function() {
var candidate = candidateWays()[0];
- context.enter(iD.modes.DrawLine(
+ context.enter(DrawLine(
context,
candidate.id,
context.graph(),
diff --git a/modules/operations/delete.js b/modules/operations/delete.js
index 0eb33e201..fa88ac7ae 100644
--- a/modules/operations/delete.js
+++ b/modules/operations/delete.js
@@ -1,5 +1,8 @@
+import { Select, Browse } from '../modes/index';
+import { sphericalDistance } from '../geo/index';
+import { DeleteMultiple } from '../actions/index';
export function Delete(selectedIDs, context) {
- var action = iD.actions.DeleteMultiple(selectedIDs);
+ var action = DeleteMultiple(selectedIDs);
var operation = function() {
var annotation,
@@ -27,8 +30,8 @@ export function Delete(selectedIDs, context) {
} else if (i === nodes.length - 1) {
i--;
} else {
- var a = iD.geo.sphericalDistance(entity.loc, context.entity(nodes[i - 1]).loc),
- b = iD.geo.sphericalDistance(entity.loc, context.entity(nodes[i + 1]).loc);
+ var a = sphericalDistance(entity.loc, context.entity(nodes[i - 1]).loc),
+ b = sphericalDistance(entity.loc, context.entity(nodes[i + 1]).loc);
i = a < b ? i - 1 : i + 1;
}
@@ -37,9 +40,9 @@ export function Delete(selectedIDs, context) {
}
if (nextSelectedID && context.hasEntity(nextSelectedID)) {
- context.enter(iD.modes.Select(context, [nextSelectedID]));
+ context.enter(Select(context, [nextSelectedID]));
} else {
- context.enter(iD.modes.Browse(context));
+ context.enter(Browse(context));
}
context.perform(
diff --git a/modules/operations/disconnect.js b/modules/operations/disconnect.js
index 46b3db69a..1c838a3bf 100644
--- a/modules/operations/disconnect.js
+++ b/modules/operations/disconnect.js
@@ -1,10 +1,11 @@
+import { Disconnect as DisconnectAction } from '../actions/index';
export function Disconnect(selectedIDs, context) {
var vertices = _.filter(selectedIDs, function vertex(entityId) {
return context.geometry(entityId) === 'vertex';
});
var entityId = vertices[0],
- action = iD.actions.Disconnect(entityId);
+ action = DisconnectAction(entityId);
if (selectedIDs.length > 1) {
action.limitWays(_.without(selectedIDs, entityId));
diff --git a/modules/operations/merge.js b/modules/operations/merge.js
index 6f5370ccd..a6d24279d 100644
--- a/modules/operations/merge.js
+++ b/modules/operations/merge.js
@@ -1,7 +1,9 @@
+import { Select } from '../modes/index';
+import { Join, Merge as MergeAction, MergePolygon } from '../actions/index';
export function Merge(selectedIDs, context) {
- var join = iD.actions.Join(selectedIDs),
- merge = iD.actions.Merge(selectedIDs),
- mergePolygon = iD.actions.MergePolygon(selectedIDs);
+ var join = Join(selectedIDs),
+ merge = MergeAction(selectedIDs),
+ mergePolygon = MergePolygon(selectedIDs);
var operation = function() {
var annotation = t('operations.merge.annotation', {n: selectedIDs.length}),
@@ -16,7 +18,7 @@ export function Merge(selectedIDs, context) {
}
context.perform(action, annotation);
- context.enter(iD.modes.Select(context, selectedIDs.filter(function(id) { return context.hasEntity(id); }))
+ context.enter(Select(context, selectedIDs.filter(function(id) { return context.hasEntity(id); }))
.suppressMenu(true));
};
diff --git a/modules/operations/move.js b/modules/operations/move.js
index b65b1b891..6f12bff0a 100644
--- a/modules/operations/move.js
+++ b/modules/operations/move.js
@@ -1,10 +1,13 @@
+import { Move as MoveMode } from '../modes/index';
+import { Extent } from '../geo/index';
+import { Move as MoveAction } from '../actions/index';
export function Move(selectedIDs, context) {
var extent = selectedIDs.reduce(function(extent, id) {
return extent.extend(context.entity(id).extent(context.graph()));
- }, iD.geo.Extent());
+ }, Extent());
var operation = function() {
- context.enter(iD.modes.Move(context, selectedIDs));
+ context.enter(MoveMode(context, selectedIDs));
};
operation.available = function() {
@@ -19,7 +22,7 @@ export function Move(selectedIDs, context) {
} else if (_.some(selectedIDs, context.hasHiddenConnections)) {
reason = 'connected_to_hidden';
}
- return iD.actions.Move(selectedIDs).disabled(context.graph()) || reason;
+ return MoveAction(selectedIDs).disabled(context.graph()) || reason;
};
operation.tooltip = function() {
diff --git a/modules/operations/orthogonalize.js b/modules/operations/orthogonalize.js
index 7b1aa1a58..e15390ede 100644
--- a/modules/operations/orthogonalize.js
+++ b/modules/operations/orthogonalize.js
@@ -1,9 +1,10 @@
+import { Orthogonalize as OrthogonalizeAction } from '../actions/index';
export function Orthogonalize(selectedIDs, context) {
var entityId = selectedIDs[0],
entity = context.entity(entityId),
extent = entity.extent(context.graph()),
geometry = context.geometry(entityId),
- action = iD.actions.Orthogonalize(entityId, context.projection);
+ action = OrthogonalizeAction(entityId, context.projection);
var operation = function() {
var annotation = t('operations.orthogonalize.annotation.' + geometry);
diff --git a/modules/operations/reverse.js b/modules/operations/reverse.js
index 9197d7249..2a6e9a0f2 100644
--- a/modules/operations/reverse.js
+++ b/modules/operations/reverse.js
@@ -1,9 +1,10 @@
+import { Reverse as ReverseAction } from '../actions/index';
export function Reverse(selectedIDs, context) {
var entityId = selectedIDs[0];
var operation = function() {
context.perform(
- iD.actions.Reverse(entityId),
+ ReverseAction(entityId),
t('operations.reverse.annotation'));
};
diff --git a/modules/operations/rotate.js b/modules/operations/rotate.js
index ea50d128c..aba5f184b 100644
--- a/modules/operations/rotate.js
+++ b/modules/operations/rotate.js
@@ -1,3 +1,4 @@
+import { RotateWay } from '../modes/index';
export function Rotate(selectedIDs, context) {
var entityId = selectedIDs[0],
entity = context.entity(entityId),
@@ -5,7 +6,7 @@ export function Rotate(selectedIDs, context) {
geometry = context.geometry(entityId);
var operation = function() {
- context.enter(iD.modes.RotateWay(context, entityId));
+ context.enter(RotateWay(context, entityId));
};
operation.available = function() {
diff --git a/modules/operations/split.js b/modules/operations/split.js
index a978245ea..b8ee2c784 100644
--- a/modules/operations/split.js
+++ b/modules/operations/split.js
@@ -1,10 +1,12 @@
+import { Select } from '../modes/index';
+import { Split as SplitAction } from '../actions/index';
export function Split(selectedIDs, context) {
var vertices = _.filter(selectedIDs, function vertex(entityId) {
return context.geometry(entityId) === 'vertex';
});
var entityId = vertices[0],
- action = iD.actions.Split(entityId);
+ action = SplitAction(entityId);
if (selectedIDs.length > 1) {
action.limitWays(_.without(selectedIDs, entityId));
@@ -21,7 +23,7 @@ export function Split(selectedIDs, context) {
}
var difference = context.perform(action, annotation);
- context.enter(iD.modes.Select(context, difference.extantIDs()));
+ context.enter(Select(context, difference.extantIDs()));
};
operation.available = function() {
diff --git a/modules/operations/straighten.js b/modules/operations/straighten.js
index 9a64d8ac1..87d13713d 100644
--- a/modules/operations/straighten.js
+++ b/modules/operations/straighten.js
@@ -1,6 +1,7 @@
+import { Straighten as StraightenAction } from '../actions/index';
export function Straighten(selectedIDs, context) {
var entityId = selectedIDs[0],
- action = iD.actions.Straighten(entityId, context.projection);
+ action = StraightenAction(entityId, context.projection);
function operation() {
var annotation = t('operations.straighten.annotation');
diff --git a/test/index.html b/test/index.html
index 76b623e94..340f59447 100644
--- a/test/index.html
+++ b/test/index.html
@@ -42,7 +42,6 @@
-