mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-15 21:48:20 +02:00
Make the extract operation a single step instead of immediately entering modeMove (close #6674)
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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()]));
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user