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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
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
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
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);

likangning93 marked this conversation as resolved.
Show resolved Hide resolved
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