diff --git a/CHANGES.md b/CHANGES.md index d36067da186d..0bdb0ce31a75 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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 diff --git a/Source/Core/GroundPolylineGeometry.js b/Source/Core/GroundPolylineGeometry.js index d950f2296b27..a5d21e7b9ef1 100644 --- a/Source/Core/GroundPolylineGeometry.js +++ b/Source/Core/GroundPolylineGeometry.js @@ -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; diff --git a/Specs/Core/GroundPolylineGeometrySpec.js b/Specs/Core/GroundPolylineGeometrySpec.js index b41332a997f3..e19454ff9358 100644 --- a/Specs/Core/GroundPolylineGeometrySpec.js +++ b/Specs/Core/GroundPolylineGeometrySpec.js @@ -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); @@ -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([