From 1ee36258a8130aecaff23851f370a362bc4b3210 Mon Sep 17 00:00:00 2001 From: hpinkos Date: Wed, 27 Jul 2016 16:34:51 -0400 Subject: [PATCH 1/2] height array of length 1 --- Source/Core/PolylinePipeline.js | 3 ++- Specs/Core/PolylinePipelineSpec.js | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Source/Core/PolylinePipeline.js b/Source/Core/PolylinePipeline.js index d7fbb27cf092..99422e918513 100644 --- a/Source/Core/PolylinePipeline.js +++ b/Source/Core/PolylinePipeline.js @@ -233,11 +233,13 @@ define([ var length = positions.length; var ellipsoid = defaultValue(options.ellipsoid, Ellipsoid.WGS84); var height = defaultValue(options.height, 0); + var hasHeightArray = isArray(height); if (length < 1) { return []; } else if (length === 1) { var p = ellipsoid.scaleToGeodeticSurface(positions[0], scaleFirst); + height = hasHeightArray ? height[0] : height; if (height !== 0) { var n = ellipsoid.geodeticSurfaceNormal(p, cartesian); Cartesian3.multiplyByScalar(n, height, n); @@ -263,7 +265,6 @@ define([ var arrayLength = (numPoints + 1) * 3; var newPositions = new Array(arrayLength); var offset = 0; - var hasHeightArray = isArray(height); for (i = 0; i < length - 1; i++) { var p0 = positions[i]; diff --git a/Specs/Core/PolylinePipelineSpec.js b/Specs/Core/PolylinePipelineSpec.js index c3fd0159271b..c698e653de90 100644 --- a/Specs/Core/PolylinePipelineSpec.js +++ b/Specs/Core/PolylinePipelineSpec.js @@ -57,6 +57,19 @@ defineSuite([ }).toThrowDeveloperError(); }); + it('generateArc accepts a height array for single value', function() { + var positions = [Cartesian3.fromDegrees(0, 0)]; + var height = [30]; + + var newPositions = PolylinePipeline.generateArc({ + positions: positions, + height: height + }); + + expect(newPositions.length).toEqual(3); + expect(Cartesian3.fromArray(newPositions, 0)).toEqualEpsilon(Cartesian3.fromDegrees(0, 0, 30), CesiumMath.EPSILON6); + }); + it('generateArc subdivides in half', function() { var p1 = Cartesian3.fromDegrees(0, 0); var p2 = Cartesian3.fromDegrees(90, 0); From 2b22345124822fa51855870bacc38f6cf164e4d7 Mon Sep 17 00:00:00 2001 From: Hannah Date: Mon, 1 Aug 2016 08:36:48 -0400 Subject: [PATCH 2/2] Update CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 35ff73c149c7..2dd3a20f6601 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,6 +11,7 @@ Change Log * Normalizing the velocity vector produced by `VelocityVectorProperty` is now optional. * Added optional `rangeMax` parameter to `Math.toSNorm` and `Math.fromSNorm`. [#4121](https://github.com/AnalyticalGraphicsInc/cesium/pull/4121) * Added leap second just prior to Jan 2017. [#4092](https://github.com/AnalyticalGraphicsInc/cesium/issues/4092) +* Fixed PolylinePipeline.generateArc to accept an array of heights when there's only one position [#4155](https://github.com/AnalyticalGraphicsInc/cesium/pull/4155) ### 1.23 - 2016-07-01