Merge pull request #3161 from openstreetmap/inter-require

Start inter-requiring actions
This commit is contained in:
Tom MacWright
2016-06-14 12:05:49 -04:00
committed by GitHub
47 changed files with 2381 additions and 2406 deletions
+1 -2
View File
@@ -4,11 +4,11 @@
"dot-notation": 2,
"eqeqeq": [2, "smart"],
"indent": [0, 4],
"keyword-spacing": 2,
"linebreak-style": [2, "unix"],
"no-caller": 2,
"no-catch-shadow": 2,
"no-div-regex": 2,
"no-empty-label": 2,
"no-extend-native": 2,
"no-extra-bind": 2,
"no-floating-decimal": 2,
@@ -45,7 +45,6 @@
"no-use-before-define": [0, "nofunc"],
"semi": [2, "always"],
"semi-spacing": 2,
"space-return-throw-case": 2,
"space-unary-ops": 2,
"wrap-regex": 0,
"quotes": [2, "single"]
+2 -6
View File
@@ -1,9 +1,5 @@
language: node_js
node_js:
- "5.11"
sudo: false
before_install:
# https://github.com/travis-ci/travis-ci/issues/3225
- mkdir travis-phantomjs
- wget https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-linux-x86_64.tar.bz2 -O $PWD/travis-phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2
- tar -xvf $PWD/travis-phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2 -C $PWD/travis-phantomjs
- export PATH=$PWD/travis-phantomjs/phantomjs-2.1.1-linux-x86_64/bin:$PATH
before_script: make
+2 -4
View File
@@ -45,10 +45,8 @@ $(BUILDJS_TARGETS): $(BUILDJS_SOURCES) build.js
MODULE_TARGETS = \
js/lib/id/actions.js
ACTIONS = $(shell ./node_modules/.bin/browserify --list modules/actions/index.js)
js/lib/id/actions.js: $(ACTIONS)
node_modules/.bin/browserify modules/actions/index.js -s iD.actions > $@
js/lib/id/actions.js: modules/
node_modules/.bin/rollup -f umd -n iD.actions modules/actions/index.js --no-strict > $@
dist/iD.js: \
js/lib/bootstrap-tooltip.js \
+2 -2
View File
@@ -24,8 +24,8 @@ Come on in, the water's lovely. More help? Ping `jfire` or `bhousel` on
(`irc.oftc.net`, in `#iD` or `#osm-dev` or `#osm`) or on the [OpenStreetMap `dev` mailing list](http://wiki.openstreetmap.org/wiki/Mailing_lists).
## Prerequisites
* [Node.js](http://nodejs.org/) version 0.10.0 or newer
* [PhantomJS](http://phantomjs.org/) version 2 or newer (for running tests)
* [Node.js](http://nodejs.org/) version 4 or newer
* Command line development tools (`make`, `git`, and a compiler) for your platform
* Ubuntu:
* `sudo apt-get install build-essential git`
+1 -1
View File
@@ -23,7 +23,7 @@ window.iD = function () {
if (arguments.length === 1) return storage.getItem(k);
else if (v === null) storage.removeItem(k);
else storage.setItem(k, v);
} catch(e) {
} catch (e) {
// localstorage quota exceeded
/* eslint-disable no-console */
if (typeof console !== 'undefined') console.error('localStorage quota exceeded');
+1 -1
View File
@@ -15,7 +15,7 @@ iD.modes.Save = function(context) {
try {
var cn = graph.childNodes(e);
result.push.apply(result, _.map(_.filter(cn, 'version'), 'id'));
} catch(err) {
} catch (err) {
/* eslint-disable no-console */
if (typeof console !== 'undefined') console.error(err);
/* eslint-enable no-console */
-1
View File
@@ -1,2 +1 @@
(function () {
'use strict';
+2209 -2236
View File
File diff suppressed because it is too large Load Diff
+6
View File
@@ -0,0 +1,6 @@
{
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
}
}
+2 -2
View File
@@ -1,5 +1,5 @@
module.exports = function(way) {
export function AddEntity(way) {
return function(graph) {
return graph.replace(way);
};
};
}
+2 -2
View File
@@ -1,4 +1,4 @@
module.exports = function(relationId, member, memberIndex) {
export function AddMember(relationId, member, memberIndex) {
return function(graph) {
var relation = graph.entity(relationId);
@@ -26,4 +26,4 @@ module.exports = function(relationId, member, memberIndex) {
return graph.replace(relation.addMember(member, memberIndex));
};
};
}
+2 -2
View File
@@ -1,4 +1,4 @@
module.exports = function(midpoint, node) {
export function AddMidpoint(midpoint, node) {
return function(graph) {
graph = graph.replace(node.move(midpoint.loc));
@@ -20,4 +20,4 @@ module.exports = function(midpoint, node) {
return graph;
};
};
}
+2 -2
View File
@@ -1,6 +1,6 @@
// https://github.com/openstreetmap/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/AddNodeToWayAction.as
module.exports = function(wayId, nodeId, index) {
export function AddVertex(wayId, nodeId, index) {
return function(graph) {
return graph.replace(graph.entity(wayId).addNode(nodeId, index));
};
};
}
+2 -2
View File
@@ -1,5 +1,5 @@
module.exports = function(relationId, member, memberIndex) {
export function ChangeMember(relationId, member, memberIndex) {
return function(graph) {
return graph.replace(graph.entity(relationId).updateMember(member, memberIndex));
};
};
}
+2 -2
View File
@@ -1,4 +1,4 @@
module.exports = function(entityId, oldPreset, newPreset) {
export function ChangePreset(entityId, oldPreset, newPreset) {
return function(graph) {
var entity = graph.entity(entityId),
geometry = entity.geometry(graph),
@@ -9,4 +9,4 @@ module.exports = function(entityId, oldPreset, newPreset) {
return graph.replace(entity.update({tags: tags}));
};
};
}
+2 -2
View File
@@ -1,6 +1,6 @@
module.exports = function(entityId, tags) {
export function ChangeTags(entityId, tags) {
return function(graph) {
var entity = graph.entity(entityId);
return graph.replace(entity.update({tags: tags}));
};
};
}
+2 -2
View File
@@ -1,4 +1,4 @@
module.exports = function(wayId, projection, maxAngle) {
export function Circularize(wayId, projection, maxAngle) {
maxAngle = (maxAngle || 20) * Math.PI / 180;
var action = function(graph) {
@@ -180,4 +180,4 @@ module.exports = function(wayId, projection, maxAngle) {
};
return action;
};
}
+5 -3
View File
@@ -1,3 +1,5 @@
import { DeleteNode } from './delete_node';
// Connect the ways at the given nodes.
//
// The last node will survive. All other nodes will be replaced with
@@ -12,7 +14,7 @@
// https://github.com/openstreetmap/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/MergeNodesAction.as
// https://github.com/openstreetmap/josm/blob/mirror/src/org/openstreetmap/josm/actions/MergeNodesAction.java
//
module.exports = function(nodeIds) {
export function Connect(nodeIds) {
return function(graph) {
var survivor = graph.entity(_.last(nodeIds));
@@ -32,11 +34,11 @@ module.exports = function(nodeIds) {
/* eslint-enable no-loop-func */
survivor = survivor.mergeTags(node.tags);
graph = iD.actions.DeleteNode(node.id)(graph);
graph = DeleteNode(node.id)(graph);
}
graph = graph.replace(survivor);
return graph;
};
};
}
+2 -2
View File
@@ -1,4 +1,4 @@
module.exports = function(ids, fromGraph) {
export function CopyEntities(ids, fromGraph) {
var copies = {};
var action = function(graph) {
@@ -18,4 +18,4 @@ module.exports = function(ids, fromGraph) {
};
return action;
};
}
+5 -3
View File
@@ -1,4 +1,6 @@
module.exports = function(relationId, memberIndex) {
import { DeleteRelation } from './delete_relation';
export function DeleteMember(relationId, memberIndex) {
return function(graph) {
var relation = graph.entity(relationId)
.removeMember(memberIndex);
@@ -6,8 +8,8 @@ module.exports = function(relationId, memberIndex) {
graph = graph.replace(relation);
if (relation.isDegenerate())
graph = iD.actions.DeleteRelation(relation.id)(graph);
graph = DeleteRelation(relation.id)(graph);
return graph;
};
};
}
+9 -5
View File
@@ -1,8 +1,12 @@
module.exports = function(ids) {
import { DeleteWay } from './delete_way';
import { DeleteNode } from './delete_node';
import { DeleteRelation } from './delete_relation';
export function DeleteMultiple(ids) {
var actions = {
way: iD.actions.DeleteWay,
node: iD.actions.DeleteNode,
relation: iD.actions.DeleteRelation
way: DeleteWay,
node: DeleteNode,
relation: DeleteRelation
};
var action = function(graph) {
@@ -24,4 +28,4 @@ module.exports = function(ids) {
};
return action;
};
}
+7 -4
View File
@@ -1,5 +1,8 @@
import { DeleteWay } from './delete_way';
import { DeleteRelation } from './delete_relation';
// https://github.com/openstreetmap/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/DeleteNodeAction.as
module.exports = function(nodeId) {
export function DeleteNode(nodeId) {
var action = function(graph) {
var node = graph.entity(nodeId);
@@ -9,7 +12,7 @@ module.exports = function(nodeId) {
graph = graph.replace(parent);
if (parent.isDegenerate()) {
graph = iD.actions.DeleteWay(parent.id)(graph);
graph = DeleteWay(parent.id)(graph);
}
});
@@ -19,7 +22,7 @@ module.exports = function(nodeId) {
graph = graph.replace(parent);
if (parent.isDegenerate()) {
graph = iD.actions.DeleteRelation(parent.id)(graph);
graph = DeleteRelation(parent.id)(graph);
}
});
@@ -31,4 +34,4 @@ module.exports = function(nodeId) {
};
return action;
};
}
+6 -4
View File
@@ -1,5 +1,7 @@
import { DeleteMultiple } from './delete_multiple';
// https://github.com/openstreetmap/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/DeleteRelationAction.as
module.exports = function(relationId) {
export function DeleteRelation(relationId) {
function deleteEntity(entity, graph) {
return !graph.parentWays(entity).length &&
!graph.parentRelations(entity).length &&
@@ -15,7 +17,7 @@ module.exports = function(relationId) {
graph = graph.replace(parent);
if (parent.isDegenerate()) {
graph = iD.actions.DeleteRelation(parent.id)(graph);
graph = DeleteRelation(parent.id)(graph);
}
});
@@ -24,7 +26,7 @@ module.exports = function(relationId) {
var entity = graph.entity(memberId);
if (deleteEntity(entity, graph)) {
graph = iD.actions.DeleteMultiple([memberId])(graph);
graph = DeleteMultiple([memberId])(graph);
}
});
@@ -37,4 +39,4 @@ module.exports = function(relationId) {
};
return action;
};
}
+5 -3
View File
@@ -1,5 +1,7 @@
import { DeleteRelation } from './delete_relation';
// https://github.com/openstreetmap/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/DeleteWayAction.as
module.exports = function(wayId) {
export function DeleteWay(wayId) {
function deleteNode(node, graph) {
return !graph.parentWays(node).length &&
!graph.parentRelations(node).length &&
@@ -15,7 +17,7 @@ module.exports = function(wayId) {
graph = graph.replace(parent);
if (parent.isDegenerate()) {
graph = iD.actions.DeleteRelation(parent.id)(graph);
graph = DeleteRelation(parent.id)(graph);
}
});
@@ -46,4 +48,4 @@ module.exports = function(wayId) {
};
return action;
};
}
+2 -2
View File
@@ -1,4 +1,4 @@
module.exports = function(entityId) {
export function DeprecateTags(entityId) {
return function(graph) {
var entity = graph.entity(entityId),
newtags = _.clone(entity.tags),
@@ -33,4 +33,4 @@ module.exports = function(entityId) {
return graph;
}
};
};
}
+2 -2
View File
@@ -1,4 +1,4 @@
module.exports = function(difference) {
export function DiscardTags(difference) {
return function(graph) {
function discardTags(entity) {
if (!_.isEmpty(entity.tags)) {
@@ -18,4 +18,4 @@ module.exports = function(difference) {
return graph;
};
};
}
+2 -2
View File
@@ -12,7 +12,7 @@
// https://github.com/openstreetmap/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/UnjoinNodeAction.as
// https://github.com/openstreetmap/josm/blob/mirror/src/org/openstreetmap/josm/actions/UnGlueAction.java
//
module.exports = function(nodeId, newNodeId) {
export function Disconnect(nodeId, newNodeId) {
var wayIds;
var action = function(graph) {
@@ -94,4 +94,4 @@ module.exports = function(nodeId, newNodeId) {
};
return action;
};
}
+33 -33
View File
@@ -1,33 +1,33 @@
module.exports.AddEntity = require('./add_entity');
module.exports.AddMember = require('./add_member');
module.exports.AddMidpoint = require('./add_midpoint');
module.exports.AddVertex = require('./add_vertex');
module.exports.ChangeMember = require('./change_member');
module.exports.ChangePreset = require('./change_preset');
module.exports.ChangeTags = require('./change_tags');
module.exports.Circularize = require('./circularize');
module.exports.Connect = require('./connect');
module.exports.CopyEntities = require('./copy_entities');
module.exports.DeleteMember = require('./delete_member');
module.exports.DeleteMultiple = require('./delete_multiple');
module.exports.DeleteNode = require('./delete_node');
module.exports.DeleteRelation = require('./delete_relation');
module.exports.DeleteWay = require('./delete_way');
module.exports.DeprecateTags = require('./deprecate_tags');
module.exports.DiscardTags = require('./discard_tags');
module.exports.Disconnect = require('./disconnect');
module.exports.Join = require('./join');
module.exports.Merge = require('./merge');
module.exports.MergePolygon = require('./merge_polygon');
module.exports.MergeRemoteChanges = require('./merge_remote_changes');
module.exports.Move = require('./move');
module.exports.MoveNode = require('./move_node');
module.exports.Noop = require('./noop');
module.exports.Orthogonalize = require('./orthogonalize');
module.exports.RestrictTurn = require('./restrict_turn');
module.exports.Reverse = require('./reverse');
module.exports.Revert = require('./revert');
module.exports.RotateWay = require('./rotate_way');
module.exports.Split = require('./split');
module.exports.Straighten = require('./straighten');
module.exports.UnrestrictTurn = require('./unrestrict_turn');
export { AddEntity } from './add_entity';
export { AddMember } from './add_member';
export { AddMidpoint } from './add_midpoint';
export { AddVertex } from './add_vertex';
export { ChangeMember } from './change_member';
export { ChangePreset } from './change_preset';
export { ChangeTags } from './change_tags';
export { Circularize } from './circularize';
export { Connect } from './connect';
export { CopyEntities } from './copy_entities';
export { DeleteMember } from './delete_member';
export { DeleteMultiple } from './delete_multiple';
export { DeleteNode } from './delete_node';
export { DeleteRelation } from './delete_relation';
export { DeleteWay } from './delete_way';
export { DeprecateTags } from './deprecate_tags';
export { DiscardTags } from './discard_tags';
export { Disconnect } from './disconnect';
export { Join } from './join';
export { Merge } from './merge';
export { MergePolygon } from './merge_polygon';
export { MergeRemoteChanges } from './merge_remote_changes';
export { Move } from './move';
export { MoveNode } from './move_node';
export { Noop } from './noop';
export { Orthogonalize } from './orthogonalize';
export { RestrictTurn } from './restrict_turn';
export { Reverse } from './reverse';
export { Revert } from './revert';
export { RotateWay } from './rotate_way';
export { Split } from './split';
export { Straighten } from './straighten';
export { UnrestrictTurn } from './unrestrict_turn';
+5 -3
View File
@@ -1,3 +1,5 @@
import { DeleteWay } from './delete_way';
// Join ways at the end node they share.
//
// This is the inverse of `iD.actions.Split`.
@@ -6,7 +8,7 @@
// https://github.com/systemed/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/MergeWaysAction.as
// https://github.com/openstreetmap/josm/blob/mirror/src/org/openstreetmap/josm/actions/CombineWayAction.java
//
module.exports = function(ids) {
export function Join(ids) {
function groupEntitiesByGeometry(graph) {
var entities = ids.map(function(id) { return graph.entity(id); });
@@ -41,7 +43,7 @@ module.exports = function(ids) {
survivor = survivor.mergeTags(way.tags);
graph = graph.replace(survivor);
graph = iD.actions.DeleteWay(way.id)(graph);
graph = DeleteWay(way.id)(graph);
});
return graph;
@@ -85,4 +87,4 @@ module.exports = function(ids) {
};
return action;
};
}
+2 -2
View File
@@ -1,4 +1,4 @@
module.exports = function(ids) {
export function Merge(ids) {
function groupEntitiesByGeometry(graph) {
var entities = ids.map(function(id) { return graph.entity(id); });
return _.extend({point: [], area: [], line: [], relation: []},
@@ -34,4 +34,4 @@ module.exports = function(ids) {
};
return action;
};
}
+2 -2
View File
@@ -1,4 +1,4 @@
module.exports = function(ids, newRelationId) {
export function MergePolygon(ids, newRelationId) {
function groupEntities(graph) {
var entities = ids.map(function (id) { return graph.entity(id); });
@@ -112,4 +112,4 @@ module.exports = function(ids, newRelationId) {
};
return action;
};
}
+6 -4
View File
@@ -1,4 +1,6 @@
module.exports = function(id, localGraph, remoteGraph, formatUser) {
import { DeleteMultiple } from './delete_multiple';
export function MergeRemoteChanges(id, localGraph, remoteGraph, formatUser) {
var option = 'safe', // 'safe', 'force_local', 'force_remote'
conflicts = [];
@@ -122,7 +124,7 @@ module.exports = function(id, localGraph, remoteGraph, formatUser) {
graph = graph.replace(updates.replacements[i]);
}
if (updates.removeIds.length) {
graph = iD.actions.DeleteMultiple(updates.removeIds)(graph);
graph = DeleteMultiple(updates.removeIds)(graph);
}
return graph;
}
@@ -204,7 +206,7 @@ module.exports = function(id, localGraph, remoteGraph, formatUser) {
// delete/undelete
if (!remote.visible) {
if (option === 'force_remote') {
return iD.actions.DeleteMultiple([id])(graph);
return DeleteMultiple([id])(graph);
} else if (option === 'force_local') {
if (target.type === 'way') {
@@ -252,4 +254,4 @@ module.exports = function(id, localGraph, remoteGraph, formatUser) {
};
return action;
};
}
+2 -2
View File
@@ -1,6 +1,6 @@
// https://github.com/openstreetmap/josm/blob/mirror/src/org/openstreetmap/josm/command/MoveCommand.java
// https://github.com/openstreetmap/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/MoveNodeAction.as
module.exports = function(moveIds, tryDelta, projection, cache) {
export function Move(moveIds, tryDelta, projection, cache) {
var delta = tryDelta;
function vecAdd(a, b) { return [a[0] + b[0], a[1] + b[1]]; }
@@ -276,4 +276,4 @@ module.exports = function(moveIds, tryDelta, projection, cache) {
};
return action;
};
}
+2 -2
View File
@@ -1,7 +1,7 @@
// https://github.com/openstreetmap/josm/blob/mirror/src/org/openstreetmap/josm/command/MoveCommand.java
// https://github.com/openstreetmap/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/MoveNodeAction.as
module.exports = function(nodeId, loc) {
export function MoveNode(nodeId, loc) {
return function(graph) {
return graph.replace(graph.entity(nodeId).move(loc));
};
};
}
+2 -2
View File
@@ -1,5 +1,5 @@
module.exports = function() {
export function Noop() {
return function(graph) {
return graph;
};
};
}
+5 -3
View File
@@ -1,8 +1,10 @@
import { DeleteNode } from './delete_node';
/*
* Based on https://github.com/openstreetmap/potlatch2/blob/master/net/systemeD/potlatch2/tools/Quadrilateralise.as
*/
module.exports = function(wayId, projection) {
export function Orthogonalize(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);
@@ -70,7 +72,7 @@ module.exports = function(wayId, projection) {
var dotp = normalizedDotProduct(i, points);
if (dotp < -1 + epsilon) {
graph = iD.actions.DeleteNode(nodes[i].id)(graph);
graph = DeleteNode(nodes[i].id)(graph);
}
}
}
@@ -169,4 +171,4 @@ module.exports = function(wayId, projection) {
};
return action;
};
}
+5 -3
View File
@@ -1,3 +1,5 @@
import { Split } from './split';
// Create a restriction relation for `turn`, which must have the following structure:
//
// {
@@ -22,7 +24,7 @@
// Normally, this will be undefined and the relation will automatically
// be assigned a new ID.
//
module.exports = function(turn, projection, restrictionId) {
export function RestrictTurn(turn, projection, restrictionId) {
return function(graph) {
var from = graph.entity(turn.from.way),
via = graph.entity(turn.via.node),
@@ -34,7 +36,7 @@ module.exports = function(turn, projection, restrictionId) {
function split(toOrFrom) {
var newID = toOrFrom.newID || iD.Way().id;
graph = iD.actions.Split(via.id, [newID])
graph = Split(via.id, [newID])
.limitWays([toOrFrom.way])(graph);
var a = graph.entity(newID),
@@ -85,4 +87,4 @@ module.exports = function(turn, projection, restrictionId) {
]
}));
};
};
}
+2 -2
View File
@@ -29,7 +29,7 @@
http://wiki.openstreetmap.org/wiki/Route#Members
http://josm.openstreetmap.de/browser/josm/trunk/src/org/openstreetmap/josm/corrector/ReverseWayTagCorrector.java
*/
module.exports = function(wayId, options) {
export function Reverse(wayId, options) {
var replacements = [
[/:right$/, ':left'], [/:left$/, ':right'],
[/:forward$/, ':backward'], [/:backward$/, ':forward']
@@ -86,4 +86,4 @@ module.exports = function(wayId, options) {
return graph.replace(way.update({nodes: nodes, tags: tags}));
};
};
}
+7 -4
View File
@@ -1,4 +1,7 @@
module.exports = function(id) {
import { DeleteWay } from './delete_way';
import { DeleteRelation } from './delete_relation';
export function Revert(id) {
var action = function(graph) {
var entity = graph.hasEntity(id),
@@ -12,7 +15,7 @@ module.exports = function(id) {
graph = graph.replace(parent);
if (parent.isDegenerate()) {
graph = iD.actions.DeleteWay(parent.id)(graph);
graph = DeleteWay(parent.id)(graph);
}
});
}
@@ -23,7 +26,7 @@ module.exports = function(id) {
graph = graph.replace(parent);
if (parent.isDegenerate()) {
graph = iD.actions.DeleteRelation(parent.id)(graph);
graph = DeleteRelation(parent.id)(graph);
}
});
}
@@ -32,4 +35,4 @@ module.exports = function(id) {
};
return action;
};
}
+2 -2
View File
@@ -1,4 +1,4 @@
module.exports = function(wayId, pivot, angle, projection) {
export function RotateWay(wayId, pivot, angle, projection) {
return function(graph) {
return graph.update(function(graph) {
var way = graph.entity(wayId);
@@ -23,4 +23,4 @@ module.exports = function(wayId, pivot, angle, projection) {
});
};
};
}
+4 -3
View File
@@ -1,3 +1,4 @@
import { AddMember } from './add_member';
// Split a way at the given node.
//
// Optionally, split only the given ways, if multiple ways share
@@ -12,7 +13,7 @@
// Reference:
// https://github.com/systemed/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/SplitWayAction.as
//
module.exports = function(nodeId, newWayIds) {
export function Split(nodeId, newWayIds) {
var wayIds;
// if the way is closed, we need to search for a partner node
@@ -117,7 +118,7 @@ module.exports = function(nodeId, newWayIds) {
role: relation.memberById(wayA.id).role
};
graph = iD.actions.AddMember(relation.id, member)(graph);
graph = AddMember(relation.id, member)(graph);
}
});
@@ -184,4 +185,4 @@ module.exports = function(nodeId, newWayIds) {
};
return action;
};
}
+5 -3
View File
@@ -1,8 +1,10 @@
import { DeleteNode } from './delete_node';
/*
* Based on https://github.com/openstreetmap/potlatch2/net/systemeD/potlatch2/tools/Straighten.as
*/
module.exports = function(wayId, projection) {
export function Straighten(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));
@@ -40,7 +42,7 @@ module.exports = function(wayId, projection) {
}
for (i = 0; i < toDelete.length; i++) {
graph = iD.actions.DeleteNode(toDelete[i].id)(graph);
graph = DeleteNode(toDelete[i].id)(graph);
}
return graph;
@@ -75,4 +77,4 @@ module.exports = function(wayId, projection) {
};
return action;
};
}
+5 -3
View File
@@ -1,3 +1,5 @@
import { DeleteRelation } from './delete_relation';
// Remove the effects of `turn.restriction` on `turn`, which must have the
// following structure:
//
@@ -16,8 +18,8 @@
// that restriction is also deleted, but at the same time restrictions on
// the turns other than the first two are created.
//
module.exports = function(turn) {
export function UnrestrictTurn(turn) {
return function(graph) {
return iD.actions.DeleteRelation(turn.restriction)(graph);
return DeleteRelation(turn.restriction)(graph);
};
};
}
+7 -6
View File
@@ -8,10 +8,10 @@
"test": "test"
},
"scripts": {
"postinstall": "rm -rf node_modules/.bin/phantomjs",
"test": "npm run lint && phantomjs node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js test/index.html dot && make && phantomjs node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js test/index_packaged.html dot",
"start": "http-server .",
"lint": "eslint js/id && npm run lint:spec:actions",
"lint:modules": "eslint modules",
"lint:spec:actions": "eslint test/spec/actions"
},
"repository": {
@@ -24,11 +24,10 @@
],
"license": "ISC",
"devDependencies": {
"browserify": "13.0.1",
"chai": "~1.9.2",
"d3": "3.5.5",
"editor-layer-index": "git://github.com/osmlab/editor-layer-index.git#gh-pages",
"eslint": "^1.10.3",
"eslint": "^2.12.0",
"glob": "~3.1.21",
"happen": "0.1.2",
"http-server": "^0.9.0",
@@ -37,17 +36,19 @@
"lodash-cli": "4.12.0",
"maki": "0.5.0",
"minimist": "~1.2.0",
"mocha": "~2.3.4",
"mocha-phantomjs-core": "^1.3.0",
"mocha": "~2.5.3",
"mocha-phantomjs-core": "^2.0.1",
"name-suggestion-index": "0.1.1",
"request": "~2.16.2",
"rollup": "0.31.2",
"sinon": "~1.6",
"sinon-chai": "~2.3.1",
"smash": "0.0",
"svg-sprite": "1.2.19",
"uglify-js": "~2.4.16",
"xml2js": "~0.4.13",
"xmlbuilder": "~4.2.0"
"xmlbuilder": "~4.2.0",
"phantomjs-prebuilt": "2.1.7"
},
"engines": {
"node": ">=0.10.0"
-1
View File
@@ -14,7 +14,6 @@
<script src="../node_modules/sinon/pkg/sinon.js"></script>
<script src="../node_modules/sinon-chai/lib/sinon-chai.js"></script>
<script src="../node_modules/happen/src/happen.js"></script>
<script src="lib/bind-shim.js"></script>
<script>
if (typeof initMochaPhantomJS === 'function') {
-1
View File
@@ -14,7 +14,6 @@
<script src="../node_modules/sinon/pkg/sinon.js"></script>
<script src="../node_modules/sinon-chai/lib/sinon-chai.js"></script>
<script src="../node_modules/happen/src/happen.js"></script>
<script src="lib/bind-shim.js"></script>
<script>
if (typeof initMochaPhantomJS === 'function') {
-26
View File
@@ -1,26 +0,0 @@
// PhantomJS is missing Function.prototype.bind:
// http://code.google.com/p/phantomjs/issues/detail?id=522
if (!Function.prototype.bind) {
Function.prototype.bind = function (oThis) {
if (typeof this !== "function") {
// closest thing possible to the ECMAScript 5 internal IsCallable function
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
}
var aArgs = Array.prototype.slice.call(arguments, 1),
fToBind = this,
fNOP = function () {},
fBound = function () {
return fToBind.apply(this instanceof fNOP && oThis
? this
: oThis,
aArgs.concat(Array.prototype.slice.call(arguments)));
};
fNOP.prototype = this.prototype;
fBound.prototype = new fNOP();
return fBound;
};
}