Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2023.02.xx] #9366 Problems with Bearing measurement (#9400) #9439

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions web/client/components/map/openlayers/MeasurementSupport.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {getMessageById} from '../../../utils/LocaleUtils';
import {createOLGeometry} from '../../../utils/openlayers/DrawUtils';

import {Polygon, LineString} from 'ol/geom';
import { never } from 'ol/events/condition';
import Overlay from 'ol/Overlay';
import VectorSource from 'ol/source/Vector';
import VectorLayer from 'ol/layer/Vector';
Expand Down Expand Up @@ -599,6 +600,7 @@ export default class MeasurementSupport extends React.Component {
// create an interaction to draw with
draw = new Draw({
source: new VectorSource(),
freehandCondition: never,
type: /** @type {ol.geom.GeometryType} */ geometryType,
style: new Style({
fill: new Fill({
Expand All @@ -621,9 +623,9 @@ export default class MeasurementSupport extends React.Component {
})
});

this.clickListener = this.props.map.on('click', this.updateMeasurementResults.bind(this, this.props));
this.clickListener = this.props.map.on('click', this.updateMeasurementResults.bind(this));
if (this.props.updateOnMouseMove) {
this.props.map.on('pointermove', this.updateMeasurementResults.bind(this, this.props));
this.props.map.on('pointermove', this.updateMeasurementResults.bind(this));
}

this.props.map.on('pointermove', (evt) => this.pointerMoveHandler(evt));
Expand Down Expand Up @@ -896,10 +898,10 @@ export default class MeasurementSupport extends React.Component {
this.props.map.removeInteraction(this.drawInteraction);
this.drawInteraction = null;
this.sketchFeature = null;
this.props.map.un('click', this.updateMeasurementResults.bind(this, this.props), this);
this.props.map.un('click', this.updateMeasurementResults.bind(this), this);
unByKey(this.clickListener);
if (this.props.updateOnMouseMove) {
this.props.map.un('pointermove', this.updateMeasurementResults.bind(this, this.props), this);
this.props.map.un('pointermove', this.updateMeasurementResults.bind(this), this);
}
}
};
Expand Down Expand Up @@ -929,13 +931,13 @@ export default class MeasurementSupport extends React.Component {
this.helpTooltipElement.classList.remove('hidden');
};

updateMeasurementResults = (props) => {
updateMeasurementResults = () => {
if (!this.sketchFeature) {
return;
}
let sketchCoords = this.sketchFeature.getGeometry().getCoordinates();

if (props.measurement.geomType === 'Bearing' && sketchCoords.length > 1) {
if (this.props.measurement.geomType === 'Bearing' && sketchCoords.length > 1) {
// calculate the azimuth as base for bearing information
if (sketchCoords.length > 2) {
this.drawInteraction.sketchCoords_ = [sketchCoords[0], sketchCoords[1], sketchCoords[0]];
Expand Down