Skip to content

Commit

Permalink
Merge pull request #5286 from rldhont/backport-5261-to-release_3_7
Browse files Browse the repository at this point in the history
[Backport release_3_7] Fix: wrong distance constraint value
  • Loading branch information
rldhont authored Jan 28, 2025
2 parents d87cd34 + c4ffb92 commit 6e12d43
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions assets/src/modules/Digitizing.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,10 @@ export default class Digitizing {
this._segmentMeasureTooltipElement = null;
this._totalMeasureTooltipElement = null;
unByKey(this._listener);

if (geom.getType() === 'LineString') {
this._updateTotalMeasureTooltip(null, geom, 'LineString', Array.from(this._measureTooltips).pop()[1]);
}
});

mainLizmap.map.addInteraction(this._drawInteraction);
Expand Down Expand Up @@ -695,20 +699,22 @@ export default class Digitizing {
// Contraint where point will be drawn on click
let constrainedPointCoords = cursorPointCoords;

const mapProjection = this._map.getView().getProjection();

if (this._distanceConstraint) {
// Draw circle with distanceConstraint as radius
const circle = circular(
transform(lastDrawnPointCoords, 'EPSG:3857', 'EPSG:4326'),
transform(lastDrawnPointCoords, mapProjection, 'EPSG:4326'),
this._distanceConstraint,
128
);

constrainedPointCoords = transform(circle.getClosestPoint(transform(cursorPointCoords, 'EPSG:3857', 'EPSG:4326')), 'EPSG:4326', 'EPSG:3857');
constrainedPointCoords = transform(circle.getClosestPoint(transform(cursorPointCoords, mapProjection, 'EPSG:4326')), 'EPSG:4326', mapProjection);

// Draw visual constraint features
this._constraintLayer.getSource().addFeature(
new Feature({
geometry: circle.transform('EPSG:4326', 'EPSG:3857')
geometry: circle.transform('EPSG:4326', mapProjection)
})
);

Expand Down

0 comments on commit 6e12d43

Please sign in to comment.