From 04bdc4da1c632696465ce0b896dd740f898ff14b Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Wed, 13 May 2020 10:58:53 -0400 Subject: [PATCH] Make the extract operation a single step instead of immediately entering modeMove (close #6674) --- modules/actions/extract.js | 6 ++-- modules/operations/extract.js | 32 +++------------------- modules/validations/mismatched_geometry.js | 4 +-- 3 files changed, 9 insertions(+), 33 deletions(-) diff --git a/modules/actions/extract.js b/modules/actions/extract.js index 6c00a3882..5e5a391dc 100644 --- a/modules/actions/extract.js +++ b/modules/actions/extract.js @@ -1,8 +1,8 @@ -import { geoPath as d3_geoPath } from 'd3-geo'; +import { geoCentroid as d3_geoCentroid } from 'd3-geo'; import { osmNode } from '../osm/node'; -export function actionExtract(entityID, projection) { +export function actionExtract(entityID) { var extractedNodeID; @@ -43,7 +43,7 @@ export function actionExtract(entityID, projection) { var keysToRetain = ['area', 'type']; var buildingKeysToRetain = ['architect', 'building', 'height', 'layer']; - var centroid = d3_geoPath(projection).centroid(entity.asGeoJSON(graph, true)); + var centroid = d3_geoCentroid(entity.asGeoJSON(graph)); var isBuilding = entity.tags.building; diff --git a/modules/operations/extract.js b/modules/operations/extract.js index 003993dd7..6a660ac78 100644 --- a/modules/operations/extract.js +++ b/modules/operations/extract.js @@ -1,44 +1,20 @@ import { actionExtract } from '../actions/extract'; -import { actionMoveNode } from '../actions/move_node'; import { behaviorOperation } from '../behavior/operation'; -import { modeMove } from '../modes/move'; +import { modeSelect } from '../modes/select'; import { t } from '../core/localizer'; import { presetManager } from '../presets'; export function operationExtract(selectedIDs, context) { var entityID = selectedIDs.length && selectedIDs[0]; - var action = actionExtract(entityID, context.projection); + var action = actionExtract(entityID); var geometry = entityID && context.graph().hasEntity(entityID) && context.graph().geometry(entityID); var extent = geometry === 'area' && context.entity(entityID).extent(context.graph()); var operation = function () { - context.perform(action); // do the extract - context.validator().validate(); - - var extractedNodeID = action.getExtractedNodeID(); - - var mouse = context.map().mouseCoordinates(); - if (mouse.some(isNaN)) { - enterMoveMode(); - - } else { - // move detached node to the mouse location (transitioned) - context.perform(actionMoveNode(extractedNodeID, mouse)); - - // after transition completes, put at final mouse location and enter move mode. - window.setTimeout(function() { - mouse = context.map().mouseCoordinates(); - context.replace(actionMoveNode(extractedNodeID, mouse)); - enterMoveMode(); - }, 150); - } - - function enterMoveMode() { - var baseGraph = context.graph(); - context.enter(modeMove(context, [extractedNodeID], baseGraph)); - } + context.perform(action, operation.annotation()); // do the extract + context.enter(modeSelect(context, [action.getExtractedNodeID()])); }; diff --git a/modules/validations/mismatched_geometry.js b/modules/validations/mismatched_geometry.js index c079ff05d..d8577a2df 100644 --- a/modules/validations/mismatched_geometry.js +++ b/modules/validations/mismatched_geometry.js @@ -202,11 +202,11 @@ export function validationMismatchedGeometry() { var extractOnClick = null; if (!context.hasHiddenConnections(entityId) && - !actionExtract(entityId, context.projection).disabled(context.graph())) { + !actionExtract(entityId).disabled(context.graph())) { extractOnClick = function(context) { var entityId = this.issue.entityIds[0]; - var action = actionExtract(entityId, context.projection); + var action = actionExtract(entityId); context.perform( action, t('operations.extract.annotation.single')