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 vertical rhumb line when using PolylineGeometry #9028

Merged
merged 5 commits into from
Jul 20, 2020
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.
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
Expand Up @@ -6,6 +6,7 @@

- Fixed 3D Tileset replacement refinement when leaf is empty. [#8996](https://github.com/CesiumGS/cesium/pull/8996)
- Fixed a bug in the assessment of terrain tile visibility [#9033](https://github.com/CesiumGS/cesium/issues/9033)
- Fixed vertical polylines with `arcType: ArcType.RHUMB`, including lines drawn via GeoJSON. [#9028](https://github.com/CesiumGS/cesium/pull/9028)

### 1.71 - 2020-07-01

Expand Down
6 changes: 4 additions & 2 deletions Source/Core/PolylinePipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ PolylinePipeline.numberOfPointsRhumbLine = function (p0, p1, granularity) {
var radiansDistanceSquared =
Math.pow(p0.longitude - p1.longitude, 2) +
Math.pow(p0.latitude - p1.latitude, 2);
return Math.ceil(
Math.sqrt(radiansDistanceSquared / (granularity * granularity))

return Math.max(
1,
Math.ceil(Math.sqrt(radiansDistanceSquared / (granularity * granularity)))
);
};

Expand Down
59 changes: 59 additions & 0 deletions Specs/Core/PolylineGeometrySpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Ellipsoid } from "../../Source/Cesium.js";
import { PolylineGeometry } from "../../Source/Cesium.js";
import { VertexFormat } from "../../Source/Cesium.js";
import createPackableSpecs from "../createPackableSpecs.js";
import CesiumMath from "../../Source/Core/Math.js";

describe("Core/PolylineGeometry", function () {
it("constructor throws with no positions", function () {
Expand Down Expand Up @@ -184,6 +185,64 @@ describe("Core/PolylineGeometry", function () {
expect(geometry).not.toBeDefined();
});

it("createGeometry returns positions if their endpoints'longtitude and latitude are the same for rhumb line", function () {
var positions = Cartesian3.fromDegreesArrayHeights([
30.0,
30.0,
10.0,
30.0,
30.0,
5.0,
]);
var geometry = PolylineGeometry.createGeometry(
new PolylineGeometry({
positions: positions,
width: 10.0,
vertexFormat: VertexFormat.POSITION_ONLY,
arcType: ArcType.RHUMB,
})
);

var attributePositions = geometry.attributes.position.values;
var geometryPosition = new Cartesian3();

Cartesian3.fromArray(attributePositions, 0, geometryPosition);
expect(
Cartesian3.equalsEpsilon(
geometryPosition,
positions[0],
CesiumMath.EPSILON7
)
).toBe(true);

Cartesian3.fromArray(attributePositions, 3, geometryPosition);
expect(
Cartesian3.equalsEpsilon(
geometryPosition,
positions[0],
CesiumMath.EPSILON7
)
).toBe(true);

Cartesian3.fromArray(attributePositions, 6, geometryPosition);
expect(
Cartesian3.equalsEpsilon(
geometryPosition,
positions[1],
CesiumMath.EPSILON7
)
).toBe(true);

Cartesian3.fromArray(attributePositions, 9, geometryPosition);
expect(
Cartesian3.equalsEpsilon(
geometryPosition,
positions[1],
CesiumMath.EPSILON7
)
).toBe(true);
});

var positions = [
new Cartesian3(1, 2, 3),
new Cartesian3(4, 5, 6),
Expand Down