mirror of
https://github.com/FoggedLens/iD.git
synced 2026-06-05 14:38:05 +02:00
Update to only flip around the vertical axis. Start renaming to 'reflect'
This commit is contained in:
+8
-12
@@ -1,9 +1,9 @@
|
||||
import _ from 'lodash';
|
||||
/* Flip the provided way horizontally or vertically
|
||||
/* Flip the provided way horizontally
|
||||
Only operates on "area" ways
|
||||
*/
|
||||
|
||||
export function actionFlip(wayId, isVertical) {
|
||||
export function actionFlip(wayId) {
|
||||
|
||||
return function (graph) {
|
||||
const targetWay = graph.entity(wayId);
|
||||
@@ -16,11 +16,11 @@ export function actionFlip(wayId, isVertical) {
|
||||
// Get the bounding rectangle of the area
|
||||
const boundingRect = targetWay.extent(graph).rectangle();
|
||||
// rectangle returned as [ lon (x) top left, lat (y) top left, lon (x) bottom right, lat (y) bottom right]
|
||||
// Obtain the left/top lonlat and the right/bottom
|
||||
const leftOrTop = isVertical ? boundingRect[1] : boundingRect[0];
|
||||
const rightOrBottom = isVertical ? boundingRect[3] : boundingRect[2];
|
||||
// Obtain the left and right lonlat's
|
||||
const left = boundingRect[0];
|
||||
const right = boundingRect[2];
|
||||
// Determine the mid-point that we will flip on
|
||||
const midPoint = leftOrTop + ((rightOrBottom - leftOrTop) / 2);
|
||||
const midPoint = left + ((right - left) / 2);
|
||||
|
||||
// Obtain all of the nodes on the way, iterate over them to translate then aggreate up
|
||||
return _(targetWay.nodes)
|
||||
@@ -31,12 +31,8 @@ export function actionFlip(wayId, isVertical) {
|
||||
.uniqBy(function (node) { return node.id; })
|
||||
// Get distance from midPoint and produce a translated node
|
||||
.map(function (node) {
|
||||
const delta = isVertical ?
|
||||
node.loc[1] - midPoint :
|
||||
node.loc[0] - midPoint;
|
||||
return isVertical ?
|
||||
node.move([node.loc[0], node.loc[1]-(2*delta)]) :
|
||||
node.move([node.loc[0]-(2*delta), node.loc[1]]);
|
||||
const delta = node.loc[0] - midPoint;
|
||||
return node.move([node.loc[0]-(2*delta), node.loc[1]]);
|
||||
})
|
||||
// Chain together consecutive updates to the graph for each updated node and return
|
||||
.reduce(function (accGraph, value) {
|
||||
|
||||
@@ -31,4 +31,4 @@ export { actionRotateWay } from './rotate_way';
|
||||
export { actionSplit } from './split';
|
||||
export { actionStraighten } from './straighten';
|
||||
export { actionUnrestrictTurn } from './unrestrict_turn';
|
||||
export { actionFlip } from './flip';
|
||||
export { actionReflect } from './flip';
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
import { t } from '../util/locale';
|
||||
import { actionFlip } from '../actions/index';
|
||||
import { uiCmd } from '../ui/index';
|
||||
|
||||
export function operationFlipVertical(selectedIDs, context) {
|
||||
var entityId = selectedIDs[0];
|
||||
|
||||
var operation = function() {
|
||||
context.perform(
|
||||
actionFlip(entityId, true),
|
||||
t('operations.flipVertical.annotation')
|
||||
);
|
||||
};
|
||||
|
||||
operation.available = function() {
|
||||
return selectedIDs.length === 1 &&
|
||||
context.geometry(entityId) === 'area';
|
||||
};
|
||||
|
||||
operation.disabled = function() {
|
||||
return false;
|
||||
};
|
||||
|
||||
operation.tooltip = function() {
|
||||
return t('operations.flipVertical.description');
|
||||
};
|
||||
|
||||
operation.id = 'flipVertical';
|
||||
operation.keys = [uiCmd('⌥V')]; // Alt-V
|
||||
operation.title = t('operations.flipVertical.title');
|
||||
|
||||
return operation;
|
||||
}
|
||||
@@ -9,5 +9,3 @@ export { operationReverse } from './reverse';
|
||||
export { operationRotate } from './rotate';
|
||||
export { operationSplit } from './split';
|
||||
export { operationStraighten } from './straighten';
|
||||
export { operationFlipHorizontal } from './flipHorizontal';
|
||||
export { operationFlipVertical } from './flipVertical';
|
||||
@@ -1,14 +1,13 @@
|
||||
import { t } from '../util/locale';
|
||||
import { actionFlip } from '../actions/index';
|
||||
import { uiCmd } from '../ui/index';
|
||||
import { actionReflect } from '../actions/index';
|
||||
|
||||
export function operationFlipHorizontal(selectedIDs, context) {
|
||||
export function operationReflect(selectedIDs, context) {
|
||||
var entityId = selectedIDs[0];
|
||||
|
||||
var operation = function() {
|
||||
context.perform(
|
||||
actionFlip(entityId, false),
|
||||
t('operations.flipHorizontal.annotation')
|
||||
actionReflect(entityId, false),
|
||||
t('operations.reflect.annotation')
|
||||
);
|
||||
};
|
||||
|
||||
@@ -22,12 +21,12 @@ export function operationFlipHorizontal(selectedIDs, context) {
|
||||
};
|
||||
|
||||
operation.tooltip = function() {
|
||||
return t('operations.flipHorizontal.description');
|
||||
return t('operations.reflect.description');
|
||||
};
|
||||
|
||||
operation.id = 'flipHorizontal';
|
||||
operation.keys = [uiCmd('⌥H')]; // Alt-H
|
||||
operation.title = t('operations.flipHorizontal.title');
|
||||
operation.keys = [t('operations.reflect.key')];
|
||||
operation.title = t('operations.reflect.title');
|
||||
|
||||
return operation;
|
||||
}
|
||||
Reference in New Issue
Block a user