Modify and snap to circle in user coordinates
Correct modify interaction at center and at drawn circle circumference Correct snap interaction at drawn circle circumference Test circle geometry in a user projection
This commit is contained in:
@@ -14,7 +14,7 @@ import PointerInteraction from './Pointer.js';
|
||||
import {getValues} from '../obj.js';
|
||||
import VectorEventType from '../source/VectorEventType.js';
|
||||
import RBush from '../structs/RBush.js';
|
||||
import {fromUserCoordinate, toUserCoordinate} from '../proj.js';
|
||||
import {getUserProjection, fromUserCoordinate, toUserCoordinate} from '../proj.js';
|
||||
|
||||
|
||||
/**
|
||||
@@ -431,8 +431,13 @@ class Snap extends PointerInteraction {
|
||||
} else if (this.edge_) {
|
||||
const isCircle = closestSegmentData.feature.getGeometry().getType() === GeometryType.CIRCLE;
|
||||
if (isCircle) {
|
||||
vertex = closestOnCircle(pixelCoordinate,
|
||||
/** @type {import("../geom/Circle.js").default} */ (closestSegmentData.feature.getGeometry()));
|
||||
let circleGeometry = closestSegmentData.feature.getGeometry();
|
||||
const userProjection = getUserProjection();
|
||||
if (userProjection) {
|
||||
circleGeometry = circleGeometry.clone().transform(userProjection, projection);
|
||||
}
|
||||
vertex = toUserCoordinate(closestOnCircle(projectedCoordinate,
|
||||
/** @type {import("../geom/Circle.js").default} */ (circleGeometry)), projection);
|
||||
} else {
|
||||
tempSegment[0] = fromUserCoordinate(closestSegment[0], projection);
|
||||
tempSegment[1] = fromUserCoordinate(closestSegment[1], projection);
|
||||
@@ -482,7 +487,16 @@ class Snap extends PointerInteraction {
|
||||
* @private
|
||||
*/
|
||||
writeCircleGeometry_(feature, geometry) {
|
||||
const polygon = fromCircle(geometry);
|
||||
const projection = this.getMap().getView().getProjection();
|
||||
let circleGeometry = geometry;
|
||||
const userProjection = getUserProjection();
|
||||
if (userProjection) {
|
||||
circleGeometry = /** @type {import("../geom/Circle.js").default} */ (circleGeometry.clone().transform(userProjection, projection));
|
||||
}
|
||||
const polygon = fromCircle(circleGeometry);
|
||||
if (userProjection) {
|
||||
polygon.transform(projection, userProjection);
|
||||
}
|
||||
const coordinates = polygon.getCoordinates()[0];
|
||||
for (let i = 0, ii = coordinates.length - 1; i < ii; ++i) {
|
||||
const segment = coordinates.slice(i, i + 2);
|
||||
|
||||
Reference in New Issue
Block a user