Files
iD/modules/modes/draw_area.js
Bryan Housel f0a27bc1ec Simplify way segmentation and fix bug with adjacent segment type
(closes #4669)

Now instead of creating MultiLineString targets, we just create a bunch of
LineString targets.  This makes the code simpler, and anyway the entity is
still there in `properties` for drawing code to decide what to do with the target.

Incidentally, this change allows iD to support an extrusion operation.
(Because each way segment has its own unique GeoJSON target now)
2018-01-09 10:12:29 -05:00

54 lines
1.1 KiB
JavaScript

import { t } from '../util/locale';
import { behaviorDrawWay } from '../behavior';
export function modeDrawArea(context, wayId, startGraph) {
var mode = {
button: 'area',
id: 'draw-area'
};
var behavior;
mode.enter = function() {
var way = context.entity(wayId);
behavior = behaviorDrawWay(context, wayId, undefined, mode, startGraph)
.tail(t('modes.draw_area.tail'));
var addNode = behavior.addNode;
behavior.addNode = function(node, d) {
var length = way.nodes.length;
var penultimate = length > 2 ? way.nodes[length - 2] : null;
if (node.id === way.first() || node.id === penultimate) {
behavior.finish();
} else {
addNode(node, d);
}
};
context.install(behavior);
};
mode.exit = function() {
context.uninstall(behavior);
};
mode.selectedIDs = function() {
return [wayId];
};
mode.activeID = function() {
return (behavior && behavior.activeID()) || [];
};
return mode;
}