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

Fix IDL intersection of rhumb lines by using the correct sign of PI #7551

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
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -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

6 changes: 5 additions & 1 deletion Source/Core/EllipsoidRhumbLine.js
Original file line number Diff line number Diff line change
@@ -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();
}
@@ -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;
};
23 changes: 23 additions & 0 deletions Specs/Core/EllipsoidRhumbLineSpec.js
Original file line number Diff line number Diff line change
@@ -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);