Skip to content

Commit

Permalink
Merge pull request #4155 from AnalyticalGraphicsInc/generateArcFix
Browse files Browse the repository at this point in the history
Allow PolylinePipeline.generateArc to accept an array of heights for one position
  • Loading branch information
pjcozzi authored Aug 1, 2016
2 parents 552c486 + f8a57c5 commit 50aac92
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Change Log
* Pack funcions now return the result array [#4156](https://github.com/AnalyticalGraphicsInc/cesium/pull/4156)
* Added optional `rangeMax` parameter to `Math.toSNorm` and `Math.fromSNorm`. [#4121](https://github.com/AnalyticalGraphicsInc/cesium/pull/4121)
* Removed `MapQuest OpenStreetMap` from the list of demo base layers since direct tile access has been discontinued. See the [MapQuest Developer Blog](http://devblog.mapquest.com/2016/06/15/modernization-of-mapquest-results-in-changes-to-open-tile-access/) for details.
* 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

Expand Down
3 changes: 2 additions & 1 deletion Source/Core/PolylinePipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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];
Expand Down
13 changes: 13 additions & 0 deletions Specs/Core/PolylinePipelineSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 50aac92

Please sign in to comment.