Skip to content

Commit

Permalink
fix ellipsoid bug in GroundPolylineGeometry.unpack
Browse files Browse the repository at this point in the history
  • Loading branch information
likangning93 committed Feb 12, 2019
1 parent f87fbad commit 96c8a7c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Change Log
* 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)
* Fixed an issue with ground polylines on globes that use ellipsoids other than WGS84. [#7552](https://github.com/AnalyticalGraphicsInc/cesium/issues/7552)

### 1.54 - 2019-02-01

Expand Down
11 changes: 2 additions & 9 deletions Source/Core/GroundPolylineGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,16 +331,9 @@ define([
var scene3DOnly = (array[index++] === 1.0);

if (!defined(result)) {
var geometry = new GroundPolylineGeometry({
positions : positions,
granularity : granularity,
loop : loop,
arcType : arcType,
ellipsoid : ellipsoid
result = new GroundPolylineGeometry({
positions : positions
});
geometry._projectionIndex = projectionIndex;
geometry._scene3DOnly = scene3DOnly;
return geometry;
}

result._positions = positions;
Expand Down
31 changes: 29 additions & 2 deletions Specs/Core/GroundPolylineGeometrySpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ defineSuite([
granularity : 10.0 // no interpolative subdivision
});
groundPolylineGeometry._scene3DOnly = true;
GroundPolylineGeometry.setProjectionAndEllipsoid(groundPolylineGeometry, new WebMercatorProjection(Ellipsoid.WGS84));
GroundPolylineGeometry.setProjectionAndEllipsoid(groundPolylineGeometry, new WebMercatorProjection(Ellipsoid.UNIT_SPHERE));

var packedArray = [0];
GroundPolylineGeometry.pack(groundPolylineGeometry, packedArray, 1);
Expand All @@ -548,11 +548,38 @@ defineSuite([
expect(Cartesian3.equals(scratchPositions[1], groundPolylineGeometry._positions[1])).toBe(true);
expect(scratch.loop).toBe(true);
expect(scratch.granularity).toEqual(10.0);
expect(scratch._ellipsoid.equals(Ellipsoid.WGS84)).toBe(true);
expect(scratch._ellipsoid.equals(Ellipsoid.UNIT_SPHERE)).toBe(true);
expect(scratch._scene3DOnly).toBe(true);
expect(scratch._projectionIndex).toEqual(1);
});

it('can unpack onto a new instance', function() {
var groundPolylineGeometry = new GroundPolylineGeometry({
positions : Cartesian3.fromDegreesArray([
-1.0, 0.0,
1.0, 0.0
]),
loop : true,
granularity : 10.0 // no interpolative subdivision
});
groundPolylineGeometry._scene3DOnly = true;
GroundPolylineGeometry.setProjectionAndEllipsoid(groundPolylineGeometry, new WebMercatorProjection(Ellipsoid.UNIT_SPHERE));

var packedArray = [0];
GroundPolylineGeometry.pack(groundPolylineGeometry, packedArray, 1);
var result = GroundPolylineGeometry.unpack(packedArray, 1);

var scratchPositions = result._positions;
expect(scratchPositions.length).toEqual(2);
expect(Cartesian3.equals(scratchPositions[0], groundPolylineGeometry._positions[0])).toBe(true);
expect(Cartesian3.equals(scratchPositions[1], groundPolylineGeometry._positions[1])).toBe(true);
expect(result.loop).toBe(true);
expect(result.granularity).toEqual(10.0);
expect(result._ellipsoid.equals(Ellipsoid.UNIT_SPHERE)).toBe(true);
expect(result._scene3DOnly).toBe(true);
expect(result._projectionIndex).toEqual(1);
});

it('provides a method for setting projection and ellipsoid', function() {
var groundPolylineGeometry = new GroundPolylineGeometry({
positions : Cartesian3.fromDegreesArray([
Expand Down

0 comments on commit 96c8a7c

Please sign in to comment.