Skip to content

Commit

Permalink
Merge pull request #7551 from shehzan10/rhumb-line-IDL-intersection-fix
Browse files Browse the repository at this point in the history
Fix IDL intersection of rhumb lines by using the correct sign of PI
  • Loading branch information
likangning93 authored Feb 8, 2019
2 parents 1c59de4 + 25bdc63 commit f87fbad
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Change Log
* Fixed Node.js support for the `Resource` class and any functionality using it internally.
* Fixed an issue where some ground polygons crossing the Prime Meridian would have incorrect bounding rectangles. [#7533](https://github.com/AnalyticalGraphicsInc/cesium/pull/7533)
* Fixed an issue where polygons on terrain using rhumb lines where being rendered incorrectly. [#7538](https://github.com/AnalyticalGraphicsInc/cesium/pulls/7538)
* Fixed an issue with `EllipsoidRhumbLines.findIntersectionWithLongitude` when longitude was IDL. [#7551](https://github.com/AnalyticalGraphicsInc/cesium/issues/7551)

### 1.54 - 2019-02-01

Expand Down
6 changes: 5 additions & 1 deletion Source/Core/EllipsoidRhumbLine.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,10 @@ define([

intersectionLongitude = CesiumMath.negativePiToPi(intersectionLongitude);

if (CesiumMath.equalsEpsilon(Math.abs(intersectionLongitude), Math.PI, CesiumMath.EPSILON14)) {
intersectionLongitude = Math.sign(start.longitude) * Math.PI;
}

if (!defined(result)) {
result = new Cartographic();
}
Expand Down Expand Up @@ -454,7 +458,7 @@ define([
} while (!CesiumMath.equalsEpsilon(newPhi, phi, CesiumMath.EPSILON12));

result.longitude = intersectionLongitude;
result.latitude = phi;
result.latitude = newPhi;
result.height = 0;
return result;
};
Expand Down
23 changes: 23 additions & 0 deletions Specs/Core/EllipsoidRhumbLineSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,29 @@ defineSuite([
expect(Cartographic.equalsEpsilon(pointUsingInterpolation, pointUsingIntersection, CesiumMath.EPSILON12)).toBe(true);
});

it('finds correct intersection with IDL', function() {
var start = Cartographic.fromDegrees(170, 10);
var end = Cartographic.fromDegrees(-170, 23);

var rhumb = new EllipsoidRhumbLine(start, end);

var idlIntersection1 = rhumb.findIntersectionWithLongitude(-Math.PI);
var idlIntersection2 = rhumb.findIntersectionWithLongitude(Math.PI);

expect(Cartographic.equalsEpsilon(idlIntersection1, idlIntersection2, CesiumMath.EPSILON12)).toBe(true);
expect(idlIntersection1.longitude).toEqualEpsilon(Math.PI, CesiumMath.EPSILON14);
expect(idlIntersection2.longitude).toEqualEpsilon(Math.PI, CesiumMath.EPSILON14);

rhumb.setEndPoints(end, start);

idlIntersection1 = rhumb.findIntersectionWithLongitude(-Math.PI);
idlIntersection2 = rhumb.findIntersectionWithLongitude(Math.PI);

expect(Cartographic.equalsEpsilon(idlIntersection1, idlIntersection2, CesiumMath.EPSILON12)).toBe(true);
expect(idlIntersection1.longitude).toEqualEpsilon(-Math.PI, CesiumMath.EPSILON14);
expect(idlIntersection2.longitude).toEqualEpsilon(-Math.PI, CesiumMath.EPSILON14);
});

it('intersection with longitude handles E-W lines', function() {
var start = new Cartographic(fifteenDegrees, 0.0);
var end = new Cartographic(fortyfiveDegrees, 0.0);
Expand Down

0 comments on commit f87fbad

Please sign in to comment.