From af666c165393efbe82fe7b22c5560122712ffdc7 Mon Sep 17 00:00:00 2001 From: Rachel Hwang Date: Mon, 30 Jan 2017 14:42:30 -0500 Subject: [PATCH 1/3] Replacing developerError with Check in polygonGeometry --- Source/Core/PolygonGeometry.js | 25 +++++++++---------------- Source/Core/PolygonOutlineGeometry.js | 24 +++++++++--------------- 2 files changed, 18 insertions(+), 31 deletions(-) diff --git a/Source/Core/PolygonGeometry.js b/Source/Core/PolygonGeometry.js index 1eb5e667d245..4526b34ebbcd 100644 --- a/Source/Core/PolygonGeometry.js +++ b/Source/Core/PolygonGeometry.js @@ -5,6 +5,7 @@ define([ './Cartesian2', './Cartesian3', './Cartographic', + './Check', './ComponentDatatype', './defaultValue', './defined', @@ -31,6 +32,7 @@ define([ Cartesian2, Cartesian3, Cartographic, + Check, ComponentDatatype, defaultValue, defined, @@ -556,9 +558,8 @@ define([ */ function PolygonGeometry(options) { //>>includeStart('debug', pragmas.debug); - if (!defined(options) || !defined(options.polygonHierarchy)) { - throw new DeveloperError('options.polygonHierarchy is required.'); - } + Check.typeOf.object('options', options); + Check.typeOf.object('options.polygonHierarchy'); if (defined(options.perPositionHeight) && options.perPositionHeight && defined(options.height)) { throw new DeveloperError('Cannot use both options.perPositionHeight and options.height'); } @@ -623,7 +624,7 @@ define([ * @param {Number} [options.height=0.0] The height of the polygon. * @param {Number} [options.extrudedHeight] The height of the polygon extrusion. * @param {VertexFormat} [options.vertexFormat=VertexFormat.DEFAULT] The vertex attributes to be computed. - * @param {Number} [options.stRotation=0.0] The rotation of the texture coordiantes, in radians. A positive rotation is counter-clockwise. + * @param {Number} [options.stRotation=0.0] The rotation of the texture coordinates, in radians. A positive rotation is counter-clockwise. * @param {Ellipsoid} [options.ellipsoid=Ellipsoid.WGS84] The ellipsoid to be used as a reference. * @param {Number} [options.granularity=CesiumMath.RADIANS_PER_DEGREE] The distance, in radians, between each latitude and longitude. Determines the number of positions in the buffer. * @param {Boolean} [options.perPositionHeight=false] Use the height of options.positions for each position instead of using options.height to determine the height. @@ -651,9 +652,7 @@ define([ options = defaultValue(options, defaultValue.EMPTY_OBJECT); //>>includeStart('debug', pragmas.debug); - if (!defined(options.positions)) { - throw new DeveloperError('options.positions is required.'); - } + Check.typeOf.object('options.positions', options.positions); //>>includeEnd('debug'); var newOptions = { @@ -684,12 +683,8 @@ define([ */ PolygonGeometry.pack = function(value, array, startingIndex) { //>>includeStart('debug', pragmas.debug); - if (!defined(value)) { - throw new DeveloperError('value is required'); - } - if (!defined(array)) { - throw new DeveloperError('array is required'); - } + Check.typeOf.object('value', value); + Check.defined('array', array); //>>includeEnd('debug'); startingIndex = defaultValue(startingIndex, 0); @@ -737,9 +732,7 @@ define([ */ PolygonGeometry.unpack = function(array, startingIndex, result) { //>>includeStart('debug', pragmas.debug); - if (!defined(array)) { - throw new DeveloperError('array is required'); - } + Check.defined('array', array); //>>includeEnd('debug'); startingIndex = defaultValue(startingIndex, 0); diff --git a/Source/Core/PolygonOutlineGeometry.js b/Source/Core/PolygonOutlineGeometry.js index 1a7ad97bfc88..80b85896de1d 100644 --- a/Source/Core/PolygonOutlineGeometry.js +++ b/Source/Core/PolygonOutlineGeometry.js @@ -3,6 +3,7 @@ define([ './arrayRemoveDuplicates', './BoundingSphere', './Cartesian3', + './Check', './ComponentDatatype', './defaultValue', './defined', @@ -25,6 +26,7 @@ define([ arrayRemoveDuplicates, BoundingSphere, Cartesian3, + Check, ComponentDatatype, defaultValue, defined, @@ -286,9 +288,9 @@ define([ */ function PolygonOutlineGeometry(options) { //>>includeStart('debug', pragmas.debug); - if (!defined(options) || !defined(options.polygonHierarchy)) { - throw new DeveloperError('options.polygonHierarchy is required.'); - } + Check.typeOf.object('options', options); + Check.typeOf.object('options.polygonHierarchy'); + if (defined(options.perPositionHeight) && options.perPositionHeight && defined(options.height)) { throw new DeveloperError('Cannot use both options.perPositionHeight and options.height'); } @@ -335,12 +337,8 @@ define([ */ PolygonOutlineGeometry.pack = function(value, array, startingIndex) { //>>includeStart('debug', pragmas.debug); - if (!defined(value)) { - throw new DeveloperError('value is required'); - } - if (!defined(array)) { - throw new DeveloperError('array is required'); - } + Check.typeOf.object('value', value); + Check.defined('array', array); //>>includeEnd('debug'); startingIndex = defaultValue(startingIndex, 0); @@ -375,9 +373,7 @@ define([ */ PolygonOutlineGeometry.unpack = function(array, startingIndex, result) { //>>includeStart('debug', pragmas.debug); - if (!defined(array)) { - throw new DeveloperError('array is required'); - } + Check.defined('array', array); //>>includeEnd('debug'); startingIndex = defaultValue(startingIndex, 0); @@ -444,9 +440,7 @@ define([ options = defaultValue(options, defaultValue.EMPTY_OBJECT); //>>includeStart('debug', pragmas.debug); - if (!defined(options.positions)) { - throw new DeveloperError('options.positions is required.'); - } + Check.typeOf.object('options.positions', options.positions); //>>includeEnd('debug'); var newOptions = { From e56141f4857f32c2ca59f559b60240dbf09e811f Mon Sep 17 00:00:00 2001 From: Rachel Hwang Date: Mon, 30 Jan 2017 15:06:02 -0500 Subject: [PATCH 2/3] fix typo --- Source/Core/PolygonGeometry.js | 2 +- Source/Core/PolygonOutlineGeometry.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/PolygonGeometry.js b/Source/Core/PolygonGeometry.js index 4526b34ebbcd..479a6e5ac329 100644 --- a/Source/Core/PolygonGeometry.js +++ b/Source/Core/PolygonGeometry.js @@ -559,7 +559,7 @@ define([ function PolygonGeometry(options) { //>>includeStart('debug', pragmas.debug); Check.typeOf.object('options', options); - Check.typeOf.object('options.polygonHierarchy'); + Check.typeOf.object('options.polygonHierarchy', options.polygonHierarchy); if (defined(options.perPositionHeight) && options.perPositionHeight && defined(options.height)) { throw new DeveloperError('Cannot use both options.perPositionHeight and options.height'); } diff --git a/Source/Core/PolygonOutlineGeometry.js b/Source/Core/PolygonOutlineGeometry.js index 80b85896de1d..f24eee42c43f 100644 --- a/Source/Core/PolygonOutlineGeometry.js +++ b/Source/Core/PolygonOutlineGeometry.js @@ -289,7 +289,7 @@ define([ function PolygonOutlineGeometry(options) { //>>includeStart('debug', pragmas.debug); Check.typeOf.object('options', options); - Check.typeOf.object('options.polygonHierarchy'); + Check.typeOf.object('options.polygonHierarchy', options.polygonHierarchy); if (defined(options.perPositionHeight) && options.perPositionHeight && defined(options.height)) { throw new DeveloperError('Cannot use both options.perPositionHeight and options.height'); From ae465510fdf4c4e7cdc9d580ff3f3b22c7df8abc Mon Sep 17 00:00:00 2001 From: Rachel Hwang Date: Mon, 30 Jan 2017 16:04:07 -0500 Subject: [PATCH 3/3] fixing array check to use defined --- Source/Core/PolygonGeometry.js | 2 +- Source/Core/PolygonOutlineGeometry.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/PolygonGeometry.js b/Source/Core/PolygonGeometry.js index 479a6e5ac329..575e122cb7d2 100644 --- a/Source/Core/PolygonGeometry.js +++ b/Source/Core/PolygonGeometry.js @@ -652,7 +652,7 @@ define([ options = defaultValue(options, defaultValue.EMPTY_OBJECT); //>>includeStart('debug', pragmas.debug); - Check.typeOf.object('options.positions', options.positions); + Check.defined('options.positions', options.positions); //>>includeEnd('debug'); var newOptions = { diff --git a/Source/Core/PolygonOutlineGeometry.js b/Source/Core/PolygonOutlineGeometry.js index f24eee42c43f..f33a77983a40 100644 --- a/Source/Core/PolygonOutlineGeometry.js +++ b/Source/Core/PolygonOutlineGeometry.js @@ -440,7 +440,7 @@ define([ options = defaultValue(options, defaultValue.EMPTY_OBJECT); //>>includeStart('debug', pragmas.debug); - Check.typeOf.object('options.positions', options.positions); + Check.defined('options.positions', options.positions); //>>includeEnd('debug'); var newOptions = {