Skip to content

Commit

Permalink
improved quality of code
Browse files Browse the repository at this point in the history
  • Loading branch information
MV88 committed Mar 13, 2017
1 parent bdc1c8c commit 0801fb8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
22 changes: 6 additions & 16 deletions web/client/components/map/leaflet/MeasurementSupport.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,26 +121,16 @@ const MeasurementSupport = React.createClass({
} else {
let bearingMarkers = this.drawControl._markers || [];

if (bearingMarkers.length <= 2 ) {
if (this.props.measurement.geomType === 'Bearing' && bearingMarkers.length >= 2) {
this.drawControl._markers = slice(this.drawControl._markers, 0, 2);
this.drawControl._poly._latlngs = slice(this.drawControl._poly._latlngs, 0, 2);
this.drawControl._poly._originalPoints = slice(this.drawControl._poly._originalPoints, 0, 2);
this.updateMeasurementResults();
}
if (bearingMarkers.length === 2 && this.props.measurement.geomType === 'Bearing') {
this.drawControl._finishShape();
this.drawControl.disable();
this.drawing = false;
}
if (bearingMarkers.length > 2) {
if (this.props.measurement.geomType === 'Bearing') {
this.drawControl._markers = slice(this.drawControl._markers, 0, 2);
this.drawControl._poly._latlngs = slice(this.drawControl._poly._latlngs, 0, 2);
this.drawControl._poly._originalPoints = slice(this.drawControl._poly._originalPoints, 0, 2);
this.updateMeasurementResults();
this.drawControl._finishShape();
this.drawControl.disable();
this.drawing = false;
} else {
this.updateMeasurementResults();
}
} else {
this.updateMeasurementResults();
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions web/client/components/map/openlayers/MeasurementSupport.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ const MeasurementSupport = React.createClass({
let bearing = 0;
let sketchCoords = this.sketchFeature.getGeometry().getCoordinates();

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

0 comments on commit 0801fb8

Please sign in to comment.