Skip to content

Commit

Permalink
Simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
llienher committed Jul 17, 2019
1 parent 5738418 commit 984c8e2
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/interaction/MeasureLength.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,7 @@ exports.prototype.linestringGeometryFunction = function(source, coordinates, opt
to[1] = b[1];

// intersection calculation
const result = {
x: 0.0,
y: 0.0
};
const intersectionPoint = this.computeLineSegmentIntersection(from[0], from[1], to[0], to[1], point1[0], point1[1], point2[0], point2[1], result);
if (intersectionPoint !== undefined) {
to[0] = intersectionPoint.x;
to[1] = intersectionPoint.y;
}
this.computeLineSegmentIntersection(from[0], from[1], to[0], to[1], point1[0], point1[1], point2[0], point2[1], to);
});
});
}
Expand Down Expand Up @@ -188,8 +180,8 @@ exports.prototype.computeLineSegmentIntersection = function(x00, y00, x01, y01,
const ub1 = numerator1B / denominator1;

if (ua1 >= 0 && ua1 <= 1 && ub1 >= 0 && ub1 <= 1) {
result.x = x00 + ua1 * (x01 - x00);
result.y = y00 + ua1 * (y01 - y00);
result[0] = x00 + ua1 * (x01 - x00);
result[1] = y00 + ua1 * (y01 - y00);
return result;
}
};
Expand Down

0 comments on commit 984c8e2

Please sign in to comment.