From f47301482974cd966c623ccbdee20078ca2ed467 Mon Sep 17 00:00:00 2001 From: Shehzan Mohammed Date: Tue, 8 Jan 2019 16:07:34 -0500 Subject: [PATCH 01/26] Initial implementation of using rhumb lines limited to PolygonGeometry --- Source/Core/LineType.js | 31 ++++++ Source/Core/PolygonGeometry.js | 24 ++-- Source/Core/PolygonGeometryLibrary.js | 10 +- Source/Core/PolygonPipeline.js | 155 ++++++++++++++++++++++++++ 4 files changed, 211 insertions(+), 9 deletions(-) create mode 100644 Source/Core/LineType.js diff --git a/Source/Core/LineType.js b/Source/Core/LineType.js new file mode 100644 index 000000000000..a7e4ab948515 --- /dev/null +++ b/Source/Core/LineType.js @@ -0,0 +1,31 @@ +define([ + './freezeObject' + ], function( + freezeObject) { + 'use strict'; + + /** + * LineType defines the path that should be taken connecting vertices. + * + * @exports LineType + */ + var LineType = { + /** + * Follow geodesic path. + * + * @type {Number} + * @constant + */ + GEODESIC : 0, + + /** + * Follow rhumb or loxodrome path. + * + * @type {Number} + * @constant + */ + RHUMB : 1 + }; + + return freezeObject(LineType); +}); diff --git a/Source/Core/PolygonGeometry.js b/Source/Core/PolygonGeometry.js index c91026befa5c..100dba946205 100644 --- a/Source/Core/PolygonGeometry.js +++ b/Source/Core/PolygonGeometry.js @@ -19,6 +19,7 @@ define([ './GeometryOffsetAttribute', './GeometryPipeline', './IndexDatatype', + './LineType', './Math', './Matrix2', './Matrix3', @@ -49,6 +50,7 @@ define([ GeometryOffsetAttribute, GeometryPipeline, IndexDatatype, + LineType, CesiumMath, Matrix2, Matrix3, @@ -386,14 +388,14 @@ define([ var createGeometryFromPositionsExtrudedPositions = []; - function createGeometryFromPositionsExtruded(ellipsoid, polygon, granularity, hierarchy, perPositionHeight, closeTop, closeBottom, vertexFormat) { + function createGeometryFromPositionsExtruded(ellipsoid, polygon, granularity, hierarchy, perPositionHeight, closeTop, closeBottom, vertexFormat, lineType) { var geos = { walls : [] }; var i; if (closeTop || closeBottom) { - var topGeo = PolygonGeometryLibrary.createGeometryFromPositions(ellipsoid, polygon, granularity, perPositionHeight, vertexFormat); + var topGeo = PolygonGeometryLibrary.createGeometryFromPositions(ellipsoid, polygon, granularity, perPositionHeight, vertexFormat, lineType); var edgePoints = topGeo.attributes.position.values; var indices = topGeo.indices; @@ -498,6 +500,7 @@ define([ * @param {Boolean} [options.perPositionHeight=false] Use the height of options.positions for each position instead of using options.height to determine the height. * @param {Boolean} [options.closeTop=true] When false, leaves off the top of an extruded polygon open. * @param {Boolean} [options.closeBottom=true] When false, leaves off the bottom of an extruded polygon open. + * @param {LineType} [options.lineType=LineType.GEODESIC] The type of line the polygon edges must follow. * * @see PolygonGeometry#createGeometry * @see PolygonGeometry#fromPositions @@ -610,6 +613,7 @@ define([ this._shadowVolume = defaultValue(options.shadowVolume, false); this._workerName = 'createPolygonGeometry'; this._offsetAttribute = options.offsetAttribute; + this._lineType = defaultValue(options.lineType, LineType.GEODESIC); this._rectangle = undefined; this._textureCoordinateRotationPoints = undefined; @@ -618,7 +622,7 @@ define([ * The number of elements used to pack the object into an array. * @type {Number} */ - this.packedLength = PolygonGeometryLibrary.computeHierarchyPackedLength(polygonHierarchy) + Ellipsoid.packedLength + VertexFormat.packedLength + 11; + this.packedLength = PolygonGeometryLibrary.computeHierarchyPackedLength(polygonHierarchy) + Ellipsoid.packedLength + VertexFormat.packedLength + 12; } /** @@ -673,7 +677,8 @@ define([ perPositionHeight : options.perPositionHeight, closeTop : options.closeTop, closeBottom : options.closeBottom, - offsetAttribute : options.offsetAttribute + offsetAttribute : options.offsetAttribute, + lineType : options.lineType }; return new PolygonGeometry(newOptions); }; @@ -713,6 +718,7 @@ define([ array[startingIndex++] = value._closeBottom ? 1.0 : 0.0; array[startingIndex++] = value._shadowVolume ? 1.0 : 0.0; array[startingIndex++] = defaultValue(value._offsetAttribute, -1); + array[startingIndex++] = value._lineType; array[startingIndex] = value.packedLength; return array; @@ -760,6 +766,7 @@ define([ var closeBottom = array[startingIndex++] === 1.0; var shadowVolume = array[startingIndex++] === 1.0; var offsetAttribute = array[startingIndex++]; + var lineType = array[startingIndex++]; var packedLength = array[startingIndex]; if (!defined(result)) { @@ -779,6 +786,7 @@ define([ result._closeBottom = closeBottom; result._shadowVolume = shadowVolume; result._offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute; + result._lineType = lineType; result.packedLength = packedLength; return result; }; @@ -820,6 +828,7 @@ define([ var perPositionHeight = polygonGeometry._perPositionHeight; var closeTop = polygonGeometry._closeTop; var closeBottom = polygonGeometry._closeBottom; + var lineType = polygonGeometry._lineType; var outerPositions = polygonHierarchy.positions; if (outerPositions.length < 3) { @@ -856,7 +865,8 @@ define([ bottom: false, top: true, wall: false, - extrude: false + extrude: false, + lineType: lineType }; var i; @@ -868,7 +878,7 @@ define([ options.shadowVolume = polygonGeometry._shadowVolume; options.offsetAttribute = polygonGeometry._offsetAttribute; for (i = 0; i < polygons.length; i++) { - var splitGeometry = createGeometryFromPositionsExtruded(ellipsoid, polygons[i], granularity, hierarchy[i], perPositionHeight, closeTop, closeBottom, vertexFormat); + var splitGeometry = createGeometryFromPositionsExtruded(ellipsoid, polygons[i], granularity, hierarchy[i], perPositionHeight, closeTop, closeBottom, vertexFormat, lineType); var topAndBottom; if (closeTop && closeBottom) { @@ -901,7 +911,7 @@ define([ } else { for (i = 0; i < polygons.length; i++) { var geometryInstance = new GeometryInstance({ - geometry : PolygonGeometryLibrary.createGeometryFromPositions(ellipsoid, polygons[i], granularity, perPositionHeight, vertexFormat) + geometry : PolygonGeometryLibrary.createGeometryFromPositions(ellipsoid, polygons[i], granularity, perPositionHeight, vertexFormat, lineType) }); geometryInstance.geometry.attributes.position.values = PolygonPipeline.scaleToGeodeticHeight(geometryInstance.geometry.attributes.position.values, height, ellipsoid, !perPositionHeight); options.geometry = geometryInstance.geometry; diff --git a/Source/Core/PolygonGeometryLibrary.js b/Source/Core/PolygonGeometryLibrary.js index 7bdd83da721a..a79edb8cf286 100644 --- a/Source/Core/PolygonGeometryLibrary.js +++ b/Source/Core/PolygonGeometryLibrary.js @@ -11,6 +11,7 @@ define([ './GeometryAttributes', './GeometryPipeline', './IndexDatatype', + './LineType', './Math', './Matrix3', './PolygonPipeline', @@ -31,6 +32,7 @@ define([ GeometryAttributes, GeometryPipeline, IndexDatatype, + LineType, CesiumMath, Matrix3, PolygonPipeline, @@ -403,7 +405,7 @@ define([ return result; }; - PolygonGeometryLibrary.createGeometryFromPositions = function(ellipsoid, polygon, granularity, perPositionHeight, vertexFormat) { + PolygonGeometryLibrary.createGeometryFromPositions = function(ellipsoid, polygon, granularity, perPositionHeight, vertexFormat, lineType) { var indices = PolygonPipeline.triangulate(polygon.positions2D, polygon.holes); /* If polygon is completely unrenderable, just use the first three vertices */ @@ -442,7 +444,11 @@ define([ return geometry; } - return PolygonPipeline.computeSubdivision(ellipsoid, positions, indices, granularity); + if (lineType === LineType.GEODESIC) { + return PolygonPipeline.computeSubdivision(ellipsoid, positions, indices, granularity); + } else if (lineType === LineType.RHUMB) { + return PolygonPipeline.computeRhumbLineSubdivision(ellipsoid, positions, indices, granularity); + } }; var computeWallIndicesSubdivided = []; diff --git a/Source/Core/PolygonPipeline.js b/Source/Core/PolygonPipeline.js index 00b3849b00e4..78f5056c07ed 100644 --- a/Source/Core/PolygonPipeline.js +++ b/Source/Core/PolygonPipeline.js @@ -2,6 +2,7 @@ define([ '../ThirdParty/earcut-2.1.1', './Cartesian2', './Cartesian3', + './Cartographic', './Check', './ComponentDatatype', './defaultValue', @@ -16,6 +17,7 @@ define([ earcut, Cartesian2, Cartesian3, + Cartographic, Check, ComponentDatatype, defaultValue, @@ -227,6 +229,159 @@ define([ }); }; + var subdivisionC0Scratch = new Cartographic(); + var subdivisionC1Scratch = new Cartographic(); + var subdivisionC2Scratch = new Cartographic(); + var subdivisionCart2Scratch0 = new Cartesian2(); + var subdivisionCart2Scratch1 = new Cartesian2(); + var subdivisionCart2Scratch2 = new Cartesian2(); + var subdivisionMidCart2Scratch = new Cartesian2(); + + /** + * Subdivides positions on rhumb lines and raises points to the surface of the ellipsoid. + * + * @param {Ellipsoid} ellipsoid The ellipsoid the polygon in on. + * @param {Cartesian3[]} positions An array of {@link Cartesian3} positions of the polygon. + * @param {Number[]} indices An array of indices that determines the triangles in the polygon. + * @param {Number} [granularity=CesiumMath.RADIANS_PER_DEGREE] The distance, in radians, between each latitude and longitude. Determines the number of positions in the buffer. + * + * @exception {DeveloperError} At least three indices are required. + * @exception {DeveloperError} The number of indices must be divisable by three. + * @exception {DeveloperError} Granularity must be greater than zero. + */ + PolygonPipeline.computeRhumbLineSubdivision = function(ellipsoid, positions, indices, granularity) { + granularity = defaultValue(granularity, CesiumMath.RADIANS_PER_DEGREE); + + //>>includeStart('debug', pragmas.debug); + Check.typeOf.object('ellipsoid', ellipsoid); + Check.defined('positions', positions); + Check.defined('indices', indices); + Check.typeOf.number.greaterThanOrEquals('indices.length', indices.length, 3); + Check.typeOf.number.equals('indices.length % 3', '0', indices.length % 3, 0); + Check.typeOf.number.greaterThan('granularity', granularity, 0.0); + //>>includeEnd('debug'); + + // triangles that need (or might need) to be subdivided. + var triangles = indices.slice(0); + + // New positions due to edge splits are appended to the positions list. + var i; + var length = positions.length; + var subdividedPositions = new Array(length * 3); + var q = 0; + for (i = 0; i < length; i++) { + var item = positions[i]; + subdividedPositions[q++] = item.x; + subdividedPositions[q++] = item.y; + subdividedPositions[q++] = item.z; + } + + var subdividedIndices = []; + + // Used to make sure shared edges are not split more than once. + var edges = {}; + + var granularitySqrd = granularity * granularity; + + while (triangles.length > 0) { + var i2 = triangles.pop(); + var i1 = triangles.pop(); + var i0 = triangles.pop(); + + var v0 = Cartesian3.fromArray(subdividedPositions, i0 * 3, subdivisionV0Scratch); + var v1 = Cartesian3.fromArray(subdividedPositions, i1 * 3, subdivisionV1Scratch); + var v2 = Cartesian3.fromArray(subdividedPositions, i2 * 3, subdivisionV2Scratch); + + var c0 = ellipsoid.cartesianToCartographic(v0, subdivisionC0Scratch); + var c1 = ellipsoid.cartesianToCartographic(v1, subdivisionC1Scratch); + var c2 = ellipsoid.cartesianToCartographic(v2, subdivisionC2Scratch); + + var c0Cart2 = Cartesian2.fromElements(c0.longitude, c0.latitude, subdivisionCart2Scratch0); + var c1Cart2 = Cartesian2.fromElements(c1.longitude, c1.latitude, subdivisionCart2Scratch1); + var c2Cart2 = Cartesian2.fromElements(c2.longitude, c2.latitude, subdivisionCart2Scratch2); + + var g0 = Cartesian2.distanceSquared(c0Cart2, c1Cart2); + var g1 = Cartesian2.distanceSquared(c1Cart2, c2Cart2); + var g2 = Cartesian2.distanceSquared(c2Cart2, c0Cart2); + + var max = Math.max(g0, g1, g2); + var edge; + var mid; + var midHeight; + var midCartesian3; + + // if the max length squared of a triangle edge is greater than the chord length of squared + // of the granularity, subdivide the triangle + if (max > granularitySqrd) { + if (g0 === max) { + edge = Math.min(i0, i1) + ' ' + Math.max(i0, i1); + + i = edges[edge]; + if (!defined(i)) { + mid = Cartesian2.add(c0Cart2, c1Cart2, subdivisionMidCart2Scratch); + Cartesian2.multiplyByScalar(mid, 0.5, mid); + midHeight = (c0.height + c1.height) / 2.0; + midCartesian3 = Cartesian3.fromRadians(mid.x, mid.y, midHeight, ellipsoid, subdivisionMidScratch); + subdividedPositions.push(midCartesian3.x, midCartesian3.y, midCartesian3.z); + i = subdividedPositions.length / 3 - 1; + edges[edge] = i; + } + + triangles.push(i0, i, i2); + triangles.push(i, i1, i2); + } else if (g1 === max) { + edge = Math.min(i1, i2) + ' ' + Math.max(i1, i2); + + i = edges[edge]; + if (!defined(i)) { + mid = Cartesian2.add(c1Cart2, c2Cart2, subdivisionMidCart2Scratch); + Cartesian2.multiplyByScalar(mid, 0.5, mid); + midHeight = (c1.height + c2.height) / 2.0; + midCartesian3 = Cartesian3.fromRadians(mid.x, mid.y, midHeight, ellipsoid, subdivisionMidScratch); + subdividedPositions.push(midCartesian3.x, midCartesian3.y, midCartesian3.z); + i = subdividedPositions.length / 3 - 1; + edges[edge] = i; + } + + triangles.push(i1, i, i0); + triangles.push(i, i2, i0); + } else if (g2 === max) { + edge = Math.min(i2, i0) + ' ' + Math.max(i2, i0); + + i = edges[edge]; + if (!defined(i)) { + mid = Cartesian2.add(c2Cart2, c0Cart2, subdivisionMidCart2Scratch); + Cartesian2.multiplyByScalar(mid, 0.5, mid); + midHeight = (c2.height + c0.height) / 2.0; + midCartesian3 = Cartesian3.fromRadians(mid.x, mid.y, midHeight, ellipsoid, subdivisionMidScratch); + subdividedPositions.push(midCartesian3.x, midCartesian3.y, midCartesian3.z); + i = subdividedPositions.length / 3 - 1; + edges[edge] = i; + } + + triangles.push(i2, i, i1); + triangles.push(i, i0, i1); + } + } else { + subdividedIndices.push(i0); + subdividedIndices.push(i1); + subdividedIndices.push(i2); + } + } + + return new Geometry({ + attributes : { + position : new GeometryAttribute({ + componentDatatype : ComponentDatatype.DOUBLE, + componentsPerAttribute : 3, + values : subdividedPositions + }) + }, + indices : subdividedIndices, + primitiveType : PrimitiveType.TRIANGLES + }); + }; + /** * Scales each position of a geometry's position attribute to a height, in place. * From ba3a6dc01f9688a6301f29244e3a07acc17c6443 Mon Sep 17 00:00:00 2001 From: Shehzan Mohammed Date: Tue, 8 Jan 2019 16:39:11 -0500 Subject: [PATCH 02/26] Rhumb lines working on PolygonGeometry with geojson load --- Source/DataSources/PolygonGeometryUpdater.js | 6 ++++++ Source/DataSources/PolygonGraphics.js | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/Source/DataSources/PolygonGeometryUpdater.js b/Source/DataSources/PolygonGeometryUpdater.js index e0e2cc9c918c..251f5a6d339a 100644 --- a/Source/DataSources/PolygonGeometryUpdater.js +++ b/Source/DataSources/PolygonGeometryUpdater.js @@ -15,6 +15,7 @@ define([ '../Core/GeometryOffsetAttribute', '../Core/isArray', '../Core/Iso8601', + '../Core/LineType', '../Core/oneTimeWarning', '../Core/OffsetGeometryInstanceAttribute', '../Core/PolygonGeometry', @@ -48,6 +49,7 @@ define([ GeometryOffsetAttribute, isArray, Iso8601, + LineType, oneTimeWarning, OffsetGeometryInstanceAttribute, PolygonGeometry, @@ -88,6 +90,7 @@ define([ this.granularity = undefined; this.stRotation = undefined; this.offsetAttribute = undefined; + this.lineType = undefined; } /** @@ -275,6 +278,7 @@ define([ !Property.isConstant(polygon.closeTop) || // !Property.isConstant(polygon.closeBottom) || // !Property.isConstant(polygon.zIndex) || // + !Property.isConstant(polygon.lineType) || // (this._onTerrain && !Property.isConstant(this._materialProperty)); }; @@ -322,6 +326,7 @@ define([ options.closeBottom = Property.getValueOrDefault(polygon.closeBottom, Iso8601.MINIMUM_VALUE, true); options.offsetAttribute = offsetAttribute; options.height = heightValue; + options.lineType = Property.getValueOrDefault(polygon.lineType, Iso8601.MINIMUM_VALUE, LineType.GEODESIC); extrudedHeightValue = GroundGeometryUpdater.getGeometryExtrudedHeight(extrudedHeightValue, extrudedHeightReferenceValue); if (extrudedHeightValue === GroundGeometryUpdater.CLAMP_TO_GROUND) { @@ -399,6 +404,7 @@ define([ options.closeBottom = Property.getValueOrDefault(polygon.closeBottom, time, true); options.offsetAttribute = offsetAttribute; options.height = heightValue; + options.lineType = Property.getValueOrDefault(polygon.lineType, time, LineType.GEODESIC); extrudedHeightValue = GroundGeometryUpdater.getGeometryExtrudedHeight(extrudedHeightValue, extrudedHeightReferenceValue); if (extrudedHeightValue === GroundGeometryUpdater.CLAMP_TO_GROUND) { diff --git a/Source/DataSources/PolygonGraphics.js b/Source/DataSources/PolygonGraphics.js index fb65382cb61e..4396d03191d7 100644 --- a/Source/DataSources/PolygonGraphics.js +++ b/Source/DataSources/PolygonGraphics.js @@ -44,6 +44,7 @@ define([ * @param {Property} [options.shadows=ShadowMode.DISABLED] An enum Property specifying whether the polygon casts or receives shadows from each light source. * @param {Property} [options.distanceDisplayCondition] A Property specifying at what distance from the camera that this polygon will be displayed. * @param {Property} [options.classificationType=ClassificationType.BOTH] An enum Property specifying whether this polygon will classify terrain, 3D Tiles, or both when on the ground. + * @param {Property} [options.lineType=LineType.GEODESIC] The type of line the polygon edges must follow. * @param {ConstantProperty} [options.zIndex=0] A property specifying the zIndex used for ordering ground geometry. Only has an effect if the polygon is constant and neither height or extrudedHeight are specified. * * @see Entity @@ -88,6 +89,8 @@ define([ this._distanceDisplayConditionSubscription = undefined; this._classificationType = undefined; this._classificationTypeSubscription = undefined; + this._lineType = undefined; + this._lineTypeSubscription = undefined; this._zIndex = undefined; this._zIndexSubscription = undefined; this._definitionChanged = new Event(); @@ -260,6 +263,14 @@ define([ */ classificationType : createPropertyDescriptor('classificationType'), + /** + * Gets or sets the {@link LineType} Property specifying the type of lines the polygon edges use. + * @memberof PolygonGraphics.prototype + * @type {Property} + * @default LineType.GEODESIC + */ + lineType : createPropertyDescriptor('lineType'), + /** * Gets or sets the zIndex Prperty specifying the ordering of ground geometry. Only has an effect if the polygon is constant and neither height or extrudedHeight are specified. * @memberof PolygonGraphics.prototype @@ -298,6 +309,7 @@ define([ result.shadows = this.shadows; result.distanceDisplayCondition = this.distanceDisplayCondition; result.classificationType = this.classificationType; + result.lineType = this.lineType; result.zIndex = this.zIndex; return result; @@ -335,6 +347,7 @@ define([ this.shadows = defaultValue(this.shadows, source.shadows); this.distanceDisplayCondition = defaultValue(this.distanceDisplayCondition, source.distanceDisplayCondition); this.classificationType = defaultValue(this.classificationType, source.classificationType); + this.lineType = defaultValue(this.lineType, source.lineType); this.zIndex = defaultValue(this.zIndex, source.zIndex); }; From 0248d9e750c898b545856674c76b5fd4fe9eb3ea Mon Sep 17 00:00:00 2001 From: Shehzan Mohammed Date: Mon, 14 Jan 2019 14:20:43 -0500 Subject: [PATCH 03/26] Add enum for LineType.STRAIGHT --- Source/Core/LineType.js | 10 +++++++++- Source/Core/PolygonGeometry.js | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Source/Core/LineType.js b/Source/Core/LineType.js index a7e4ab948515..bc3922a55828 100644 --- a/Source/Core/LineType.js +++ b/Source/Core/LineType.js @@ -24,7 +24,15 @@ define([ * @type {Number} * @constant */ - RHUMB : 1 + RHUMB : 1, + + /** + * Straight line that does not conform to the surface of the ellipsoid. + * + * @type {Number} + * @constant + */ + STRAIGHT : 2 }; return freezeObject(LineType); diff --git a/Source/Core/PolygonGeometry.js b/Source/Core/PolygonGeometry.js index 100dba946205..32f76e813d46 100644 --- a/Source/Core/PolygonGeometry.js +++ b/Source/Core/PolygonGeometry.js @@ -581,6 +581,9 @@ define([ if (defined(options.perPositionHeight) && options.perPositionHeight && defined(options.height)) { throw new DeveloperError('Cannot use both options.perPositionHeight and options.height'); } + if (defined(options.lineType) && options.lineType === LineType.STRAIGHT) { + throw new DeveloperError('Cannot use option.lineType as LineType.STRAIGHT'); + } //>>includeEnd('debug'); var polygonHierarchy = options.polygonHierarchy; From f90b6d4181cdb1e397ffba3f4e631f1d18af2241 Mon Sep 17 00:00:00 2001 From: Shehzan Mohammed Date: Mon, 14 Jan 2019 14:27:05 -0500 Subject: [PATCH 04/26] Add rhumb line support to polygon and polyline geometry with extrude support --- Source/Core/PolygonGeometry.js | 4 +- Source/Core/PolygonGeometryLibrary.js | 63 ++++++- Source/Core/PolygonOutlineGeometry.js | 60 +++++-- Source/Core/PolylineGeometry.js | 105 +++++++++--- Source/Core/PolylinePipeline.js | 161 ++++++++++++++++++ Source/Core/SimplePolylineGeometry.js | 26 ++- Source/DataSources/Entity.js | 2 +- Source/DataSources/PolylineGeometryUpdater.js | 19 ++- Source/DataSources/PolylineGraphics.js | 23 ++- Source/Scene/DebugModelMatrixPrimitive.js | 8 +- 10 files changed, 418 insertions(+), 53 deletions(-) diff --git a/Source/Core/PolygonGeometry.js b/Source/Core/PolygonGeometry.js index 32f76e813d46..9fc8c825d93a 100644 --- a/Source/Core/PolygonGeometry.js +++ b/Source/Core/PolygonGeometry.js @@ -457,7 +457,7 @@ define([ outerRing = outerRing.slice().reverse(); } - var wallGeo = PolygonGeometryLibrary.computeWallGeometry(outerRing, ellipsoid, granularity, perPositionHeight); + var wallGeo = PolygonGeometryLibrary.computeWallGeometry(outerRing, ellipsoid, granularity, perPositionHeight, lineType); geos.walls.push(new GeometryInstance({ geometry : wallGeo })); @@ -474,7 +474,7 @@ define([ hole = hole.slice().reverse(); } - wallGeo = PolygonGeometryLibrary.computeWallGeometry(hole, ellipsoid, granularity); + wallGeo = PolygonGeometryLibrary.computeWallGeometry(hole, ellipsoid, granularity, perPositionHeight, lineType); geos.walls.push(new GeometryInstance({ geometry : wallGeo })); diff --git a/Source/Core/PolygonGeometryLibrary.js b/Source/Core/PolygonGeometryLibrary.js index a79edb8cf286..833cdf7f576c 100644 --- a/Source/Core/PolygonGeometryLibrary.js +++ b/Source/Core/PolygonGeometryLibrary.js @@ -2,10 +2,12 @@ define([ './arrayRemoveDuplicates', './Cartesian2', './Cartesian3', + './Cartographic', './ComponentDatatype', './defaultValue', './defined', './Ellipsoid', + './EllipsoidRhumb', './Geometry', './GeometryAttribute', './GeometryAttributes', @@ -23,10 +25,12 @@ define([ arrayRemoveDuplicates, Cartesian2, Cartesian3, + Cartographic, ComponentDatatype, defaultValue, defined, Ellipsoid, + EllipsoidRhumb, Geometry, GeometryAttribute, GeometryAttributes, @@ -147,6 +151,20 @@ define([ return Math.pow(2, countDivide); }; + var scratchEllipsoidRhumb = new EllipsoidRhumb(); + var scratchCartographic0 = new Cartographic(); + var scratchCartographic1 = new Cartographic(); + var scratchCartographic2 = new Cartographic(); + var scratchCartesian0 = new Cartesian3(); + PolygonGeometryLibrary.subdivideRhumbLineCount = function(ellipsoid, p0, p1, minDistance) { + var c0 = ellipsoid.cartesianToCartographic(p0, scratchCartographic0); + var c1 = ellipsoid.cartesianToCartographic(p1, scratchCartographic1); + var rhumb = EllipsoidRhumb.fromStartAndEnd(c0, c1, ellipsoid, scratchEllipsoidRhumb); + var n = rhumb.surfaceDistance / minDistance; + var countDivide = Math.max(0, Math.ceil(Math.log(n) / Math.log(2))); + return Math.pow(2, countDivide); + }; + PolygonGeometryLibrary.subdivideLine = function(p0, p1, minDistance, result) { var numVertices = PolygonGeometryLibrary.subdivideLineCount(p0, p1, minDistance); var length = Cartesian3.distance(p0, p1); @@ -170,6 +188,32 @@ define([ return positions; }; + PolygonGeometryLibrary.subdivideRhumbLine = function(ellipsoid, p0, p1, minDistance, result) { + var numVertices = PolygonGeometryLibrary.subdivideRhumbLineCount(ellipsoid, p0, p1, minDistance); + var c0 = ellipsoid.cartesianToCartographic(p0, scratchCartographic0); + var c1 = ellipsoid.cartesianToCartographic(p1, scratchCartographic1); + var rhumb = EllipsoidRhumb.fromStartAndEnd(c0, c1, ellipsoid, scratchEllipsoidRhumb); + var distanceBetweenVertices = rhumb.surfaceDistance / numVertices; + + if (!defined(result)) { + result = []; + } + + var positions = result; + positions.length = numVertices * 3; + + var index = 0; + for ( var i = 0; i < numVertices; i++) { + var c = rhumb.interpolateUsingSurfaceDistance(i * distanceBetweenVertices, scratchCartographic2); + var p = ellipsoid.cartographicToCartesian(c, scratchCartesian0); + positions[index++] = p.x; + positions[index++] = p.y; + positions[index++] = p.z; + } + + return positions; + }; + var scaleToGeodeticHeightN1 = new Cartesian3(); var scaleToGeodeticHeightN2 = new Cartesian3(); var scaleToGeodeticHeightP1 = new Cartesian3(); @@ -455,7 +499,7 @@ define([ var p1Scratch = new Cartesian3(); var p2Scratch = new Cartesian3(); - PolygonGeometryLibrary.computeWallGeometry = function(positions, ellipsoid, granularity, perPositionHeight) { + PolygonGeometryLibrary.computeWallGeometry = function(positions, ellipsoid, granularity, perPositionHeight, lineType) { var edgePositions; var topEdgeLength; var i; @@ -469,8 +513,14 @@ define([ var minDistance = CesiumMath.chordLength(granularity, ellipsoid.maximumRadius); var numVertices = 0; - for (i = 0; i < length; i++) { - numVertices += PolygonGeometryLibrary.subdivideLineCount(positions[i], positions[(i + 1) % length], minDistance); + if (lineType === LineType.GEODESIC) { + for (i = 0; i < length; i++) { + numVertices += PolygonGeometryLibrary.subdivideLineCount(positions[i], positions[(i + 1) % length], minDistance); + } + } else if (lineType === LineType.RHUMB) { + for (i = 0; i < length; i++) { + numVertices += PolygonGeometryLibrary.subdivideRhumbLineCount(ellipsoid, positions[i], positions[(i + 1) % length], minDistance); + } } topEdgeLength = (numVertices + length) * 3; @@ -479,7 +529,12 @@ define([ p1 = positions[i]; p2 = positions[(i + 1) % length]; - var tempPositions = PolygonGeometryLibrary.subdivideLine(p1, p2, minDistance, computeWallIndicesSubdivided); + var tempPositions; + if (lineType === LineType.GEODESIC) { + tempPositions = PolygonGeometryLibrary.subdivideLine(p1, p2, minDistance, computeWallIndicesSubdivided); + } else if (lineType === LineType.RHUMB) { + tempPositions = PolygonGeometryLibrary.subdivideRhumbLine(ellipsoid, p1, p2, minDistance, computeWallIndicesSubdivided); + } var tempPositionsLength = tempPositions.length; for (var j = 0; j < tempPositionsLength; ++j, ++index) { edgePositions[index] = tempPositions[j]; diff --git a/Source/Core/PolygonOutlineGeometry.js b/Source/Core/PolygonOutlineGeometry.js index 8d7b404a5874..02c22944c3c4 100644 --- a/Source/Core/PolygonOutlineGeometry.js +++ b/Source/Core/PolygonOutlineGeometry.js @@ -17,6 +17,7 @@ define([ './GeometryOffsetAttribute', './GeometryPipeline', './IndexDatatype', + './LineType', './Math', './PolygonGeometryLibrary', './PolygonPipeline', @@ -42,6 +43,7 @@ define([ GeometryOffsetAttribute, GeometryPipeline, IndexDatatype, + LineType, CesiumMath, PolygonGeometryLibrary, PolygonPipeline, @@ -52,7 +54,7 @@ define([ var createGeometryFromPositionsPositions = []; var createGeometryFromPositionsSubdivided = []; - function createGeometryFromPositions(ellipsoid, positions, minDistance, perPositionHeight) { + function createGeometryFromPositions(ellipsoid, positions, granularity, perPositionHeight, lineType) { var tangentPlane = EllipsoidTangentPlane.fromPoints(positions, ellipsoid); var positions2D = tangentPlane.projectPointsOntoPlane(positions, createGeometryFromPositionsPositions); @@ -62,6 +64,8 @@ define([ positions = positions.slice().reverse(); } + var minDistance = CesiumMath.chordLength(granularity, ellipsoid.maximumRadius); + var subdividedPositions; var i; @@ -70,12 +74,23 @@ define([ if (!perPositionHeight) { var numVertices = 0; - for (i = 0; i < length; i++) { - numVertices += PolygonGeometryLibrary.subdivideLineCount(positions[i], positions[(i + 1) % length], minDistance); + if (lineType === LineType.GEODESIC) { + for (i = 0; i < length; i++) { + numVertices += PolygonGeometryLibrary.subdivideLineCount(positions[i], positions[(i + 1) % length], minDistance); + } + } else if (lineType === LineType.RHUMB) { + for (i = 0; i < length; i++) { + numVertices += PolygonGeometryLibrary.subdivideRhumbLineCount(ellipsoid, positions[i], positions[(i + 1) % length], minDistance); + } } subdividedPositions = new Float64Array(numVertices * 3); for (i = 0; i < length; i++) { - var tempPositions = PolygonGeometryLibrary.subdivideLine(positions[i], positions[(i + 1) % length], minDistance, createGeometryFromPositionsSubdivided); + var tempPositions; + if (lineType === LineType.GEODESIC) { + tempPositions = PolygonGeometryLibrary.subdivideLine(positions[i], positions[(i + 1) % length], minDistance, createGeometryFromPositionsSubdivided); + } else if (lineType === LineType.RHUMB) { + tempPositions = PolygonGeometryLibrary.subdivideRhumbLine(ellipsoid, positions[i], positions[(i + 1) % length], minDistance, createGeometryFromPositionsSubdivided); + } var tempPositionsLength = tempPositions.length; for (var j = 0; j < tempPositionsLength; ++j) { subdividedPositions[index++] = tempPositions[j]; @@ -121,7 +136,7 @@ define([ }); } - function createGeometryFromPositionsExtruded(ellipsoid, positions, minDistance, perPositionHeight) { + function createGeometryFromPositionsExtruded(ellipsoid, positions, granularity, perPositionHeight, lineType) { var tangentPlane = EllipsoidTangentPlane.fromPoints(positions, ellipsoid); var positions2D = tangentPlane.projectPointsOntoPlane(positions, createGeometryFromPositionsPositions); @@ -131,6 +146,8 @@ define([ positions = positions.slice().reverse(); } + var minDistance = CesiumMath.chordLength(granularity, ellipsoid.maximumRadius); + var subdividedPositions; var i; @@ -140,14 +157,25 @@ define([ if (!perPositionHeight) { var numVertices = 0; - for (i = 0; i < length; i++) { - numVertices += PolygonGeometryLibrary.subdivideLineCount(positions[i], positions[(i + 1) % length], minDistance); + if (lineType === LineType.GEODESIC) { + for (i = 0; i < length; i++) { + numVertices += PolygonGeometryLibrary.subdivideLineCount(positions[i], positions[(i + 1) % length], minDistance); + } + } else if (lineType === LineType.RHUMB) { + for (i = 0; i < length; i++) { + numVertices += PolygonGeometryLibrary.subdivideRhumbLineCount(ellipsoid, positions[i], positions[(i + 1) % length], minDistance); + } } subdividedPositions = new Float64Array(numVertices * 3 * 2); for (i = 0; i < length; ++i) { corners[i] = index / 3; - var tempPositions = PolygonGeometryLibrary.subdivideLine(positions[i], positions[(i + 1) % length], minDistance, createGeometryFromPositionsSubdivided); + var tempPositions; + if (lineType === LineType.GEODESIC) { + tempPositions = PolygonGeometryLibrary.subdivideLine(positions[i], positions[(i + 1) % length], minDistance, createGeometryFromPositionsSubdivided); + } else if (lineType === LineType.RHUMB) { + tempPositions = PolygonGeometryLibrary.subdivideRhumbLine(ellipsoid, positions[i], positions[(i + 1) % length], minDistance, createGeometryFromPositionsSubdivided); + } var tempPositionsLength = tempPositions.length; for (var j = 0; j < tempPositionsLength; ++j) { subdividedPositions[index++] = tempPositions[j]; @@ -218,6 +246,7 @@ define([ * @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. + * @param {LineType} [options.lineType=LineType.GEODESIC] The type of path the outline must follow. * * @see PolygonOutlineGeometry#createGeometry * @see PolygonOutlineGeometry#fromPositions @@ -304,6 +333,7 @@ define([ var granularity = defaultValue(options.granularity, CesiumMath.RADIANS_PER_DEGREE); var perPositionHeight = defaultValue(options.perPositionHeight, false); var perPositionHeightExtrude = perPositionHeight && defined(options.extrudedHeight); + var lineType = defaultValue(options.lineType, LineType.GEODESIC); var height = defaultValue(options.height, 0.0); var extrudedHeight = defaultValue(options.extrudedHeight, height); @@ -318,6 +348,7 @@ define([ this._granularity = granularity; this._height = height; this._extrudedHeight = extrudedHeight; + this._lineType = lineType; this._polygonHierarchy = polygonHierarchy; this._perPositionHeight = perPositionHeight; this._perPositionHeightExtrude = perPositionHeightExtrude; @@ -328,7 +359,7 @@ define([ * The number of elements used to pack the object into an array. * @type {Number} */ - this.packedLength = PolygonGeometryLibrary.computeHierarchyPackedLength(polygonHierarchy) + Ellipsoid.packedLength + 7; + this.packedLength = PolygonGeometryLibrary.computeHierarchyPackedLength(polygonHierarchy) + Ellipsoid.packedLength + 8; } /** @@ -358,6 +389,7 @@ define([ array[startingIndex++] = value._granularity; array[startingIndex++] = value._perPositionHeightExtrude ? 1.0 : 0.0; array[startingIndex++] = value._perPositionHeight ? 1.0 : 0.0; + array[startingIndex++] = value._lineType; array[startingIndex++] = defaultValue(value._offsetAttribute, -1); array[startingIndex] = value.packedLength; @@ -396,6 +428,7 @@ define([ var granularity = array[startingIndex++]; var perPositionHeightExtrude = array[startingIndex++] === 1.0; var perPositionHeight = array[startingIndex++] === 1.0; + var lineType = array[startingIndex++]; var offsetAttribute = array[startingIndex++]; var packedLength = array[startingIndex]; @@ -410,6 +443,7 @@ define([ result._granularity = granularity; result._perPositionHeight = perPositionHeight; result._perPositionHeightExtrude = perPositionHeightExtrude; + result._lineType = lineType; result._offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute; result.packedLength = packedLength; @@ -426,6 +460,7 @@ define([ * @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. + * @param {LineType} [options.lineType=LineType.GEODESIC] The type of path the outline must follow. * @returns {PolygonOutlineGeometry} * * @@ -460,6 +495,7 @@ define([ ellipsoid : options.ellipsoid, granularity : options.granularity, perPositionHeight : options.perPositionHeight, + lineType: options.lineType, offsetAttribute : options.offsetAttribute }; return new PolygonOutlineGeometry(newOptions); @@ -476,6 +512,7 @@ define([ var granularity = polygonGeometry._granularity; var polygonHierarchy = polygonGeometry._polygonHierarchy; var perPositionHeight = polygonGeometry._perPositionHeight; + var lineType = polygonGeometry._lineType; var polygons = PolygonGeometryLibrary.polygonOutlinesFromHierarchy(polygonHierarchy, !perPositionHeight, ellipsoid); @@ -485,7 +522,6 @@ define([ var geometryInstance; var geometries = []; - var minDistance = CesiumMath.chordLength(granularity, ellipsoid.maximumRadius); var height = polygonGeometry._height; var extrudedHeight = polygonGeometry._extrudedHeight; @@ -494,7 +530,7 @@ define([ var i; if (extrude) { for (i = 0; i < polygons.length; i++) { - geometryInstance = createGeometryFromPositionsExtruded(ellipsoid, polygons[i], minDistance, perPositionHeight); + geometryInstance = createGeometryFromPositionsExtruded(ellipsoid, polygons[i], granularity, perPositionHeight, lineType); geometryInstance.geometry = PolygonGeometryLibrary.scaleToGeodeticHeightExtruded(geometryInstance.geometry, height, extrudedHeight, ellipsoid, perPositionHeight); if (defined(polygonGeometry._offsetAttribute)) { var size = geometryInstance.geometry.attributes.position.values.length / 3; @@ -516,7 +552,7 @@ define([ } } else { for (i = 0; i < polygons.length; i++) { - geometryInstance = createGeometryFromPositions(ellipsoid, polygons[i], minDistance, perPositionHeight); + geometryInstance = createGeometryFromPositions(ellipsoid, polygons[i], granularity, perPositionHeight, lineType); geometryInstance.geometry.attributes.position.values = PolygonPipeline.scaleToGeodeticHeight(geometryInstance.geometry.attributes.position.values, height, ellipsoid, !perPositionHeight); if (defined(polygonGeometry._offsetAttribute)) { diff --git a/Source/Core/PolylineGeometry.js b/Source/Core/PolylineGeometry.js index c2c76de00730..50ccb2cedb74 100644 --- a/Source/Core/PolylineGeometry.js +++ b/Source/Core/PolylineGeometry.js @@ -6,6 +6,7 @@ define([ './ComponentDatatype', './defaultValue', './defined', + './deprecationWarning', './DeveloperError', './Ellipsoid', './Geometry', @@ -13,6 +14,7 @@ define([ './GeometryAttributes', './GeometryType', './IndexDatatype', + './LineType', './Math', './PolylinePipeline', './PrimitiveType', @@ -25,6 +27,7 @@ define([ ComponentDatatype, defaultValue, defined, + deprecationWarning, DeveloperError, Ellipsoid, Geometry, @@ -32,6 +35,7 @@ define([ GeometryAttributes, GeometryType, IndexDatatype, + LineType, CesiumMath, PolylinePipeline, PrimitiveType, @@ -88,7 +92,8 @@ define([ * @param {Color[]} [options.colors] An Array of {@link Color} defining the per vertex or per segment colors. * @param {Boolean} [options.colorsPerVertex=false] A boolean that determines whether the colors will be flat across each segment of the line or interpolated across the vertices. * @param {Boolean} [options.followSurface=true] A boolean that determines whether positions will be adjusted to the surface of the ellipsoid via a great arc. - * @param {Number} [options.granularity=CesiumMath.RADIANS_PER_DEGREE] The distance, in radians, between each latitude and longitude if options.followSurface=true. Determines the number of positions in the buffer. + * @param {LineType} [options.lineType=LineType.GEODESIC] The type of line the polyline segments must follow. + * @param {Number} [options.granularity=CesiumMath.RADIANS_PER_DEGREE] The distance, in radians, between each latitude and longitude if options.lineType is not LineType.STRAIGHT. Determines the number of positions in the buffer. * @param {VertexFormat} [options.vertexFormat=VertexFormat.DEFAULT] The vertex attributes to be computed. * @param {Ellipsoid} [options.ellipsoid=Ellipsoid.WGS84] The ellipsoid to be used as a reference. * @@ -136,7 +141,14 @@ define([ this._width = width; this._colorsPerVertex = colorsPerVertex; this._vertexFormat = VertexFormat.clone(defaultValue(options.vertexFormat, VertexFormat.DEFAULT)); + this._followSurface = defaultValue(options.followSurface, true); + if (defined(options.followSurface)) { + deprecationWarning('PolylineGeometry.followSurface', 'PolylineGeometry.followSurface is deprecated and will be removed in Cesium 1.55. Use PolylineGeometry.lineType instead.'); + options.lineType = options.followSurface ? LineType.GEODESIC : LineType.STRAIGHT; + } + this._lineType = defaultValue(options.lineType, LineType.GEODESIC); + this._granularity = defaultValue(options.granularity, CesiumMath.RADIANS_PER_DEGREE); this._ellipsoid = Ellipsoid.clone(defaultValue(options.ellipsoid, Ellipsoid.WGS84)); this._workerName = 'createPolylineGeometry'; @@ -198,7 +210,7 @@ define([ array[startingIndex++] = value._width; array[startingIndex++] = value._colorsPerVertex ? 1.0 : 0.0; - array[startingIndex++] = value._followSurface ? 1.0 : 0.0; + array[startingIndex++] = value._lineType; array[startingIndex] = value._granularity; return array; @@ -213,7 +225,7 @@ define([ vertexFormat : scratchVertexFormat, width : undefined, colorsPerVertex : undefined, - followSurface : undefined, + lineType : undefined, granularity : undefined }; @@ -258,7 +270,7 @@ define([ var width = array[startingIndex++]; var colorsPerVertex = array[startingIndex++] === 1.0; - var followSurface = array[startingIndex++] === 1.0; + var lineType = array[startingIndex++]; var granularity = array[startingIndex]; if (!defined(result)) { @@ -266,7 +278,7 @@ define([ scratchOptions.colors = colors; scratchOptions.width = width; scratchOptions.colorsPerVertex = colorsPerVertex; - scratchOptions.followSurface = followSurface; + scratchOptions.lineType = lineType; scratchOptions.granularity = granularity; return new PolylineGeometry(scratchOptions); } @@ -277,7 +289,7 @@ define([ result._vertexFormat = VertexFormat.clone(vertexFormat, result._vertexFormat); result._width = width; result._colorsPerVertex = colorsPerVertex; - result._followSurface = followSurface; + result._lineType = lineType; result._granularity = granularity; return result; @@ -299,7 +311,7 @@ define([ var vertexFormat = polylineGeometry._vertexFormat; var colors = polylineGeometry._colors; var colorsPerVertex = polylineGeometry._colorsPerVertex; - var followSurface = polylineGeometry._followSurface; + var lineType = polylineGeometry._lineType; var granularity = polylineGeometry._granularity; var ellipsoid = polylineGeometry._ellipsoid; @@ -316,29 +328,40 @@ define([ return undefined; } - if (followSurface) { - var heights = PolylinePipeline.extractHeights(positions, ellipsoid); + var heights; + var colorLength; + var newColors; + var newColorIndex; + var numColors; + var p0; + var p1; + var c0; + var c1; + var interpolatedColors; + var interpolatedColorsLength; + if (lineType === LineType.GEODESIC) { + heights = PolylinePipeline.extractHeights(positions, ellipsoid); var minDistance = CesiumMath.chordLength(granularity, ellipsoid.maximumRadius); if (defined(colors)) { - var colorLength = 1; + colorLength = 1; for (i = 0; i < positionsLength - 1; ++i) { colorLength += PolylinePipeline.numberOfPoints(positions[i], positions[i+1], minDistance); } - var newColors = new Array(colorLength); - var newColorIndex = 0; + newColors = new Array(colorLength); + newColorIndex = 0; for (i = 0; i < positionsLength - 1; ++i) { - var p0 = positions[i]; - var p1 = positions[i+1]; - var c0 = colors[i]; + p0 = positions[i]; + p1 = positions[i+1]; + c0 = colors[i]; - var numColors = PolylinePipeline.numberOfPoints(p0, p1, minDistance); + numColors = PolylinePipeline.numberOfPoints(p0, p1, minDistance); if (colorsPerVertex && i < colorLength) { - var c1 = colors[i+1]; - var interpolatedColors = interpolateColors(p0, p1, c0, c1, numColors); - var interpolatedColorsLength = interpolatedColors.length; + c1 = colors[i+1]; + interpolatedColors = interpolateColors(p0, p1, c0, c1, numColors); + interpolatedColorsLength = interpolatedColors.length; for (j = 0; j < interpolatedColorsLength; ++j) { newColors[newColorIndex++] = interpolatedColors[j]; } @@ -361,6 +384,50 @@ define([ ellipsoid: ellipsoid, height: heights }); + } else if (lineType === LineType.RHUMB) { + heights = PolylinePipeline.extractHeights(positions, ellipsoid); + + if (defined(colors)) { + colorLength = 1; + for (i = 0; i < positionsLength - 1; ++i) { + colorLength += PolylinePipeline.numberOfPointsRhumbLine(positions[i], positions[i+1], granularity); + } + + newColors = new Array(colorLength); + newColorIndex = 0; + + for (i = 0; i < positionsLength - 1; ++i) { + p0 = positions[i]; + p1 = positions[i+1]; + c0 = colors[i]; + + numColors = PolylinePipeline.numberOfPointsRhumbLine(p0, p1, granularity); + if (colorsPerVertex && i < colorLength) { + c1 = colors[i+1]; + interpolatedColors = interpolateColors(p0, p1, c0, c1, numColors); + interpolatedColorsLength = interpolatedColors.length; + for (j = 0; j < interpolatedColorsLength; ++j) { + newColors[newColorIndex++] = interpolatedColors[j]; + } + } else { + for (j = 0; j < numColors; ++j) { + newColors[newColorIndex++] = Color.clone(c0); + } + } + } + + newColors[newColorIndex] = Color.clone(colors[colors.length-1]); + colors = newColors; + + scratchInterpolateColorsArray.length = 0; + } + + positions = PolylinePipeline.generateCartesianRhumbArc({ + positions: positions, + granularity: granularity, + ellipsoid: ellipsoid, + height: heights + }); } positionsLength = positions.length; diff --git a/Source/Core/PolylinePipeline.js b/Source/Core/PolylinePipeline.js index d1da46883445..751e7908dfd8 100644 --- a/Source/Core/PolylinePipeline.js +++ b/Source/Core/PolylinePipeline.js @@ -6,6 +6,7 @@ define([ './DeveloperError', './Ellipsoid', './EllipsoidGeodesic', + './EllipsoidRhumb', './IntersectionTests', './isArray', './Math', @@ -19,6 +20,7 @@ define([ DeveloperError, Ellipsoid, EllipsoidGeodesic, + EllipsoidRhumb, IntersectionTests, isArray, CesiumMath, @@ -36,6 +38,11 @@ define([ return Math.ceil(distance / minDistance); }; + PolylinePipeline.numberOfPointsRhumbLine = function(p0, p1, granularity) { + var radiansDistanceSquared = Math.pow((p0.longitude - p1.longitude), 2) + Math.pow((p0.latitude - p1.latitude), 2); + return Math.ceil(Math.sqrt(radiansDistanceSquared / (granularity * granularity))); + }; + var cartoScratch = new Cartographic(); PolylinePipeline.extractHeights = function(positions, ellipsoid) { var length = positions.length; @@ -87,6 +94,7 @@ define([ var scaleFirst = new Cartesian3(); var scaleLast = new Cartesian3(); var ellipsoidGeodesic = new EllipsoidGeodesic(); + var ellipsoidRhumb = new EllipsoidRhumb(); //Returns subdivided line scaled to ellipsoid surface starting at p1 and ending at p2. //Result includes p1, but not include p2. This function is called for a sequence of line segments, @@ -119,6 +127,38 @@ define([ return index; } + //Returns subdivided line scaled to ellipsoid surface starting at p1 and ending at p2. + //Result includes p1, but not include p2. This function is called for a sequence of line segments, + //and this prevents duplication of end point. + function generateCartesianRhumbArc(p0, p1, granularity, ellipsoid, h0, h1, array, offset) { + var first = ellipsoid.scaleToGeodeticSurface(p0, scaleFirst); + var last = ellipsoid.scaleToGeodeticSurface(p1, scaleLast); + var start = ellipsoid.cartesianToCartographic(first, carto1); + var end = ellipsoid.cartesianToCartographic(last, carto2); + + var numPoints = PolylinePipeline.numberOfPointsRhumbLine(start, end, granularity); + var heights = subdivideHeights(numPoints, h0, h1); + + ellipsoidRhumb.setEndPoints(start, end); + var surfaceDistanceBetweenPoints = ellipsoidRhumb.surfaceDistance / numPoints; + + var index = offset; + start.height = h0; + var cart = ellipsoid.cartographicToCartesian(start, cartesian); + Cartesian3.pack(cart, array, index); + index += 3; + + for (var i = 1; i < numPoints; i++) { + var carto = ellipsoidRhumb.interpolateUsingSurfaceDistance(i * surfaceDistanceBetweenPoints, carto2); + carto.height = heights[i]; + cart = ellipsoid.cartographicToCartesian(carto, cartesian); + Cartesian3.pack(cart, array, index); + index += 3; + } + + return index; + } + /** * Breaks a {@link Polyline} into segments such that it does not cross the ±180 degree meridian of an ellipsoid. * @@ -287,6 +327,97 @@ define([ return newPositions; }; + var scratchCartographic0 = new Cartographic(); + var scratchCartographic1 = new Cartographic(); + + /** + * Subdivides polyline and raises all points to the specified height using Rhumb lines. Returns an array of numbers to represent the positions. + * @param {Object} options Object with the following properties: + * @param {Cartesian3[]} options.positions The array of type {Cartesian3} representing positions. + * @param {Number|Number[]} [options.height=0.0] A number or array of numbers representing the heights of each position. + * @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 {Ellipsoid} [options.ellipsoid=Ellipsoid.WGS84] The ellipsoid on which the positions lie. + * @returns {Number[]} A new array of positions of type {Number} that have been subdivided and raised to the surface of the ellipsoid. + * + * @example + * var positions = Cesium.Cartesian3.fromDegreesArray([ + * -105.0, 40.0, + * -100.0, 38.0, + * -105.0, 35.0, + * -100.0, 32.0 + * ]); + * var surfacePositions = Cesium.PolylinePipeline.generateRhumbArc({ + * positons: positions + * }); + */ + PolylinePipeline.generateRhumbArc = function(options) { + if (!defined(options)) { + options = {}; + } + var positions = options.positions; + //>>includeStart('debug', pragmas.debug); + if (!defined(positions)) { + throw new DeveloperError('options.positions is required.'); + } + //>>includeEnd('debug'); + + 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); + Cartesian3.add(p, n, p); + } + + return [p.x, p.y, p.z]; + } + + var granularity = defaultValue(options.granularity, CesiumMath.RADIANS_PER_DEGREE); + + var numPoints = 0; + var i; + + var c0 = ellipsoid.cartesianToCartographic(positions[0], scratchCartographic0); + var c1; + for (i = 0; i < length - 1; i++) { + c1 = ellipsoid.cartesianToCartographic(positions[i + 1], scratchCartographic1); + numPoints += PolylinePipeline.numberOfPointsRhumbLine(c0, c1, granularity); + c0 = Cartographic.clone(c1, scratchCartographic0); + } + + var arrayLength = (numPoints + 1) * 3; + var newPositions = new Array(arrayLength); + var offset = 0; + + for (i = 0; i < length - 1; i++) { + var p0 = positions[i]; + var p1 = positions[i + 1]; + + var h0 = hasHeightArray ? height[i] : height; + var h1 = hasHeightArray ? height[i + 1] : height; + + offset = generateCartesianRhumbArc(p0, p1, granularity, ellipsoid, h0, h1, newPositions, offset); + } + + subdivideHeightsScratchArray.length = 0; + + var lastPoint = positions[length - 1]; + var carto = ellipsoid.cartesianToCartographic(lastPoint, carto1); + carto.height = hasHeightArray ? height[length - 1] : height; + var cart = ellipsoid.cartographicToCartesian(carto, cartesian); + Cartesian3.pack(cart, newPositions, arrayLength - 3); + + return newPositions; + }; + /** * Subdivides polyline and raises all points to the specified height. Returns an array of new {Cartesian3} positions. * @param {Object} options Object with the following properties: @@ -317,5 +448,35 @@ define([ return newPositions; }; + /** + * Subdivides polyline and raises all points to the specified height using Rhumb Lines. Returns an array of new {Cartesian3} positions. + * @param {Object} options Object with the following properties: + * @param {Cartesian3[]} options.positions The array of type {Cartesian3} representing positions. + * @param {Number|Number[]} [options.height=0.0] A number or array of numbers representing the heights of each position. + * @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 {Ellipsoid} [options.ellipsoid=Ellipsoid.WGS84] The ellipsoid on which the positions lie. + * @returns {Cartesian3[]} A new array of cartesian3 positions that have been subdivided and raised to the surface of the ellipsoid. + * + * @example + * var positions = Cesium.Cartesian3.fromDegreesArray([ + * -105.0, 40.0, + * -100.0, 38.0, + * -105.0, 35.0, + * -100.0, 32.0 + * ]); + * var surfacePositions = Cesium.PolylinePipeline.generateCartesianRhumbArc({ + * positons: positions + * }); + */ + PolylinePipeline.generateCartesianRhumbArc = function(options) { + var numberArray = PolylinePipeline.generateRhumbArc(options); + var size = numberArray.length/3; + var newPositions = new Array(size); + for (var i = 0; i < size; i++) { + newPositions[i] = Cartesian3.unpack(numberArray, i*3); + } + return newPositions; + }; + return PolylinePipeline; }); diff --git a/Source/Core/SimplePolylineGeometry.js b/Source/Core/SimplePolylineGeometry.js index c384ede5125d..c7b775d2de53 100644 --- a/Source/Core/SimplePolylineGeometry.js +++ b/Source/Core/SimplePolylineGeometry.js @@ -5,12 +5,14 @@ define([ './ComponentDatatype', './defaultValue', './defined', + './deprecationWarning', './DeveloperError', './Ellipsoid', './Geometry', './GeometryAttribute', './GeometryAttributes', './IndexDatatype', + './LineType', './Math', './PolylinePipeline', './PrimitiveType' @@ -21,12 +23,14 @@ define([ ComponentDatatype, defaultValue, defined, + deprecationWarning, DeveloperError, Ellipsoid, Geometry, GeometryAttribute, GeometryAttributes, IndexDatatype, + LineType, CesiumMath, PolylinePipeline, PrimitiveType) { @@ -84,7 +88,8 @@ define([ * @param {Color[]} [options.colors] An Array of {@link Color} defining the per vertex or per segment colors. * @param {Boolean} [options.colorsPerVertex=false] A boolean that determines whether the colors will be flat across each segment of the line or interpolated across the vertices. * @param {Boolean} [options.followSurface=true] A boolean that determines whether positions will be adjusted to the surface of the ellipsoid via a great arc. - * @param {Number} [options.granularity=CesiumMath.RADIANS_PER_DEGREE] The distance, in radians, between each latitude and longitude if options.followSurface=true. Determines the number of positions in the buffer. + * @param {LineType} [options.lineType=LineType.GEODESIC] The type of line the polyline segments must follow. + * @param {Number} [options.granularity=CesiumMath.RADIANS_PER_DEGREE] The distance, in radians, between each latitude and longitude if options.lineType is not LineType.STRAIGHT. Determines the number of positions in the buffer. * @param {Ellipsoid} [options.ellipsoid=Ellipsoid.WGS84] The ellipsoid to be used as a reference. * * @exception {DeveloperError} At least two positions are required. @@ -121,7 +126,14 @@ define([ this._positions = positions; this._colors = colors; this._colorsPerVertex = colorsPerVertex; + this._followSurface = defaultValue(options.followSurface, true); + if (defined(options.followSurface)) { + deprecationWarning('PolylineGeometry.followSurface', 'PolylineGeometry.followSurface is deprecated and will be removed in Cesium 1.55. Use PolylineGeometry.lineType instead.'); + options.lineType = options.followSurface ? LineType.GEODESIC : LineType.STRAIGHT; + } + this._lineType = defaultValue(options.lineType, LineType.GEODESIC); + this._granularity = defaultValue(options.granularity, CesiumMath.RADIANS_PER_DEGREE); this._ellipsoid = defaultValue(options.ellipsoid, Ellipsoid.WGS84); this._workerName = 'createSimplePolylineGeometry'; @@ -179,7 +191,7 @@ define([ startingIndex += Ellipsoid.packedLength; array[startingIndex++] = value._colorsPerVertex ? 1.0 : 0.0; - array[startingIndex++] = value._followSurface ? 1.0 : 0.0; + array[startingIndex++] = value._lineType; array[startingIndex] = value._granularity; return array; @@ -222,7 +234,7 @@ define([ startingIndex += Ellipsoid.packedLength; var colorsPerVertex = array[startingIndex++] === 1.0; - var followSurface = array[startingIndex++] === 1.0; + var lineType = array[startingIndex++]; var granularity = array[startingIndex]; if (!defined(result)) { @@ -231,7 +243,7 @@ define([ colors : colors, ellipsoid : ellipsoid, colorsPerVertex : colorsPerVertex, - followSurface : followSurface, + lineType : lineType, granularity : granularity }); } @@ -240,7 +252,7 @@ define([ result._colors = colors; result._ellipsoid = ellipsoid; result._colorsPerVertex = colorsPerVertex; - result._followSurface = followSurface; + result._lineType = lineType; result._granularity = granularity; return result; @@ -265,7 +277,7 @@ define([ var positions = simplePolylineGeometry._positions; var colors = simplePolylineGeometry._colors; var colorsPerVertex = simplePolylineGeometry._colorsPerVertex; - var followSurface = simplePolylineGeometry._followSurface; + var lineType = simplePolylineGeometry._lineType; var granularity = simplePolylineGeometry._granularity; var ellipsoid = simplePolylineGeometry._ellipsoid; @@ -281,7 +293,7 @@ define([ var color; var offset = 0; - if (followSurface) { + if (lineType === LineType.GEODESIC) { var heights = PolylinePipeline.extractHeights(positions, ellipsoid); var generateArcOptions = generateArcOptionsScratch; generateArcOptions.minDistance = minDistance; diff --git a/Source/DataSources/Entity.js b/Source/DataSources/Entity.js index dae9820c5d4d..0b5fd179c124 100644 --- a/Source/DataSources/Entity.js +++ b/Source/DataSources/Entity.js @@ -678,7 +678,7 @@ define([ /** * Checks if the given Scene supports polylines clamped to terrain or 3D Tiles. * If this feature is not supported, Entities with PolylineGraphics will be rendered with vertices at - * the provided heights and using the `followSurface` parameter instead of clamped to the ground. + * the provided heights and using the `lineType` parameter instead of clamped to the ground. * * @param {Scene} scene The current scene. * @returns {Boolean} Whether or not the current scene supports polylines on terrain or 3D TIles. diff --git a/Source/DataSources/PolylineGeometryUpdater.js b/Source/DataSources/PolylineGeometryUpdater.js index a7aa2b5fd20a..2a28679753ce 100644 --- a/Source/DataSources/PolylineGeometryUpdater.js +++ b/Source/DataSources/PolylineGeometryUpdater.js @@ -6,6 +6,7 @@ define([ '../Core/defaultValue', '../Core/defined', '../Core/defineProperties', + '../Core/deprecationWarning', '../Core/destroyObject', '../Core/DeveloperError', '../Core/DistanceDisplayCondition', @@ -14,6 +15,7 @@ define([ '../Core/GeometryInstance', '../Core/GroundPolylineGeometry', '../Core/Iso8601', + '../Core/LineType', '../Core/oneTimeWarning', '../Core/PolylineGeometry', '../Core/PolylinePipeline', @@ -38,6 +40,7 @@ define([ defaultValue, defined, defineProperties, + deprecationWarning, destroyObject, DeveloperError, DistanceDisplayCondition, @@ -46,6 +49,7 @@ define([ GeometryInstance, GroundPolylineGeometry, Iso8601, + LineType, oneTimeWarning, PolylineGeometry, PolylinePipeline, @@ -81,6 +85,7 @@ define([ this.positions = undefined; this.width = undefined; this.followSurface = undefined; + this.lineType = undefined; this.granularity = undefined; } @@ -498,11 +503,12 @@ define([ var width = polyline.width; var followSurface = polyline.followSurface; + var lineType = polyline.lineType; var clampToGround = polyline.clampToGround; var granularity = polyline.granularity; if (!positionsProperty.isConstant || !Property.isConstant(width) || - !Property.isConstant(followSurface) || !Property.isConstant(granularity) || + !Property.isConstant(followSurface) || !Property.isConstant(lineType) || !Property.isConstant(granularity) || !Property.isConstant(clampToGround) || !Property.isConstant(zIndex)) { if (!this._dynamic) { this._dynamic = true; @@ -533,6 +539,7 @@ define([ geometryOptions.positions = positions; geometryOptions.width = defined(width) ? width.getValue(Iso8601.MINIMUM_VALUE) : undefined; geometryOptions.followSurface = defined(followSurface) ? followSurface.getValue(Iso8601.MINIMUM_VALUE) : undefined; + geometryOptions.lineType = defined(lineType) ? lineType.getValue(Iso8601.MINIMUM_VALUE) : undefined; geometryOptions.granularity = defined(granularity) ? granularity.getValue(Iso8601.MINIMUM_VALUE) : undefined; var groundGeometryOptions = this._groundGeometryOptions; @@ -682,9 +689,15 @@ define([ return; } - var followSurface = Property.getValueOrDefault(polyline._followSurface, time, true); + var followSurface = Property.getValueOrUndefined(polyline._followSurface, time); + var lineType = LineType.GEODESIC; + if (defined(followSurface)) { + lineType = followSurface ? LineType.GEODESIC : LineType.STRAIGHT; + } + lineType = Property.getValueOrDefault(polyline._lineType, time, lineType); + var globe = geometryUpdater._scene.globe; - if (followSurface && defined(globe)) { + if (lineType !== LineType.STRAIGHT && defined(globe)) { generateCartesianArcOptions.ellipsoid = globe.ellipsoid; generateCartesianArcOptions.positions = positions; generateCartesianArcOptions.granularity = Property.getValueOrUndefined(polyline._granularity, time); diff --git a/Source/DataSources/PolylineGraphics.js b/Source/DataSources/PolylineGraphics.js index 8f1e912d3cfc..eb31bb6f8f8b 100644 --- a/Source/DataSources/PolylineGraphics.js +++ b/Source/DataSources/PolylineGraphics.js @@ -2,16 +2,20 @@ define([ '../Core/defaultValue', '../Core/defined', '../Core/defineProperties', + '../Core/deprecationWarning', '../Core/DeveloperError', '../Core/Event', + '../Core/LineType', './createMaterialPropertyDescriptor', './createPropertyDescriptor' ], function( defaultValue, defined, defineProperties, + deprecationWarning, DeveloperError, Event, + LineType, createMaterialPropertyDescriptor, createPropertyDescriptor) { 'use strict'; @@ -27,12 +31,13 @@ define([ * @param {Object} [options] Object with the following properties: * @param {Property} [options.positions] A Property specifying the array of {@link Cartesian3} positions that define the line strip. * @param {Property} [options.followSurface=true] A boolean Property specifying whether the line segments should be great arcs or linearly connected. + * @param {LineType} [options.lineType=LineType.GEODESIC] The type of line the polyline segments must follow. * @param {Property} [options.clampToGround=false] A boolean Property specifying whether the Polyline should be clamped to the ground. * @param {Property} [options.width=1.0] A numeric Property specifying the width in pixels. * @param {Property} [options.show=true] A boolean Property specifying the visibility of the polyline. * @param {MaterialProperty} [options.material=Color.WHITE] A Property specifying the material used to draw the polyline. * @param {MaterialProperty} [options.depthFailMaterial] A property specifying the material used to draw the polyline when it is below the terrain. - * @param {Property} [options.granularity=Cesium.Math.RADIANS_PER_DEGREE] A numeric Property specifying the angular distance between each latitude and longitude if followSurface is true. + * @param {Property} [options.granularity=Cesium.Math.RADIANS_PER_DEGREE] A numeric Property specifying the angular distance between each latitude and longitude if lineType is now LineType.STRAIGHT. * @param {Property} [options.shadows=ShadowMode.DISABLED] An enum Property specifying whether the polyline casts or receives shadows from each light source. * @param {Property} [options.distanceDisplayCondition] A Property specifying at what distance from the camera that this polyline will be displayed. * @param {Property} [options.classificationType=ClassificationType.BOTH] An enum Property specifying whether this polyline will classify terrain, 3D Tiles, or both when on the ground. @@ -52,6 +57,8 @@ define([ this._positionsSubscription = undefined; this._followSurface = undefined; this._followSurfaceSubscription = undefined; + this._lineType = undefined; + this._lineTypeSubscription = undefined; this._clampToGround = undefined; this._clampToGroundSubscription = undefined; this._granularity = undefined; @@ -136,10 +143,20 @@ define([ * should be great arcs or linearly connected. * @memberof PolylineGraphics.prototype * @type {Property} + * @deprecated This property has been deprecated. Use {@link PolylineGraphics#lineType} instead. * @default true */ followSurface : createPropertyDescriptor('followSurface'), + /** + * Gets or sets the {@link LineType} Property specifying whether the line segments should be great arcs, rhumb lines or linearly connected. + * @memberof PolylineGraphics.prototype + * @type {Property} + * @deprecated This property has been deprecated. Use {@link PolylineGraphics#lineType} instead. + * @default LineType.GEODESIC + */ + lineType : createPropertyDescriptor('lineType'), + /** * Gets or sets the boolean Property specifying whether the polyline * should be clamped to the ground. @@ -150,7 +167,7 @@ define([ clampToGround : createPropertyDescriptor('clampToGround'), /** - * Gets or sets the numeric Property specifying the angular distance between each latitude and longitude if followSurface is true and clampToGround is false. + * Gets or sets the numeric Property specifying the angular distance between each latitude and longitude if lineType is not LineType.STRAIGHT and clampToGround is false. * @memberof PolylineGraphics.prototype * @type {Property} * @default Cesium.Math.RADIANS_PER_DEGREE @@ -206,6 +223,7 @@ define([ result.positions = this.positions; result.width = this.width; result.followSurface = this.followSurface; + result.lineType = this.lineType; result.clampToGround = this.clampToGround; result.granularity = this.granularity; result.shadows = this.shadows; @@ -235,6 +253,7 @@ define([ this.positions = defaultValue(this.positions, source.positions); this.width = defaultValue(this.width, source.width); this.followSurface = defaultValue(this.followSurface, source.followSurface); + this.lineType = defaultValue(this.lineType, source.lineType); this.clampToGround = defaultValue(this.clampToGround, source.clampToGround); this.granularity = defaultValue(this.granularity, source.granularity); this.shadows = defaultValue(this.shadows, source.shadows); diff --git a/Source/Scene/DebugModelMatrixPrimitive.js b/Source/Scene/DebugModelMatrixPrimitive.js index 633324e66a05..56e4d68bfdcd 100644 --- a/Source/Scene/DebugModelMatrixPrimitive.js +++ b/Source/Scene/DebugModelMatrixPrimitive.js @@ -5,6 +5,7 @@ define([ '../Core/defined', '../Core/destroyObject', '../Core/GeometryInstance', + '../Core/LineType', '../Core/Matrix4', '../Core/PolylineGeometry', './PolylineColorAppearance', @@ -16,6 +17,7 @@ define([ defined, destroyObject, GeometryInstance, + LineType, Matrix4, PolylineGeometry, PolylineColorAppearance, @@ -142,7 +144,7 @@ define([ Color.RED, Color.RED ], - followSurface: false + lineType: LineType.STRAIGHT }), modelMatrix : Matrix4.multiplyByUniformScale(this.modelMatrix, this.length, new Matrix4()), id : this.id, @@ -160,7 +162,7 @@ define([ Color.GREEN, Color.GREEN ], - followSurface: false + lineType: LineType.STRAIGHT }), modelMatrix : Matrix4.multiplyByUniformScale(this.modelMatrix, this.length, new Matrix4()), id : this.id, @@ -178,7 +180,7 @@ define([ Color.BLUE, Color.BLUE ], - followSurface: false + lineType: LineType.STRAIGHT }), modelMatrix : Matrix4.multiplyByUniformScale(this.modelMatrix, this.length, new Matrix4()), id : this.id, From 5be47b2aae1998437366f4637a8ce9ef37a7d91e Mon Sep 17 00:00:00 2001 From: Shehzan Mohammed Date: Mon, 14 Jan 2019 14:27:27 -0500 Subject: [PATCH 05/26] Add lineType support to GeoJsonDataSource --- Source/DataSources/GeoJsonDataSource.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Source/DataSources/GeoJsonDataSource.js b/Source/DataSources/GeoJsonDataSource.js index cb96f4419cb9..69a18b889ef5 100644 --- a/Source/DataSources/GeoJsonDataSource.js +++ b/Source/DataSources/GeoJsonDataSource.js @@ -8,6 +8,7 @@ define([ '../Core/DeveloperError', '../Core/Event', '../Core/getFilenameFromUri', + '../Core/LineType', '../Core/PinBuilder', '../Core/PolygonHierarchy', '../Core/Resource', @@ -36,6 +37,7 @@ define([ DeveloperError, Event, getFilenameFromUri, + LineType, PinBuilder, PolygonHierarchy, Resource, @@ -75,6 +77,7 @@ define([ var defaultStrokeWidth = 2; var defaultFill = Color.fromBytes(255, 255, 0, 100); var defaultClampToGround = false; + var defaultLineType = LineType.RHUMB; var sizes = { small : 24, @@ -365,6 +368,7 @@ define([ polylineGraphics.material = material; polylineGraphics.width = widthProperty; polylineGraphics.positions = new ConstantProperty(coordinatesArrayToCartesianArray(coordinates, crsFunction)); + polylineGraphics.lineType = options.lineType; } function processLineString(dataSource, geoJson, geometry, crsFunction, options) { @@ -434,6 +438,7 @@ define([ polygon.outlineColor = outlineColorProperty; polygon.outlineWidth = widthProperty; polygon.material = material; + polygon.lineType = options.lineType; var holes = []; for (var i = 1, len = coordinates.length; i < len; i++) { @@ -522,6 +527,7 @@ define([ * @param {Number} [options.strokeWidth=GeoJsonDataSource.strokeWidth] The default width of polylines and polygon outlines. * @param {Color} [options.fill=GeoJsonDataSource.fill] The default color for polygon interiors. * @param {Boolean} [options.clampToGround=GeoJsonDataSource.clampToGround] true if we want the geometry features (polygons or linestrings) clamped to the ground. + * @param {LineType} [options.lineType=GeoJsonDataSource.lineType] The line type used to interpolate between points. * * @returns {Promise.} A promise that will resolve when the data is loaded. */ @@ -629,6 +635,20 @@ define([ defaultClampToGround = value; } }, + /** + * Gets or sets default of the path interpolation type. + * @memberof GeoJsonDataSource + * @type {LineType} + * @default false + */ + lineType : { + get : function() { + return defaultLineType; + }, + set : function(value) { + defaultLineType = value; + } + }, /** * Gets an object that maps the name of a crs to a callback function which takes a GeoJSON coordinate @@ -800,6 +820,7 @@ define([ * @param {Number} [options.strokeWidth=GeoJsonDataSource.strokeWidth] The default width of polylines and polygon outlines. * @param {Color} [options.fill=GeoJsonDataSource.fill] The default color for polygon interiors. * @param {Boolean} [options.clampToGround=GeoJsonDataSource.clampToGround] true if we want the features clamped to the ground. + * @param {LineType} [options.lineType=GeoJsonDataSource.lineType] The line type used to interpolate between points. * * @returns {Promise.} a promise that will resolve when the GeoJSON is loaded. */ @@ -831,7 +852,8 @@ define([ strokeWidthProperty : new ConstantProperty(defaultValue(options.strokeWidth, defaultStrokeWidth)), strokeMaterialProperty : new ColorMaterialProperty(defaultValue(options.stroke, defaultStroke)), fillMaterialProperty : new ColorMaterialProperty(defaultValue(options.fill, defaultFill)), - clampToGround : defaultValue(options.clampToGround, defaultClampToGround) + clampToGround : defaultValue(options.clampToGround, defaultClampToGround), + lineType : defaultValue(options.lineType, defaultLineType) }; var that = this; From 7c60e885367249b7cee090a45a477a95008304ef Mon Sep 17 00:00:00 2001 From: Shehzan Mohammed Date: Mon, 14 Jan 2019 16:51:25 -0500 Subject: [PATCH 06/26] Add rhumb line support to GroundPolylineGeometry --- Source/Core/GroundPolylineGeometry.js | 43 ++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/Source/Core/GroundPolylineGeometry.js b/Source/Core/GroundPolylineGeometry.js index 938a2c08e001..4e60a9bfbf92 100644 --- a/Source/Core/GroundPolylineGeometry.js +++ b/Source/Core/GroundPolylineGeometry.js @@ -13,11 +13,13 @@ define([ './defineProperties', './Ellipsoid', './EllipsoidGeodesic', + './EllipsoidRhumb', './EncodedCartesian3', './GeographicProjection', './Geometry', './GeometryAttribute', './IntersectionTests', + './LineType', './Matrix3', './Plane', './Quaternion', @@ -38,11 +40,13 @@ define([ defineProperties, Ellipsoid, EllipsoidGeodesic, + EllipsoidRhumb, EncodedCartesian3, GeographicProjection, Geometry, GeometryAttribute, IntersectionTests, + LineType, Matrix3, Plane, Quaternion, @@ -80,6 +84,7 @@ define([ * @param {Number} [options.width=1.0] The screen space width in pixels. * @param {Number} [options.granularity=9999.0] The distance interval in meters used for interpolating options.points. Defaults to 9999.0 meters. Zero indicates no interpolation. * @param {Boolean} [options.loop=false] Whether during geometry creation a line segment will be added between the last and first line positions to make this Polyline a loop. + * @param {LineType} [options.lineType=LineType.GEODESIC] The type of line the polyline segments must follow. * * @exception {DeveloperError} At least two positions are required. * @@ -104,6 +109,9 @@ define([ if ((!defined(positions)) || (positions.length < 2)) { throw new DeveloperError('At least two positions are required.'); } + if (defined(options.lineType) && options.lineType === LineType.STRAIGHT) { + throw new DeveloperError('Only Geodesic and Rhumb line types are supported.'); + } //>>includeEnd('debug'); /** @@ -130,6 +138,13 @@ define([ */ this.loop = defaultValue(options.loop, false); + /** + * The type of path the polyline must follow. + * @type {LineType} + * @default LineType.GEODESIC + */ + this.lineType = defaultValue(options.lineType, LineType.GEODESIC); + this._ellipsoid = Ellipsoid.WGS84; // MapProjections can't be packed, so store the index to a known MapProjection. @@ -150,7 +165,7 @@ define([ */ packedLength: { get: function() { - return 1.0 + this._positions.length * 3 + 1.0 + 1.0 + Ellipsoid.packedLength + 1.0 + 1.0; + return 1.0 + this._positions.length * 3 + 1.0 + 1.0 + Ellipsoid.packedLength + 1.0 + 1.0 + 1.0; } } }); @@ -195,12 +210,19 @@ define([ var interpolatedBottomScratch = new Cartesian3(); var interpolatedTopScratch = new Cartesian3(); var interpolatedNormalScratch = new Cartesian3(); - function interpolateSegment(start, end, minHeight, maxHeight, granularity, ellipsoid, normalsArray, bottomPositionsArray, topPositionsArray, cartographicsArray) { + function interpolateSegment(start, end, minHeight, maxHeight, granularity, lineType, ellipsoid, normalsArray, bottomPositionsArray, topPositionsArray, cartographicsArray) { if (granularity === 0.0) { return; } - var ellipsoidGeodesic = new EllipsoidGeodesic(start, end, ellipsoid); - var surfaceDistance = ellipsoidGeodesic.surfaceDistance; + + var ellipsoidLine; + if (lineType === LineType.GEODESIC) { + ellipsoidLine = new EllipsoidGeodesic(start, end, ellipsoid); + } else if (lineType === LineType.RHUMB) { + ellipsoidLine = new EllipsoidRhumb(start, end, ellipsoid); + } + + var surfaceDistance = ellipsoidLine.surfaceDistance; if (surfaceDistance < granularity) { return; } @@ -214,7 +236,7 @@ define([ var pointsToAdd = segments - 1; var packIndex = normalsArray.length; for (var i = 0; i < pointsToAdd; i++) { - var interpolatedCartographic = ellipsoidGeodesic.interpolateUsingSurfaceDistance(distanceFromStart, interpolatedCartographicScratch); + var interpolatedCartographic = ellipsoidLine.interpolateUsingSurfaceDistance(distanceFromStart, interpolatedCartographicScratch); var interpolatedBottom = getPosition(ellipsoid, interpolatedCartographic, minHeight, interpolatedBottomScratch); var interpolatedTop = getPosition(ellipsoid, interpolatedCartographic, maxHeight, interpolatedTopScratch); @@ -266,6 +288,7 @@ define([ array[index++] = value.granularity; array[index++] = value.loop ? 1.0 : 0.0; + array[index++] = value.lineType; Ellipsoid.pack(value._ellipsoid, array, index); index += Ellipsoid.packedLength; @@ -299,6 +322,7 @@ define([ var granularity = array[index++]; var loop = array[index++] === 1.0; + var lineType = array[index++]; var ellipsoid = Ellipsoid.unpack(array, index); index += Ellipsoid.packedLength; @@ -311,6 +335,7 @@ define([ positions : positions, granularity : granularity, loop : loop, + lineType : lineType, ellipsoid : ellipsoid }); geometry._projectionIndex = projectionIndex; @@ -321,6 +346,7 @@ define([ result._positions = positions; result.granularity = granularity; result.loop = loop; + result.lineType = lineType; result._ellipsoid = ellipsoid; result._projectionIndex = projectionIndex; result._scene3DOnly = scene3DOnly; @@ -397,6 +423,7 @@ define([ var loop = groundPolylineGeometry.loop; var ellipsoid = groundPolylineGeometry._ellipsoid; var granularity = groundPolylineGeometry.granularity; + var lineType = groundPolylineGeometry.lineType; var projection = new PROJECTIONS[groundPolylineGeometry._projectionIndex](ellipsoid); var minHeight = WALL_INITIAL_MIN_HEIGHT; @@ -495,7 +522,7 @@ define([ cartographicsArray.push(startCartographic.latitude); cartographicsArray.push(startCartographic.longitude); - interpolateSegment(startCartographic, nextCartographic, minHeight, maxHeight, granularity, ellipsoid, normalsArray, bottomPositionsArray, topPositionsArray, cartographicsArray); + interpolateSegment(startCartographic, nextCartographic, minHeight, maxHeight, granularity, lineType, ellipsoid, normalsArray, bottomPositionsArray, topPositionsArray, cartographicsArray); // All inbetween points for (i = 1; i < cartographicsLength - 1; ++i) { @@ -514,7 +541,7 @@ define([ cartographicsArray.push(vertexCartographic.latitude); cartographicsArray.push(vertexCartographic.longitude); - interpolateSegment(cartographics[i], cartographics[i + 1], minHeight, maxHeight, granularity, ellipsoid, normalsArray, bottomPositionsArray, topPositionsArray, cartographicsArray); + interpolateSegment(cartographics[i], cartographics[i + 1], minHeight, maxHeight, granularity, lineType, ellipsoid, normalsArray, bottomPositionsArray, topPositionsArray, cartographicsArray); } // Last point - either loop or attach a normal "perpendicular" to the wall. @@ -542,7 +569,7 @@ define([ cartographicsArray.push(endCartographic.longitude); if (loop) { - interpolateSegment(endCartographic, startCartographic, minHeight, maxHeight, granularity, ellipsoid, normalsArray, bottomPositionsArray, topPositionsArray, cartographicsArray); + interpolateSegment(endCartographic, startCartographic, minHeight, maxHeight, granularity, lineType, ellipsoid, normalsArray, bottomPositionsArray, topPositionsArray, cartographicsArray); index = normalsArray.length; for (i = 0; i < 3; ++i) { normalsArray[index + i] = normalsArray[i]; From d9db99a10c5700018fda3c57ce5957cce497fa12 Mon Sep 17 00:00:00 2001 From: Shehzan Mohammed Date: Tue, 15 Jan 2019 15:19:03 -0500 Subject: [PATCH 07/26] Rename EllipsoidRhumb -> EllipsoidRhumbLine --- Source/Core/GroundPolylineGeometry.js | 6 +++--- Source/Core/PolygonGeometryLibrary.js | 10 +++++----- Source/Core/PolylinePipeline.js | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Source/Core/GroundPolylineGeometry.js b/Source/Core/GroundPolylineGeometry.js index 4e60a9bfbf92..03f21f3b65c6 100644 --- a/Source/Core/GroundPolylineGeometry.js +++ b/Source/Core/GroundPolylineGeometry.js @@ -13,7 +13,7 @@ define([ './defineProperties', './Ellipsoid', './EllipsoidGeodesic', - './EllipsoidRhumb', + './EllipsoidRhumbLine', './EncodedCartesian3', './GeographicProjection', './Geometry', @@ -40,7 +40,7 @@ define([ defineProperties, Ellipsoid, EllipsoidGeodesic, - EllipsoidRhumb, + EllipsoidRhumbLine, EncodedCartesian3, GeographicProjection, Geometry, @@ -219,7 +219,7 @@ define([ if (lineType === LineType.GEODESIC) { ellipsoidLine = new EllipsoidGeodesic(start, end, ellipsoid); } else if (lineType === LineType.RHUMB) { - ellipsoidLine = new EllipsoidRhumb(start, end, ellipsoid); + ellipsoidLine = new EllipsoidRhumbLine(start, end, ellipsoid); } var surfaceDistance = ellipsoidLine.surfaceDistance; diff --git a/Source/Core/PolygonGeometryLibrary.js b/Source/Core/PolygonGeometryLibrary.js index 833cdf7f576c..4453f2b85ce3 100644 --- a/Source/Core/PolygonGeometryLibrary.js +++ b/Source/Core/PolygonGeometryLibrary.js @@ -7,7 +7,7 @@ define([ './defaultValue', './defined', './Ellipsoid', - './EllipsoidRhumb', + './EllipsoidRhumbLine', './Geometry', './GeometryAttribute', './GeometryAttributes', @@ -30,7 +30,7 @@ define([ defaultValue, defined, Ellipsoid, - EllipsoidRhumb, + EllipsoidRhumbLine, Geometry, GeometryAttribute, GeometryAttributes, @@ -151,7 +151,7 @@ define([ return Math.pow(2, countDivide); }; - var scratchEllipsoidRhumb = new EllipsoidRhumb(); + var scratchEllipsoidRhumb = new EllipsoidRhumbLine(); var scratchCartographic0 = new Cartographic(); var scratchCartographic1 = new Cartographic(); var scratchCartographic2 = new Cartographic(); @@ -159,7 +159,7 @@ define([ PolygonGeometryLibrary.subdivideRhumbLineCount = function(ellipsoid, p0, p1, minDistance) { var c0 = ellipsoid.cartesianToCartographic(p0, scratchCartographic0); var c1 = ellipsoid.cartesianToCartographic(p1, scratchCartographic1); - var rhumb = EllipsoidRhumb.fromStartAndEnd(c0, c1, ellipsoid, scratchEllipsoidRhumb); + var rhumb = EllipsoidRhumbLine.fromStartAndEnd(c0, c1, ellipsoid, scratchEllipsoidRhumb); var n = rhumb.surfaceDistance / minDistance; var countDivide = Math.max(0, Math.ceil(Math.log(n) / Math.log(2))); return Math.pow(2, countDivide); @@ -192,7 +192,7 @@ define([ var numVertices = PolygonGeometryLibrary.subdivideRhumbLineCount(ellipsoid, p0, p1, minDistance); var c0 = ellipsoid.cartesianToCartographic(p0, scratchCartographic0); var c1 = ellipsoid.cartesianToCartographic(p1, scratchCartographic1); - var rhumb = EllipsoidRhumb.fromStartAndEnd(c0, c1, ellipsoid, scratchEllipsoidRhumb); + var rhumb = EllipsoidRhumbLine.fromStartAndEnd(c0, c1, ellipsoid, scratchEllipsoidRhumb); var distanceBetweenVertices = rhumb.surfaceDistance / numVertices; if (!defined(result)) { diff --git a/Source/Core/PolylinePipeline.js b/Source/Core/PolylinePipeline.js index 751e7908dfd8..6df8391263ee 100644 --- a/Source/Core/PolylinePipeline.js +++ b/Source/Core/PolylinePipeline.js @@ -6,7 +6,7 @@ define([ './DeveloperError', './Ellipsoid', './EllipsoidGeodesic', - './EllipsoidRhumb', + './EllipsoidRhumbLine', './IntersectionTests', './isArray', './Math', @@ -20,7 +20,7 @@ define([ DeveloperError, Ellipsoid, EllipsoidGeodesic, - EllipsoidRhumb, + EllipsoidRhumbLine, IntersectionTests, isArray, CesiumMath, @@ -94,7 +94,7 @@ define([ var scaleFirst = new Cartesian3(); var scaleLast = new Cartesian3(); var ellipsoidGeodesic = new EllipsoidGeodesic(); - var ellipsoidRhumb = new EllipsoidRhumb(); + var ellipsoidRhumb = new EllipsoidRhumbLine(); //Returns subdivided line scaled to ellipsoid surface starting at p1 and ending at p2. //Result includes p1, but not include p2. This function is called for a sequence of line segments, From 6362be576edbe08929187eaa3b15bcc953f33588 Mon Sep 17 00:00:00 2001 From: Shehzan Mohammed Date: Tue, 15 Jan 2019 16:04:24 -0500 Subject: [PATCH 08/26] Fix GroundPolylineGeometry across PM and IDL, Add granularity, lineType options to PolylineGeometryUpdater --- Source/Core/GroundPolylineGeometry.js | 43 +++++++++++++++++-- Source/DataSources/PolylineGeometryUpdater.js | 6 +++ 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/Source/Core/GroundPolylineGeometry.js b/Source/Core/GroundPolylineGeometry.js index 03f21f3b65c6..271aefbf2ff3 100644 --- a/Source/Core/GroundPolylineGeometry.js +++ b/Source/Core/GroundPolylineGeometry.js @@ -165,7 +165,7 @@ define([ */ packedLength: { get: function() { - return 1.0 + this._positions.length * 3 + 1.0 + 1.0 + Ellipsoid.packedLength + 1.0 + 1.0 + 1.0; + return 1.0 + this._positions.length * 3 + 1.0 + 1.0 + 1.0 + Ellipsoid.packedLength + 1.0 + 1.0; } } }); @@ -410,6 +410,10 @@ define([ var nextBottomScratch = new Cartesian3(); var vertexNormalScratch = new Cartesian3(); var intersectionScratch = new Cartesian3(); + var cartographicScratch0 = new Cartographic(); + var cartographicScratch1 = new Cartographic(); + var cartographicIntersectionScratch = new Cartographic(); + var rhumbLineScratch = new EllipsoidRhumbLine(); /** * Computes shadow volumes for the ground polyline, consisting of its vertices, indices, and a bounding sphere. * Vertices are "fat," packing all the data needed in each volume to describe a line on terrain or 3D Tiles. @@ -444,7 +448,12 @@ define([ // may get split by the plane of IDL + Prime Meridian. var p0; var p1; + var c0; + var c1; + var rhumbLine; var intersection; + var intersectionCartographic; + var intersectionLongitude; var splitPositions = [positions[0]]; for (i = 0; i < positionsLength - 1; i++) { p0 = positions[i]; @@ -453,7 +462,21 @@ define([ if (defined(intersection) && !Cartesian3.equalsEpsilon(intersection, p0, CesiumMath.EPSILON7) && !Cartesian3.equalsEpsilon(intersection, p1, CesiumMath.EPSILON7)) { - splitPositions.push(Cartesian3.clone(intersection)); + if (groundPolylineGeometry.lineType === LineType.GEODESIC) { + splitPositions.push(Cartesian3.clone(intersection)); + } else if (groundPolylineGeometry.lineType === LineType.RHUMB) { + intersectionLongitude = ellipsoid.cartesianToCartographic(intersection, cartographicScratch0).longitude; + c0 = ellipsoid.cartesianToCartographic(p0, cartographicScratch0); + c1 = ellipsoid.cartesianToCartographic(p1, cartographicScratch1); + rhumbLine = EllipsoidRhumbLine.fromStartAndEnd(c0, c1, ellipsoid, rhumbLineScratch); + intersectionCartographic = rhumbLine.findIntersectionWithLongitude(intersectionLongitude, cartographicIntersectionScratch); + intersection = ellipsoid.cartographicToCartesian(intersectionCartographic, intersectionScratch); + if (defined(intersection) && + !Cartesian3.equalsEpsilon(intersection, p0, CesiumMath.EPSILON7) && + !Cartesian3.equalsEpsilon(intersection, p1, CesiumMath.EPSILON7)) { + splitPositions.push(Cartesian3.clone(intersection)); + } + } } splitPositions.push(p1); } @@ -465,7 +488,21 @@ define([ if (defined(intersection) && !Cartesian3.equalsEpsilon(intersection, p0, CesiumMath.EPSILON7) && !Cartesian3.equalsEpsilon(intersection, p1, CesiumMath.EPSILON7)) { - splitPositions.push(Cartesian3.clone(intersection)); + if (groundPolylineGeometry.lineType === LineType.GEODESIC) { + splitPositions.push(Cartesian3.clone(intersection)); + } else if (groundPolylineGeometry.lineType === LineType.RHUMB) { + intersectionLongitude = ellipsoid.cartesianToCartographic(intersection, cartographicScratch0).longitude; + c0 = ellipsoid.cartesianToCartographic(p0, cartographicScratch0); + c1 = ellipsoid.cartesianToCartographic(p1, cartographicScratch1); + rhumbLine = EllipsoidRhumbLine.fromStartAndEnd(c0, c1, ellipsoid, rhumbLineScratch); + intersectionCartographic = rhumbLine.findIntersectionWithLongitude(intersectionLongitude, cartographicIntersectionScratch); + intersection = ellipsoid.cartographicToCartesian(intersectionCartographic, intersectionScratch); + if (defined(intersection) && + !Cartesian3.equalsEpsilon(intersection, p0, CesiumMath.EPSILON7) && + !Cartesian3.equalsEpsilon(intersection, p1, CesiumMath.EPSILON7)) { + splitPositions.push(Cartesian3.clone(intersection)); + } + } } } var cartographicsLength = splitPositions.length; diff --git a/Source/DataSources/PolylineGeometryUpdater.js b/Source/DataSources/PolylineGeometryUpdater.js index 2a28679753ce..fc0146ea55ff 100644 --- a/Source/DataSources/PolylineGeometryUpdater.js +++ b/Source/DataSources/PolylineGeometryUpdater.js @@ -92,6 +92,8 @@ define([ function GroundGeometryOptions() { this.positions = undefined; this.width = undefined; + this.lineType = undefined; + this.granularity = undefined; } /** @@ -545,6 +547,8 @@ define([ var groundGeometryOptions = this._groundGeometryOptions; groundGeometryOptions.positions = positions; groundGeometryOptions.width = geometryOptions.width; + groundGeometryOptions.lineType = geometryOptions.lineType; + groundGeometryOptions.granularity = geometryOptions.granularity; this._clampToGround = defined(clampToGround) ? clampToGround.getValue(Iso8601.MINIMUM_VALUE) : false; @@ -633,6 +637,8 @@ define([ geometryUpdater._clampToGround = Property.getValueOrDefault(polyline._clampToGround, time, false); geometryUpdater._groundGeometryOptions.positions = positions; geometryUpdater._groundGeometryOptions.width = Property.getValueOrDefault(polyline._width, time, 1); + geometryUpdater._groundGeometryOptions.lineType = Property.getValueOrDefault(polyline._lineType, time, LineType.GEODESIC); + geometryUpdater._groundGeometryOptions.granularity = Property.getValueOrDefault(polyline._granulatiry, time, 9999); var groundPrimitives = this._groundPrimitives; From 4c2141dbb7abd3e4a220646d9ab20decfce85c6f Mon Sep 17 00:00:00 2001 From: Shehzan Mohammed Date: Wed, 16 Jan 2019 15:43:15 -0500 Subject: [PATCH 09/26] Add tests for all the classes where LineType is used --- Source/Core/PolygonOutlineGeometry.js | 3 + Source/Core/PolylineGeometry.js | 1 + Source/Core/SimplePolylineGeometry.js | 1 + Source/DataSources/PolylineGeometryUpdater.js | 13 ++ Specs/Core/GroundPolylineGeometrySpec.js | 59 +++++++- Specs/Core/PolygonGeometrySpec.js | 128 +++++++++++++++++- Specs/Core/PolygonOutlineGeometrySpec.js | 87 +++++++++++- Specs/Core/PolygonPipelineSpec.js | 75 ++++++++++ Specs/Core/PolylineGeometrySpec.js | 97 ++++++++++++- Specs/Core/PolylinePipelineSpec.js | 57 ++++++++ Specs/Core/SimplePolylineGeometrySpec.js | 61 ++++++++- Specs/DataSources/GeoJsonDataSourceSpec.js | 125 +++++++++++++++++ .../DataSources/PolygonGeometryUpdaterSpec.js | 21 ++- Specs/DataSources/PolygonGraphicsSpec.js | 13 ++ .../PolylineGeometryUpdaterSpec.js | 111 +++++++++++++-- Specs/DataSources/PolylineGraphicsSpec.js | 14 ++ 16 files changed, 844 insertions(+), 22 deletions(-) diff --git a/Source/Core/PolygonOutlineGeometry.js b/Source/Core/PolygonOutlineGeometry.js index 02c22944c3c4..39116352bb4a 100644 --- a/Source/Core/PolygonOutlineGeometry.js +++ b/Source/Core/PolygonOutlineGeometry.js @@ -326,6 +326,9 @@ define([ if (options.perPositionHeight && defined(options.height)) { throw new DeveloperError('Cannot use both options.perPositionHeight and options.height'); } + if (defined(options.lineType) && options.lineType === LineType.STRAIGHT) { + throw new DeveloperError('Cannot use option.lineType as LineType.STRAIGHT'); + } //>>includeEnd('debug'); var polygonHierarchy = options.polygonHierarchy; diff --git a/Source/Core/PolylineGeometry.js b/Source/Core/PolylineGeometry.js index 50ccb2cedb74..0fa135010f6f 100644 --- a/Source/Core/PolylineGeometry.js +++ b/Source/Core/PolylineGeometry.js @@ -148,6 +148,7 @@ define([ options.lineType = options.followSurface ? LineType.GEODESIC : LineType.STRAIGHT; } this._lineType = defaultValue(options.lineType, LineType.GEODESIC); + this._followSurface = (this._lineType !== LineType.STRAIGHT); this._granularity = defaultValue(options.granularity, CesiumMath.RADIANS_PER_DEGREE); this._ellipsoid = Ellipsoid.clone(defaultValue(options.ellipsoid, Ellipsoid.WGS84)); diff --git a/Source/Core/SimplePolylineGeometry.js b/Source/Core/SimplePolylineGeometry.js index c7b775d2de53..added91c34b8 100644 --- a/Source/Core/SimplePolylineGeometry.js +++ b/Source/Core/SimplePolylineGeometry.js @@ -133,6 +133,7 @@ define([ options.lineType = options.followSurface ? LineType.GEODESIC : LineType.STRAIGHT; } this._lineType = defaultValue(options.lineType, LineType.GEODESIC); + this._followSurface = this._lineType === LineType.STRAIGHT; this._granularity = defaultValue(options.granularity, CesiumMath.RADIANS_PER_DEGREE); this._ellipsoid = defaultValue(options.ellipsoid, Ellipsoid.WGS84); diff --git a/Source/DataSources/PolylineGeometryUpdater.js b/Source/DataSources/PolylineGeometryUpdater.js index fc0146ea55ff..fc58db897d91 100644 --- a/Source/DataSources/PolylineGeometryUpdater.js +++ b/Source/DataSources/PolylineGeometryUpdater.js @@ -316,6 +316,19 @@ define([ } }, + /** + * Gets a value indicating if the path of the line. + * @memberof PolylineGeometryUpdater.prototype + * + * @type {LineType} + * @readonly + */ + lineType : { + get : function() { + return this._lineType; + } + }, + /** * Gets a value indicating if the geometry is clamped to the ground. * Returns false if polylines on terrain is not supported. diff --git a/Specs/Core/GroundPolylineGeometrySpec.js b/Specs/Core/GroundPolylineGeometrySpec.js index 9fdcc6f2e00a..9ccc1aba87a0 100644 --- a/Specs/Core/GroundPolylineGeometrySpec.js +++ b/Specs/Core/GroundPolylineGeometrySpec.js @@ -4,9 +4,10 @@ defineSuite([ 'Core/arraySlice', 'Core/Cartesian3', 'Core/Cartographic', - 'Core/Math', 'Core/Ellipsoid', 'Core/GeographicProjection', + 'Core/LineType', + 'Core/Math', 'Core/WebMercatorProjection', 'Specs/createPackableSpecs' ], function( @@ -15,9 +16,10 @@ defineSuite([ arraySlice, Cartesian3, Cartographic, - CesiumMath, Ellipsoid, GeographicProjection, + LineType, + CesiumMath, WebMercatorProjection, createPackableSpecs) { 'use strict'; @@ -364,6 +366,58 @@ defineSuite([ expect(geometry.attributes.position.values.length).toEqual(24 * 3); }); + it('interpolates long polyline segments for rhumb lines', function() { + // rhumb distance = 289020, geodesic distance = 288677 + var positions = Cartesian3.fromDegreesArray([ + 10, 75, + 20, 75 + ]); + + var rhumbGroundPolylineGeometry = new GroundPolylineGeometry({ + positions : positions, + granularity : 2890.0, + lineType: LineType.RHUMB + }); + var geodesicGroundPolylineGeometry = new GroundPolylineGeometry({ + positions : positions, + granularity : 2890.0, + lineType: LineType.GEODESIC + }); + + var rhumbGeometry = GroundPolylineGeometry.createGeometry(rhumbGroundPolylineGeometry); + var geodesicGeometry = GroundPolylineGeometry.createGeometry(geodesicGroundPolylineGeometry); + + expect(rhumbGeometry.indices.length).toEqual(3636); + expect(geodesicGeometry.indices.length).toEqual(3600); + expect(geodesicGeometry.attributes.position.values.length).toEqual(2400); + expect(rhumbGeometry.attributes.position.values.length).toEqual(2424); + + // Interpolate one segment but not the other + positions = Cartesian3.fromDegreesArray([ + 10, 75, + 20, 75, + 20.01, 75 + ]); + rhumbGroundPolylineGeometry = new GroundPolylineGeometry({ + positions : positions, + granularity : 2890.0, + lineType: LineType.RHUMB + }); + geodesicGroundPolylineGeometry = new GroundPolylineGeometry({ + positions : positions, + granularity : 2890.0, + lineType: LineType.GEODESIC + }); + + rhumbGeometry = GroundPolylineGeometry.createGeometry(rhumbGroundPolylineGeometry); + geodesicGeometry = GroundPolylineGeometry.createGeometry(geodesicGroundPolylineGeometry); + + expect(rhumbGeometry.indices.length).toEqual(3636 + 36); + expect(geodesicGeometry.indices.length).toEqual(3600 + 36); + expect(geodesicGeometry.attributes.position.values.length).toEqual(2400 + 24); + expect(rhumbGeometry.attributes.position.values.length).toEqual(2424 + 24); + }); + it('loops when there are enough positions and loop is specified', function() { var groundPolylineGeometry = new GroundPolylineGeometry({ positions : Cartesian3.fromDegreesArray([ @@ -564,6 +618,7 @@ defineSuite([ Cartesian3.pack(positions[2], packedInstance, packedInstance.length); packedInstance.push(polyline.granularity); packedInstance.push(polyline.loop ? 1.0 : 0.0); + packedInstance.push(polyline.lineType); Ellipsoid.pack(Ellipsoid.WGS84, packedInstance, packedInstance.length); diff --git a/Specs/Core/PolygonGeometrySpec.js b/Specs/Core/PolygonGeometrySpec.js index 15601a327dc1..1f39d2f70067 100644 --- a/Specs/Core/PolygonGeometrySpec.js +++ b/Specs/Core/PolygonGeometrySpec.js @@ -6,6 +6,7 @@ defineSuite([ 'Core/Ellipsoid', 'Core/GeometryOffsetAttribute', 'Core/GeometryPipeline', + 'Core/LineType', 'Core/Math', 'Core/Rectangle', 'Core/VertexFormat', @@ -18,6 +19,7 @@ defineSuite([ Ellipsoid, GeometryOffsetAttribute, GeometryPipeline, + LineType, CesiumMath, Rectangle, VertexFormat, @@ -59,6 +61,17 @@ defineSuite([ }))).toBeUndefined(); }); + it('throws if lineType is not valid', function() { + expect(function() { + return new PolygonGeometry({ + positions : [Cartesian3.fromDegrees(0, 0), + Cartesian3.fromDegrees(1, 0), + Cartesian3.fromDegrees(1, 1)], + lineType: LineType.STRAIGHT + }); + }).toThrowDeveloperError(); + }); + it('createGeometry returns undefined due to duplicate positions', function() { var geometry = PolygonGeometry.createGeometry(PolygonGeometry.fromPositions({ positions : Cartesian3.fromDegreesArray([ @@ -176,6 +189,82 @@ defineSuite([ expect(ellipsoid.cartesianToCartographic(Cartesian3.fromArray(p.attributes.position.values, 3)).height).toEqualEpsilon(0, CesiumMath.EPSILON6); }); + it('create geometry creates with rhumb lines', function() { + var p = PolygonGeometry.createGeometry(PolygonGeometry.fromPositions({ + vertexFormat : VertexFormat.POSITION_ONLY, + positions : Cartesian3.fromDegreesArray([ + -1.0, -1.0, + 1.0, -1.0, + 1.0, 1.0, + -1.0, 1.0 + ]), + granularity : CesiumMath.RADIANS_PER_DEGREE, + lineType : LineType.RHUMB + })); + + expect(p.attributes.position.values.length).toEqual(13 * 3); // 8 around edge + 5 in the middle + expect(p.indices.length).toEqual(16 * 3); //4 squares * 4 triangles per square + }); + + it('create geometry throws if lineType is STRAIGHT', function() { + expect(function() { + PolygonGeometry.createGeometry(PolygonGeometry.fromPositions({ + vertexFormat: VertexFormat.POSITION_ONLY, + positions: Cartesian3.fromDegreesArray([ + -1.0, -1.0, + 1.0, -1.0, + 1.0, 1.0, + -1.0, 1.0 + ]), + granularity: CesiumMath.RADIANS_PER_DEGREE, + lineType: LineType.STRAIGHT + })); + }).toThrowDeveloperError(); + }); + + it('create geometry creates with lines with different number of subdivisions for geodesic and rhumb', function() { + var positions = Cartesian3.fromDegreesArray([ + -30.0, -30.0, + 30.0, -30.0, + 30.0, 30.0, + -30.0, 30.0 + ]); + var geodesic = PolygonGeometry.createGeometry(PolygonGeometry.fromPositions({ + vertexFormat : VertexFormat.POSITION_ONLY, + positions : positions, + granularity : CesiumMath.RADIANS_PER_DEGREE, + lineType : LineType.GEODESIC + })); + var rhumb = PolygonGeometry.createGeometry(PolygonGeometry.fromPositions({ + vertexFormat : VertexFormat.POSITION_ONLY, + positions : positions, + granularity : CesiumMath.RADIANS_PER_DEGREE, + lineType : LineType.RHUMB + })); + + expect(geodesic.attributes.position.values.length).not.toEqual(rhumb.attributes.position.values.length); + expect(geodesic.indices.length).not.toEqual(rhumb.indices.length); + }); + + it('computes positions with per position heights for rhumb lines', function() { + var ellipsoid = Ellipsoid.WGS84; + var height = 100.0; + var positions = Cartesian3.fromDegreesArrayHeights([ + -1.0, -1.0, height, + 1.0, -1.0, 0.0, + 1.0, 1.0, 0.0, + -1.0, 1.0, 0.0 + ]); + var p = PolygonGeometry.createGeometry(PolygonGeometry.fromPositions({ + positions : positions, + perPositionHeight : true, + lineType : LineType.RHUMB + })); + + expect(ellipsoid.cartesianToCartographic(Cartesian3.fromArray(p.attributes.position.values, 0)).height).toEqualEpsilon(height, CesiumMath.EPSILON6); + expect(ellipsoid.cartesianToCartographic(Cartesian3.fromArray(p.attributes.position.values, 3)).height).toEqualEpsilon(0, CesiumMath.EPSILON6); + }); + it('computes all attributes', function() { var p = PolygonGeometry.createGeometry(PolygonGeometry.fromPositions({ vertexFormat : VertexFormat.ALL, @@ -233,6 +322,43 @@ defineSuite([ expect(p.indices.length).toEqual(10 * 3); }); + it('creates a polygon from hierarchy with rhumb lines', function() { + var hierarchy = { + positions : Cartesian3.fromDegreesArray([ + -124.0, 35.0, + -110.0, 35.0, + -110.0, 40.0, + -124.0, 40.0 + ]), + holes : [{ + positions : Cartesian3.fromDegreesArray([ + -122.0, 36.0, + -122.0, 39.0, + -112.0, 39.0, + -112.0, 36.0 + ]), + holes : [{ + positions : Cartesian3.fromDegreesArray([ + -120.0, 36.5, + -114.0, 36.5, + -114.0, 38.5, + -120.0, 38.5 + ]) + }] + }] + }; + + var p = PolygonGeometry.createGeometry(new PolygonGeometry({ + vertexFormat : VertexFormat.POSITION_ONLY, + polygonHierarchy : hierarchy, + granularity : CesiumMath.PI_OVER_THREE, + lineType : LineType.RHUMB + })); + + expect(p.attributes.position.values.length).toEqual(12 * 3); // 4 points * 3 rectangles + expect(p.indices.length).toEqual(10 * 3); + }); + it('removes duplicates in polygon hierarchy', function() { var hierarchy = { positions : Cartesian3.fromDegreesArray([ @@ -1067,6 +1193,6 @@ defineSuite([ addPositions(packedInstance, holePositions1); packedInstance.push(Ellipsoid.WGS84.radii.x, Ellipsoid.WGS84.radii.y, Ellipsoid.WGS84.radii.z); packedInstance.push(1.0, 0.0, 0.0, 0.0, 0.0, 0.0); - packedInstance.push(0.0, 0.0, CesiumMath.PI_OVER_THREE, 0.0, 0.0, 1.0, 0, 1, 0, -1, 53); + packedInstance.push(0.0, 0.0, CesiumMath.PI_OVER_THREE, 0.0, 0.0, 1.0, 0, 1, 0, -1, LineType.GEODESIC, 54); createPackableSpecs(PolygonGeometry, polygon, packedInstance); }); diff --git a/Specs/Core/PolygonOutlineGeometrySpec.js b/Specs/Core/PolygonOutlineGeometrySpec.js index 013329d16c0b..1851ce1529ff 100644 --- a/Specs/Core/PolygonOutlineGeometrySpec.js +++ b/Specs/Core/PolygonOutlineGeometrySpec.js @@ -5,6 +5,7 @@ defineSuite([ 'Core/Cartesian3', 'Core/Ellipsoid', 'Core/GeometryOffsetAttribute', + 'Core/LineType', 'Core/Math', 'Specs/createPackableSpecs' ], function( @@ -14,6 +15,7 @@ defineSuite([ Cartesian3, Ellipsoid, GeometryOffsetAttribute, + LineType, CesiumMath, createPackableSpecs) { 'use strict'; @@ -53,6 +55,17 @@ defineSuite([ }))).toBeUndefined(); }); + it('throws if lineType is not valid', function() { + expect(function() { + return new PolygonOutlineGeometry({ + positions : [Cartesian3.fromDegrees(0, 0), + Cartesian3.fromDegrees(1, 0), + Cartesian3.fromDegrees(1, 1)], + lineType: LineType.STRAIGHT + }); + }).toThrowDeveloperError(); + }); + it('createGeometry returns undefined due to duplicate positions', function() { var geometry = PolygonOutlineGeometry.createGeometry(PolygonOutlineGeometry.fromPositions({ positions : Cartesian3.fromDegreesArray([ @@ -168,6 +181,78 @@ defineSuite([ expect(ellipsoid.cartesianToCartographic(Cartesian3.fromArray(p.attributes.position.values, 3)).height).toEqualEpsilon(0, CesiumMath.EPSILON6); }); + it('create geometry creates with rhumb lines', function() { + var p = PolygonOutlineGeometry.createGeometry(PolygonOutlineGeometry.fromPositions({ + positions : Cartesian3.fromDegreesArray([ + -1.0, -1.0, + 1.0, -1.0, + 1.0, 1.0, + -1.0, 1.0 + ]), + granularity : CesiumMath.RADIANS_PER_DEGREE, + lineType : LineType.RHUMB + })); + + expect(p.attributes.position.values.length).toEqual(8 * 3); // 8 around edge + expect(p.indices.length).toEqual(16); // 4 squares + }); + + it('create geometry throws if lineType is STRAIGHT', function() { + expect(function() { + PolygonOutlineGeometry.createGeometry(PolygonOutlineGeometry.fromPositions({ + positions: Cartesian3.fromDegreesArray([ + -1.0, -1.0, + 1.0, -1.0, + 1.0, 1.0, + -1.0, 1.0 + ]), + granularity: CesiumMath.RADIANS_PER_DEGREE, + lineType: LineType.STRAIGHT + })); + }).toThrowDeveloperError(); + }); + + it('create geometry creates with lines with different number of subdivisions for geodesic and rhumb', function() { + var positions = Cartesian3.fromDegreesArray([ + -80.0, 75.0, + 80.0, 75.0, + 80.0, 45.0, + -80.0, 45.0 + ]); + var geodesic = PolygonOutlineGeometry.createGeometry(PolygonOutlineGeometry.fromPositions({ + positions : positions, + granularity : CesiumMath.RADIANS_PER_DEGREE, + lineType : LineType.GEODESIC + })); + var rhumb = PolygonOutlineGeometry.createGeometry(PolygonOutlineGeometry.fromPositions({ + positions : positions, + granularity : CesiumMath.RADIANS_PER_DEGREE, + lineType : LineType.RHUMB + })); + + expect(geodesic.attributes.position.values.length).not.toEqual(rhumb.attributes.position.values.length); + expect(geodesic.indices.length).not.toEqual(rhumb.indices.length); + }); + + it('computes positions with per position heights for rhumb lines', function() { + var ellipsoid = Ellipsoid.WGS84; + var height = 100.0; + var positions = Cartesian3.fromDegreesArrayHeights([ + -1.0, -1.0, height, + 1.0, -1.0, 0.0, + 1.0, 1.0, 0.0, + -1.0, 1.0, 0.0 + ]); + var p = PolygonOutlineGeometry.createGeometry(PolygonOutlineGeometry.fromPositions({ + positions : positions, + perPositionHeight : true, + lineType : LineType.RHUMB + })); + + expect(ellipsoid.cartesianToCartographic(Cartesian3.fromArray(p.attributes.position.values, 0)).height).toEqualEpsilon(height, CesiumMath.EPSILON6); + expect(ellipsoid.cartesianToCartographic(Cartesian3.fromArray(p.attributes.position.values, 3)).height).toEqualEpsilon(0, CesiumMath.EPSILON6); + }); + it('uses correct value with extrudedHeight and perPositionHeight', function() { var ellipsoid = Ellipsoid.WGS84; var maxHeight = 100.0; @@ -524,6 +609,6 @@ defineSuite([ packedInstance.push(3.0, 0.0); addPositions(packedInstance, holePositions1); packedInstance.push(Ellipsoid.WGS84.radii.x, Ellipsoid.WGS84.radii.y, Ellipsoid.WGS84.radii.z); - packedInstance.push(0.0, 0.0, CesiumMath.PI_OVER_THREE, 0.0, 1.0, -1, 43); + packedInstance.push(0.0, 0.0, CesiumMath.PI_OVER_THREE, 0.0, 1.0, LineType.GEODESIC, -1, 44); createPackableSpecs(PolygonOutlineGeometry, polygon, packedInstance); }); diff --git a/Specs/Core/PolygonPipelineSpec.js b/Specs/Core/PolygonPipelineSpec.js index 47e5bc747db4..8c95e5af8e1e 100644 --- a/Specs/Core/PolygonPipelineSpec.js +++ b/Specs/Core/PolygonPipelineSpec.js @@ -193,4 +193,79 @@ defineSuite([ expect(subdivision.indices[1]).toEqual(1); expect(subdivision.indices[2]).toEqual(2); }); + + /////////////////////////////////////////////////////////////////////// + + it('computeRhumbLineSubdivision throws without ellipsoid', function() { + expect(function() { + PolygonPipeline.computeRhumbLineSubdivision(); + }).toThrowDeveloperError(); + }); + + it('computeRhumbLineSubdivision throws without positions', function() { + expect(function() { + PolygonPipeline.computeRhumbLineSubdivision(Ellipsoid.WGS84); + }).toThrowDeveloperError(); + }); + + it('computeRhumbLineSubdivision throws without indices', function() { + expect(function() { + PolygonPipeline.computeRhumbLineSubdivision(Ellipsoid.WGS84, []); + }).toThrowDeveloperError(); + }); + + it('computeRhumbLineSubdivision throws with less than 3 indices', function() { + expect(function() { + PolygonPipeline.computeRhumbLineSubdivision(Ellipsoid.WGS84, [], [1, 2]); + }).toThrowDeveloperError(); + }); + + it('computeRhumbLineSubdivision throws without a multiple of 3 indices', function() { + expect(function() { + PolygonPipeline.computeRhumbLineSubdivision(Ellipsoid.WGS84, [], [1, 2, 3, 4]); + }).toThrowDeveloperError(); + }); + + it('computeRhumbLineSubdivision throws with negative granularity', function() { + expect(function() { + PolygonPipeline.computeRhumbLineSubdivision(Ellipsoid.WGS84, [], [1, 2, 3], -1.0); + }).toThrowDeveloperError(); + }); + + it('computeRhumbLineSubdivision', function() { + var positions = Cartesian3.fromDegreesArray([ + 0, 0, + 1, 0, + 1, 1 + ]); + var indices = [0, 1, 2]; + var subdivision = PolygonPipeline.computeRhumbLineSubdivision(Ellipsoid.WGS84, positions, indices, 2 * CesiumMath.RADIANS_PER_DEGREE); + + expect(subdivision.attributes.position.values[0]).toEqual(positions[0].x); + expect(subdivision.attributes.position.values[1]).toEqual(positions[0].y); + expect(subdivision.attributes.position.values[2]).toEqual(positions[0].y); + expect(subdivision.attributes.position.values[3]).toEqual(positions[1].x); + expect(subdivision.attributes.position.values[4]).toEqual(positions[1].y); + expect(subdivision.attributes.position.values[5]).toEqual(positions[1].z); + expect(subdivision.attributes.position.values[6]).toEqual(positions[2].x); + expect(subdivision.attributes.position.values[7]).toEqual(positions[2].y); + expect(subdivision.attributes.position.values[8]).toEqual(positions[2].z); + + expect(subdivision.indices[0]).toEqual(0); + expect(subdivision.indices[1]).toEqual(1); + expect(subdivision.indices[2]).toEqual(2); + }); + + it('computeRhumbLineSubdivision with subvisisions', function() { + var positions = Cartesian3.fromDegreesArray([ + 0, 0, + 1, 0, + 1, 1 + ]); + var indices = [0, 1, 2]; + var subdivision = PolygonPipeline.computeRhumbLineSubdivision(Ellipsoid.WGS84, positions, indices, 0.5 * CesiumMath.RADIANS_PER_DEGREE); + + expect(subdivision.attributes.position.values.length).toEqual(30); // 10 vertices + expect(subdivision.indices.length).toEqual(27); // 9 triangles + }); }); diff --git a/Specs/Core/PolylineGeometrySpec.js b/Specs/Core/PolylineGeometrySpec.js index 8a2f9d43651d..6947f189094c 100644 --- a/Specs/Core/PolylineGeometrySpec.js +++ b/Specs/Core/PolylineGeometrySpec.js @@ -3,6 +3,7 @@ defineSuite([ 'Core/Cartesian3', 'Core/Color', 'Core/Ellipsoid', + 'Core/LineType', 'Core/VertexFormat', 'Specs/createPackableSpecs' ], function( @@ -10,6 +11,7 @@ defineSuite([ Cartesian3, Color, Ellipsoid, + LineType, VertexFormat, createPackableSpecs) { 'use strict'; @@ -37,6 +39,25 @@ defineSuite([ }).toThrowDeveloperError(); }); + it('constructor converts followSurface to lineType', function() { + var line = new PolylineGeometry({ + positions: [Cartesian3.ZERO, Cartesian3.UNIT_X, Cartesian3.UNIT_Y], + followSurface: false + }); + + expect(line._followSurface).toBe(false); + expect(line._lineType).toBe(LineType.STRAIGHT); + + line = new PolylineGeometry({ + positions: [Cartesian3.ZERO, Cartesian3.UNIT_X, Cartesian3.UNIT_Y], + followSurface: true + }); + console.log(line); + + expect(line._followSurface).toBe(true); + expect(line._lineType).toBe(LineType.GEODESIC); + }); + it('constructor returns undefined when line width is negative', function() { var positions = [new Cartesian3(1.0, 0.0, 0.0), new Cartesian3(0.0, 1.0, 0.0), new Cartesian3(0.0, 0.0, 1.0)]; var line = PolylineGeometry.createGeometry(new PolylineGeometry({ @@ -75,6 +96,36 @@ defineSuite([ expect(line.indices.length).toEqual(positions.length * 6 - 6); }); + it('constructor computes all vertex attributes for rhumb lines', function() { + var positions = Cartesian3.fromDegreesArray([ + 30, 30, + 30, 60, + 60, 60 + ]); + var line = PolylineGeometry.createGeometry(new PolylineGeometry({ + positions : positions, + width : 10.0, + vertexFormat : VertexFormat.ALL, + granularity : Math.PI, + ellipsoid : Ellipsoid.UNIT_SPHERE, + lineType : LineType.RHUMB + })); + + expect(line.attributes.position).toBeDefined(); + expect(line.attributes.prevPosition).toBeDefined(); + expect(line.attributes.nextPosition).toBeDefined(); + expect(line.attributes.expandAndWidth).toBeDefined(); + expect(line.attributes.st).toBeDefined(); + + var numVertices = (positions.length * 4 - 4); + expect(line.attributes.position.values.length).toEqual(numVertices * 3); + expect(line.attributes.prevPosition.values.length).toEqual(numVertices * 3); + expect(line.attributes.nextPosition.values.length).toEqual(numVertices * 3); + expect(line.attributes.expandAndWidth.values.length).toEqual(numVertices * 2); + expect(line.attributes.st.values.length).toEqual(numVertices * 2); + expect(line.indices.length).toEqual(positions.length * 6 - 6); + }); + it('constructor computes per segment colors', function() { var positions = [new Cartesian3(1.0, 0.0, 0.0), new Cartesian3(0.0, 1.0, 0.0), new Cartesian3(0.0, 0.0, 1.0)]; var colors = [new Color(1.0, 0.0, 0.0, 1.0), new Color(0.0, 1.0, 0.0, 1.0), new Color(0.0, 0.0, 1.0, 1.0)]; @@ -120,7 +171,7 @@ defineSuite([ positions : positions, width : 10.0, vertexFormat : VertexFormat.POSITION_ONLY, - followSurface : false + lineType : LineType.STRAIGHT })); expect(geometry).not.toBeDefined(); }); @@ -131,23 +182,59 @@ defineSuite([ width : 10.0, colors : [Color.RED, Color.LIME, Color.BLUE], colorsPerVertex : true, - followSurface : false, + lineType : LineType.STRAIGHT, granularity : 11, vertexFormat : VertexFormat.POSITION_ONLY, ellipsoid : new Ellipsoid(12, 13, 14) }); - var packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 3, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 12, 13, 14, 1, 0, 0, 0, 0, 0, 10, 1, 0, 11]; + var packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 3, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 12, 13, 14, 1, 0, 0, 0, 0, 0, 10, 1, 2, 11]; createPackableSpecs(PolylineGeometry, line, packedInstance, 'per vertex colors'); line = new PolylineGeometry({ positions : positions, width : 10.0, colorsPerVertex : false, - followSurface : false, + lineType : LineType.STRAIGHT, granularity : 11, vertexFormat : VertexFormat.POSITION_ONLY, ellipsoid : new Ellipsoid(12, 13, 14) }); - packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 12, 13, 14, 1, 0, 0, 0, 0, 0, 10, 0, 0, 11]; + packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 12, 13, 14, 1, 0, 0, 0, 0, 0, 10, 0, 2, 11]; createPackableSpecs(PolylineGeometry, line, packedInstance); + + line = new PolylineGeometry({ + positions : positions, + width : 10.0, + colorsPerVertex : false, + lineType : LineType.GEODESIC, + granularity : 11, + vertexFormat : VertexFormat.POSITION_ONLY, + ellipsoid : new Ellipsoid(12, 13, 14) + }); + packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 12, 13, 14, 1, 0, 0, 0, 0, 0, 10, 0, 0, 11]; + createPackableSpecs(PolylineGeometry, line, packedInstance, 'geodesic line'); + + line = new PolylineGeometry({ + positions : positions, + width : 10.0, + colorsPerVertex : false, + lineType : LineType.RHUMB, + granularity : 11, + vertexFormat : VertexFormat.POSITION_ONLY, + ellipsoid : new Ellipsoid(12, 13, 14) + }); + packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 12, 13, 14, 1, 0, 0, 0, 0, 0, 10, 0, 1, 11]; + createPackableSpecs(PolylineGeometry, line, packedInstance, 'rhumb line'); + + line = new PolylineGeometry({ + positions : positions, + width : 10.0, + colorsPerVertex : false, + lineType : LineType.STRAIGHT, + granularity : 11, + vertexFormat : VertexFormat.POSITION_ONLY, + ellipsoid : new Ellipsoid(12, 13, 14) + }); + packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 12, 13, 14, 1, 0, 0, 0, 0, 0, 10, 0, 2, 11]; + createPackableSpecs(PolylineGeometry, line, packedInstance, 'straight line'); }); diff --git a/Specs/Core/PolylinePipelineSpec.js b/Specs/Core/PolylinePipelineSpec.js index e0024afbfba0..6f62ec382a52 100644 --- a/Specs/Core/PolylinePipelineSpec.js +++ b/Specs/Core/PolylinePipelineSpec.js @@ -108,4 +108,61 @@ defineSuite([ expect(newPositions).toEqual([0,0,1]); }); + it('generateRhumbArc throws without positions', function() { + expect(function() { + PolylinePipeline.generateRhumbArc(); + }).toThrowDeveloperError(); + }); + + it('generateRhumbArc accepts a height array for single value', function() { + var positions = [Cartesian3.fromDegrees(0, 0)]; + var height = [30]; + + var newPositions = PolylinePipeline.generateRhumbArc({ + positions: positions, + height: height + }); + + expect(newPositions.length).toEqual(3); + expect(Cartesian3.fromArray(newPositions, 0)).toEqualEpsilon(Cartesian3.fromDegrees(0, 0, 30), CesiumMath.EPSILON6); + }); + + it('generateRhumbArc subdivides in half', function() { + var p1 = Cartesian3.fromDegrees(0, 30); + var p2 = Cartesian3.fromDegrees(90, 30); + var p3 = Cartesian3.fromDegrees(45, 30); + var positions = [p1, p2]; + + var newPositions = PolylinePipeline.generateRhumbArc({ + positions: positions, + granularity: CesiumMath.PI_OVER_FOUR, + ellipsoid: Ellipsoid.WGS84 + }); + + expect(newPositions.length).toEqual(3*3); + var p1n = Cartesian3.fromArray(newPositions, 0); + var p3n = Cartesian3.fromArray(newPositions, 3); + var p2n = Cartesian3.fromArray(newPositions, 6); + expect(Cartesian3.equalsEpsilon(p1, p1n, CesiumMath.EPSILON4)).toEqual(true); + expect(Cartesian3.equalsEpsilon(p2, p2n, CesiumMath.EPSILON4)).toEqual(true); + expect(Cartesian3.equalsEpsilon(p3, p3n, CesiumMath.EPSILON4)).toEqual(true); + }); + + it('generateRhumbArc works with empty array', function() { + var newPositions = PolylinePipeline.generateRhumbArc({ + positions: [] + }); + + expect(newPositions.length).toEqual(0); + }); + + it('generateRhumbArc works one position', function() { + var newPositions = PolylinePipeline.generateRhumbArc({ + positions: [Cartesian3.UNIT_Z], + ellipsoid: Ellipsoid.UNIT_SPHERE + }); + + expect(newPositions.length).toEqual(3); + expect(newPositions).toEqual([0,0,1]); + }); }); diff --git a/Specs/Core/SimplePolylineGeometrySpec.js b/Specs/Core/SimplePolylineGeometrySpec.js index dee7e598eff7..185e68783e0e 100644 --- a/Specs/Core/SimplePolylineGeometrySpec.js +++ b/Specs/Core/SimplePolylineGeometrySpec.js @@ -4,6 +4,7 @@ defineSuite([ 'Core/Cartesian3', 'Core/Color', 'Core/Ellipsoid', + 'Core/LineType', 'Core/Math', 'Core/PrimitiveType', 'Specs/createPackableSpecs' @@ -13,6 +14,7 @@ defineSuite([ Cartesian3, Color, Ellipsoid, + LineType, CesiumMath, PrimitiveType, createPackableSpecs) { @@ -55,6 +57,28 @@ defineSuite([ expect(line.boundingSphere).toEqual(BoundingSphere.fromPoints(positions)); }); + it('constructor computes all vertex attributes for rhumb lines', function() { + var positions = Cartesian3.fromDegreesArray([ + 30, 30, + 30, 60, + 60, 60 + ]); + var line = SimplePolylineGeometry.createGeometry(new SimplePolylineGeometry({ + positions: positions, + granularity: Math.PI, + ellipsoid: Ellipsoid.UNIT_SPHERE, + lineType: LineType.RHUMB + })); + + var cartesian3Array = []; + Cartesian3.packArray(positions, cartesian3Array); + + expect(line.attributes.position.values).toEqualEpsilon(cartesian3Array, CesiumMath.EPSILON10); + expect(line.indices).toEqual([0, 1, 1, 2]); + expect(line.primitiveType).toEqual(PrimitiveType.LINES); + expect(line.boundingSphere).toEqual(BoundingSphere.fromPoints(positions)); + }); + it('constructor computes per segment colors', function() { var positions = [new Cartesian3(1.0, 0.0, 0.0), new Cartesian3(0.0, 1.0, 0.0), new Cartesian3(0.0, 0.0, 1.0)]; var colors = [new Color(1.0, 0.0, 0.0, 1.0), new Color(0.0, 1.0, 0.0, 1.0), new Color(0.0, 0.0, 1.0, 1.0)]; @@ -141,7 +165,7 @@ defineSuite([ granularity : 11, ellipsoid : new Ellipsoid(12, 13, 14) }); - var packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 3, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 12, 13, 14, 1, 0, 11]; + var packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 3, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 12, 13, 14, 1, 2, 11]; createPackableSpecs(SimplePolylineGeometry, line, packedInstance, 'per vertex colors'); line = new SimplePolylineGeometry({ @@ -151,6 +175,39 @@ defineSuite([ granularity : 11, ellipsoid : new Ellipsoid(12, 13, 14) }); - packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 12, 13, 14, 0, 0, 11]; + packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 12, 13, 14, 0, 2, 11]; createPackableSpecs(SimplePolylineGeometry, line, packedInstance); + + line = new SimplePolylineGeometry({ + positions : positions, + width : 10.0, + colorsPerVertex : false, + lineType : LineType.GEODESIC, + granularity : 11, + ellipsoid : new Ellipsoid(12, 13, 14) + }); + packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 12, 13, 14, 0, 0, 11]; + createPackableSpecs(SimplePolylineGeometry, line, packedInstance, 'geodesic line'); + + line = new SimplePolylineGeometry({ + positions : positions, + width : 10.0, + colorsPerVertex : false, + lineType : LineType.RHUMB, + granularity : 11, + ellipsoid : new Ellipsoid(12, 13, 14) + }); + packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 12, 13, 14, 0, 1, 11]; + createPackableSpecs(SimplePolylineGeometry, line, packedInstance, 'rhumb line'); + + line = new SimplePolylineGeometry({ + positions : positions, + width : 10.0, + colorsPerVertex : false, + lineType : LineType.STRAIGHT, + granularity : 11, + ellipsoid : new Ellipsoid(12, 13, 14) + }); + packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 12, 13, 14, 0, 2, 11]; + createPackableSpecs(SimplePolylineGeometry, line, packedInstance, 'straight line'); }); diff --git a/Specs/DataSources/GeoJsonDataSourceSpec.js b/Specs/DataSources/GeoJsonDataSourceSpec.js index 135e6a4d0279..6f9ddca0bca3 100644 --- a/Specs/DataSources/GeoJsonDataSourceSpec.js +++ b/Specs/DataSources/GeoJsonDataSourceSpec.js @@ -4,6 +4,7 @@ defineSuite([ 'Core/Color', 'Core/Event', 'Core/JulianDate', + 'Core/LineType', 'Core/PolygonHierarchy', 'Core/RuntimeError', 'DataSources/CallbackProperty', @@ -17,6 +18,7 @@ defineSuite([ Color, Event, JulianDate, + LineType, PolygonHierarchy, RuntimeError, CallbackProperty, @@ -33,6 +35,7 @@ defineSuite([ var defaultStrokeWidth; var defaultFill; var defaultClampToGround; + var defaultLineType; beforeAll(function() { defaultMarkerSize = GeoJsonDataSource.markerSize; @@ -42,6 +45,7 @@ defineSuite([ defaultStrokeWidth = GeoJsonDataSource.strokeWidth; defaultFill = GeoJsonDataSource.fill; defaultClampToGround = GeoJsonDataSource.clampToGround; + defaultLineType = GeoJsonDataSource.lineType; }); beforeEach(function() { @@ -52,6 +56,7 @@ defineSuite([ GeoJsonDataSource.strokeWidth = defaultStrokeWidth; GeoJsonDataSource.fill = defaultFill; GeoJsonDataSource.clampToGround = defaultClampToGround; + GeoJsonDataSource.lineType = defaultLineType; }); var time = new JulianDate(); @@ -674,9 +679,26 @@ defineSuite([ var entityCollection = dataSource.entities; var entity = entityCollection.values[0]; expect(entity.properties).toBe(lineString.properties); + console.log(entity.polyline); expect(entity.polyline.positions.getValue(time)).toEqual(coordinatesArrayToCartesian(lineString.coordinates)); expect(entity.polyline.material.color.getValue(time)).toEqual(GeoJsonDataSource.stroke); expect(entity.polyline.width.getValue(time)).toEqual(2); + expect(entity.polyline.lineType.getValue(time)).toEqual(GeoJsonDataSource.lineType); + }); + }); + + it('Works with lineString geometry with geodesic lines', function() { + var dataSource = new GeoJsonDataSource(); + return dataSource.load(lineString, { + lineType : LineType.GEODESIC + }).then(function() { + var entityCollection = dataSource.entities; + var entity = entityCollection.values[0]; + expect(entity.properties).toBe(lineString.properties); + expect(entity.polyline.positions.getValue(time)).toEqual(coordinatesArrayToCartesian(lineString.coordinates)); + expect(entity.polyline.material.color.getValue(time)).toEqual(GeoJsonDataSource.stroke); + expect(entity.polyline.width.getValue(time)).toEqual(2); + expect(entity.polyline.lineType.getValue(time)).toEqual(LineType.GEODESIC); }); }); @@ -692,6 +714,24 @@ defineSuite([ expect(entity.polyline.material.color.getValue(time)).toEqual(GeoJsonDataSource.stroke); expect(entity.polyline.width.getValue(time)).toEqual(2); expect(entity.polyline.clampToGround.getValue(time)).toEqual(true); + expect(entity.polyline.lineType.getValue(time)).toEqual(GeoJsonDataSource.lineType); + }); + }); + + it('Works with lineString geometry with geodesic lines clamped to ground', function() { + var dataSource = new GeoJsonDataSource(); + return dataSource.load(lineString, { + clampToGround : true, + lineType : LineType.GEODESIC + }).then(function() { + var entityCollection = dataSource.entities; + var entity = entityCollection.values[0]; + expect(entity.properties).toBe(lineString.properties); + expect(entity.polyline.positions.getValue(time)).toEqual(coordinatesArrayToCartesian(lineString.coordinates)); + expect(entity.polyline.material.color.getValue(time)).toEqual(GeoJsonDataSource.stroke); + expect(entity.polyline.width.getValue(time)).toEqual(2); + expect(entity.polyline.clampToGround.getValue(time)).toEqual(true); + expect(entity.polyline.lineType.getValue(time)).toEqual(LineType.GEODESIC); }); }); @@ -707,6 +747,26 @@ defineSuite([ expect(entity.polyline.positions.getValue(time)).toEqual(lines[i]); expect(entity.polyline.material.color.getValue(time)).toEqual(Color.YELLOW); expect(entity.polyline.width.getValue(time)).toEqual(2); + expect(entity.polyline.lineType.getValue(time)).toEqual(GeoJsonDataSource.lineType); + } + }); + }); + + it('Works with multiLineString geometry with geodesic lines', function() { + var dataSource = new GeoJsonDataSource(); + return dataSource.load(multiLineString, { + lineType : LineType.GEODESIC + }).then(function() { + var entityCollection = dataSource.entities; + var entities = entityCollection.values; + var lines = multiLineToCartesian(multiLineString); + for (var i = 0; i < multiLineString.coordinates.length; i++) { + var entity = entities[i]; + expect(entity.properties).toBe(multiLineString.properties); + expect(entity.polyline.positions.getValue(time)).toEqual(lines[i]); + expect(entity.polyline.material.color.getValue(time)).toEqual(Color.YELLOW); + expect(entity.polyline.width.getValue(time)).toEqual(2); + expect(entity.polyline.lineType.getValue(time)).toEqual(LineType.GEODESIC); } }); }); @@ -730,6 +790,27 @@ defineSuite([ }); }); + it('Works with multiLineString geometry with geodesic lines clamped to ground', function() { + var dataSource = new GeoJsonDataSource(); + return dataSource.load(multiLineString, { + clampToGround : true, + lineType : LineType.GEODESIC + }).then(function() { + var entityCollection = dataSource.entities; + var entities = entityCollection.values; + var lines = multiLineToCartesian(multiLineString); + for (var i = 0; i < multiLineString.coordinates.length; i++) { + var entity = entities[i]; + expect(entity.properties).toBe(multiLineString.properties); + expect(entity.polyline.positions.getValue(time)).toEqual(lines[i]); + expect(entity.polyline.material.color.getValue(time)).toEqual(Color.YELLOW); + expect(entity.polyline.width.getValue(time)).toEqual(2); + expect(entity.polyline.clampToGround.getValue(time)).toEqual(true); + expect(entity.polyline.lineType.getValue(time)).toEqual(LineType.GEODESIC); + } + }); + }); + it('Works with polygon geometry', function() { var dataSource = new GeoJsonDataSource(); return dataSource.load(polygon).then(function() { @@ -743,6 +824,26 @@ defineSuite([ expect(entity.polygon.outlineWidth.getValue(time)).toEqual(GeoJsonDataSource.strokeWidth); expect(entity.polygon.outlineColor.getValue(time)).toEqual(GeoJsonDataSource.stroke); expect(entity.polygon.height).toBeInstanceOf(ConstantProperty); + expect(entity.polygon.lineType.getValue(time)).toEqual(GeoJsonDataSource.lineType); + }); + }); + + it('Works with polygon geometry with geodesic lines', function() { + var dataSource = new GeoJsonDataSource(); + return dataSource.load(polygon, { + lineType : LineType.GEODESIC + }).then(function() { + var entityCollection = dataSource.entities; + var entity = entityCollection.values[0]; + expect(entity.properties).toBe(polygon.properties); + expect(entity.polygon.hierarchy.getValue(time)).toEqual(new PolygonHierarchy(polygonCoordinatesToCartesian(polygon.coordinates[0]))); + expect(entity.polygon.perPositionHeight).toBeUndefined(); + expect(entity.polygon.material.color.getValue(time)).toEqual(GeoJsonDataSource.fill); + expect(entity.polygon.outline.getValue(time)).toEqual(true); + expect(entity.polygon.outlineWidth.getValue(time)).toEqual(GeoJsonDataSource.strokeWidth); + expect(entity.polygon.outlineColor.getValue(time)).toEqual(GeoJsonDataSource.stroke); + expect(entity.polygon.height).toBeInstanceOf(ConstantProperty); + expect(entity.polygon.lineType.getValue(time)).toEqual(LineType.GEODESIC); }); }); @@ -761,7 +862,27 @@ defineSuite([ expect(entity.polygon.outlineWidth.getValue(time)).toEqual(GeoJsonDataSource.strokeWidth); expect(entity.polygon.outlineColor.getValue(time)).toEqual(GeoJsonDataSource.stroke); expect(entity.polygon.height).toBeUndefined(); + expect(entity.polygon.lineType.getValue(time)).toEqual(GeoJsonDataSource.lineType); + }); + }); + it('Works with polygon geometry with geodesic lines clamped to ground', function() { + var dataSource = new GeoJsonDataSource(); + return dataSource.load(polygon, { + clampToGround : true, + lineType : LineType.GEODESIC + }).then(function() { + var entityCollection = dataSource.entities; + var entity = entityCollection.values[0]; + expect(entity.properties).toBe(polygon.properties); + expect(entity.polygon.hierarchy.getValue(time)).toEqual(new PolygonHierarchy(polygonCoordinatesToCartesian(polygon.coordinates[0]))); + expect(entity.polygon.perPositionHeight).toBeUndefined(); + expect(entity.polygon.material.color.getValue(time)).toEqual(GeoJsonDataSource.fill); + expect(entity.polygon.outline.getValue(time)).toEqual(true); + expect(entity.polygon.outlineWidth.getValue(time)).toEqual(GeoJsonDataSource.strokeWidth); + expect(entity.polygon.outlineColor.getValue(time)).toEqual(GeoJsonDataSource.stroke); + expect(entity.polygon.height).toBeUndefined(); + expect(entity.polygon.lineType.getValue(time)).toEqual(LineType.GEODESIC); }); }); @@ -777,6 +898,7 @@ defineSuite([ expect(entity.polygon.outline.getValue(time)).toEqual(true); expect(entity.polygon.outlineWidth.getValue(time)).toEqual(GeoJsonDataSource.strokeWidth); expect(entity.polygon.outlineColor.getValue(time)).toEqual(GeoJsonDataSource.stroke); + expect(entity.polygon.lineType.getValue(time)).toEqual(GeoJsonDataSource.lineType); }); }); @@ -861,6 +983,7 @@ defineSuite([ GeoJsonDataSource.stroke = Color.ORANGE; GeoJsonDataSource.strokeWidth = 8; GeoJsonDataSource.fill = Color.RED; + GeoJsonDataSource.lineType = LineType.GEODESIC; var dataSource = new GeoJsonDataSource(); return dataSource.load(mixedGeometries).then(function() { @@ -870,11 +993,13 @@ defineSuite([ var entity = entities[0]; expect(entity.polyline.material.color.getValue()).toEqual(GeoJsonDataSource.stroke); expect(entity.polyline.width.getValue()).toEqual(GeoJsonDataSource.strokeWidth); + expect(entity.polyline.lineType.getValue()).toEqual(GeoJsonDataSource.lineType); entity = entities[1]; expect(entity.polygon.material.color.getValue()).toEqual(GeoJsonDataSource.fill); expect(entity.polygon.outlineColor.getValue()).toEqual(GeoJsonDataSource.stroke); expect(entity.polygon.outlineWidth.getValue()).toEqual(GeoJsonDataSource.strokeWidth); + expect(entity.polygon.lineType.getValue()).toEqual(GeoJsonDataSource.lineType); entity = entities[2]; var expectedImage = dataSource._pinBuilder.fromMakiIconId(GeoJsonDataSource.markerSymbol, GeoJsonDataSource.markerColor, GeoJsonDataSource.markerSize); diff --git a/Specs/DataSources/PolygonGeometryUpdaterSpec.js b/Specs/DataSources/PolygonGeometryUpdaterSpec.js index 52814aaf77a2..80021cc40cfa 100644 --- a/Specs/DataSources/PolygonGeometryUpdaterSpec.js +++ b/Specs/DataSources/PolygonGeometryUpdaterSpec.js @@ -6,6 +6,7 @@ defineSuite([ 'Core/Ellipsoid', 'Core/GeometryOffsetAttribute', 'Core/JulianDate', + 'Core/LineType', 'Core/Math', 'Core/CoplanarPolygonGeometry', 'Core/CoplanarPolygonOutlineGeometry', @@ -35,6 +36,7 @@ defineSuite([ Ellipsoid, GeometryOffsetAttribute, JulianDate, + LineType, CesiumMath, CoplanarPolygonGeometry, CoplanarPolygonOutlineGeometry, @@ -227,6 +229,16 @@ defineSuite([ expect(updater.isDynamic).toBe(true); }); + it('A time-varying lineType causes geometry to be dynamic', function() { + var entity = createBasicPolygon(); + var updater = new PolygonGeometryUpdater(entity, scene); + entity.polygon.lineType = new SampledProperty(Number); + entity.polygon.lineType.addSample(time, 1); + updater._onEntityPropertyChanged(entity, 'polygon'); + + expect(updater.isDynamic).toBe(true); + }); + it('Creates geometry with expected properties', function() { var options = { height : 431, @@ -234,8 +246,9 @@ defineSuite([ granularity : 0.97, stRotation : 12, perPositionHeight : false, - closeTop: true, - closeBottom: false + closeTop : true, + closeBottom : false, + lineType : LineType.GEODESIC }; var entity = createBasicPolygon(); @@ -249,6 +262,7 @@ defineSuite([ polygon.height = new ConstantProperty(options.height); polygon.extrudedHeight = new ConstantProperty(options.extrudedHeight); polygon.granularity = new ConstantProperty(options.granularity); + polygon.lineType = new ConstantProperty(options.lineType); var updater = new PolygonGeometryUpdater(entity, scene); @@ -263,6 +277,7 @@ defineSuite([ expect(geometry._extrudedHeight).toEqual(options.extrudedHeight); expect(geometry._closeTop).toEqual(options.closeTop); expect(geometry._closeBottom).toEqual(options.closeBottom); + expect(geometry._lineType).toEqual(options.lineType); expect(geometry._offsetAttribute).toBeUndefined(); instance = updater.createOutlineGeometryInstance(time); @@ -358,6 +373,7 @@ defineSuite([ polygon.stRotation = createDynamicProperty(1); polygon.closeTop = createDynamicProperty(false); polygon.closeBottom = createDynamicProperty(false); + polygon.lineType = createDynamicProperty(LineType.RHUMB); var entity = new Entity(); entity.polygon = polygon; @@ -376,6 +392,7 @@ defineSuite([ expect(options.stRotation).toEqual(polygon.stRotation.getValue()); expect(options.closeTop).toEqual(polygon.closeTop.getValue()); expect(options.closeBottom).toEqual(polygon.closeBottom.getValue()); + expect(options.lineType).toEqual(polygon.lineType.getValue()); expect(options.offsetAttribute).toBeUndefined(); }); diff --git a/Specs/DataSources/PolygonGraphicsSpec.js b/Specs/DataSources/PolygonGraphicsSpec.js index a313822e45b6..ad368bd4a5c2 100644 --- a/Specs/DataSources/PolygonGraphicsSpec.js +++ b/Specs/DataSources/PolygonGraphicsSpec.js @@ -2,6 +2,7 @@ defineSuite([ 'DataSources/PolygonGraphics', 'Core/Color', 'Core/DistanceDisplayCondition', + 'Core/LineType', 'Core/PolygonHierarchy', 'DataSources/ColorMaterialProperty', 'DataSources/ConstantProperty', @@ -13,6 +14,7 @@ defineSuite([ PolygonGraphics, Color, DistanceDisplayCondition, + LineType, PolygonHierarchy, ColorMaterialProperty, ConstantProperty, @@ -41,6 +43,7 @@ defineSuite([ shadows : ShadowMode.DISABLED, distanceDisplayCondition : new DistanceDisplayCondition(), classificationType : ClassificationType.TERRAIN, + lineType: LineType.GEODESIC, zIndex: 22 }; @@ -62,6 +65,7 @@ defineSuite([ expect(polygon.shadows).toBeInstanceOf(ConstantProperty); expect(polygon.distanceDisplayCondition).toBeInstanceOf(ConstantProperty); expect(polygon.classificationType).toBeInstanceOf(ConstantProperty); + expect(polygon.lineType).toBeInstanceOf(ConstantProperty); expect(polygon.zIndex).toBeInstanceOf(ConstantProperty); expect(polygon.material.color.getValue()).toEqual(options.material); @@ -81,6 +85,7 @@ defineSuite([ expect(polygon.shadows.getValue()).toEqual(options.shadows); expect(polygon.distanceDisplayCondition.getValue()).toEqual(options.distanceDisplayCondition); expect(polygon.classificationType.getValue()).toEqual(options.classificationType); + expect(polygon.lineType.getValue()).toEqual(options.lineType); expect(polygon.zIndex.getValue()).toEqual(22); }); @@ -103,6 +108,7 @@ defineSuite([ source.shadows = new ConstantProperty(ShadowMode.ENABLED); source.distanceDisplayCondition = new ConstantProperty(new DistanceDisplayCondition()); source.classificationType = new ConstantProperty(ClassificationType.TERRAIN); + source.lineType = new ConstantProperty(LineType.RHUMB); source.zIndex = new ConstantProperty(30); var target = new PolygonGraphics(); @@ -125,6 +131,7 @@ defineSuite([ expect(target.shadows).toBe(source.shadows); expect(target.distanceDisplayCondition).toBe(source.distanceDisplayCondition); expect(target.classificationType).toBe(source.classificationType); + expect(target.lineType).toBe(source.lineType); expect(target.zIndex).toBe(source.zIndex); }); @@ -148,6 +155,7 @@ defineSuite([ var shadows = new ConstantProperty(); var distanceDisplayCondition = new ConstantProperty(); var classificationType = new ConstantProperty(); + var lineType = new ConstantProperty(); var zIndex = new ConstantProperty(); var target = new PolygonGraphics(); @@ -168,6 +176,7 @@ defineSuite([ target.shadows = shadows; target.distanceDisplayCondition = distanceDisplayCondition; target.classificationType = classificationType; + target.lineType = lineType; target.zIndex = zIndex; target.merge(source); @@ -189,6 +198,7 @@ defineSuite([ expect(target.shadows).toBe(shadows); expect(target.distanceDisplayCondition).toBe(distanceDisplayCondition); expect(target.classificationType).toBe(classificationType); + expect(target.lineType).toBe(lineType); expect(target.zIndex).toBe(zIndex); }); @@ -211,6 +221,7 @@ defineSuite([ source.shadows = new ConstantProperty(); source.distanceDisplayCondition = new ConstantProperty(); source.classificationType = new ConstantProperty(); + source.lineType = new ConstantProperty(); source.zIndex = new ConstantProperty(); var result = source.clone(); @@ -231,6 +242,7 @@ defineSuite([ expect(result.shadows).toBe(source.shadows); expect(result.distanceDisplayCondition).toBe(source.distanceDisplayCondition); expect(result.classificationType).toBe(source.classificationType); + expect(result.lineType).toBe(source.lineType); expect(result.zIndex).toBe(source.zIndex); }); @@ -260,6 +272,7 @@ defineSuite([ testDefinitionChanged(property, 'shadows', ShadowMode.ENABLED, ShadowMode.DISABLED); testDefinitionChanged(property, 'distanceDisplayCondition', new DistanceDisplayCondition(), new DistanceDisplayCondition(10.0, 100.0)); testDefinitionChanged(property, 'classificationType', ClassificationType.TERRAIN, ClassificationType.BOTH); + testDefinitionChanged(property, 'lineType', LineType.GEODESIC, LineType.RHUMB); testDefinitionChanged(property, 'zIndex', 54, 3); }); }); diff --git a/Specs/DataSources/PolylineGeometryUpdaterSpec.js b/Specs/DataSources/PolylineGeometryUpdaterSpec.js index 67f2e43daff3..4ed39e045dff 100644 --- a/Specs/DataSources/PolylineGeometryUpdaterSpec.js +++ b/Specs/DataSources/PolylineGeometryUpdaterSpec.js @@ -5,10 +5,12 @@ defineSuite([ 'Core/Cartesian3', 'Core/Color', 'Core/ColorGeometryInstanceAttribute', + 'Core/defined', 'Core/DistanceDisplayCondition', 'Core/DistanceDisplayConditionGeometryInstanceAttribute', 'Core/GroundPolylineGeometry', 'Core/JulianDate', + 'Core/LineType', 'Core/PolylinePipeline', 'Core/ShowGeometryInstanceAttribute', 'Core/TimeInterval', @@ -37,10 +39,12 @@ defineSuite([ Cartesian3, Color, ColorGeometryInstanceAttribute, + defined, DistanceDisplayCondition, DistanceDisplayConditionGeometryInstanceAttribute, GroundPolylineGeometry, JulianDate, + LineType, PolylinePipeline, ShowGeometryInstanceAttribute, TimeInterval, @@ -115,6 +119,7 @@ defineSuite([ expect(updater.distanceDisplayConditionProperty).toBe(undefined); expect(updater.isDynamic).toBe(false); expect(updater.clampToGround).toBe(false); + expect(updater.lineType).toBe(undefined); expect(updater.zIndex).toBe(0); expect(updater.isOutlineVisible(time)).toBe(false); @@ -159,6 +164,7 @@ defineSuite([ expect(updater.distanceDisplayConditionProperty).toEqual(new ConstantProperty(new DistanceDisplayCondition())); expect(updater.isDynamic).toBe(false); expect(updater.clampToGround).toBe(false); + expect(updater.lineType).toBe(undefined); expect(updater.zIndex).toEqual(new ConstantProperty(0)); }); @@ -229,6 +235,14 @@ defineSuite([ expect(updater.isDynamic).toBe(true); }); + it('A time-varying lineType causes geometry to be dynamic', function() { + var entity = createBasicPolyline(); + var updater = new PolylineGeometryUpdater(entity, scene); + entity.polyline.lineType = new SampledProperty(Number); + entity.polyline.lineType.addSample(time, 1); + expect(updater.isDynamic).toBe(true); + }); + it('A time-varying zIndex causes geometry to be dynamic', function() { var entity = createBasicPolyline(); var updater = new PolylineGeometryUpdater(entity, scene); @@ -251,6 +265,7 @@ defineSuite([ polyline.granularity = new ConstantProperty(options.granularity); polyline.distanceDisplayCondition = options.distanceDisplayCondition; polyline.clampToGround = new ConstantProperty(clampToGround); + polyline.lineType = new ConstantProperty(options.lineType); var updater = new PolylineGeometryUpdater(entity, scene); @@ -265,7 +280,12 @@ defineSuite([ expect(geometry.width).toEqual(options.width); } else { expect(geometry._width).toEqual(options.width); - expect(geometry._followSurface).toEqual(options.followSurface); + if (defined(options.followSurface)) { + expect(geometry._followSurface).toEqual(options.followSurface); + } + if (defined(options.lineType)) { + expect(geometry._lineType).toEqual(options.lineType); + } expect(geometry._granularity).toEqual(options.granularity); if (options.depthFailMaterial && options.depthFailMaterial instanceof ColorMaterialProperty) { @@ -293,7 +313,8 @@ defineSuite([ width : 3, followSurface : false, clampToGround : false, - granularity : 1.0 + granularity : 1.0, + lineType : LineType.STRAIGHT }); if (!Entity.supportsPolylinesOnTerrain(scene)) { @@ -307,7 +328,8 @@ defineSuite([ width : 3, followSurface : false, clampToGround : true, - granularity : 1.0 + granularity : 1.0, + lineType : LineType.GEODESIC }); }); @@ -317,9 +339,10 @@ defineSuite([ material : new ColorMaterialProperty(Color.RED), depthFailMaterial : new ColorMaterialProperty(Color.BLUE), width : 3, - followSurface : false, + followSurface : true, clampToGround : false, - granularity : 1.0 + granularity : 1.0, + lineType : LineType.GEODESIC }); }); @@ -329,9 +352,9 @@ defineSuite([ material : new ColorMaterialProperty(Color.RED), depthFailMaterial : new GridMaterialProperty(), width : 3, - followSurface : false, clampToGround : false, - granularity : 1.0 + granularity : 1.0, + lineType : LineType.RHUMB }); }); @@ -342,7 +365,8 @@ defineSuite([ width : 4, followSurface : true, clampToGround : false, - granularity : 0.5 + granularity : 0.5, + lineType: LineType.GEODESIC }); if (!Entity.supportsPolylinesOnTerrain(scene)) { @@ -356,7 +380,8 @@ defineSuite([ width : 4, followSurface : true, clampToGround : true, - granularity : 0.5 + granularity : 0.5, + lineType: LineType.GEODESIC }); }); @@ -477,6 +502,7 @@ defineSuite([ polyline.material = new ColorMaterialProperty(Color.RED); polyline.followSurface = new ConstantProperty(false); polyline.granularity = new ConstantProperty(0.001); + polyline.LineType = new ConstantProperty(LineType.STRAIGHT); var updater = new PolylineGeometryUpdater(entity, scene); @@ -499,6 +525,7 @@ defineSuite([ expect(primitive.positions.length).toEqual(2); polyline.followSurface = new ConstantProperty(true); + polyline.lineType = new ConstantProperty(LineType.GEODESIC); dynamicUpdater.update(time3); expect(primitive.width).toEqual(3); @@ -561,6 +588,54 @@ defineSuite([ updater.destroy(); }); + it('lineType can be dynamic', function() { + var entity = new Entity(); + var polyline = new PolylineGraphics(); + entity.polyline = polyline; + + var time = new JulianDate(0, 0); + + var lineTypeVar = LineType.GEODESIC; + var lineType = new CallbackProperty(function() { + return lineTypeVar; + }, false); + + polyline.show = new ConstantProperty(true); + polyline.width = new ConstantProperty(1.0); + polyline.positions = new ConstantProperty([Cartesian3.fromDegrees(0, 0, 0), Cartesian3.fromDegrees(0, 1, 0)]); + polyline.material = new ColorMaterialProperty(Color.RED); + polyline.followSurface = new ConstantProperty(true); + polyline.granularity = new ConstantProperty(0.001); + polyline.clampToGround = new ConstantProperty(true); + polyline.lineType = lineType; + + var updater = new PolylineGeometryUpdater(entity, scene); + + var groundPrimitives = scene.groundPrimitives; + expect(groundPrimitives.length).toBe(0); + + var dynamicUpdater = updater.createDynamicUpdater(scene.primitives, groundPrimitives); + expect(dynamicUpdater.isDestroyed()).toBe(false); + expect(groundPrimitives.length).toBe(0); + + dynamicUpdater.update(time); + + expect(groundPrimitives.length).toBe(1); + var primitive = groundPrimitives.get(0); + + expect(primitive.show).toEqual(true); + + lineTypeVar = false; + dynamicUpdater.update(time); + + dynamicUpdater.destroy(); + + expect(scene.primitives.length).toBe(0); + expect(groundPrimitives.length).toBe(0); + + updater.destroy(); + }); + it('geometryChanged event is raised when expected', function() { var entity = createBasicPolyline(); var updater = new PolylineGeometryUpdater(entity, scene); @@ -784,6 +859,24 @@ defineSuite([ scene.globe = new Globe(); }); + it('lineType GEODESIC with undefined globe does not call generateCartesianArc', function() { + var entity = createBasicPolyline(); + entity.polyline.width = createDynamicProperty(1); + scene.globe = undefined; + var updater = new PolylineGeometryUpdater(entity, scene); + var dynamicUpdater = updater.createDynamicUpdater(scene.primitives, scene.groundPrimitives); + spyOn(PolylinePipeline, 'generateCartesianArc').and.callThrough(); + dynamicUpdater.update(time); + expect(PolylinePipeline.generateCartesianArc).not.toHaveBeenCalled(); + dynamicUpdater.destroy(); + updater.destroy(); + + expect(scene.primitives.length).toBe(0); + expect(scene.groundPrimitives.length).toBe(0); + + scene.globe = new Globe(); + }); + it('clampToGround true without support for polylines on terrain does not generate GroundPolylineGeometry', function() { spyOn(Entity, 'supportsPolylinesOnTerrain').and.callFake(function() { return false; diff --git a/Specs/DataSources/PolylineGraphicsSpec.js b/Specs/DataSources/PolylineGraphicsSpec.js index b44bb4244dfe..ee61edc5530c 100644 --- a/Specs/DataSources/PolylineGraphicsSpec.js +++ b/Specs/DataSources/PolylineGraphicsSpec.js @@ -2,6 +2,7 @@ defineSuite([ 'DataSources/PolylineGraphics', 'Core/Color', 'Core/DistanceDisplayCondition', + 'Core/LineType', 'DataSources/ColorMaterialProperty', 'DataSources/ConstantProperty', 'Scene/ClassificationType', @@ -12,6 +13,7 @@ defineSuite([ PolylineGraphics, Color, DistanceDisplayCondition, + LineType, ColorMaterialProperty, ConstantProperty, ClassificationType, @@ -33,6 +35,7 @@ defineSuite([ shadows : ShadowMode.DISABLED, distanceDisplayCondition : new DistanceDisplayCondition(), classificationType : ClassificationType.TERRAIN, + lineType: LineType.GEODESIC, zIndex : 0 }; @@ -48,6 +51,7 @@ defineSuite([ expect(polyline.shadows).toBeInstanceOf(ConstantProperty); expect(polyline.distanceDisplayCondition).toBeInstanceOf(ConstantProperty); expect(polyline.classificationType).toBeInstanceOf(ConstantProperty); + expect(polyline.lineType).toBeInstanceOf(ConstantProperty); expect(polyline.zIndex).toBeInstanceOf(ConstantProperty); expect(polyline.material.color.getValue()).toEqual(options.material); @@ -61,6 +65,7 @@ defineSuite([ expect(polyline.shadows.getValue()).toEqual(options.shadows); expect(polyline.distanceDisplayCondition.getValue()).toEqual(options.distanceDisplayCondition); expect(polyline.classificationType.getValue()).toEqual(options.classificationType); + expect(polyline.lineType.getValue()).toEqual(options.lineType); expect(polyline.zIndex.getValue()).toEqual(options.zIndex); }); @@ -77,6 +82,7 @@ defineSuite([ source.shadows = new ConstantProperty(ShadowMode.ENABLED); source.distanceDisplayCondition = new ConstantProperty(new DistanceDisplayCondition()); source.classificationType = new ConstantProperty(ClassificationType.TERRAIN); + source.lineType = new ConstantProperty(LineType.GEODESIC); source.zIndex = new ConstantProperty(); var target = new PolylineGraphics(); @@ -92,6 +98,7 @@ defineSuite([ expect(target.shadows).toBe(source.shadows); expect(target.distanceDisplayCondition).toBe(source.distanceDisplayCondition); expect(target.classificationType).toBe(source.classificationType); + expect(target.lineType).toBe(source.lineType); expect(target.zIndex).toBe(source.zIndex); }); @@ -108,6 +115,7 @@ defineSuite([ source.shadows = new ConstantProperty(); source.distanceDisplayCondition = new ConstantProperty(); source.classificationType = new ConstantProperty(); + source.lineType = new ConstantProperty(); source.zIndex = new ConstantProperty(); var color = new ColorMaterialProperty(); @@ -121,6 +129,7 @@ defineSuite([ var shadows = new ConstantProperty(); var distanceDisplayCondition = new ConstantProperty(); var classificationType = new ConstantProperty(); + var lineType = new ConstantProperty(); var zIndex = new ConstantProperty(); var target = new PolylineGraphics(); @@ -135,6 +144,7 @@ defineSuite([ target.shadows = shadows; target.distanceDisplayCondition = distanceDisplayCondition; target.classificationType = classificationType; + target.lineType = lineType; target.zIndex = zIndex; target.merge(source); @@ -149,6 +159,7 @@ defineSuite([ expect(target.shadows).toBe(shadows); expect(target.distanceDisplayCondition).toBe(distanceDisplayCondition); expect(target.classificationType).toBe(classificationType); + expect(target.lineType).toBe(lineType); expect(target.zIndex).toBe(zIndex); }); @@ -165,6 +176,7 @@ defineSuite([ source.shadows = new ConstantProperty(); source.distanceDisplayCondition = new ConstantProperty(); source.classificationType = new ConstantProperty(); + source.lineType = new ConstantProperty(); source.zIndex = new ConstantProperty(); var result = source.clone(); @@ -179,6 +191,7 @@ defineSuite([ expect(result.shadows).toBe(source.shadows); expect(result.distanceDisplayCondition).toBe(source.distanceDisplayCondition); expect(result.classificationType).toBe(source.classificationType); + expect(result.lineType).toBe(source.lineType); expect(result.zIndex).toBe(source.zIndex); }); @@ -202,6 +215,7 @@ defineSuite([ testDefinitionChanged(property, 'shadows', ShadowMode.ENABLED, ShadowMode.DISABLED); testDefinitionChanged(property, 'distanceDisplayCondition', new DistanceDisplayCondition(), new DistanceDisplayCondition(10.0, 20.0)); testDefinitionChanged(property, 'classificationType', ClassificationType.TERRAIN); + testDefinitionChanged(property, 'lineType', LineType.GEODESIC, LineType.RHUMB); testDefinitionChanged(property, 'zIndex', 20, 5); }); }); From 9cbc2483f804412fef4c8f9004970954c63f7905 Mon Sep 17 00:00:00 2001 From: Shehzan Mohammed Date: Thu, 17 Jan 2019 11:31:00 -0500 Subject: [PATCH 10/26] Remove usage of EllipsoidRhumbLine.fromStartAndEnd --- Source/Core/GroundPolylineGeometry.js | 7 +++---- Source/Core/PolygonGeometryLibrary.js | 5 ++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Source/Core/GroundPolylineGeometry.js b/Source/Core/GroundPolylineGeometry.js index 271aefbf2ff3..adaf9e1a2850 100644 --- a/Source/Core/GroundPolylineGeometry.js +++ b/Source/Core/GroundPolylineGeometry.js @@ -413,7 +413,6 @@ define([ var cartographicScratch0 = new Cartographic(); var cartographicScratch1 = new Cartographic(); var cartographicIntersectionScratch = new Cartographic(); - var rhumbLineScratch = new EllipsoidRhumbLine(); /** * Computes shadow volumes for the ground polyline, consisting of its vertices, indices, and a bounding sphere. * Vertices are "fat," packing all the data needed in each volume to describe a line on terrain or 3D Tiles. @@ -450,7 +449,7 @@ define([ var p1; var c0; var c1; - var rhumbLine; + var rhumbLine = new EllipsoidRhumbLine(undefined, undefined, ellipsoid); var intersection; var intersectionCartographic; var intersectionLongitude; @@ -468,7 +467,7 @@ define([ intersectionLongitude = ellipsoid.cartesianToCartographic(intersection, cartographicScratch0).longitude; c0 = ellipsoid.cartesianToCartographic(p0, cartographicScratch0); c1 = ellipsoid.cartesianToCartographic(p1, cartographicScratch1); - rhumbLine = EllipsoidRhumbLine.fromStartAndEnd(c0, c1, ellipsoid, rhumbLineScratch); + rhumbLine.setEndPoints(c0, c1); intersectionCartographic = rhumbLine.findIntersectionWithLongitude(intersectionLongitude, cartographicIntersectionScratch); intersection = ellipsoid.cartographicToCartesian(intersectionCartographic, intersectionScratch); if (defined(intersection) && @@ -494,7 +493,7 @@ define([ intersectionLongitude = ellipsoid.cartesianToCartographic(intersection, cartographicScratch0).longitude; c0 = ellipsoid.cartesianToCartographic(p0, cartographicScratch0); c1 = ellipsoid.cartesianToCartographic(p1, cartographicScratch1); - rhumbLine = EllipsoidRhumbLine.fromStartAndEnd(c0, c1, ellipsoid, rhumbLineScratch); + rhumbLine.setEndPoints(c0, c1); intersectionCartographic = rhumbLine.findIntersectionWithLongitude(intersectionLongitude, cartographicIntersectionScratch); intersection = ellipsoid.cartographicToCartesian(intersectionCartographic, intersectionScratch); if (defined(intersection) && diff --git a/Source/Core/PolygonGeometryLibrary.js b/Source/Core/PolygonGeometryLibrary.js index 4453f2b85ce3..7de8b8791ffd 100644 --- a/Source/Core/PolygonGeometryLibrary.js +++ b/Source/Core/PolygonGeometryLibrary.js @@ -151,7 +151,6 @@ define([ return Math.pow(2, countDivide); }; - var scratchEllipsoidRhumb = new EllipsoidRhumbLine(); var scratchCartographic0 = new Cartographic(); var scratchCartographic1 = new Cartographic(); var scratchCartographic2 = new Cartographic(); @@ -159,7 +158,7 @@ define([ PolygonGeometryLibrary.subdivideRhumbLineCount = function(ellipsoid, p0, p1, minDistance) { var c0 = ellipsoid.cartesianToCartographic(p0, scratchCartographic0); var c1 = ellipsoid.cartesianToCartographic(p1, scratchCartographic1); - var rhumb = EllipsoidRhumbLine.fromStartAndEnd(c0, c1, ellipsoid, scratchEllipsoidRhumb); + var rhumb = new EllipsoidRhumbLine(c0, c1, ellipsoid); var n = rhumb.surfaceDistance / minDistance; var countDivide = Math.max(0, Math.ceil(Math.log(n) / Math.log(2))); return Math.pow(2, countDivide); @@ -192,7 +191,7 @@ define([ var numVertices = PolygonGeometryLibrary.subdivideRhumbLineCount(ellipsoid, p0, p1, minDistance); var c0 = ellipsoid.cartesianToCartographic(p0, scratchCartographic0); var c1 = ellipsoid.cartesianToCartographic(p1, scratchCartographic1); - var rhumb = EllipsoidRhumbLine.fromStartAndEnd(c0, c1, ellipsoid, scratchEllipsoidRhumb); + var rhumb = new EllipsoidRhumbLine(c0, c1, ellipsoid); var distanceBetweenVertices = rhumb.surfaceDistance / numVertices; if (!defined(result)) { From 851a21eb4a4fb4f949b066d583385d68018a289d Mon Sep 17 00:00:00 2001 From: Shehzan Mohammed Date: Thu, 17 Jan 2019 14:20:24 -0500 Subject: [PATCH 11/26] Fix propagation of lineType from shadow volume --- Source/Core/PolygonGeometry.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Core/PolygonGeometry.js b/Source/Core/PolygonGeometry.js index 9fc8c825d93a..b8a1207c11c9 100644 --- a/Source/Core/PolygonGeometry.js +++ b/Source/Core/PolygonGeometry.js @@ -975,7 +975,8 @@ define([ extrudedHeight : minHeight, height : maxHeight, vertexFormat : VertexFormat.POSITION_ONLY, - shadowVolume: true + shadowVolume: true, + lineType : polygonGeometry._lineType }); }; From 39e6d9557121e9fe8a77152ed203beafa86bdd3e Mon Sep 17 00:00:00 2001 From: Shehzan Mohammed Date: Thu, 17 Jan 2019 14:20:52 -0500 Subject: [PATCH 12/26] Add rhumb line polygons and polylines to sandcastle examples --- Apps/Sandcastle/gallery/Polygon.html | 15 ++++++++++++ Apps/Sandcastle/gallery/Polyline.html | 13 ++++++++++- .../gallery/development/Ground Primitive.html | 23 ++++++++++++++++++- .../gallery/development/Polylines.html | 14 +++++++++++ 4 files changed, 63 insertions(+), 2 deletions(-) diff --git a/Apps/Sandcastle/gallery/Polygon.html b/Apps/Sandcastle/gallery/Polygon.html index e5052bbc06f5..d17262108afd 100644 --- a/Apps/Sandcastle/gallery/Polygon.html +++ b/Apps/Sandcastle/gallery/Polygon.html @@ -125,6 +125,21 @@ } }); +var purplePolygonUsingRhumbLines = viewer.entities.add({ + name : 'Purple polygon using rhumb lines with outline', + polygon : { + hierarchy : Cesium.Cartesian3.fromDegreesArray([-120.0, 45.0, + -80.0, 45.0, + -80.0, 55.0, + -120.0, 55.0]), + extrudedHeight: 50000, + material : Cesium.Color.PURPLE, + outline : true, + outlineColor : Cesium.Color.MAGENTA, + lineType : Cesium.LineType.RHUMB + } +}); + viewer.zoomTo(viewer.entities);//Sandcastle_End Sandcastle.finishedLoading(); } diff --git a/Apps/Sandcastle/gallery/Polyline.html b/Apps/Sandcastle/gallery/Polyline.html index 6ae30db914c5..a05226f3e885 100644 --- a/Apps/Sandcastle/gallery/Polyline.html +++ b/Apps/Sandcastle/gallery/Polyline.html @@ -40,6 +40,17 @@ } }); +var greenRhumbLine = viewer.entities.add({ + name : 'Green rhumb line', + polyline : { + positions : Cesium.Cartesian3.fromDegreesArray([-75, 35, + -125, 35]), + width : 5, + lineType : Cesium.LineType.RHUMB, + material : Cesium.Color.GREEN + } +}); + var glowingLine = viewer.entities.add({ name : 'Glowing blue line on the surface', polyline : { @@ -73,7 +84,7 @@ positions : Cesium.Cartesian3.fromDegreesArrayHeights([-75, 43, 500000, -125, 43, 500000]), width : 10, - followSurface : false, + lineType : Cesium.LineType.STRAIGHT, material : new Cesium.PolylineArrowMaterialProperty(Cesium.Color.PURPLE) } }); diff --git a/Apps/Sandcastle/gallery/development/Ground Primitive.html b/Apps/Sandcastle/gallery/development/Ground Primitive.html index 7406c23b0225..96a6c6199c2f 100644 --- a/Apps/Sandcastle/gallery/development/Ground Primitive.html +++ b/Apps/Sandcastle/gallery/development/Ground Primitive.html @@ -31,6 +31,7 @@ terrainProvider: Cesium.createWorldTerrain() }); var scene = viewer.scene; +viewer.extend(Cesium.viewerCesiumInspectorMixin); function offsetPositions(positions, degreeOffset) { positions = scene.globe.ellipsoid.cartesianArrayToCartographicArray(positions); @@ -260,7 +261,7 @@ }, Cesium.ScreenSpaceEventType.MOUSE_MOVE); }); -Sandcastle.addToolbarButton('Create large polygons', function() { +Sandcastle.addDefaultToolbarButton('Create large polygons', function() { // Circle geometry scene.groundPrimitives.add(new Cesium.GroundPrimitive({ geometryInstances : new Cesium.GeometryInstance({ @@ -325,6 +326,26 @@ }), classificationType : Cesium.ClassificationType.TERRAIN })); + + // Rhumb line polygon geometry + scene.groundPrimitives.add(new Cesium.GroundPrimitive({ + geometryInstances : new Cesium.GeometryInstance({ + geometry : new Cesium.PolygonGeometry({ + polygonHierarchy: new Cesium.PolygonHierarchy(Cesium.Cartesian3.fromDegreesArray([ + -130, 55, + -100, 55, + -100, 45, + -130, 45 + ])), + lineType : Cesium.LineType.RHUMB + }), + attributes: { + color: Cesium.ColorGeometryInstanceAttribute.fromColor(new Cesium.Color(1.0, 1.0, 0.0, 0.5)) + }, + id : 'rhumbPolygon' + }), + classificationType : Cesium.ClassificationType.TERRAIN + })); }); Sandcastle.reset = function() { diff --git a/Apps/Sandcastle/gallery/development/Polylines.html b/Apps/Sandcastle/gallery/development/Polylines.html index 2f40bfaebf59..db16318e2ddc 100644 --- a/Apps/Sandcastle/gallery/development/Polylines.html +++ b/Apps/Sandcastle/gallery/development/Polylines.html @@ -119,6 +119,20 @@ }) }); Sandcastle.declare(fadingPolyline); // For highlighting on mouseover in Sandcastle. + + // A rhumb line with two points. + var rhumbLine = polylines.add({ + positions : Cesium.PolylinePipeline.generateCartesianRhumbArc({ + positions : Cesium.Cartesian3.fromDegreesArray([-130.0, 30.0, + -75.0, 30.0]) + }), + width: 5, + material : Cesium.Material.fromType('Color', { + color : new Cesium.Color(0.0, 1.0, 0.0, 1.0) + }) + }); + Sandcastle.declare(rhumbLine); // For highlighting on mouseover in Sandcastle. + } var viewer = new Cesium.Viewer('cesiumContainer'); From 739eb52d672397f0b5ad698c0137f5e8d2854c75 Mon Sep 17 00:00:00 2001 From: Shehzan Mohammed Date: Fri, 18 Jan 2019 10:43:22 -0500 Subject: [PATCH 13/26] Update CHANGES.md --- CHANGES.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 0e481e64659c..afe7113d0594 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -9,6 +9,8 @@ Change Log ##### Deprecated :hourglass_flowing_sand: * `Scene.clampToHeight` now takes an optional `width` argument before the `result` argument. The previous function definition will no longer work in 1.56. [#7287](https://github.com/AnalyticalGraphicsInc/cesium/pull/7287) +* `PolylineGeometry.followSurface` has been superceded by `PolylineGeometry.lineType`. The previous definition will no longer work in 1.55. +* `SimplePolylineGeometry.followSurface` has been superceded by `SimplePolylineGeometry.lineType`. The previous definition will no longer work in 1.55. ##### Additions :tada: * Added support for textured ground entities (entities with unspecified `height`) and `GroundPrimitives` on 3D Tiles. [#7434](https://github.com/AnalyticalGraphicsInc/cesium/pull/7434) @@ -17,6 +19,8 @@ Change Log * Added the ability to specify the width of the intersection volume for `Scene.sampleHeight`, `Scene.clampToHeight`, `Scene.sampleHeightMostDetailed`, and `Scene.clampToHeightMostDetailed`. [#7287](https://github.com/AnalyticalGraphicsInc/cesium/pull/7287) * Added a [new Sandcastle example](https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/?src=Time%20Dynamic%20Wheels.html) on using `nodeTransformations` to rotate a model's wheels based on its velocity. [#7361](https://github.com/AnalyticalGraphicsInc/cesium/pull/7361) * Added `EllipsoidRhumbLine` class as a rhumb line counterpart to `EllipsoidGeodesic`. [#7484](https://github.com/AnalyticalGraphicsInc/cesium/pull/7484) +* Added rhumb line support to `PolygonGeometry`, `PolygonOutlineGeometry`, `PolylineGeometry`, `GroundPolylineGeometry`, and `SimplePolylineGeometry`. +* Added `lineType` as optional parameter to `GeoJsonDataSource`. ##### Fixes :wrench: * Fixed 3D Tiles performance regression. [#7482](https://github.com/AnalyticalGraphicsInc/cesium/pull/7482) @@ -27,6 +31,7 @@ Change Log * Fixed image size issue when using multiple particle systems. [#7412](https://github.com/AnalyticalGraphicsInc/cesium/pull/7412) * Fixed Sandcastle's "Open in New Window" button not displaying imagery due to blob URI limitations. [#7250](https://github.com/AnalyticalGraphicsInc/cesium/pull/7250) * Fixed an issue where setting `scene.globe.cartographicLimitRectangle` to `undefined` would cause a crash. [#7477](https://github.com/AnalyticalGraphicsInc/cesium/issues/7477) +* Fixed `GeoJsonDataSource` to use polygons and polylines that use rhumb lines. ### 1.53 - 2019-01-02 From 62b28a842710d1d5e679aa3ac3289da092e735ca Mon Sep 17 00:00:00 2001 From: Shehzan Mohammed Date: Fri, 18 Jan 2019 11:21:51 -0500 Subject: [PATCH 14/26] Fix tests failing because of ground primitives --- Specs/DataSources/PolylineGeometryUpdaterSpec.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Specs/DataSources/PolylineGeometryUpdaterSpec.js b/Specs/DataSources/PolylineGeometryUpdaterSpec.js index 4ed39e045dff..f58baa5a5677 100644 --- a/Specs/DataSources/PolylineGeometryUpdaterSpec.js +++ b/Specs/DataSources/PolylineGeometryUpdaterSpec.js @@ -589,6 +589,10 @@ defineSuite([ }); it('lineType can be dynamic', function() { + if (!Entity.supportsPolylinesOnTerrain(scene)) { + return; + } + var entity = new Entity(); var polyline = new PolylineGraphics(); entity.polyline = polyline; @@ -842,6 +846,10 @@ defineSuite([ }); it('followSurface true with undefined globe does not call generateCartesianArc', function() { + if (!Entity.supportsPolylinesOnTerrain(scene)) { + return; + } + var entity = createBasicPolyline(); entity.polyline.width = createDynamicProperty(1); scene.globe = undefined; @@ -860,6 +868,10 @@ defineSuite([ }); it('lineType GEODESIC with undefined globe does not call generateCartesianArc', function() { + if (!Entity.supportsPolylinesOnTerrain(scene)) { + return; + } + var entity = createBasicPolyline(); entity.polyline.width = createDynamicProperty(1); scene.globe = undefined; From 2745a2d5fe701e7a33c493013db483336dd79ff8 Mon Sep 17 00:00:00 2001 From: Shehzan Mohammed Date: Fri, 18 Jan 2019 16:16:43 -0500 Subject: [PATCH 15/26] Revert inadvertent change to sandcastle --- Apps/Sandcastle/gallery/development/Ground Primitive.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Apps/Sandcastle/gallery/development/Ground Primitive.html b/Apps/Sandcastle/gallery/development/Ground Primitive.html index 96a6c6199c2f..fa38f9035d0e 100644 --- a/Apps/Sandcastle/gallery/development/Ground Primitive.html +++ b/Apps/Sandcastle/gallery/development/Ground Primitive.html @@ -261,7 +261,7 @@ }, Cesium.ScreenSpaceEventType.MOUSE_MOVE); }); -Sandcastle.addDefaultToolbarButton('Create large polygons', function() { +Sandcastle.addToolbarButton('Create large polygons', function() { // Circle geometry scene.groundPrimitives.add(new Cesium.GroundPrimitive({ geometryInstances : new Cesium.GeometryInstance({ From 9ee96b7f4ae7fe6ece3cec9c077501b1d5a7e9d5 Mon Sep 17 00:00:00 2001 From: Shehzan Mohammed Date: Mon, 21 Jan 2019 09:50:57 -0500 Subject: [PATCH 16/26] Add PR numbers to CHANGES.md --- CHANGES.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index ab1367e24c85..da965684333f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -19,8 +19,8 @@ Change Log * Added the ability to specify the width of the intersection volume for `Scene.sampleHeight`, `Scene.clampToHeight`, `Scene.sampleHeightMostDetailed`, and `Scene.clampToHeightMostDetailed`. [#7287](https://github.com/AnalyticalGraphicsInc/cesium/pull/7287) * Added a [new Sandcastle example](https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/?src=Time%20Dynamic%20Wheels.html) on using `nodeTransformations` to rotate a model's wheels based on its velocity. [#7361](https://github.com/AnalyticalGraphicsInc/cesium/pull/7361) * Added `EllipsoidRhumbLine` class as a rhumb line counterpart to `EllipsoidGeodesic`. [#7484](https://github.com/AnalyticalGraphicsInc/cesium/pull/7484) -* Added rhumb line support to `PolygonGeometry`, `PolygonOutlineGeometry`, `PolylineGeometry`, `GroundPolylineGeometry`, and `SimplePolylineGeometry`. -* Added `lineType` as optional parameter to `GeoJsonDataSource`. +* Added rhumb line support to `PolygonGeometry`, `PolygonOutlineGeometry`, `PolylineGeometry`, `GroundPolylineGeometry`, and `SimplePolylineGeometry`. [#7492](https://github.com/AnalyticalGraphicsInc/cesium/pull/7492) +* Added `lineType` as optional parameter to `GeoJsonDataSource`. [#7492](https://github.com/AnalyticalGraphicsInc/cesium/pull/7492) ##### Fixes :wrench: * Fixed 3D Tiles performance regression. [#7482](https://github.com/AnalyticalGraphicsInc/cesium/pull/7482) @@ -32,7 +32,7 @@ Change Log * Fixed Sandcastle's "Open in New Window" button not displaying imagery due to blob URI limitations. [#7250](https://github.com/AnalyticalGraphicsInc/cesium/pull/7250) * Fixed an issue where setting `scene.globe.cartographicLimitRectangle` to `undefined` would cause a crash. [#7477](https://github.com/AnalyticalGraphicsInc/cesium/issues/7477) * Fixed `PrimitiveCollection.removeAll` to no longer `contain` removed primitives. [#7491](https://github.com/AnalyticalGraphicsInc/cesium/pull/7491) -* Fixed `GeoJsonDataSource` to use polygons and polylines that use rhumb lines. +* Fixed `GeoJsonDataSource` to use polygons and polylines that use rhumb lines. [#7492](https://github.com/AnalyticalGraphicsInc/cesium/pull/7492) ### 1.53 - 2019-01-02 From a47ebd13858bc1fc59db3044ef95d35c14e5e65a Mon Sep 17 00:00:00 2001 From: Shehzan Mohammed Date: Tue, 22 Jan 2019 13:46:46 -0500 Subject: [PATCH 17/26] Fixes from PR comments --- Source/Core/GroundPolylineGeometry.js | 4 +- Source/Core/PolygonGeometry.js | 5 +- Source/Core/PolygonGeometryLibrary.js | 4 +- Source/Core/PolygonOutlineGeometry.js | 17 ++- Source/Core/PolygonPipeline.js | 9 +- Source/Core/PolylineGeometry.js | 111 ++++++------------ Source/Core/PolylinePipeline.js | 3 + Source/Core/SimplePolylineGeometry.js | 28 ++++- Source/DataSources/GeoJsonDataSource.js | 6 +- Source/DataSources/PolylineGeometryUpdater.js | 4 +- Source/DataSources/PolylineGraphics.js | 2 - Specs/Core/PolygonPipelineSpec.js | 2 +- Specs/Core/PolylineGeometrySpec.js | 15 +-- Specs/Core/SimplePolylineGeometrySpec.js | 2 +- Specs/DataSources/GeoJsonDataSourceSpec.js | 1 - .../PolylineGeometryUpdaterSpec.js | 23 ++-- 16 files changed, 98 insertions(+), 138 deletions(-) diff --git a/Source/Core/GroundPolylineGeometry.js b/Source/Core/GroundPolylineGeometry.js index adaf9e1a2850..3a99a74c3934 100644 --- a/Source/Core/GroundPolylineGeometry.js +++ b/Source/Core/GroundPolylineGeometry.js @@ -84,7 +84,7 @@ define([ * @param {Number} [options.width=1.0] The screen space width in pixels. * @param {Number} [options.granularity=9999.0] The distance interval in meters used for interpolating options.points. Defaults to 9999.0 meters. Zero indicates no interpolation. * @param {Boolean} [options.loop=false] Whether during geometry creation a line segment will be added between the last and first line positions to make this Polyline a loop. - * @param {LineType} [options.lineType=LineType.GEODESIC] The type of line the polyline segments must follow. + * @param {LineType} [options.lineType=LineType.GEODESIC] The type of line the polyline segments must follow. Valid options are {@link LineType.GEODESIC} and {@link LineType.RHUMB}. * * @exception {DeveloperError} At least two positions are required. * @@ -139,7 +139,7 @@ define([ this.loop = defaultValue(options.loop, false); /** - * The type of path the polyline must follow. + * The type of path the polyline must follow. Valid options are {@link LineType.GEODESIC} and {@link LineType.RHUMB}. * @type {LineType} * @default LineType.GEODESIC */ diff --git a/Source/Core/PolygonGeometry.js b/Source/Core/PolygonGeometry.js index b8a1207c11c9..dd0dea876afa 100644 --- a/Source/Core/PolygonGeometry.js +++ b/Source/Core/PolygonGeometry.js @@ -500,7 +500,7 @@ define([ * @param {Boolean} [options.perPositionHeight=false] Use the height of options.positions for each position instead of using options.height to determine the height. * @param {Boolean} [options.closeTop=true] When false, leaves off the top of an extruded polygon open. * @param {Boolean} [options.closeBottom=true] When false, leaves off the bottom of an extruded polygon open. - * @param {LineType} [options.lineType=LineType.GEODESIC] The type of line the polygon edges must follow. + * @param {LineType} [options.lineType=LineType.GEODESIC] The type of line the polygon edges must follow. Valid options are {@link LineType.GEODESIC} and {@link LineType.RHUMB}. * * @see PolygonGeometry#createGeometry * @see PolygonGeometry#fromPositions @@ -582,7 +582,7 @@ define([ throw new DeveloperError('Cannot use both options.perPositionHeight and options.height'); } if (defined(options.lineType) && options.lineType === LineType.STRAIGHT) { - throw new DeveloperError('Cannot use option.lineType as LineType.STRAIGHT'); + throw new DeveloperError('Cannot use {@link LineType.STRAIGHT} as option.lineType'); } //>>includeEnd('debug'); @@ -642,6 +642,7 @@ define([ * @param {Boolean} [options.perPositionHeight=false] Use the height of options.positions for each position instead of using options.height to determine the height. * @param {Boolean} [options.closeTop=true] When false, leaves off the top of an extruded polygon open. * @param {Boolean} [options.closeBottom=true] When false, leaves off the bottom of an extruded polygon open. + * @param {LineType} [options.lineType=LineType.GEODESIC] The type of line the polygon edges must follow. Valid options are {@link LineType.GEODESIC} and {@link LineType.RHUMB}. * @returns {PolygonGeometry} * * diff --git a/Source/Core/PolygonGeometryLibrary.js b/Source/Core/PolygonGeometryLibrary.js index 7de8b8791ffd..b573656f878b 100644 --- a/Source/Core/PolygonGeometryLibrary.js +++ b/Source/Core/PolygonGeometryLibrary.js @@ -147,7 +147,7 @@ define([ PolygonGeometryLibrary.subdivideLineCount = function(p0, p1, minDistance) { var distance = Cartesian3.distance(p0, p1); var n = distance / minDistance; - var countDivide = Math.max(0, Math.ceil(Math.log(n) / Math.log(2))); + var countDivide = Math.max(0, Math.ceil(CesiumMath.log2(n))); return Math.pow(2, countDivide); }; @@ -160,7 +160,7 @@ define([ var c1 = ellipsoid.cartesianToCartographic(p1, scratchCartographic1); var rhumb = new EllipsoidRhumbLine(c0, c1, ellipsoid); var n = rhumb.surfaceDistance / minDistance; - var countDivide = Math.max(0, Math.ceil(Math.log(n) / Math.log(2))); + var countDivide = Math.max(0, Math.ceil(CesiumMath.log2(n))); return Math.pow(2, countDivide); }; diff --git a/Source/Core/PolygonOutlineGeometry.js b/Source/Core/PolygonOutlineGeometry.js index 39116352bb4a..c96fc1509824 100644 --- a/Source/Core/PolygonOutlineGeometry.js +++ b/Source/Core/PolygonOutlineGeometry.js @@ -54,7 +54,7 @@ define([ var createGeometryFromPositionsPositions = []; var createGeometryFromPositionsSubdivided = []; - function createGeometryFromPositions(ellipsoid, positions, granularity, perPositionHeight, lineType) { + function createGeometryFromPositions(ellipsoid, positions, minDistance, perPositionHeight, lineType) { var tangentPlane = EllipsoidTangentPlane.fromPoints(positions, ellipsoid); var positions2D = tangentPlane.projectPointsOntoPlane(positions, createGeometryFromPositionsPositions); @@ -64,8 +64,6 @@ define([ positions = positions.slice().reverse(); } - var minDistance = CesiumMath.chordLength(granularity, ellipsoid.maximumRadius); - var subdividedPositions; var i; @@ -136,7 +134,7 @@ define([ }); } - function createGeometryFromPositionsExtruded(ellipsoid, positions, granularity, perPositionHeight, lineType) { + function createGeometryFromPositionsExtruded(ellipsoid, positions, minDistance, perPositionHeight, lineType) { var tangentPlane = EllipsoidTangentPlane.fromPoints(positions, ellipsoid); var positions2D = tangentPlane.projectPointsOntoPlane(positions, createGeometryFromPositionsPositions); @@ -146,8 +144,6 @@ define([ positions = positions.slice().reverse(); } - var minDistance = CesiumMath.chordLength(granularity, ellipsoid.maximumRadius); - var subdividedPositions; var i; @@ -246,7 +242,7 @@ define([ * @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. - * @param {LineType} [options.lineType=LineType.GEODESIC] The type of path the outline must follow. + * @param {LineType} [options.lineType=LineType.GEODESIC] The type of path the outline must follow. Valid options are {@link LineType.GEODESIC} and {@link LineType.RHUMB}. * * @see PolygonOutlineGeometry#createGeometry * @see PolygonOutlineGeometry#fromPositions @@ -463,7 +459,7 @@ define([ * @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. - * @param {LineType} [options.lineType=LineType.GEODESIC] The type of path the outline must follow. + * @param {LineType} [options.lineType=LineType.GEODESIC] The type of path the outline must follow. Valid options are {@link LinkType.GEODESIC} and {@link LineType.RHUMB}. * @returns {PolygonOutlineGeometry} * * @@ -525,6 +521,7 @@ define([ var geometryInstance; var geometries = []; + var minDistance = CesiumMath.chordLength(granularity, ellipsoid.maximumRadius); var height = polygonGeometry._height; var extrudedHeight = polygonGeometry._extrudedHeight; @@ -533,7 +530,7 @@ define([ var i; if (extrude) { for (i = 0; i < polygons.length; i++) { - geometryInstance = createGeometryFromPositionsExtruded(ellipsoid, polygons[i], granularity, perPositionHeight, lineType); + geometryInstance = createGeometryFromPositionsExtruded(ellipsoid, polygons[i], minDistance, perPositionHeight, lineType); geometryInstance.geometry = PolygonGeometryLibrary.scaleToGeodeticHeightExtruded(geometryInstance.geometry, height, extrudedHeight, ellipsoid, perPositionHeight); if (defined(polygonGeometry._offsetAttribute)) { var size = geometryInstance.geometry.attributes.position.values.length / 3; @@ -555,7 +552,7 @@ define([ } } else { for (i = 0; i < polygons.length; i++) { - geometryInstance = createGeometryFromPositions(ellipsoid, polygons[i], granularity, perPositionHeight, lineType); + geometryInstance = createGeometryFromPositions(ellipsoid, polygons[i], minDistance, perPositionHeight, lineType); geometryInstance.geometry.attributes.position.values = PolygonPipeline.scaleToGeodeticHeight(geometryInstance.geometry.attributes.position.values, height, ellipsoid, !perPositionHeight); if (defined(polygonGeometry._offsetAttribute)) { diff --git a/Source/Core/PolygonPipeline.js b/Source/Core/PolygonPipeline.js index 78f5056c07ed..cd59af0c3530 100644 --- a/Source/Core/PolygonPipeline.js +++ b/Source/Core/PolygonPipeline.js @@ -310,8 +310,7 @@ define([ var midHeight; var midCartesian3; - // if the max length squared of a triangle edge is greater than the chord length of squared - // of the granularity, subdivide the triangle + // if the max length squared of a triangle edge is greater than squared granularity, subdivide the triangle if (max > granularitySqrd) { if (g0 === max) { edge = Math.min(i0, i1) + ' ' + Math.max(i0, i1); @@ -320,7 +319,7 @@ define([ if (!defined(i)) { mid = Cartesian2.add(c0Cart2, c1Cart2, subdivisionMidCart2Scratch); Cartesian2.multiplyByScalar(mid, 0.5, mid); - midHeight = (c0.height + c1.height) / 2.0; + midHeight = (c0.height + c1.height) * 0.5; midCartesian3 = Cartesian3.fromRadians(mid.x, mid.y, midHeight, ellipsoid, subdivisionMidScratch); subdividedPositions.push(midCartesian3.x, midCartesian3.y, midCartesian3.z); i = subdividedPositions.length / 3 - 1; @@ -336,7 +335,7 @@ define([ if (!defined(i)) { mid = Cartesian2.add(c1Cart2, c2Cart2, subdivisionMidCart2Scratch); Cartesian2.multiplyByScalar(mid, 0.5, mid); - midHeight = (c1.height + c2.height) / 2.0; + midHeight = (c1.height + c2.height) * 0.5; midCartesian3 = Cartesian3.fromRadians(mid.x, mid.y, midHeight, ellipsoid, subdivisionMidScratch); subdividedPositions.push(midCartesian3.x, midCartesian3.y, midCartesian3.z); i = subdividedPositions.length / 3 - 1; @@ -352,7 +351,7 @@ define([ if (!defined(i)) { mid = Cartesian2.add(c2Cart2, c0Cart2, subdivisionMidCart2Scratch); Cartesian2.multiplyByScalar(mid, 0.5, mid); - midHeight = (c2.height + c0.height) / 2.0; + midHeight = (c2.height + c0.height) * 0.5; midCartesian3 = Cartesian3.fromRadians(mid.x, mid.y, midHeight, ellipsoid, subdivisionMidScratch); subdividedPositions.push(midCartesian3.x, midCartesian3.y, midCartesian3.z); i = subdividedPositions.length / 3 - 1; diff --git a/Source/Core/PolylineGeometry.js b/Source/Core/PolylineGeometry.js index 0fa135010f6f..68f6caac7f08 100644 --- a/Source/Core/PolylineGeometry.js +++ b/Source/Core/PolylineGeometry.js @@ -329,84 +329,38 @@ define([ return undefined; } - var heights; - var colorLength; - var newColors; - var newColorIndex; - var numColors; - var p0; - var p1; - var c0; - var c1; - var interpolatedColors; - var interpolatedColorsLength; - if (lineType === LineType.GEODESIC) { - heights = PolylinePipeline.extractHeights(positions, ellipsoid); - var minDistance = CesiumMath.chordLength(granularity, ellipsoid.maximumRadius); - - if (defined(colors)) { - colorLength = 1; - for (i = 0; i < positionsLength - 1; ++i) { - colorLength += PolylinePipeline.numberOfPoints(positions[i], positions[i+1], minDistance); - } - - newColors = new Array(colorLength); - newColorIndex = 0; - - for (i = 0; i < positionsLength - 1; ++i) { - p0 = positions[i]; - p1 = positions[i+1]; - c0 = colors[i]; - - numColors = PolylinePipeline.numberOfPoints(p0, p1, minDistance); - if (colorsPerVertex && i < colorLength) { - c1 = colors[i+1]; - interpolatedColors = interpolateColors(p0, p1, c0, c1, numColors); - interpolatedColorsLength = interpolatedColors.length; - for (j = 0; j < interpolatedColorsLength; ++j) { - newColors[newColorIndex++] = interpolatedColors[j]; - } - } else { - for (j = 0; j < numColors; ++j) { - newColors[newColorIndex++] = Color.clone(c0); - } - } - } - - newColors[newColorIndex] = Color.clone(colors[colors.length-1]); - colors = newColors; - - scratchInterpolateColorsArray.length = 0; + if (lineType === LineType.GEODESIC || lineType === LineType.RHUMB) { + var subdivisionSize; + var numberOfPointsFunction; + if (lineType === LineType.GEODESIC) { + subdivisionSize = CesiumMath.chordLength(granularity, ellipsoid.maximumRadius); + numberOfPointsFunction = PolylinePipeline.numberOfPoints; + } else { + subdivisionSize = granularity; + numberOfPointsFunction = PolylinePipeline.numberOfPointsRhumbLine; } - positions = PolylinePipeline.generateCartesianArc({ - positions: positions, - minDistance: minDistance, - ellipsoid: ellipsoid, - height: heights - }); - } else if (lineType === LineType.RHUMB) { - heights = PolylinePipeline.extractHeights(positions, ellipsoid); + var heights = PolylinePipeline.extractHeights(positions, ellipsoid); if (defined(colors)) { - colorLength = 1; + var colorLength = 1; for (i = 0; i < positionsLength - 1; ++i) { - colorLength += PolylinePipeline.numberOfPointsRhumbLine(positions[i], positions[i+1], granularity); + colorLength += numberOfPointsFunction(positions[i], positions[i + 1], subdivisionSize); } - newColors = new Array(colorLength); - newColorIndex = 0; + var newColors = new Array(colorLength); + var newColorIndex = 0; for (i = 0; i < positionsLength - 1; ++i) { - p0 = positions[i]; - p1 = positions[i+1]; - c0 = colors[i]; + var p0 = positions[i]; + var p1 = positions[i + 1]; + var c0 = colors[i]; - numColors = PolylinePipeline.numberOfPointsRhumbLine(p0, p1, granularity); + var numColors = numberOfPointsFunction(p0, p1, subdivisionSize); if (colorsPerVertex && i < colorLength) { - c1 = colors[i+1]; - interpolatedColors = interpolateColors(p0, p1, c0, c1, numColors); - interpolatedColorsLength = interpolatedColors.length; + var c1 = colors[i + 1]; + var interpolatedColors = interpolateColors(p0, p1, c0, c1, numColors); + var interpolatedColorsLength = interpolatedColors.length; for (j = 0; j < interpolatedColorsLength; ++j) { newColors[newColorIndex++] = interpolatedColors[j]; } @@ -417,18 +371,27 @@ define([ } } - newColors[newColorIndex] = Color.clone(colors[colors.length-1]); + newColors[newColorIndex] = Color.clone(colors[colors.length - 1]); colors = newColors; scratchInterpolateColorsArray.length = 0; } - positions = PolylinePipeline.generateCartesianRhumbArc({ - positions: positions, - granularity: granularity, - ellipsoid: ellipsoid, - height: heights - }); + if (lineType === LineType.GEODESIC) { + positions = PolylinePipeline.generateCartesianArc({ + positions: positions, + minDistance: subdivisionSize, + ellipsoid: ellipsoid, + height: heights + }); + } else { + positions = PolylinePipeline.generateCartesianRhumbArc({ + positions: positions, + granularity: subdivisionSize, + ellipsoid: ellipsoid, + height: heights + }); + } } positionsLength = positions.length; diff --git a/Source/Core/PolylinePipeline.js b/Source/Core/PolylinePipeline.js index 6df8391263ee..4c54a8d2c6cc 100644 --- a/Source/Core/PolylinePipeline.js +++ b/Source/Core/PolylinePipeline.js @@ -139,6 +139,9 @@ define([ var numPoints = PolylinePipeline.numberOfPointsRhumbLine(start, end, granularity); var heights = subdivideHeights(numPoints, h0, h1); + if (!ellipsoidRhumb.ellipsoid.equals(ellipsoid)) { + ellipsoidRhumb = new EllipsoidRhumbLine(undefined, undefined, ellipsoid); + } ellipsoidRhumb.setEndPoints(start, end); var surfaceDistanceBetweenPoints = ellipsoidRhumb.surfaceDistance / numPoints; diff --git a/Source/Core/SimplePolylineGeometry.js b/Source/Core/SimplePolylineGeometry.js index added91c34b8..df2f40f43c6f 100644 --- a/Source/Core/SimplePolylineGeometry.js +++ b/Source/Core/SimplePolylineGeometry.js @@ -294,16 +294,34 @@ define([ var color; var offset = 0; - if (lineType === LineType.GEODESIC) { + if (lineType === LineType.GEODESIC || lineType === LineType.RHUMB) { + var subdivisionSize; + var numberOfPointsFunction; + var generateArcFunction; + if (lineType === LineType.GEODESIC) { + subdivisionSize = CesiumMath.chordLength(granularity, ellipsoid.maximumRadius); + numberOfPointsFunction = PolylinePipeline.numberOfPoints; + generateArcFunction = PolylinePipeline.generateArc; + } else { + subdivisionSize = granularity; + numberOfPointsFunction = PolylinePipeline.numberOfPointsRhumbLine; + generateArcFunction = PolylinePipeline.generateRhumbArc; + } + var heights = PolylinePipeline.extractHeights(positions, ellipsoid); + var generateArcOptions = generateArcOptionsScratch; - generateArcOptions.minDistance = minDistance; + if (lineType === LineType.GEODESIC) { + generateArcOptions.minDistance = minDistance; + } else { + generateArcOptions.granularity = granularity; + } generateArcOptions.ellipsoid = ellipsoid; if (perSegmentColors) { var positionCount = 0; for (i = 0; i < length - 1; i++) { - positionCount += PolylinePipeline.numberOfPoints(positions[i], positions[i+1], minDistance) + 1; + positionCount += numberOfPointsFunction(positions[i], positions[i+1], subdivisionSize) + 1; } positionValues = new Float64Array(positionCount * 3); @@ -320,7 +338,7 @@ define([ scratchArray2[0] = heights[i]; scratchArray2[1] = heights[i + 1]; - var pos = PolylinePipeline.generateArc(generateArcOptions); + var pos = generateArcFunction(generateArcOptions); if (defined(colors)) { var segLen = pos.length / 3; @@ -339,7 +357,7 @@ define([ } else { generateArcOptions.positions = positions; generateArcOptions.height= heights; - positionValues = new Float64Array(PolylinePipeline.generateArc(generateArcOptions)); + positionValues = new Float64Array(generateArcFunction(generateArcOptions)); if (defined(colors)) { colorValues = new Uint8Array(positionValues.length / 3 * 4); diff --git a/Source/DataSources/GeoJsonDataSource.js b/Source/DataSources/GeoJsonDataSource.js index 69a18b889ef5..cf1c40f5b6ef 100644 --- a/Source/DataSources/GeoJsonDataSource.js +++ b/Source/DataSources/GeoJsonDataSource.js @@ -527,7 +527,7 @@ define([ * @param {Number} [options.strokeWidth=GeoJsonDataSource.strokeWidth] The default width of polylines and polygon outlines. * @param {Color} [options.fill=GeoJsonDataSource.fill] The default color for polygon interiors. * @param {Boolean} [options.clampToGround=GeoJsonDataSource.clampToGround] true if we want the geometry features (polygons or linestrings) clamped to the ground. - * @param {LineType} [options.lineType=GeoJsonDataSource.lineType] The line type used to interpolate between points. + * @param {LineType} [options.lineType=GeoJsonDataSource.lineType] The line type used to interpolate between points. Valid options are {@link LineType.GEODESIC} and {@link LineType.RHUMB}. * * @returns {Promise.} A promise that will resolve when the data is loaded. */ @@ -636,7 +636,7 @@ define([ } }, /** - * Gets or sets default of the path interpolation type. + * Gets or sets default of the path interpolation type. Valid options are {@link LineType.GEODESIC} and {@link LineType.RHUMB}. * @memberof GeoJsonDataSource * @type {LineType} * @default false @@ -820,7 +820,7 @@ define([ * @param {Number} [options.strokeWidth=GeoJsonDataSource.strokeWidth] The default width of polylines and polygon outlines. * @param {Color} [options.fill=GeoJsonDataSource.fill] The default color for polygon interiors. * @param {Boolean} [options.clampToGround=GeoJsonDataSource.clampToGround] true if we want the features clamped to the ground. - * @param {LineType} [options.lineType=GeoJsonDataSource.lineType] The line type used to interpolate between points. + * @param {LineType} [options.lineType=GeoJsonDataSource.lineType] The line type used to interpolate between points. Valid options are {@link LineType.GEODESIC} and {@link LineType.RHUMB}. * * @returns {Promise.} a promise that will resolve when the GeoJSON is loaded. */ diff --git a/Source/DataSources/PolylineGeometryUpdater.js b/Source/DataSources/PolylineGeometryUpdater.js index fc58db897d91..8a513edabbcf 100644 --- a/Source/DataSources/PolylineGeometryUpdater.js +++ b/Source/DataSources/PolylineGeometryUpdater.js @@ -6,7 +6,6 @@ define([ '../Core/defaultValue', '../Core/defined', '../Core/defineProperties', - '../Core/deprecationWarning', '../Core/destroyObject', '../Core/DeveloperError', '../Core/DistanceDisplayCondition', @@ -40,7 +39,6 @@ define([ defaultValue, defined, defineProperties, - deprecationWarning, destroyObject, DeveloperError, DistanceDisplayCondition, @@ -651,7 +649,7 @@ define([ geometryUpdater._groundGeometryOptions.positions = positions; geometryUpdater._groundGeometryOptions.width = Property.getValueOrDefault(polyline._width, time, 1); geometryUpdater._groundGeometryOptions.lineType = Property.getValueOrDefault(polyline._lineType, time, LineType.GEODESIC); - geometryUpdater._groundGeometryOptions.granularity = Property.getValueOrDefault(polyline._granulatiry, time, 9999); + geometryUpdater._groundGeometryOptions.granularity = Property.getValueOrDefault(polyline._granularity, time, 9999); var groundPrimitives = this._groundPrimitives; diff --git a/Source/DataSources/PolylineGraphics.js b/Source/DataSources/PolylineGraphics.js index eb31bb6f8f8b..0fbab544ab54 100644 --- a/Source/DataSources/PolylineGraphics.js +++ b/Source/DataSources/PolylineGraphics.js @@ -2,7 +2,6 @@ define([ '../Core/defaultValue', '../Core/defined', '../Core/defineProperties', - '../Core/deprecationWarning', '../Core/DeveloperError', '../Core/Event', '../Core/LineType', @@ -12,7 +11,6 @@ define([ defaultValue, defined, defineProperties, - deprecationWarning, DeveloperError, Event, LineType, diff --git a/Specs/Core/PolygonPipelineSpec.js b/Specs/Core/PolygonPipelineSpec.js index 8c95e5af8e1e..cb343750e8ff 100644 --- a/Specs/Core/PolygonPipelineSpec.js +++ b/Specs/Core/PolygonPipelineSpec.js @@ -256,7 +256,7 @@ defineSuite([ expect(subdivision.indices[2]).toEqual(2); }); - it('computeRhumbLineSubdivision with subvisisions', function() { + it('computeRhumbLineSubdivision with subdivisions', function() { var positions = Cartesian3.fromDegreesArray([ 0, 0, 1, 0, diff --git a/Specs/Core/PolylineGeometrySpec.js b/Specs/Core/PolylineGeometrySpec.js index 6947f189094c..da70f932a05c 100644 --- a/Specs/Core/PolylineGeometrySpec.js +++ b/Specs/Core/PolylineGeometrySpec.js @@ -52,7 +52,6 @@ defineSuite([ positions: [Cartesian3.ZERO, Cartesian3.UNIT_X, Cartesian3.UNIT_Y], followSurface: true }); - console.log(line); expect(line._followSurface).toBe(true); expect(line._lineType).toBe(LineType.GEODESIC); @@ -200,7 +199,7 @@ defineSuite([ ellipsoid : new Ellipsoid(12, 13, 14) }); packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 12, 13, 14, 1, 0, 0, 0, 0, 0, 10, 0, 2, 11]; - createPackableSpecs(PolylineGeometry, line, packedInstance); + createPackableSpecs(PolylineGeometry, line, packedInstance, 'straight line'); line = new PolylineGeometry({ positions : positions, @@ -225,16 +224,4 @@ defineSuite([ }); packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 12, 13, 14, 1, 0, 0, 0, 0, 0, 10, 0, 1, 11]; createPackableSpecs(PolylineGeometry, line, packedInstance, 'rhumb line'); - - line = new PolylineGeometry({ - positions : positions, - width : 10.0, - colorsPerVertex : false, - lineType : LineType.STRAIGHT, - granularity : 11, - vertexFormat : VertexFormat.POSITION_ONLY, - ellipsoid : new Ellipsoid(12, 13, 14) - }); - packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 12, 13, 14, 1, 0, 0, 0, 0, 0, 10, 0, 2, 11]; - createPackableSpecs(PolylineGeometry, line, packedInstance, 'straight line'); }); diff --git a/Specs/Core/SimplePolylineGeometrySpec.js b/Specs/Core/SimplePolylineGeometrySpec.js index 185e68783e0e..68093c39d2b2 100644 --- a/Specs/Core/SimplePolylineGeometrySpec.js +++ b/Specs/Core/SimplePolylineGeometrySpec.js @@ -73,7 +73,7 @@ defineSuite([ var cartesian3Array = []; Cartesian3.packArray(positions, cartesian3Array); - expect(line.attributes.position.values).toEqualEpsilon(cartesian3Array, CesiumMath.EPSILON10); + expect(line.attributes.position.values).toEqualEpsilon(cartesian3Array, CesiumMath.EPSILON8); expect(line.indices).toEqual([0, 1, 1, 2]); expect(line.primitiveType).toEqual(PrimitiveType.LINES); expect(line.boundingSphere).toEqual(BoundingSphere.fromPoints(positions)); diff --git a/Specs/DataSources/GeoJsonDataSourceSpec.js b/Specs/DataSources/GeoJsonDataSourceSpec.js index 6f9ddca0bca3..6f9423ab1911 100644 --- a/Specs/DataSources/GeoJsonDataSourceSpec.js +++ b/Specs/DataSources/GeoJsonDataSourceSpec.js @@ -679,7 +679,6 @@ defineSuite([ var entityCollection = dataSource.entities; var entity = entityCollection.values[0]; expect(entity.properties).toBe(lineString.properties); - console.log(entity.polyline); expect(entity.polyline.positions.getValue(time)).toEqual(coordinatesArrayToCartesian(lineString.coordinates)); expect(entity.polyline.material.color.getValue(time)).toEqual(GeoJsonDataSource.stroke); expect(entity.polyline.width.getValue(time)).toEqual(2); diff --git a/Specs/DataSources/PolylineGeometryUpdaterSpec.js b/Specs/DataSources/PolylineGeometryUpdaterSpec.js index f58baa5a5677..eb39e204a9f4 100644 --- a/Specs/DataSources/PolylineGeometryUpdaterSpec.js +++ b/Specs/DataSources/PolylineGeometryUpdaterSpec.js @@ -589,10 +589,6 @@ defineSuite([ }); it('lineType can be dynamic', function() { - if (!Entity.supportsPolylinesOnTerrain(scene)) { - return; - } - var entity = new Entity(); var polyline = new PolylineGraphics(); entity.polyline = polyline; @@ -610,32 +606,33 @@ defineSuite([ polyline.material = new ColorMaterialProperty(Color.RED); polyline.followSurface = new ConstantProperty(true); polyline.granularity = new ConstantProperty(0.001); - polyline.clampToGround = new ConstantProperty(true); + polyline.clampToGround = new ConstantProperty(false); polyline.lineType = lineType; var updater = new PolylineGeometryUpdater(entity, scene); - var groundPrimitives = scene.groundPrimitives; - expect(groundPrimitives.length).toBe(0); + var primitives = scene.primitives; + expect(primitives.length).toBe(0); - var dynamicUpdater = updater.createDynamicUpdater(scene.primitives, groundPrimitives); + var dynamicUpdater = updater.createDynamicUpdater(primitives, scene.groundPrimitives); expect(dynamicUpdater.isDestroyed()).toBe(false); - expect(groundPrimitives.length).toBe(0); + expect(primitives.length).toBe(0); dynamicUpdater.update(time); - expect(groundPrimitives.length).toBe(1); - var primitive = groundPrimitives.get(0); + expect(primitives.length).toBe(1); + var polylineCollection = primitives.get(0); + var primitive = polylineCollection.get(0); expect(primitive.show).toEqual(true); - lineTypeVar = false; + lineTypeVar = LineType.STRAIGHT; dynamicUpdater.update(time); dynamicUpdater.destroy(); expect(scene.primitives.length).toBe(0); - expect(groundPrimitives.length).toBe(0); + expect(primitives.length).toBe(0); updater.destroy(); }); From 1dcdbe2917a5d68a51094e4800c65c626989b9bb Mon Sep 17 00:00:00 2001 From: Shehzan Mohammed Date: Wed, 23 Jan 2019 10:22:11 -0500 Subject: [PATCH 18/26] Some more fixes from PR review --- Source/Core/PolygonGeometryLibrary.js | 5 ++++- Source/Core/SimplePolylineGeometry.js | 3 ++- Source/DataSources/PolylineGraphics.js | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Source/Core/PolygonGeometryLibrary.js b/Source/Core/PolygonGeometryLibrary.js index b573656f878b..b240a0491991 100644 --- a/Source/Core/PolygonGeometryLibrary.js +++ b/Source/Core/PolygonGeometryLibrary.js @@ -188,10 +188,13 @@ define([ }; PolygonGeometryLibrary.subdivideRhumbLine = function(ellipsoid, p0, p1, minDistance, result) { - var numVertices = PolygonGeometryLibrary.subdivideRhumbLineCount(ellipsoid, p0, p1, minDistance); var c0 = ellipsoid.cartesianToCartographic(p0, scratchCartographic0); var c1 = ellipsoid.cartesianToCartographic(p1, scratchCartographic1); var rhumb = new EllipsoidRhumbLine(c0, c1, ellipsoid); + + var n = rhumb.surfaceDistance / minDistance; + var countDivide = Math.max(0, Math.ceil(CesiumMath.log2(n))); + var numVertices = Math.pow(2, countDivide); var distanceBetweenVertices = rhumb.surfaceDistance / numVertices; if (!defined(result)) { diff --git a/Source/Core/SimplePolylineGeometry.js b/Source/Core/SimplePolylineGeometry.js index df2f40f43c6f..d03d2ba71171 100644 --- a/Source/Core/SimplePolylineGeometry.js +++ b/Source/Core/SimplePolylineGeometry.js @@ -265,7 +265,8 @@ define([ positions : scratchArray1, height: scratchArray2, ellipsoid: undefined, - minDistance : undefined + minDistance : undefined, + granularity : undefined }; /** diff --git a/Source/DataSources/PolylineGraphics.js b/Source/DataSources/PolylineGraphics.js index 0fbab544ab54..3fb006ba3b03 100644 --- a/Source/DataSources/PolylineGraphics.js +++ b/Source/DataSources/PolylineGraphics.js @@ -35,7 +35,7 @@ define([ * @param {Property} [options.show=true] A boolean Property specifying the visibility of the polyline. * @param {MaterialProperty} [options.material=Color.WHITE] A Property specifying the material used to draw the polyline. * @param {MaterialProperty} [options.depthFailMaterial] A property specifying the material used to draw the polyline when it is below the terrain. - * @param {Property} [options.granularity=Cesium.Math.RADIANS_PER_DEGREE] A numeric Property specifying the angular distance between each latitude and longitude if lineType is now LineType.STRAIGHT. + * @param {Property} [options.granularity=Cesium.Math.RADIANS_PER_DEGREE] A numeric Property specifying the angular distance between each latitude and longitude if lineType is not LineType.STRAIGHT. * @param {Property} [options.shadows=ShadowMode.DISABLED] An enum Property specifying whether the polyline casts or receives shadows from each light source. * @param {Property} [options.distanceDisplayCondition] A Property specifying at what distance from the camera that this polyline will be displayed. * @param {Property} [options.classificationType=ClassificationType.BOTH] An enum Property specifying whether this polyline will classify terrain, 3D Tiles, or both when on the ground. From 1883350f3ea67f3dc10876b2b00119ba9a1d75d3 Mon Sep 17 00:00:00 2001 From: Shehzan Mohammed Date: Wed, 23 Jan 2019 12:27:42 -0500 Subject: [PATCH 19/26] Check polyline difference after update --- Specs/DataSources/PolylineGeometryUpdaterSpec.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Specs/DataSources/PolylineGeometryUpdaterSpec.js b/Specs/DataSources/PolylineGeometryUpdaterSpec.js index eb39e204a9f4..c4819af3893f 100644 --- a/Specs/DataSources/PolylineGeometryUpdaterSpec.js +++ b/Specs/DataSources/PolylineGeometryUpdaterSpec.js @@ -622,13 +622,17 @@ defineSuite([ expect(primitives.length).toBe(1); var polylineCollection = primitives.get(0); - var primitive = polylineCollection.get(0); + var polylineObject = polylineCollection.get(0); - expect(primitive.show).toEqual(true); + expect(polylineObject.show).toEqual(true); + + var geodesicPolylinePositionsLength = polylineObject.positions.length; lineTypeVar = LineType.STRAIGHT; dynamicUpdater.update(time); + expect(polylineObject.positions.length).not.toEqual(geodesicPolylinePositionsLength); + dynamicUpdater.destroy(); expect(scene.primitives.length).toBe(0); From 6584a8f73d6742a84b960106bbd31a747f262f66 Mon Sep 17 00:00:00 2001 From: Shehzan Mohammed Date: Wed, 23 Jan 2019 13:23:51 -0500 Subject: [PATCH 20/26] Typo --- Source/Core/PolygonGeometry.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/PolygonGeometry.js b/Source/Core/PolygonGeometry.js index dd0dea876afa..83db2ae6e960 100644 --- a/Source/Core/PolygonGeometry.js +++ b/Source/Core/PolygonGeometry.js @@ -582,7 +582,7 @@ define([ throw new DeveloperError('Cannot use both options.perPositionHeight and options.height'); } if (defined(options.lineType) && options.lineType === LineType.STRAIGHT) { - throw new DeveloperError('Cannot use {@link LineType.STRAIGHT} as option.lineType'); + throw new DeveloperError('Cannot use LineType.STRAIGHT as option.lineType'); } //>>includeEnd('debug'); From b2e70edd61218f841c740cf5bbe766e57ccd08bc Mon Sep 17 00:00:00 2001 From: Shehzan Mohammed Date: Wed, 23 Jan 2019 13:24:56 -0500 Subject: [PATCH 21/26] Remove lineType option from GeoJsonDataSource. Always uses RHUMB lines --- CHANGES.md | 1 - Source/DataSources/GeoJsonDataSource.js | 24 +--- Specs/DataSources/GeoJsonDataSourceSpec.js | 125 --------------------- 3 files changed, 3 insertions(+), 147 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index da965684333f..8b878179c282 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -20,7 +20,6 @@ Change Log * Added a [new Sandcastle example](https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/?src=Time%20Dynamic%20Wheels.html) on using `nodeTransformations` to rotate a model's wheels based on its velocity. [#7361](https://github.com/AnalyticalGraphicsInc/cesium/pull/7361) * Added `EllipsoidRhumbLine` class as a rhumb line counterpart to `EllipsoidGeodesic`. [#7484](https://github.com/AnalyticalGraphicsInc/cesium/pull/7484) * Added rhumb line support to `PolygonGeometry`, `PolygonOutlineGeometry`, `PolylineGeometry`, `GroundPolylineGeometry`, and `SimplePolylineGeometry`. [#7492](https://github.com/AnalyticalGraphicsInc/cesium/pull/7492) -* Added `lineType` as optional parameter to `GeoJsonDataSource`. [#7492](https://github.com/AnalyticalGraphicsInc/cesium/pull/7492) ##### Fixes :wrench: * Fixed 3D Tiles performance regression. [#7482](https://github.com/AnalyticalGraphicsInc/cesium/pull/7482) diff --git a/Source/DataSources/GeoJsonDataSource.js b/Source/DataSources/GeoJsonDataSource.js index cf1c40f5b6ef..bd3513a52795 100644 --- a/Source/DataSources/GeoJsonDataSource.js +++ b/Source/DataSources/GeoJsonDataSource.js @@ -77,7 +77,6 @@ define([ var defaultStrokeWidth = 2; var defaultFill = Color.fromBytes(255, 255, 0, 100); var defaultClampToGround = false; - var defaultLineType = LineType.RHUMB; var sizes = { small : 24, @@ -368,7 +367,7 @@ define([ polylineGraphics.material = material; polylineGraphics.width = widthProperty; polylineGraphics.positions = new ConstantProperty(coordinatesArrayToCartesianArray(coordinates, crsFunction)); - polylineGraphics.lineType = options.lineType; + polylineGraphics.lineType = LineType.RHUMB; } function processLineString(dataSource, geoJson, geometry, crsFunction, options) { @@ -438,7 +437,7 @@ define([ polygon.outlineColor = outlineColorProperty; polygon.outlineWidth = widthProperty; polygon.material = material; - polygon.lineType = options.lineType; + polygon.lineType = LineType.RHUMB; var holes = []; for (var i = 1, len = coordinates.length; i < len; i++) { @@ -527,7 +526,6 @@ define([ * @param {Number} [options.strokeWidth=GeoJsonDataSource.strokeWidth] The default width of polylines and polygon outlines. * @param {Color} [options.fill=GeoJsonDataSource.fill] The default color for polygon interiors. * @param {Boolean} [options.clampToGround=GeoJsonDataSource.clampToGround] true if we want the geometry features (polygons or linestrings) clamped to the ground. - * @param {LineType} [options.lineType=GeoJsonDataSource.lineType] The line type used to interpolate between points. Valid options are {@link LineType.GEODESIC} and {@link LineType.RHUMB}. * * @returns {Promise.} A promise that will resolve when the data is loaded. */ @@ -635,20 +633,6 @@ define([ defaultClampToGround = value; } }, - /** - * Gets or sets default of the path interpolation type. Valid options are {@link LineType.GEODESIC} and {@link LineType.RHUMB}. - * @memberof GeoJsonDataSource - * @type {LineType} - * @default false - */ - lineType : { - get : function() { - return defaultLineType; - }, - set : function(value) { - defaultLineType = value; - } - }, /** * Gets an object that maps the name of a crs to a callback function which takes a GeoJSON coordinate @@ -820,7 +804,6 @@ define([ * @param {Number} [options.strokeWidth=GeoJsonDataSource.strokeWidth] The default width of polylines and polygon outlines. * @param {Color} [options.fill=GeoJsonDataSource.fill] The default color for polygon interiors. * @param {Boolean} [options.clampToGround=GeoJsonDataSource.clampToGround] true if we want the features clamped to the ground. - * @param {LineType} [options.lineType=GeoJsonDataSource.lineType] The line type used to interpolate between points. Valid options are {@link LineType.GEODESIC} and {@link LineType.RHUMB}. * * @returns {Promise.} a promise that will resolve when the GeoJSON is loaded. */ @@ -852,8 +835,7 @@ define([ strokeWidthProperty : new ConstantProperty(defaultValue(options.strokeWidth, defaultStrokeWidth)), strokeMaterialProperty : new ColorMaterialProperty(defaultValue(options.stroke, defaultStroke)), fillMaterialProperty : new ColorMaterialProperty(defaultValue(options.fill, defaultFill)), - clampToGround : defaultValue(options.clampToGround, defaultClampToGround), - lineType : defaultValue(options.lineType, defaultLineType) + clampToGround : defaultValue(options.clampToGround, defaultClampToGround) }; var that = this; diff --git a/Specs/DataSources/GeoJsonDataSourceSpec.js b/Specs/DataSources/GeoJsonDataSourceSpec.js index 6f9423ab1911..4ae059cbdc05 100644 --- a/Specs/DataSources/GeoJsonDataSourceSpec.js +++ b/Specs/DataSources/GeoJsonDataSourceSpec.js @@ -4,7 +4,6 @@ defineSuite([ 'Core/Color', 'Core/Event', 'Core/JulianDate', - 'Core/LineType', 'Core/PolygonHierarchy', 'Core/RuntimeError', 'DataSources/CallbackProperty', @@ -18,7 +17,6 @@ defineSuite([ Color, Event, JulianDate, - LineType, PolygonHierarchy, RuntimeError, CallbackProperty, @@ -35,7 +33,6 @@ defineSuite([ var defaultStrokeWidth; var defaultFill; var defaultClampToGround; - var defaultLineType; beforeAll(function() { defaultMarkerSize = GeoJsonDataSource.markerSize; @@ -45,7 +42,6 @@ defineSuite([ defaultStrokeWidth = GeoJsonDataSource.strokeWidth; defaultFill = GeoJsonDataSource.fill; defaultClampToGround = GeoJsonDataSource.clampToGround; - defaultLineType = GeoJsonDataSource.lineType; }); beforeEach(function() { @@ -56,7 +52,6 @@ defineSuite([ GeoJsonDataSource.strokeWidth = defaultStrokeWidth; GeoJsonDataSource.fill = defaultFill; GeoJsonDataSource.clampToGround = defaultClampToGround; - GeoJsonDataSource.lineType = defaultLineType; }); var time = new JulianDate(); @@ -682,22 +677,6 @@ defineSuite([ expect(entity.polyline.positions.getValue(time)).toEqual(coordinatesArrayToCartesian(lineString.coordinates)); expect(entity.polyline.material.color.getValue(time)).toEqual(GeoJsonDataSource.stroke); expect(entity.polyline.width.getValue(time)).toEqual(2); - expect(entity.polyline.lineType.getValue(time)).toEqual(GeoJsonDataSource.lineType); - }); - }); - - it('Works with lineString geometry with geodesic lines', function() { - var dataSource = new GeoJsonDataSource(); - return dataSource.load(lineString, { - lineType : LineType.GEODESIC - }).then(function() { - var entityCollection = dataSource.entities; - var entity = entityCollection.values[0]; - expect(entity.properties).toBe(lineString.properties); - expect(entity.polyline.positions.getValue(time)).toEqual(coordinatesArrayToCartesian(lineString.coordinates)); - expect(entity.polyline.material.color.getValue(time)).toEqual(GeoJsonDataSource.stroke); - expect(entity.polyline.width.getValue(time)).toEqual(2); - expect(entity.polyline.lineType.getValue(time)).toEqual(LineType.GEODESIC); }); }); @@ -713,24 +692,6 @@ defineSuite([ expect(entity.polyline.material.color.getValue(time)).toEqual(GeoJsonDataSource.stroke); expect(entity.polyline.width.getValue(time)).toEqual(2); expect(entity.polyline.clampToGround.getValue(time)).toEqual(true); - expect(entity.polyline.lineType.getValue(time)).toEqual(GeoJsonDataSource.lineType); - }); - }); - - it('Works with lineString geometry with geodesic lines clamped to ground', function() { - var dataSource = new GeoJsonDataSource(); - return dataSource.load(lineString, { - clampToGround : true, - lineType : LineType.GEODESIC - }).then(function() { - var entityCollection = dataSource.entities; - var entity = entityCollection.values[0]; - expect(entity.properties).toBe(lineString.properties); - expect(entity.polyline.positions.getValue(time)).toEqual(coordinatesArrayToCartesian(lineString.coordinates)); - expect(entity.polyline.material.color.getValue(time)).toEqual(GeoJsonDataSource.stroke); - expect(entity.polyline.width.getValue(time)).toEqual(2); - expect(entity.polyline.clampToGround.getValue(time)).toEqual(true); - expect(entity.polyline.lineType.getValue(time)).toEqual(LineType.GEODESIC); }); }); @@ -746,26 +707,6 @@ defineSuite([ expect(entity.polyline.positions.getValue(time)).toEqual(lines[i]); expect(entity.polyline.material.color.getValue(time)).toEqual(Color.YELLOW); expect(entity.polyline.width.getValue(time)).toEqual(2); - expect(entity.polyline.lineType.getValue(time)).toEqual(GeoJsonDataSource.lineType); - } - }); - }); - - it('Works with multiLineString geometry with geodesic lines', function() { - var dataSource = new GeoJsonDataSource(); - return dataSource.load(multiLineString, { - lineType : LineType.GEODESIC - }).then(function() { - var entityCollection = dataSource.entities; - var entities = entityCollection.values; - var lines = multiLineToCartesian(multiLineString); - for (var i = 0; i < multiLineString.coordinates.length; i++) { - var entity = entities[i]; - expect(entity.properties).toBe(multiLineString.properties); - expect(entity.polyline.positions.getValue(time)).toEqual(lines[i]); - expect(entity.polyline.material.color.getValue(time)).toEqual(Color.YELLOW); - expect(entity.polyline.width.getValue(time)).toEqual(2); - expect(entity.polyline.lineType.getValue(time)).toEqual(LineType.GEODESIC); } }); }); @@ -789,27 +730,6 @@ defineSuite([ }); }); - it('Works with multiLineString geometry with geodesic lines clamped to ground', function() { - var dataSource = new GeoJsonDataSource(); - return dataSource.load(multiLineString, { - clampToGround : true, - lineType : LineType.GEODESIC - }).then(function() { - var entityCollection = dataSource.entities; - var entities = entityCollection.values; - var lines = multiLineToCartesian(multiLineString); - for (var i = 0; i < multiLineString.coordinates.length; i++) { - var entity = entities[i]; - expect(entity.properties).toBe(multiLineString.properties); - expect(entity.polyline.positions.getValue(time)).toEqual(lines[i]); - expect(entity.polyline.material.color.getValue(time)).toEqual(Color.YELLOW); - expect(entity.polyline.width.getValue(time)).toEqual(2); - expect(entity.polyline.clampToGround.getValue(time)).toEqual(true); - expect(entity.polyline.lineType.getValue(time)).toEqual(LineType.GEODESIC); - } - }); - }); - it('Works with polygon geometry', function() { var dataSource = new GeoJsonDataSource(); return dataSource.load(polygon).then(function() { @@ -823,26 +743,6 @@ defineSuite([ expect(entity.polygon.outlineWidth.getValue(time)).toEqual(GeoJsonDataSource.strokeWidth); expect(entity.polygon.outlineColor.getValue(time)).toEqual(GeoJsonDataSource.stroke); expect(entity.polygon.height).toBeInstanceOf(ConstantProperty); - expect(entity.polygon.lineType.getValue(time)).toEqual(GeoJsonDataSource.lineType); - }); - }); - - it('Works with polygon geometry with geodesic lines', function() { - var dataSource = new GeoJsonDataSource(); - return dataSource.load(polygon, { - lineType : LineType.GEODESIC - }).then(function() { - var entityCollection = dataSource.entities; - var entity = entityCollection.values[0]; - expect(entity.properties).toBe(polygon.properties); - expect(entity.polygon.hierarchy.getValue(time)).toEqual(new PolygonHierarchy(polygonCoordinatesToCartesian(polygon.coordinates[0]))); - expect(entity.polygon.perPositionHeight).toBeUndefined(); - expect(entity.polygon.material.color.getValue(time)).toEqual(GeoJsonDataSource.fill); - expect(entity.polygon.outline.getValue(time)).toEqual(true); - expect(entity.polygon.outlineWidth.getValue(time)).toEqual(GeoJsonDataSource.strokeWidth); - expect(entity.polygon.outlineColor.getValue(time)).toEqual(GeoJsonDataSource.stroke); - expect(entity.polygon.height).toBeInstanceOf(ConstantProperty); - expect(entity.polygon.lineType.getValue(time)).toEqual(LineType.GEODESIC); }); }); @@ -861,27 +761,6 @@ defineSuite([ expect(entity.polygon.outlineWidth.getValue(time)).toEqual(GeoJsonDataSource.strokeWidth); expect(entity.polygon.outlineColor.getValue(time)).toEqual(GeoJsonDataSource.stroke); expect(entity.polygon.height).toBeUndefined(); - expect(entity.polygon.lineType.getValue(time)).toEqual(GeoJsonDataSource.lineType); - }); - }); - - it('Works with polygon geometry with geodesic lines clamped to ground', function() { - var dataSource = new GeoJsonDataSource(); - return dataSource.load(polygon, { - clampToGround : true, - lineType : LineType.GEODESIC - }).then(function() { - var entityCollection = dataSource.entities; - var entity = entityCollection.values[0]; - expect(entity.properties).toBe(polygon.properties); - expect(entity.polygon.hierarchy.getValue(time)).toEqual(new PolygonHierarchy(polygonCoordinatesToCartesian(polygon.coordinates[0]))); - expect(entity.polygon.perPositionHeight).toBeUndefined(); - expect(entity.polygon.material.color.getValue(time)).toEqual(GeoJsonDataSource.fill); - expect(entity.polygon.outline.getValue(time)).toEqual(true); - expect(entity.polygon.outlineWidth.getValue(time)).toEqual(GeoJsonDataSource.strokeWidth); - expect(entity.polygon.outlineColor.getValue(time)).toEqual(GeoJsonDataSource.stroke); - expect(entity.polygon.height).toBeUndefined(); - expect(entity.polygon.lineType.getValue(time)).toEqual(LineType.GEODESIC); }); }); @@ -897,7 +776,6 @@ defineSuite([ expect(entity.polygon.outline.getValue(time)).toEqual(true); expect(entity.polygon.outlineWidth.getValue(time)).toEqual(GeoJsonDataSource.strokeWidth); expect(entity.polygon.outlineColor.getValue(time)).toEqual(GeoJsonDataSource.stroke); - expect(entity.polygon.lineType.getValue(time)).toEqual(GeoJsonDataSource.lineType); }); }); @@ -982,7 +860,6 @@ defineSuite([ GeoJsonDataSource.stroke = Color.ORANGE; GeoJsonDataSource.strokeWidth = 8; GeoJsonDataSource.fill = Color.RED; - GeoJsonDataSource.lineType = LineType.GEODESIC; var dataSource = new GeoJsonDataSource(); return dataSource.load(mixedGeometries).then(function() { @@ -992,13 +869,11 @@ defineSuite([ var entity = entities[0]; expect(entity.polyline.material.color.getValue()).toEqual(GeoJsonDataSource.stroke); expect(entity.polyline.width.getValue()).toEqual(GeoJsonDataSource.strokeWidth); - expect(entity.polyline.lineType.getValue()).toEqual(GeoJsonDataSource.lineType); entity = entities[1]; expect(entity.polygon.material.color.getValue()).toEqual(GeoJsonDataSource.fill); expect(entity.polygon.outlineColor.getValue()).toEqual(GeoJsonDataSource.stroke); expect(entity.polygon.outlineWidth.getValue()).toEqual(GeoJsonDataSource.strokeWidth); - expect(entity.polygon.lineType.getValue()).toEqual(GeoJsonDataSource.lineType); entity = entities[2]; var expectedImage = dataSource._pinBuilder.fromMakiIconId(GeoJsonDataSource.markerSymbol, GeoJsonDataSource.markerColor, GeoJsonDataSource.markerSize); From 81b2ecba211c6b1b8b7e2935f9730de6e10d9d88 Mon Sep 17 00:00:00 2001 From: Shehzan Mohammed Date: Wed, 23 Jan 2019 15:57:37 -0500 Subject: [PATCH 22/26] Add checks for invalid lineType option, cleaner checks in constructors --- Source/Core/GroundPolylineGeometry.js | 6 ++++-- Source/Core/PolygonGeometry.js | 4 ++-- Source/Core/PolygonGeometryLibrary.js | 4 ++++ Source/Core/PolygonOutlineGeometry.js | 4 ++-- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Source/Core/GroundPolylineGeometry.js b/Source/Core/GroundPolylineGeometry.js index 3a99a74c3934..07623f139a37 100644 --- a/Source/Core/GroundPolylineGeometry.js +++ b/Source/Core/GroundPolylineGeometry.js @@ -109,8 +109,8 @@ define([ if ((!defined(positions)) || (positions.length < 2)) { throw new DeveloperError('At least two positions are required.'); } - if (defined(options.lineType) && options.lineType === LineType.STRAIGHT) { - throw new DeveloperError('Only Geodesic and Rhumb line types are supported.'); + if (defined(options.lineType) && options.lineType !== LineType.GEODESIC && options.lineType !== LineType.RHUMB) { + throw new DeveloperError('Valid options for lineType are LineType.GEODESIC and LineType.RHUMB.'); } //>>includeEnd('debug'); @@ -220,6 +220,8 @@ define([ ellipsoidLine = new EllipsoidGeodesic(start, end, ellipsoid); } else if (lineType === LineType.RHUMB) { ellipsoidLine = new EllipsoidRhumbLine(start, end, ellipsoid); + } else { + throw new DeveloperError('Unrecognized lineType. Valid options are LineType.GEODESIC and LineType.RHUMB'); } var surfaceDistance = ellipsoidLine.surfaceDistance; diff --git a/Source/Core/PolygonGeometry.js b/Source/Core/PolygonGeometry.js index 83db2ae6e960..5bd008a61270 100644 --- a/Source/Core/PolygonGeometry.js +++ b/Source/Core/PolygonGeometry.js @@ -581,8 +581,8 @@ define([ if (defined(options.perPositionHeight) && options.perPositionHeight && defined(options.height)) { throw new DeveloperError('Cannot use both options.perPositionHeight and options.height'); } - if (defined(options.lineType) && options.lineType === LineType.STRAIGHT) { - throw new DeveloperError('Cannot use LineType.STRAIGHT as option.lineType'); + if (defined(options.lineType) && options.lineType !== LineType.GEODESIC && options.lineType !== LineType.RHUMB) { + throw new DeveloperError('Invalid lineType. Valid options are LineType.GEODESIC and LineType.RHUMB.'); } //>>includeEnd('debug'); diff --git a/Source/Core/PolygonGeometryLibrary.js b/Source/Core/PolygonGeometryLibrary.js index b240a0491991..dec022ecbd3e 100644 --- a/Source/Core/PolygonGeometryLibrary.js +++ b/Source/Core/PolygonGeometryLibrary.js @@ -6,6 +6,7 @@ define([ './ComponentDatatype', './defaultValue', './defined', + './DeveloperError', './Ellipsoid', './EllipsoidRhumbLine', './Geometry', @@ -29,6 +30,7 @@ define([ ComponentDatatype, defaultValue, defined, + DeveloperError, Ellipsoid, EllipsoidRhumbLine, Geometry, @@ -536,6 +538,8 @@ define([ tempPositions = PolygonGeometryLibrary.subdivideLine(p1, p2, minDistance, computeWallIndicesSubdivided); } else if (lineType === LineType.RHUMB) { tempPositions = PolygonGeometryLibrary.subdivideRhumbLine(ellipsoid, p1, p2, minDistance, computeWallIndicesSubdivided); + } else { + throw new DeveloperError('Unrecognized lineType. Valid options are LineType.GEODESIC and LineType.RHUMB'); } var tempPositionsLength = tempPositions.length; for (var j = 0; j < tempPositionsLength; ++j, ++index) { diff --git a/Source/Core/PolygonOutlineGeometry.js b/Source/Core/PolygonOutlineGeometry.js index c96fc1509824..ee03c2aebbaa 100644 --- a/Source/Core/PolygonOutlineGeometry.js +++ b/Source/Core/PolygonOutlineGeometry.js @@ -322,8 +322,8 @@ define([ if (options.perPositionHeight && defined(options.height)) { throw new DeveloperError('Cannot use both options.perPositionHeight and options.height'); } - if (defined(options.lineType) && options.lineType === LineType.STRAIGHT) { - throw new DeveloperError('Cannot use option.lineType as LineType.STRAIGHT'); + if (defined(options.lineType) && options.lineType !== LineType.GEODESIC && options.lineType !== LineType.RHUMB) { + throw new DeveloperError('Invalid lineType. Valid options are LineType.GEODESIC and LineType.RHUMB.'); } //>>includeEnd('debug'); From ce9f96b501234a7120f406f286bf0740121c1124 Mon Sep 17 00:00:00 2001 From: Shehzan Mohammed Date: Wed, 23 Jan 2019 15:57:57 -0500 Subject: [PATCH 23/26] Better desciption of changing followSurface to lineType in CHANGES.md --- CHANGES.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 8b878179c282..6a37ac248c54 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -9,8 +9,8 @@ Change Log ##### Deprecated :hourglass_flowing_sand: * `Scene.clampToHeight` now takes an optional `width` argument before the `result` argument. The previous function definition will no longer work in 1.56. [#7287](https://github.com/AnalyticalGraphicsInc/cesium/pull/7287) -* `PolylineGeometry.followSurface` has been superceded by `PolylineGeometry.lineType`. The previous definition will no longer work in 1.55. -* `SimplePolylineGeometry.followSurface` has been superceded by `SimplePolylineGeometry.lineType`. The previous definition will no longer work in 1.55. +* `PolylineGeometry.followSurface` has been superceded by `PolylineGeometry.lineType`. The previous definition will no longer work in 1.57. Replace `followSurface: false` with `lineType: Cesium.LineType.STRAIGHT` and `followSurface: true` with `lineType: Cesium.LineType.GEODESIC`. [#7492](https://github.com/AnalyticalGraphicsInc/cesium/pull/7492) +* `SimplePolylineGeometry.followSurface` has been superceded by `SimplePolylineGeometry.lineType`. The previous definition will no longer work in 1.57. Replace `followSurface: false` with `lineType: Cesium.LineType.STRAIGHT` and `followSurface: true` with `lineType: Cesium.LineType.GEODESIC`. [#7492](https://github.com/AnalyticalGraphicsInc/cesium/pull/7492) ##### Additions :tada: * Added support for textured ground entities (entities with unspecified `height`) and `GroundPrimitives` on 3D Tiles. [#7434](https://github.com/AnalyticalGraphicsInc/cesium/pull/7434) From 96d25d513fb43ea244cc4e38102eaa75dbe9be26 Mon Sep 17 00:00:00 2001 From: Shehzan Mohammed Date: Wed, 23 Jan 2019 21:38:25 -0500 Subject: [PATCH 24/26] Change LineType to ArcType, LineType.STRAIGHT to ArcType.NONE --- Apps/Sandcastle/gallery/Polygon.html | 2 +- Apps/Sandcastle/gallery/Polyline.html | 4 +- .../gallery/development/Ground Primitive.html | 2 +- CHANGES.md | 4 +- Source/Core/{LineType.js => ArcType.js} | 20 ++++---- Source/Core/GroundPolylineGeometry.js | 50 +++++++++---------- Source/Core/PolygonGeometry.js | 40 +++++++-------- Source/Core/PolygonGeometryLibrary.js | 22 ++++---- Source/Core/PolygonOutlineGeometry.js | 50 +++++++++---------- Source/Core/PolylineGeometry.js | 34 ++++++------- Source/Core/SimplePolylineGeometry.js | 32 ++++++------ Source/DataSources/Entity.js | 2 +- Source/DataSources/GeoJsonDataSource.js | 8 +-- Source/DataSources/PolygonGeometryUpdater.js | 12 ++--- Source/DataSources/PolygonGraphics.js | 16 +++--- Source/DataSources/PolylineGeometryUpdater.js | 32 ++++++------ Source/DataSources/PolylineGraphics.js | 28 +++++------ Source/Scene/DebugModelMatrixPrimitive.js | 10 ++-- Specs/Core/GroundPolylineGeometrySpec.js | 14 +++--- Specs/Core/PolygonGeometrySpec.js | 24 ++++----- Specs/Core/PolygonOutlineGeometrySpec.js | 22 ++++---- Specs/Core/PolylineGeometrySpec.js | 30 +++++------ Specs/Core/SimplePolylineGeometrySpec.js | 22 ++++---- .../DataSources/PolygonGeometryUpdaterSpec.js | 20 ++++---- Specs/DataSources/PolygonGraphicsSpec.js | 26 +++++----- .../PolylineGeometryUpdaterSpec.js | 50 +++++++++---------- Specs/DataSources/PolylineGraphicsSpec.js | 28 +++++------ 27 files changed, 302 insertions(+), 302 deletions(-) rename Source/Core/{LineType.js => ArcType.js} (70%) diff --git a/Apps/Sandcastle/gallery/Polygon.html b/Apps/Sandcastle/gallery/Polygon.html index d17262108afd..d9fd0a94d3f1 100644 --- a/Apps/Sandcastle/gallery/Polygon.html +++ b/Apps/Sandcastle/gallery/Polygon.html @@ -136,7 +136,7 @@ material : Cesium.Color.PURPLE, outline : true, outlineColor : Cesium.Color.MAGENTA, - lineType : Cesium.LineType.RHUMB + arcType : Cesium.ArcType.RHUMB } }); diff --git a/Apps/Sandcastle/gallery/Polyline.html b/Apps/Sandcastle/gallery/Polyline.html index a05226f3e885..40e35964751c 100644 --- a/Apps/Sandcastle/gallery/Polyline.html +++ b/Apps/Sandcastle/gallery/Polyline.html @@ -46,7 +46,7 @@ positions : Cesium.Cartesian3.fromDegreesArray([-75, 35, -125, 35]), width : 5, - lineType : Cesium.LineType.RHUMB, + arcType : Cesium.ArcType.RHUMB, material : Cesium.Color.GREEN } }); @@ -84,7 +84,7 @@ positions : Cesium.Cartesian3.fromDegreesArrayHeights([-75, 43, 500000, -125, 43, 500000]), width : 10, - lineType : Cesium.LineType.STRAIGHT, + arcType : Cesium.ArcType.NONE, material : new Cesium.PolylineArrowMaterialProperty(Cesium.Color.PURPLE) } }); diff --git a/Apps/Sandcastle/gallery/development/Ground Primitive.html b/Apps/Sandcastle/gallery/development/Ground Primitive.html index fa38f9035d0e..936323c65b6f 100644 --- a/Apps/Sandcastle/gallery/development/Ground Primitive.html +++ b/Apps/Sandcastle/gallery/development/Ground Primitive.html @@ -337,7 +337,7 @@ -100, 45, -130, 45 ])), - lineType : Cesium.LineType.RHUMB + arcType : Cesium.ArcType.RHUMB }), attributes: { color: Cesium.ColorGeometryInstanceAttribute.fromColor(new Cesium.Color(1.0, 1.0, 0.0, 0.5)) diff --git a/CHANGES.md b/CHANGES.md index 6a37ac248c54..b19c37bda547 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -9,8 +9,8 @@ Change Log ##### Deprecated :hourglass_flowing_sand: * `Scene.clampToHeight` now takes an optional `width` argument before the `result` argument. The previous function definition will no longer work in 1.56. [#7287](https://github.com/AnalyticalGraphicsInc/cesium/pull/7287) -* `PolylineGeometry.followSurface` has been superceded by `PolylineGeometry.lineType`. The previous definition will no longer work in 1.57. Replace `followSurface: false` with `lineType: Cesium.LineType.STRAIGHT` and `followSurface: true` with `lineType: Cesium.LineType.GEODESIC`. [#7492](https://github.com/AnalyticalGraphicsInc/cesium/pull/7492) -* `SimplePolylineGeometry.followSurface` has been superceded by `SimplePolylineGeometry.lineType`. The previous definition will no longer work in 1.57. Replace `followSurface: false` with `lineType: Cesium.LineType.STRAIGHT` and `followSurface: true` with `lineType: Cesium.LineType.GEODESIC`. [#7492](https://github.com/AnalyticalGraphicsInc/cesium/pull/7492) +* `PolylineGeometry.followSurface` has been superceded by `PolylineGeometry.arcType`. The previous definition will no longer work in 1.57. Replace `followSurface: false` with `arcType: Cesium.ArcType.NONE` and `followSurface: true` with `arcType: Cesium.ArcType.GEODESIC`. [#7492](https://github.com/AnalyticalGraphicsInc/cesium/pull/7492) +* `SimplePolylineGeometry.followSurface` has been superceded by `SimplePolylineGeometry.arcType`. The previous definition will no longer work in 1.57. Replace `followSurface: false` with `arcType: Cesium.ArcType.NONE` and `followSurface: true` with `arcType: Cesium.ArcType.GEODESIC`. [#7492](https://github.com/AnalyticalGraphicsInc/cesium/pull/7492) ##### Additions :tada: * Added support for textured ground entities (entities with unspecified `height`) and `GroundPrimitives` on 3D Tiles. [#7434](https://github.com/AnalyticalGraphicsInc/cesium/pull/7434) diff --git a/Source/Core/LineType.js b/Source/Core/ArcType.js similarity index 70% rename from Source/Core/LineType.js rename to Source/Core/ArcType.js index bc3922a55828..f4c54cc9305c 100644 --- a/Source/Core/LineType.js +++ b/Source/Core/ArcType.js @@ -5,35 +5,35 @@ define([ 'use strict'; /** - * LineType defines the path that should be taken connecting vertices. + * ArcType defines the path that should be taken connecting vertices. * - * @exports LineType + * @exports ArcType */ - var LineType = { + var ArcType = { /** - * Follow geodesic path. + * Straight line that does not conform to the surface of the ellipsoid. * * @type {Number} * @constant */ - GEODESIC : 0, + NONE : 0, /** - * Follow rhumb or loxodrome path. + * Follow geodesic path. * * @type {Number} * @constant */ - RHUMB : 1, + GEODESIC : 1, /** - * Straight line that does not conform to the surface of the ellipsoid. + * Follow rhumb or loxodrome path. * * @type {Number} * @constant */ - STRAIGHT : 2 + RHUMB : 2 }; - return freezeObject(LineType); + return freezeObject(ArcType); }); diff --git a/Source/Core/GroundPolylineGeometry.js b/Source/Core/GroundPolylineGeometry.js index 07623f139a37..3a750dfcaaa2 100644 --- a/Source/Core/GroundPolylineGeometry.js +++ b/Source/Core/GroundPolylineGeometry.js @@ -19,7 +19,7 @@ define([ './Geometry', './GeometryAttribute', './IntersectionTests', - './LineType', + './ArcType', './Matrix3', './Plane', './Quaternion', @@ -46,7 +46,7 @@ define([ Geometry, GeometryAttribute, IntersectionTests, - LineType, + ArcType, Matrix3, Plane, Quaternion, @@ -84,7 +84,7 @@ define([ * @param {Number} [options.width=1.0] The screen space width in pixels. * @param {Number} [options.granularity=9999.0] The distance interval in meters used for interpolating options.points. Defaults to 9999.0 meters. Zero indicates no interpolation. * @param {Boolean} [options.loop=false] Whether during geometry creation a line segment will be added between the last and first line positions to make this Polyline a loop. - * @param {LineType} [options.lineType=LineType.GEODESIC] The type of line the polyline segments must follow. Valid options are {@link LineType.GEODESIC} and {@link LineType.RHUMB}. + * @param {ArcType} [options.arcType=ArcType.GEODESIC] The type of line the polyline segments must follow. Valid options are {@link ArcType.GEODESIC} and {@link ArcType.RHUMB}. * * @exception {DeveloperError} At least two positions are required. * @@ -109,8 +109,8 @@ define([ if ((!defined(positions)) || (positions.length < 2)) { throw new DeveloperError('At least two positions are required.'); } - if (defined(options.lineType) && options.lineType !== LineType.GEODESIC && options.lineType !== LineType.RHUMB) { - throw new DeveloperError('Valid options for lineType are LineType.GEODESIC and LineType.RHUMB.'); + if (defined(options.arcType) && options.arcType !== ArcType.GEODESIC && options.arcType !== ArcType.RHUMB) { + throw new DeveloperError('Valid options for arcType are ArcType.GEODESIC and ArcType.RHUMB.'); } //>>includeEnd('debug'); @@ -139,11 +139,11 @@ define([ this.loop = defaultValue(options.loop, false); /** - * The type of path the polyline must follow. Valid options are {@link LineType.GEODESIC} and {@link LineType.RHUMB}. - * @type {LineType} - * @default LineType.GEODESIC + * The type of path the polyline must follow. Valid options are {@link ArcType.GEODESIC} and {@link ArcType.RHUMB}. + * @type {ArcType} + * @default ArcType.GEODESIC */ - this.lineType = defaultValue(options.lineType, LineType.GEODESIC); + this.arcType = defaultValue(options.arcType, ArcType.GEODESIC); this._ellipsoid = Ellipsoid.WGS84; @@ -210,18 +210,18 @@ define([ var interpolatedBottomScratch = new Cartesian3(); var interpolatedTopScratch = new Cartesian3(); var interpolatedNormalScratch = new Cartesian3(); - function interpolateSegment(start, end, minHeight, maxHeight, granularity, lineType, ellipsoid, normalsArray, bottomPositionsArray, topPositionsArray, cartographicsArray) { + function interpolateSegment(start, end, minHeight, maxHeight, granularity, arcType, ellipsoid, normalsArray, bottomPositionsArray, topPositionsArray, cartographicsArray) { if (granularity === 0.0) { return; } var ellipsoidLine; - if (lineType === LineType.GEODESIC) { + if (arcType === ArcType.GEODESIC) { ellipsoidLine = new EllipsoidGeodesic(start, end, ellipsoid); - } else if (lineType === LineType.RHUMB) { + } else if (arcType === ArcType.RHUMB) { ellipsoidLine = new EllipsoidRhumbLine(start, end, ellipsoid); } else { - throw new DeveloperError('Unrecognized lineType. Valid options are LineType.GEODESIC and LineType.RHUMB'); + throw new DeveloperError('Unrecognized arcType. Valid options are ArcType.GEODESIC and ArcType.RHUMB'); } var surfaceDistance = ellipsoidLine.surfaceDistance; @@ -290,7 +290,7 @@ define([ array[index++] = value.granularity; array[index++] = value.loop ? 1.0 : 0.0; - array[index++] = value.lineType; + array[index++] = value.arcType; Ellipsoid.pack(value._ellipsoid, array, index); index += Ellipsoid.packedLength; @@ -324,7 +324,7 @@ define([ var granularity = array[index++]; var loop = array[index++] === 1.0; - var lineType = array[index++]; + var arcType = array[index++]; var ellipsoid = Ellipsoid.unpack(array, index); index += Ellipsoid.packedLength; @@ -337,7 +337,7 @@ define([ positions : positions, granularity : granularity, loop : loop, - lineType : lineType, + arcType : arcType, ellipsoid : ellipsoid }); geometry._projectionIndex = projectionIndex; @@ -348,7 +348,7 @@ define([ result._positions = positions; result.granularity = granularity; result.loop = loop; - result.lineType = lineType; + result.arcType = arcType; result._ellipsoid = ellipsoid; result._projectionIndex = projectionIndex; result._scene3DOnly = scene3DOnly; @@ -428,7 +428,7 @@ define([ var loop = groundPolylineGeometry.loop; var ellipsoid = groundPolylineGeometry._ellipsoid; var granularity = groundPolylineGeometry.granularity; - var lineType = groundPolylineGeometry.lineType; + var arcType = groundPolylineGeometry.arcType; var projection = new PROJECTIONS[groundPolylineGeometry._projectionIndex](ellipsoid); var minHeight = WALL_INITIAL_MIN_HEIGHT; @@ -463,9 +463,9 @@ define([ if (defined(intersection) && !Cartesian3.equalsEpsilon(intersection, p0, CesiumMath.EPSILON7) && !Cartesian3.equalsEpsilon(intersection, p1, CesiumMath.EPSILON7)) { - if (groundPolylineGeometry.lineType === LineType.GEODESIC) { + if (groundPolylineGeometry.arcType === ArcType.GEODESIC) { splitPositions.push(Cartesian3.clone(intersection)); - } else if (groundPolylineGeometry.lineType === LineType.RHUMB) { + } else if (groundPolylineGeometry.arcType === ArcType.RHUMB) { intersectionLongitude = ellipsoid.cartesianToCartographic(intersection, cartographicScratch0).longitude; c0 = ellipsoid.cartesianToCartographic(p0, cartographicScratch0); c1 = ellipsoid.cartesianToCartographic(p1, cartographicScratch1); @@ -489,9 +489,9 @@ define([ if (defined(intersection) && !Cartesian3.equalsEpsilon(intersection, p0, CesiumMath.EPSILON7) && !Cartesian3.equalsEpsilon(intersection, p1, CesiumMath.EPSILON7)) { - if (groundPolylineGeometry.lineType === LineType.GEODESIC) { + if (groundPolylineGeometry.arcType === ArcType.GEODESIC) { splitPositions.push(Cartesian3.clone(intersection)); - } else if (groundPolylineGeometry.lineType === LineType.RHUMB) { + } else if (groundPolylineGeometry.arcType === ArcType.RHUMB) { intersectionLongitude = ellipsoid.cartesianToCartographic(intersection, cartographicScratch0).longitude; c0 = ellipsoid.cartesianToCartographic(p0, cartographicScratch0); c1 = ellipsoid.cartesianToCartographic(p1, cartographicScratch1); @@ -560,7 +560,7 @@ define([ cartographicsArray.push(startCartographic.latitude); cartographicsArray.push(startCartographic.longitude); - interpolateSegment(startCartographic, nextCartographic, minHeight, maxHeight, granularity, lineType, ellipsoid, normalsArray, bottomPositionsArray, topPositionsArray, cartographicsArray); + interpolateSegment(startCartographic, nextCartographic, minHeight, maxHeight, granularity, arcType, ellipsoid, normalsArray, bottomPositionsArray, topPositionsArray, cartographicsArray); // All inbetween points for (i = 1; i < cartographicsLength - 1; ++i) { @@ -579,7 +579,7 @@ define([ cartographicsArray.push(vertexCartographic.latitude); cartographicsArray.push(vertexCartographic.longitude); - interpolateSegment(cartographics[i], cartographics[i + 1], minHeight, maxHeight, granularity, lineType, ellipsoid, normalsArray, bottomPositionsArray, topPositionsArray, cartographicsArray); + interpolateSegment(cartographics[i], cartographics[i + 1], minHeight, maxHeight, granularity, arcType, ellipsoid, normalsArray, bottomPositionsArray, topPositionsArray, cartographicsArray); } // Last point - either loop or attach a normal "perpendicular" to the wall. @@ -607,7 +607,7 @@ define([ cartographicsArray.push(endCartographic.longitude); if (loop) { - interpolateSegment(endCartographic, startCartographic, minHeight, maxHeight, granularity, lineType, ellipsoid, normalsArray, bottomPositionsArray, topPositionsArray, cartographicsArray); + interpolateSegment(endCartographic, startCartographic, minHeight, maxHeight, granularity, arcType, ellipsoid, normalsArray, bottomPositionsArray, topPositionsArray, cartographicsArray); index = normalsArray.length; for (i = 0; i < 3; ++i) { normalsArray[index + i] = normalsArray[i]; diff --git a/Source/Core/PolygonGeometry.js b/Source/Core/PolygonGeometry.js index 5bd008a61270..dd40f44165a7 100644 --- a/Source/Core/PolygonGeometry.js +++ b/Source/Core/PolygonGeometry.js @@ -19,7 +19,7 @@ define([ './GeometryOffsetAttribute', './GeometryPipeline', './IndexDatatype', - './LineType', + './ArcType', './Math', './Matrix2', './Matrix3', @@ -50,7 +50,7 @@ define([ GeometryOffsetAttribute, GeometryPipeline, IndexDatatype, - LineType, + ArcType, CesiumMath, Matrix2, Matrix3, @@ -388,14 +388,14 @@ define([ var createGeometryFromPositionsExtrudedPositions = []; - function createGeometryFromPositionsExtruded(ellipsoid, polygon, granularity, hierarchy, perPositionHeight, closeTop, closeBottom, vertexFormat, lineType) { + function createGeometryFromPositionsExtruded(ellipsoid, polygon, granularity, hierarchy, perPositionHeight, closeTop, closeBottom, vertexFormat, arcType) { var geos = { walls : [] }; var i; if (closeTop || closeBottom) { - var topGeo = PolygonGeometryLibrary.createGeometryFromPositions(ellipsoid, polygon, granularity, perPositionHeight, vertexFormat, lineType); + var topGeo = PolygonGeometryLibrary.createGeometryFromPositions(ellipsoid, polygon, granularity, perPositionHeight, vertexFormat, arcType); var edgePoints = topGeo.attributes.position.values; var indices = topGeo.indices; @@ -457,7 +457,7 @@ define([ outerRing = outerRing.slice().reverse(); } - var wallGeo = PolygonGeometryLibrary.computeWallGeometry(outerRing, ellipsoid, granularity, perPositionHeight, lineType); + var wallGeo = PolygonGeometryLibrary.computeWallGeometry(outerRing, ellipsoid, granularity, perPositionHeight, arcType); geos.walls.push(new GeometryInstance({ geometry : wallGeo })); @@ -474,7 +474,7 @@ define([ hole = hole.slice().reverse(); } - wallGeo = PolygonGeometryLibrary.computeWallGeometry(hole, ellipsoid, granularity, perPositionHeight, lineType); + wallGeo = PolygonGeometryLibrary.computeWallGeometry(hole, ellipsoid, granularity, perPositionHeight, arcType); geos.walls.push(new GeometryInstance({ geometry : wallGeo })); @@ -500,7 +500,7 @@ define([ * @param {Boolean} [options.perPositionHeight=false] Use the height of options.positions for each position instead of using options.height to determine the height. * @param {Boolean} [options.closeTop=true] When false, leaves off the top of an extruded polygon open. * @param {Boolean} [options.closeBottom=true] When false, leaves off the bottom of an extruded polygon open. - * @param {LineType} [options.lineType=LineType.GEODESIC] The type of line the polygon edges must follow. Valid options are {@link LineType.GEODESIC} and {@link LineType.RHUMB}. + * @param {ArcType} [options.arcType=ArcType.GEODESIC] The type of line the polygon edges must follow. Valid options are {@link ArcType.GEODESIC} and {@link ArcType.RHUMB}. * * @see PolygonGeometry#createGeometry * @see PolygonGeometry#fromPositions @@ -581,8 +581,8 @@ define([ if (defined(options.perPositionHeight) && options.perPositionHeight && defined(options.height)) { throw new DeveloperError('Cannot use both options.perPositionHeight and options.height'); } - if (defined(options.lineType) && options.lineType !== LineType.GEODESIC && options.lineType !== LineType.RHUMB) { - throw new DeveloperError('Invalid lineType. Valid options are LineType.GEODESIC and LineType.RHUMB.'); + if (defined(options.arcType) && options.arcType !== ArcType.GEODESIC && options.arcType !== ArcType.RHUMB) { + throw new DeveloperError('Invalid arcType. Valid options are ArcType.GEODESIC and ArcType.RHUMB.'); } //>>includeEnd('debug'); @@ -616,7 +616,7 @@ define([ this._shadowVolume = defaultValue(options.shadowVolume, false); this._workerName = 'createPolygonGeometry'; this._offsetAttribute = options.offsetAttribute; - this._lineType = defaultValue(options.lineType, LineType.GEODESIC); + this._arcType = defaultValue(options.arcType, ArcType.GEODESIC); this._rectangle = undefined; this._textureCoordinateRotationPoints = undefined; @@ -642,7 +642,7 @@ define([ * @param {Boolean} [options.perPositionHeight=false] Use the height of options.positions for each position instead of using options.height to determine the height. * @param {Boolean} [options.closeTop=true] When false, leaves off the top of an extruded polygon open. * @param {Boolean} [options.closeBottom=true] When false, leaves off the bottom of an extruded polygon open. - * @param {LineType} [options.lineType=LineType.GEODESIC] The type of line the polygon edges must follow. Valid options are {@link LineType.GEODESIC} and {@link LineType.RHUMB}. + * @param {ArcType} [options.arcType=ArcType.GEODESIC] The type of line the polygon edges must follow. Valid options are {@link ArcType.GEODESIC} and {@link ArcType.RHUMB}. * @returns {PolygonGeometry} * * @@ -682,7 +682,7 @@ define([ closeTop : options.closeTop, closeBottom : options.closeBottom, offsetAttribute : options.offsetAttribute, - lineType : options.lineType + arcType : options.arcType }; return new PolygonGeometry(newOptions); }; @@ -722,7 +722,7 @@ define([ array[startingIndex++] = value._closeBottom ? 1.0 : 0.0; array[startingIndex++] = value._shadowVolume ? 1.0 : 0.0; array[startingIndex++] = defaultValue(value._offsetAttribute, -1); - array[startingIndex++] = value._lineType; + array[startingIndex++] = value._arcType; array[startingIndex] = value.packedLength; return array; @@ -770,7 +770,7 @@ define([ var closeBottom = array[startingIndex++] === 1.0; var shadowVolume = array[startingIndex++] === 1.0; var offsetAttribute = array[startingIndex++]; - var lineType = array[startingIndex++]; + var arcType = array[startingIndex++]; var packedLength = array[startingIndex]; if (!defined(result)) { @@ -790,7 +790,7 @@ define([ result._closeBottom = closeBottom; result._shadowVolume = shadowVolume; result._offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute; - result._lineType = lineType; + result._arcType = arcType; result.packedLength = packedLength; return result; }; @@ -832,7 +832,7 @@ define([ var perPositionHeight = polygonGeometry._perPositionHeight; var closeTop = polygonGeometry._closeTop; var closeBottom = polygonGeometry._closeBottom; - var lineType = polygonGeometry._lineType; + var arcType = polygonGeometry._arcType; var outerPositions = polygonHierarchy.positions; if (outerPositions.length < 3) { @@ -870,7 +870,7 @@ define([ top: true, wall: false, extrude: false, - lineType: lineType + arcType: arcType }; var i; @@ -882,7 +882,7 @@ define([ options.shadowVolume = polygonGeometry._shadowVolume; options.offsetAttribute = polygonGeometry._offsetAttribute; for (i = 0; i < polygons.length; i++) { - var splitGeometry = createGeometryFromPositionsExtruded(ellipsoid, polygons[i], granularity, hierarchy[i], perPositionHeight, closeTop, closeBottom, vertexFormat, lineType); + var splitGeometry = createGeometryFromPositionsExtruded(ellipsoid, polygons[i], granularity, hierarchy[i], perPositionHeight, closeTop, closeBottom, vertexFormat, arcType); var topAndBottom; if (closeTop && closeBottom) { @@ -915,7 +915,7 @@ define([ } else { for (i = 0; i < polygons.length; i++) { var geometryInstance = new GeometryInstance({ - geometry : PolygonGeometryLibrary.createGeometryFromPositions(ellipsoid, polygons[i], granularity, perPositionHeight, vertexFormat, lineType) + geometry : PolygonGeometryLibrary.createGeometryFromPositions(ellipsoid, polygons[i], granularity, perPositionHeight, vertexFormat, arcType) }); geometryInstance.geometry.attributes.position.values = PolygonPipeline.scaleToGeodeticHeight(geometryInstance.geometry.attributes.position.values, height, ellipsoid, !perPositionHeight); options.geometry = geometryInstance.geometry; @@ -977,7 +977,7 @@ define([ height : maxHeight, vertexFormat : VertexFormat.POSITION_ONLY, shadowVolume: true, - lineType : polygonGeometry._lineType + arcType : polygonGeometry._arcType }); }; diff --git a/Source/Core/PolygonGeometryLibrary.js b/Source/Core/PolygonGeometryLibrary.js index dec022ecbd3e..019dec38daaf 100644 --- a/Source/Core/PolygonGeometryLibrary.js +++ b/Source/Core/PolygonGeometryLibrary.js @@ -14,7 +14,7 @@ define([ './GeometryAttributes', './GeometryPipeline', './IndexDatatype', - './LineType', + './ArcType', './Math', './Matrix3', './PolygonPipeline', @@ -38,7 +38,7 @@ define([ GeometryAttributes, GeometryPipeline, IndexDatatype, - LineType, + ArcType, CesiumMath, Matrix3, PolygonPipeline, @@ -453,7 +453,7 @@ define([ return result; }; - PolygonGeometryLibrary.createGeometryFromPositions = function(ellipsoid, polygon, granularity, perPositionHeight, vertexFormat, lineType) { + PolygonGeometryLibrary.createGeometryFromPositions = function(ellipsoid, polygon, granularity, perPositionHeight, vertexFormat, arcType) { var indices = PolygonPipeline.triangulate(polygon.positions2D, polygon.holes); /* If polygon is completely unrenderable, just use the first three vertices */ @@ -492,9 +492,9 @@ define([ return geometry; } - if (lineType === LineType.GEODESIC) { + if (arcType === ArcType.GEODESIC) { return PolygonPipeline.computeSubdivision(ellipsoid, positions, indices, granularity); - } else if (lineType === LineType.RHUMB) { + } else if (arcType === ArcType.RHUMB) { return PolygonPipeline.computeRhumbLineSubdivision(ellipsoid, positions, indices, granularity); } }; @@ -503,7 +503,7 @@ define([ var p1Scratch = new Cartesian3(); var p2Scratch = new Cartesian3(); - PolygonGeometryLibrary.computeWallGeometry = function(positions, ellipsoid, granularity, perPositionHeight, lineType) { + PolygonGeometryLibrary.computeWallGeometry = function(positions, ellipsoid, granularity, perPositionHeight, arcType) { var edgePositions; var topEdgeLength; var i; @@ -517,11 +517,11 @@ define([ var minDistance = CesiumMath.chordLength(granularity, ellipsoid.maximumRadius); var numVertices = 0; - if (lineType === LineType.GEODESIC) { + if (arcType === ArcType.GEODESIC) { for (i = 0; i < length; i++) { numVertices += PolygonGeometryLibrary.subdivideLineCount(positions[i], positions[(i + 1) % length], minDistance); } - } else if (lineType === LineType.RHUMB) { + } else if (arcType === ArcType.RHUMB) { for (i = 0; i < length; i++) { numVertices += PolygonGeometryLibrary.subdivideRhumbLineCount(ellipsoid, positions[i], positions[(i + 1) % length], minDistance); } @@ -534,12 +534,12 @@ define([ p2 = positions[(i + 1) % length]; var tempPositions; - if (lineType === LineType.GEODESIC) { + if (arcType === ArcType.GEODESIC) { tempPositions = PolygonGeometryLibrary.subdivideLine(p1, p2, minDistance, computeWallIndicesSubdivided); - } else if (lineType === LineType.RHUMB) { + } else if (arcType === ArcType.RHUMB) { tempPositions = PolygonGeometryLibrary.subdivideRhumbLine(ellipsoid, p1, p2, minDistance, computeWallIndicesSubdivided); } else { - throw new DeveloperError('Unrecognized lineType. Valid options are LineType.GEODESIC and LineType.RHUMB'); + throw new DeveloperError('Unrecognized arcType. Valid options are ArcType.GEODESIC and ArcType.RHUMB'); } var tempPositionsLength = tempPositions.length; for (var j = 0; j < tempPositionsLength; ++j, ++index) { diff --git a/Source/Core/PolygonOutlineGeometry.js b/Source/Core/PolygonOutlineGeometry.js index ee03c2aebbaa..a35783e1cc62 100644 --- a/Source/Core/PolygonOutlineGeometry.js +++ b/Source/Core/PolygonOutlineGeometry.js @@ -17,7 +17,7 @@ define([ './GeometryOffsetAttribute', './GeometryPipeline', './IndexDatatype', - './LineType', + './ArcType', './Math', './PolygonGeometryLibrary', './PolygonPipeline', @@ -43,7 +43,7 @@ define([ GeometryOffsetAttribute, GeometryPipeline, IndexDatatype, - LineType, + ArcType, CesiumMath, PolygonGeometryLibrary, PolygonPipeline, @@ -54,7 +54,7 @@ define([ var createGeometryFromPositionsPositions = []; var createGeometryFromPositionsSubdivided = []; - function createGeometryFromPositions(ellipsoid, positions, minDistance, perPositionHeight, lineType) { + function createGeometryFromPositions(ellipsoid, positions, minDistance, perPositionHeight, arcType) { var tangentPlane = EllipsoidTangentPlane.fromPoints(positions, ellipsoid); var positions2D = tangentPlane.projectPointsOntoPlane(positions, createGeometryFromPositionsPositions); @@ -72,11 +72,11 @@ define([ if (!perPositionHeight) { var numVertices = 0; - if (lineType === LineType.GEODESIC) { + if (arcType === ArcType.GEODESIC) { for (i = 0; i < length; i++) { numVertices += PolygonGeometryLibrary.subdivideLineCount(positions[i], positions[(i + 1) % length], minDistance); } - } else if (lineType === LineType.RHUMB) { + } else if (arcType === ArcType.RHUMB) { for (i = 0; i < length; i++) { numVertices += PolygonGeometryLibrary.subdivideRhumbLineCount(ellipsoid, positions[i], positions[(i + 1) % length], minDistance); } @@ -84,9 +84,9 @@ define([ subdividedPositions = new Float64Array(numVertices * 3); for (i = 0; i < length; i++) { var tempPositions; - if (lineType === LineType.GEODESIC) { + if (arcType === ArcType.GEODESIC) { tempPositions = PolygonGeometryLibrary.subdivideLine(positions[i], positions[(i + 1) % length], minDistance, createGeometryFromPositionsSubdivided); - } else if (lineType === LineType.RHUMB) { + } else if (arcType === ArcType.RHUMB) { tempPositions = PolygonGeometryLibrary.subdivideRhumbLine(ellipsoid, positions[i], positions[(i + 1) % length], minDistance, createGeometryFromPositionsSubdivided); } var tempPositionsLength = tempPositions.length; @@ -134,7 +134,7 @@ define([ }); } - function createGeometryFromPositionsExtruded(ellipsoid, positions, minDistance, perPositionHeight, lineType) { + function createGeometryFromPositionsExtruded(ellipsoid, positions, minDistance, perPositionHeight, arcType) { var tangentPlane = EllipsoidTangentPlane.fromPoints(positions, ellipsoid); var positions2D = tangentPlane.projectPointsOntoPlane(positions, createGeometryFromPositionsPositions); @@ -153,11 +153,11 @@ define([ if (!perPositionHeight) { var numVertices = 0; - if (lineType === LineType.GEODESIC) { + if (arcType === ArcType.GEODESIC) { for (i = 0; i < length; i++) { numVertices += PolygonGeometryLibrary.subdivideLineCount(positions[i], positions[(i + 1) % length], minDistance); } - } else if (lineType === LineType.RHUMB) { + } else if (arcType === ArcType.RHUMB) { for (i = 0; i < length; i++) { numVertices += PolygonGeometryLibrary.subdivideRhumbLineCount(ellipsoid, positions[i], positions[(i + 1) % length], minDistance); } @@ -167,9 +167,9 @@ define([ for (i = 0; i < length; ++i) { corners[i] = index / 3; var tempPositions; - if (lineType === LineType.GEODESIC) { + if (arcType === ArcType.GEODESIC) { tempPositions = PolygonGeometryLibrary.subdivideLine(positions[i], positions[(i + 1) % length], minDistance, createGeometryFromPositionsSubdivided); - } else if (lineType === LineType.RHUMB) { + } else if (arcType === ArcType.RHUMB) { tempPositions = PolygonGeometryLibrary.subdivideRhumbLine(ellipsoid, positions[i], positions[(i + 1) % length], minDistance, createGeometryFromPositionsSubdivided); } var tempPositionsLength = tempPositions.length; @@ -242,7 +242,7 @@ define([ * @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. - * @param {LineType} [options.lineType=LineType.GEODESIC] The type of path the outline must follow. Valid options are {@link LineType.GEODESIC} and {@link LineType.RHUMB}. + * @param {ArcType} [options.arcType=ArcType.GEODESIC] The type of path the outline must follow. Valid options are {@link ArcType.GEODESIC} and {@link ArcType.RHUMB}. * * @see PolygonOutlineGeometry#createGeometry * @see PolygonOutlineGeometry#fromPositions @@ -322,8 +322,8 @@ define([ if (options.perPositionHeight && defined(options.height)) { throw new DeveloperError('Cannot use both options.perPositionHeight and options.height'); } - if (defined(options.lineType) && options.lineType !== LineType.GEODESIC && options.lineType !== LineType.RHUMB) { - throw new DeveloperError('Invalid lineType. Valid options are LineType.GEODESIC and LineType.RHUMB.'); + if (defined(options.arcType) && options.arcType !== ArcType.GEODESIC && options.arcType !== ArcType.RHUMB) { + throw new DeveloperError('Invalid arcType. Valid options are ArcType.GEODESIC and ArcType.RHUMB.'); } //>>includeEnd('debug'); @@ -332,7 +332,7 @@ define([ var granularity = defaultValue(options.granularity, CesiumMath.RADIANS_PER_DEGREE); var perPositionHeight = defaultValue(options.perPositionHeight, false); var perPositionHeightExtrude = perPositionHeight && defined(options.extrudedHeight); - var lineType = defaultValue(options.lineType, LineType.GEODESIC); + var arcType = defaultValue(options.arcType, ArcType.GEODESIC); var height = defaultValue(options.height, 0.0); var extrudedHeight = defaultValue(options.extrudedHeight, height); @@ -347,7 +347,7 @@ define([ this._granularity = granularity; this._height = height; this._extrudedHeight = extrudedHeight; - this._lineType = lineType; + this._arcType = arcType; this._polygonHierarchy = polygonHierarchy; this._perPositionHeight = perPositionHeight; this._perPositionHeightExtrude = perPositionHeightExtrude; @@ -388,7 +388,7 @@ define([ array[startingIndex++] = value._granularity; array[startingIndex++] = value._perPositionHeightExtrude ? 1.0 : 0.0; array[startingIndex++] = value._perPositionHeight ? 1.0 : 0.0; - array[startingIndex++] = value._lineType; + array[startingIndex++] = value._arcType; array[startingIndex++] = defaultValue(value._offsetAttribute, -1); array[startingIndex] = value.packedLength; @@ -427,7 +427,7 @@ define([ var granularity = array[startingIndex++]; var perPositionHeightExtrude = array[startingIndex++] === 1.0; var perPositionHeight = array[startingIndex++] === 1.0; - var lineType = array[startingIndex++]; + var arcType = array[startingIndex++]; var offsetAttribute = array[startingIndex++]; var packedLength = array[startingIndex]; @@ -442,7 +442,7 @@ define([ result._granularity = granularity; result._perPositionHeight = perPositionHeight; result._perPositionHeightExtrude = perPositionHeightExtrude; - result._lineType = lineType; + result._arcType = arcType; result._offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute; result.packedLength = packedLength; @@ -459,7 +459,7 @@ define([ * @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. - * @param {LineType} [options.lineType=LineType.GEODESIC] The type of path the outline must follow. Valid options are {@link LinkType.GEODESIC} and {@link LineType.RHUMB}. + * @param {ArcType} [options.arcType=ArcType.GEODESIC] The type of path the outline must follow. Valid options are {@link LinkType.GEODESIC} and {@link ArcType.RHUMB}. * @returns {PolygonOutlineGeometry} * * @@ -494,7 +494,7 @@ define([ ellipsoid : options.ellipsoid, granularity : options.granularity, perPositionHeight : options.perPositionHeight, - lineType: options.lineType, + arcType: options.arcType, offsetAttribute : options.offsetAttribute }; return new PolygonOutlineGeometry(newOptions); @@ -511,7 +511,7 @@ define([ var granularity = polygonGeometry._granularity; var polygonHierarchy = polygonGeometry._polygonHierarchy; var perPositionHeight = polygonGeometry._perPositionHeight; - var lineType = polygonGeometry._lineType; + var arcType = polygonGeometry._arcType; var polygons = PolygonGeometryLibrary.polygonOutlinesFromHierarchy(polygonHierarchy, !perPositionHeight, ellipsoid); @@ -530,7 +530,7 @@ define([ var i; if (extrude) { for (i = 0; i < polygons.length; i++) { - geometryInstance = createGeometryFromPositionsExtruded(ellipsoid, polygons[i], minDistance, perPositionHeight, lineType); + geometryInstance = createGeometryFromPositionsExtruded(ellipsoid, polygons[i], minDistance, perPositionHeight, arcType); geometryInstance.geometry = PolygonGeometryLibrary.scaleToGeodeticHeightExtruded(geometryInstance.geometry, height, extrudedHeight, ellipsoid, perPositionHeight); if (defined(polygonGeometry._offsetAttribute)) { var size = geometryInstance.geometry.attributes.position.values.length / 3; @@ -552,7 +552,7 @@ define([ } } else { for (i = 0; i < polygons.length; i++) { - geometryInstance = createGeometryFromPositions(ellipsoid, polygons[i], minDistance, perPositionHeight, lineType); + geometryInstance = createGeometryFromPositions(ellipsoid, polygons[i], minDistance, perPositionHeight, arcType); geometryInstance.geometry.attributes.position.values = PolygonPipeline.scaleToGeodeticHeight(geometryInstance.geometry.attributes.position.values, height, ellipsoid, !perPositionHeight); if (defined(polygonGeometry._offsetAttribute)) { diff --git a/Source/Core/PolylineGeometry.js b/Source/Core/PolylineGeometry.js index 68f6caac7f08..6b857c38ef31 100644 --- a/Source/Core/PolylineGeometry.js +++ b/Source/Core/PolylineGeometry.js @@ -14,7 +14,7 @@ define([ './GeometryAttributes', './GeometryType', './IndexDatatype', - './LineType', + './ArcType', './Math', './PolylinePipeline', './PrimitiveType', @@ -35,7 +35,7 @@ define([ GeometryAttributes, GeometryType, IndexDatatype, - LineType, + ArcType, CesiumMath, PolylinePipeline, PrimitiveType, @@ -92,8 +92,8 @@ define([ * @param {Color[]} [options.colors] An Array of {@link Color} defining the per vertex or per segment colors. * @param {Boolean} [options.colorsPerVertex=false] A boolean that determines whether the colors will be flat across each segment of the line or interpolated across the vertices. * @param {Boolean} [options.followSurface=true] A boolean that determines whether positions will be adjusted to the surface of the ellipsoid via a great arc. - * @param {LineType} [options.lineType=LineType.GEODESIC] The type of line the polyline segments must follow. - * @param {Number} [options.granularity=CesiumMath.RADIANS_PER_DEGREE] The distance, in radians, between each latitude and longitude if options.lineType is not LineType.STRAIGHT. Determines the number of positions in the buffer. + * @param {ArcType} [options.arcType=ArcType.GEODESIC] The type of line the polyline segments must follow. + * @param {Number} [options.granularity=CesiumMath.RADIANS_PER_DEGREE] The distance, in radians, between each latitude and longitude if options.arcType is not ArcType.NONE. Determines the number of positions in the buffer. * @param {VertexFormat} [options.vertexFormat=VertexFormat.DEFAULT] The vertex attributes to be computed. * @param {Ellipsoid} [options.ellipsoid=Ellipsoid.WGS84] The ellipsoid to be used as a reference. * @@ -144,11 +144,11 @@ define([ this._followSurface = defaultValue(options.followSurface, true); if (defined(options.followSurface)) { - deprecationWarning('PolylineGeometry.followSurface', 'PolylineGeometry.followSurface is deprecated and will be removed in Cesium 1.55. Use PolylineGeometry.lineType instead.'); - options.lineType = options.followSurface ? LineType.GEODESIC : LineType.STRAIGHT; + deprecationWarning('PolylineGeometry.followSurface', 'PolylineGeometry.followSurface is deprecated and will be removed in Cesium 1.55. Use PolylineGeometry.arcType instead.'); + options.arcType = options.followSurface ? ArcType.GEODESIC : ArcType.NONE; } - this._lineType = defaultValue(options.lineType, LineType.GEODESIC); - this._followSurface = (this._lineType !== LineType.STRAIGHT); + this._arcType = defaultValue(options.arcType, ArcType.GEODESIC); + this._followSurface = (this._arcType !== ArcType.NONE); this._granularity = defaultValue(options.granularity, CesiumMath.RADIANS_PER_DEGREE); this._ellipsoid = Ellipsoid.clone(defaultValue(options.ellipsoid, Ellipsoid.WGS84)); @@ -211,7 +211,7 @@ define([ array[startingIndex++] = value._width; array[startingIndex++] = value._colorsPerVertex ? 1.0 : 0.0; - array[startingIndex++] = value._lineType; + array[startingIndex++] = value._arcType; array[startingIndex] = value._granularity; return array; @@ -226,7 +226,7 @@ define([ vertexFormat : scratchVertexFormat, width : undefined, colorsPerVertex : undefined, - lineType : undefined, + arcType : undefined, granularity : undefined }; @@ -271,7 +271,7 @@ define([ var width = array[startingIndex++]; var colorsPerVertex = array[startingIndex++] === 1.0; - var lineType = array[startingIndex++]; + var arcType = array[startingIndex++]; var granularity = array[startingIndex]; if (!defined(result)) { @@ -279,7 +279,7 @@ define([ scratchOptions.colors = colors; scratchOptions.width = width; scratchOptions.colorsPerVertex = colorsPerVertex; - scratchOptions.lineType = lineType; + scratchOptions.arcType = arcType; scratchOptions.granularity = granularity; return new PolylineGeometry(scratchOptions); } @@ -290,7 +290,7 @@ define([ result._vertexFormat = VertexFormat.clone(vertexFormat, result._vertexFormat); result._width = width; result._colorsPerVertex = colorsPerVertex; - result._lineType = lineType; + result._arcType = arcType; result._granularity = granularity; return result; @@ -312,7 +312,7 @@ define([ var vertexFormat = polylineGeometry._vertexFormat; var colors = polylineGeometry._colors; var colorsPerVertex = polylineGeometry._colorsPerVertex; - var lineType = polylineGeometry._lineType; + var arcType = polylineGeometry._arcType; var granularity = polylineGeometry._granularity; var ellipsoid = polylineGeometry._ellipsoid; @@ -329,10 +329,10 @@ define([ return undefined; } - if (lineType === LineType.GEODESIC || lineType === LineType.RHUMB) { + if (arcType === ArcType.GEODESIC || arcType === ArcType.RHUMB) { var subdivisionSize; var numberOfPointsFunction; - if (lineType === LineType.GEODESIC) { + if (arcType === ArcType.GEODESIC) { subdivisionSize = CesiumMath.chordLength(granularity, ellipsoid.maximumRadius); numberOfPointsFunction = PolylinePipeline.numberOfPoints; } else { @@ -377,7 +377,7 @@ define([ scratchInterpolateColorsArray.length = 0; } - if (lineType === LineType.GEODESIC) { + if (arcType === ArcType.GEODESIC) { positions = PolylinePipeline.generateCartesianArc({ positions: positions, minDistance: subdivisionSize, diff --git a/Source/Core/SimplePolylineGeometry.js b/Source/Core/SimplePolylineGeometry.js index d03d2ba71171..67bb31740c4f 100644 --- a/Source/Core/SimplePolylineGeometry.js +++ b/Source/Core/SimplePolylineGeometry.js @@ -12,7 +12,7 @@ define([ './GeometryAttribute', './GeometryAttributes', './IndexDatatype', - './LineType', + './ArcType', './Math', './PolylinePipeline', './PrimitiveType' @@ -30,7 +30,7 @@ define([ GeometryAttribute, GeometryAttributes, IndexDatatype, - LineType, + ArcType, CesiumMath, PolylinePipeline, PrimitiveType) { @@ -88,8 +88,8 @@ define([ * @param {Color[]} [options.colors] An Array of {@link Color} defining the per vertex or per segment colors. * @param {Boolean} [options.colorsPerVertex=false] A boolean that determines whether the colors will be flat across each segment of the line or interpolated across the vertices. * @param {Boolean} [options.followSurface=true] A boolean that determines whether positions will be adjusted to the surface of the ellipsoid via a great arc. - * @param {LineType} [options.lineType=LineType.GEODESIC] The type of line the polyline segments must follow. - * @param {Number} [options.granularity=CesiumMath.RADIANS_PER_DEGREE] The distance, in radians, between each latitude and longitude if options.lineType is not LineType.STRAIGHT. Determines the number of positions in the buffer. + * @param {ArcType} [options.arcType=ArcType.GEODESIC] The type of line the polyline segments must follow. + * @param {Number} [options.granularity=CesiumMath.RADIANS_PER_DEGREE] The distance, in radians, between each latitude and longitude if options.arcType is not ArcType.NONE. Determines the number of positions in the buffer. * @param {Ellipsoid} [options.ellipsoid=Ellipsoid.WGS84] The ellipsoid to be used as a reference. * * @exception {DeveloperError} At least two positions are required. @@ -129,11 +129,11 @@ define([ this._followSurface = defaultValue(options.followSurface, true); if (defined(options.followSurface)) { - deprecationWarning('PolylineGeometry.followSurface', 'PolylineGeometry.followSurface is deprecated and will be removed in Cesium 1.55. Use PolylineGeometry.lineType instead.'); - options.lineType = options.followSurface ? LineType.GEODESIC : LineType.STRAIGHT; + deprecationWarning('PolylineGeometry.followSurface', 'PolylineGeometry.followSurface is deprecated and will be removed in Cesium 1.55. Use PolylineGeometry.arcType instead.'); + options.arcType = options.followSurface ? ArcType.GEODESIC : ArcType.NONE; } - this._lineType = defaultValue(options.lineType, LineType.GEODESIC); - this._followSurface = this._lineType === LineType.STRAIGHT; + this._arcType = defaultValue(options.arcType, ArcType.GEODESIC); + this._followSurface = this._arcType === ArcType.NONE; this._granularity = defaultValue(options.granularity, CesiumMath.RADIANS_PER_DEGREE); this._ellipsoid = defaultValue(options.ellipsoid, Ellipsoid.WGS84); @@ -192,7 +192,7 @@ define([ startingIndex += Ellipsoid.packedLength; array[startingIndex++] = value._colorsPerVertex ? 1.0 : 0.0; - array[startingIndex++] = value._lineType; + array[startingIndex++] = value._arcType; array[startingIndex] = value._granularity; return array; @@ -235,7 +235,7 @@ define([ startingIndex += Ellipsoid.packedLength; var colorsPerVertex = array[startingIndex++] === 1.0; - var lineType = array[startingIndex++]; + var arcType = array[startingIndex++]; var granularity = array[startingIndex]; if (!defined(result)) { @@ -244,7 +244,7 @@ define([ colors : colors, ellipsoid : ellipsoid, colorsPerVertex : colorsPerVertex, - lineType : lineType, + arcType : arcType, granularity : granularity }); } @@ -253,7 +253,7 @@ define([ result._colors = colors; result._ellipsoid = ellipsoid; result._colorsPerVertex = colorsPerVertex; - result._lineType = lineType; + result._arcType = arcType; result._granularity = granularity; return result; @@ -279,7 +279,7 @@ define([ var positions = simplePolylineGeometry._positions; var colors = simplePolylineGeometry._colors; var colorsPerVertex = simplePolylineGeometry._colorsPerVertex; - var lineType = simplePolylineGeometry._lineType; + var arcType = simplePolylineGeometry._arcType; var granularity = simplePolylineGeometry._granularity; var ellipsoid = simplePolylineGeometry._ellipsoid; @@ -295,11 +295,11 @@ define([ var color; var offset = 0; - if (lineType === LineType.GEODESIC || lineType === LineType.RHUMB) { + if (arcType === ArcType.GEODESIC || arcType === ArcType.RHUMB) { var subdivisionSize; var numberOfPointsFunction; var generateArcFunction; - if (lineType === LineType.GEODESIC) { + if (arcType === ArcType.GEODESIC) { subdivisionSize = CesiumMath.chordLength(granularity, ellipsoid.maximumRadius); numberOfPointsFunction = PolylinePipeline.numberOfPoints; generateArcFunction = PolylinePipeline.generateArc; @@ -312,7 +312,7 @@ define([ var heights = PolylinePipeline.extractHeights(positions, ellipsoid); var generateArcOptions = generateArcOptionsScratch; - if (lineType === LineType.GEODESIC) { + if (arcType === ArcType.GEODESIC) { generateArcOptions.minDistance = minDistance; } else { generateArcOptions.granularity = granularity; diff --git a/Source/DataSources/Entity.js b/Source/DataSources/Entity.js index 0b5fd179c124..04be1bef39b7 100644 --- a/Source/DataSources/Entity.js +++ b/Source/DataSources/Entity.js @@ -678,7 +678,7 @@ define([ /** * Checks if the given Scene supports polylines clamped to terrain or 3D Tiles. * If this feature is not supported, Entities with PolylineGraphics will be rendered with vertices at - * the provided heights and using the `lineType` parameter instead of clamped to the ground. + * the provided heights and using the `arcType` parameter instead of clamped to the ground. * * @param {Scene} scene The current scene. * @returns {Boolean} Whether or not the current scene supports polylines on terrain or 3D TIles. diff --git a/Source/DataSources/GeoJsonDataSource.js b/Source/DataSources/GeoJsonDataSource.js index bd3513a52795..f8876fdb477c 100644 --- a/Source/DataSources/GeoJsonDataSource.js +++ b/Source/DataSources/GeoJsonDataSource.js @@ -8,7 +8,7 @@ define([ '../Core/DeveloperError', '../Core/Event', '../Core/getFilenameFromUri', - '../Core/LineType', + '../Core/ArcType', '../Core/PinBuilder', '../Core/PolygonHierarchy', '../Core/Resource', @@ -37,7 +37,7 @@ define([ DeveloperError, Event, getFilenameFromUri, - LineType, + ArcType, PinBuilder, PolygonHierarchy, Resource, @@ -367,7 +367,7 @@ define([ polylineGraphics.material = material; polylineGraphics.width = widthProperty; polylineGraphics.positions = new ConstantProperty(coordinatesArrayToCartesianArray(coordinates, crsFunction)); - polylineGraphics.lineType = LineType.RHUMB; + polylineGraphics.arcType = ArcType.RHUMB; } function processLineString(dataSource, geoJson, geometry, crsFunction, options) { @@ -437,7 +437,7 @@ define([ polygon.outlineColor = outlineColorProperty; polygon.outlineWidth = widthProperty; polygon.material = material; - polygon.lineType = LineType.RHUMB; + polygon.arcType = ArcType.RHUMB; var holes = []; for (var i = 1, len = coordinates.length; i < len; i++) { diff --git a/Source/DataSources/PolygonGeometryUpdater.js b/Source/DataSources/PolygonGeometryUpdater.js index 251f5a6d339a..aabb9366ce91 100644 --- a/Source/DataSources/PolygonGeometryUpdater.js +++ b/Source/DataSources/PolygonGeometryUpdater.js @@ -15,7 +15,7 @@ define([ '../Core/GeometryOffsetAttribute', '../Core/isArray', '../Core/Iso8601', - '../Core/LineType', + '../Core/ArcType', '../Core/oneTimeWarning', '../Core/OffsetGeometryInstanceAttribute', '../Core/PolygonGeometry', @@ -49,7 +49,7 @@ define([ GeometryOffsetAttribute, isArray, Iso8601, - LineType, + ArcType, oneTimeWarning, OffsetGeometryInstanceAttribute, PolygonGeometry, @@ -90,7 +90,7 @@ define([ this.granularity = undefined; this.stRotation = undefined; this.offsetAttribute = undefined; - this.lineType = undefined; + this.arcType = undefined; } /** @@ -278,7 +278,7 @@ define([ !Property.isConstant(polygon.closeTop) || // !Property.isConstant(polygon.closeBottom) || // !Property.isConstant(polygon.zIndex) || // - !Property.isConstant(polygon.lineType) || // + !Property.isConstant(polygon.arcType) || // (this._onTerrain && !Property.isConstant(this._materialProperty)); }; @@ -326,7 +326,7 @@ define([ options.closeBottom = Property.getValueOrDefault(polygon.closeBottom, Iso8601.MINIMUM_VALUE, true); options.offsetAttribute = offsetAttribute; options.height = heightValue; - options.lineType = Property.getValueOrDefault(polygon.lineType, Iso8601.MINIMUM_VALUE, LineType.GEODESIC); + options.arcType = Property.getValueOrDefault(polygon.arcType, Iso8601.MINIMUM_VALUE, ArcType.GEODESIC); extrudedHeightValue = GroundGeometryUpdater.getGeometryExtrudedHeight(extrudedHeightValue, extrudedHeightReferenceValue); if (extrudedHeightValue === GroundGeometryUpdater.CLAMP_TO_GROUND) { @@ -404,7 +404,7 @@ define([ options.closeBottom = Property.getValueOrDefault(polygon.closeBottom, time, true); options.offsetAttribute = offsetAttribute; options.height = heightValue; - options.lineType = Property.getValueOrDefault(polygon.lineType, time, LineType.GEODESIC); + options.arcType = Property.getValueOrDefault(polygon.arcType, time, ArcType.GEODESIC); extrudedHeightValue = GroundGeometryUpdater.getGeometryExtrudedHeight(extrudedHeightValue, extrudedHeightReferenceValue); if (extrudedHeightValue === GroundGeometryUpdater.CLAMP_TO_GROUND) { diff --git a/Source/DataSources/PolygonGraphics.js b/Source/DataSources/PolygonGraphics.js index 4396d03191d7..ede07748796f 100644 --- a/Source/DataSources/PolygonGraphics.js +++ b/Source/DataSources/PolygonGraphics.js @@ -44,7 +44,7 @@ define([ * @param {Property} [options.shadows=ShadowMode.DISABLED] An enum Property specifying whether the polygon casts or receives shadows from each light source. * @param {Property} [options.distanceDisplayCondition] A Property specifying at what distance from the camera that this polygon will be displayed. * @param {Property} [options.classificationType=ClassificationType.BOTH] An enum Property specifying whether this polygon will classify terrain, 3D Tiles, or both when on the ground. - * @param {Property} [options.lineType=LineType.GEODESIC] The type of line the polygon edges must follow. + * @param {Property} [options.arcType=ArcType.GEODESIC] The type of line the polygon edges must follow. * @param {ConstantProperty} [options.zIndex=0] A property specifying the zIndex used for ordering ground geometry. Only has an effect if the polygon is constant and neither height or extrudedHeight are specified. * * @see Entity @@ -89,8 +89,8 @@ define([ this._distanceDisplayConditionSubscription = undefined; this._classificationType = undefined; this._classificationTypeSubscription = undefined; - this._lineType = undefined; - this._lineTypeSubscription = undefined; + this._arcType = undefined; + this._arcTypeSubscription = undefined; this._zIndex = undefined; this._zIndexSubscription = undefined; this._definitionChanged = new Event(); @@ -264,12 +264,12 @@ define([ classificationType : createPropertyDescriptor('classificationType'), /** - * Gets or sets the {@link LineType} Property specifying the type of lines the polygon edges use. + * Gets or sets the {@link ArcType} Property specifying the type of lines the polygon edges use. * @memberof PolygonGraphics.prototype * @type {Property} - * @default LineType.GEODESIC + * @default ArcType.GEODESIC */ - lineType : createPropertyDescriptor('lineType'), + arcType : createPropertyDescriptor('arcType'), /** * Gets or sets the zIndex Prperty specifying the ordering of ground geometry. Only has an effect if the polygon is constant and neither height or extrudedHeight are specified. @@ -309,7 +309,7 @@ define([ result.shadows = this.shadows; result.distanceDisplayCondition = this.distanceDisplayCondition; result.classificationType = this.classificationType; - result.lineType = this.lineType; + result.arcType = this.arcType; result.zIndex = this.zIndex; return result; @@ -347,7 +347,7 @@ define([ this.shadows = defaultValue(this.shadows, source.shadows); this.distanceDisplayCondition = defaultValue(this.distanceDisplayCondition, source.distanceDisplayCondition); this.classificationType = defaultValue(this.classificationType, source.classificationType); - this.lineType = defaultValue(this.lineType, source.lineType); + this.arcType = defaultValue(this.arcType, source.arcType); this.zIndex = defaultValue(this.zIndex, source.zIndex); }; diff --git a/Source/DataSources/PolylineGeometryUpdater.js b/Source/DataSources/PolylineGeometryUpdater.js index 8a513edabbcf..6ef60d4ac047 100644 --- a/Source/DataSources/PolylineGeometryUpdater.js +++ b/Source/DataSources/PolylineGeometryUpdater.js @@ -14,7 +14,7 @@ define([ '../Core/GeometryInstance', '../Core/GroundPolylineGeometry', '../Core/Iso8601', - '../Core/LineType', + '../Core/ArcType', '../Core/oneTimeWarning', '../Core/PolylineGeometry', '../Core/PolylinePipeline', @@ -47,7 +47,7 @@ define([ GeometryInstance, GroundPolylineGeometry, Iso8601, - LineType, + ArcType, oneTimeWarning, PolylineGeometry, PolylinePipeline, @@ -83,14 +83,14 @@ define([ this.positions = undefined; this.width = undefined; this.followSurface = undefined; - this.lineType = undefined; + this.arcType = undefined; this.granularity = undefined; } function GroundGeometryOptions() { this.positions = undefined; this.width = undefined; - this.lineType = undefined; + this.arcType = undefined; this.granularity = undefined; } @@ -318,12 +318,12 @@ define([ * Gets a value indicating if the path of the line. * @memberof PolylineGeometryUpdater.prototype * - * @type {LineType} + * @type {ArcType} * @readonly */ - lineType : { + arcType : { get : function() { - return this._lineType; + return this._arcType; } }, @@ -516,12 +516,12 @@ define([ var width = polyline.width; var followSurface = polyline.followSurface; - var lineType = polyline.lineType; + var arcType = polyline.arcType; var clampToGround = polyline.clampToGround; var granularity = polyline.granularity; if (!positionsProperty.isConstant || !Property.isConstant(width) || - !Property.isConstant(followSurface) || !Property.isConstant(lineType) || !Property.isConstant(granularity) || + !Property.isConstant(followSurface) || !Property.isConstant(arcType) || !Property.isConstant(granularity) || !Property.isConstant(clampToGround) || !Property.isConstant(zIndex)) { if (!this._dynamic) { this._dynamic = true; @@ -552,13 +552,13 @@ define([ geometryOptions.positions = positions; geometryOptions.width = defined(width) ? width.getValue(Iso8601.MINIMUM_VALUE) : undefined; geometryOptions.followSurface = defined(followSurface) ? followSurface.getValue(Iso8601.MINIMUM_VALUE) : undefined; - geometryOptions.lineType = defined(lineType) ? lineType.getValue(Iso8601.MINIMUM_VALUE) : undefined; + geometryOptions.arcType = defined(arcType) ? arcType.getValue(Iso8601.MINIMUM_VALUE) : undefined; geometryOptions.granularity = defined(granularity) ? granularity.getValue(Iso8601.MINIMUM_VALUE) : undefined; var groundGeometryOptions = this._groundGeometryOptions; groundGeometryOptions.positions = positions; groundGeometryOptions.width = geometryOptions.width; - groundGeometryOptions.lineType = geometryOptions.lineType; + groundGeometryOptions.arcType = geometryOptions.arcType; groundGeometryOptions.granularity = geometryOptions.granularity; this._clampToGround = defined(clampToGround) ? clampToGround.getValue(Iso8601.MINIMUM_VALUE) : false; @@ -648,7 +648,7 @@ define([ geometryUpdater._clampToGround = Property.getValueOrDefault(polyline._clampToGround, time, false); geometryUpdater._groundGeometryOptions.positions = positions; geometryUpdater._groundGeometryOptions.width = Property.getValueOrDefault(polyline._width, time, 1); - geometryUpdater._groundGeometryOptions.lineType = Property.getValueOrDefault(polyline._lineType, time, LineType.GEODESIC); + geometryUpdater._groundGeometryOptions.arcType = Property.getValueOrDefault(polyline._arcType, time, ArcType.GEODESIC); geometryUpdater._groundGeometryOptions.granularity = Property.getValueOrDefault(polyline._granularity, time, 9999); var groundPrimitives = this._groundPrimitives; @@ -707,14 +707,14 @@ define([ } var followSurface = Property.getValueOrUndefined(polyline._followSurface, time); - var lineType = LineType.GEODESIC; + var arcType = ArcType.GEODESIC; if (defined(followSurface)) { - lineType = followSurface ? LineType.GEODESIC : LineType.STRAIGHT; + arcType = followSurface ? ArcType.GEODESIC : ArcType.NONE; } - lineType = Property.getValueOrDefault(polyline._lineType, time, lineType); + arcType = Property.getValueOrDefault(polyline._arcType, time, arcType); var globe = geometryUpdater._scene.globe; - if (lineType !== LineType.STRAIGHT && defined(globe)) { + if (arcType !== ArcType.NONE && defined(globe)) { generateCartesianArcOptions.ellipsoid = globe.ellipsoid; generateCartesianArcOptions.positions = positions; generateCartesianArcOptions.granularity = Property.getValueOrUndefined(polyline._granularity, time); diff --git a/Source/DataSources/PolylineGraphics.js b/Source/DataSources/PolylineGraphics.js index 3fb006ba3b03..24195c6b4266 100644 --- a/Source/DataSources/PolylineGraphics.js +++ b/Source/DataSources/PolylineGraphics.js @@ -4,7 +4,7 @@ define([ '../Core/defineProperties', '../Core/DeveloperError', '../Core/Event', - '../Core/LineType', + '../Core/ArcType', './createMaterialPropertyDescriptor', './createPropertyDescriptor' ], function( @@ -13,7 +13,7 @@ define([ defineProperties, DeveloperError, Event, - LineType, + ArcType, createMaterialPropertyDescriptor, createPropertyDescriptor) { 'use strict'; @@ -29,13 +29,13 @@ define([ * @param {Object} [options] Object with the following properties: * @param {Property} [options.positions] A Property specifying the array of {@link Cartesian3} positions that define the line strip. * @param {Property} [options.followSurface=true] A boolean Property specifying whether the line segments should be great arcs or linearly connected. - * @param {LineType} [options.lineType=LineType.GEODESIC] The type of line the polyline segments must follow. + * @param {ArcType} [options.arcType=ArcType.GEODESIC] The type of line the polyline segments must follow. * @param {Property} [options.clampToGround=false] A boolean Property specifying whether the Polyline should be clamped to the ground. * @param {Property} [options.width=1.0] A numeric Property specifying the width in pixels. * @param {Property} [options.show=true] A boolean Property specifying the visibility of the polyline. * @param {MaterialProperty} [options.material=Color.WHITE] A Property specifying the material used to draw the polyline. * @param {MaterialProperty} [options.depthFailMaterial] A property specifying the material used to draw the polyline when it is below the terrain. - * @param {Property} [options.granularity=Cesium.Math.RADIANS_PER_DEGREE] A numeric Property specifying the angular distance between each latitude and longitude if lineType is not LineType.STRAIGHT. + * @param {Property} [options.granularity=Cesium.Math.RADIANS_PER_DEGREE] A numeric Property specifying the angular distance between each latitude and longitude if arcType is not ArcType.NONE. * @param {Property} [options.shadows=ShadowMode.DISABLED] An enum Property specifying whether the polyline casts or receives shadows from each light source. * @param {Property} [options.distanceDisplayCondition] A Property specifying at what distance from the camera that this polyline will be displayed. * @param {Property} [options.classificationType=ClassificationType.BOTH] An enum Property specifying whether this polyline will classify terrain, 3D Tiles, or both when on the ground. @@ -55,8 +55,8 @@ define([ this._positionsSubscription = undefined; this._followSurface = undefined; this._followSurfaceSubscription = undefined; - this._lineType = undefined; - this._lineTypeSubscription = undefined; + this._arcType = undefined; + this._arcTypeSubscription = undefined; this._clampToGround = undefined; this._clampToGroundSubscription = undefined; this._granularity = undefined; @@ -141,19 +141,19 @@ define([ * should be great arcs or linearly connected. * @memberof PolylineGraphics.prototype * @type {Property} - * @deprecated This property has been deprecated. Use {@link PolylineGraphics#lineType} instead. + * @deprecated This property has been deprecated. Use {@link PolylineGraphics#arcType} instead. * @default true */ followSurface : createPropertyDescriptor('followSurface'), /** - * Gets or sets the {@link LineType} Property specifying whether the line segments should be great arcs, rhumb lines or linearly connected. + * Gets or sets the {@link ArcType} Property specifying whether the line segments should be great arcs, rhumb lines or linearly connected. * @memberof PolylineGraphics.prototype * @type {Property} - * @deprecated This property has been deprecated. Use {@link PolylineGraphics#lineType} instead. - * @default LineType.GEODESIC + * @deprecated This property has been deprecated. Use {@link PolylineGraphics#arcType} instead. + * @default ArcType.GEODESIC */ - lineType : createPropertyDescriptor('lineType'), + arcType : createPropertyDescriptor('arcType'), /** * Gets or sets the boolean Property specifying whether the polyline @@ -165,7 +165,7 @@ define([ clampToGround : createPropertyDescriptor('clampToGround'), /** - * Gets or sets the numeric Property specifying the angular distance between each latitude and longitude if lineType is not LineType.STRAIGHT and clampToGround is false. + * Gets or sets the numeric Property specifying the angular distance between each latitude and longitude if arcType is not ArcType.NONE and clampToGround is false. * @memberof PolylineGraphics.prototype * @type {Property} * @default Cesium.Math.RADIANS_PER_DEGREE @@ -221,7 +221,7 @@ define([ result.positions = this.positions; result.width = this.width; result.followSurface = this.followSurface; - result.lineType = this.lineType; + result.arcType = this.arcType; result.clampToGround = this.clampToGround; result.granularity = this.granularity; result.shadows = this.shadows; @@ -251,7 +251,7 @@ define([ this.positions = defaultValue(this.positions, source.positions); this.width = defaultValue(this.width, source.width); this.followSurface = defaultValue(this.followSurface, source.followSurface); - this.lineType = defaultValue(this.lineType, source.lineType); + this.arcType = defaultValue(this.arcType, source.arcType); this.clampToGround = defaultValue(this.clampToGround, source.clampToGround); this.granularity = defaultValue(this.granularity, source.granularity); this.shadows = defaultValue(this.shadows, source.shadows); diff --git a/Source/Scene/DebugModelMatrixPrimitive.js b/Source/Scene/DebugModelMatrixPrimitive.js index 56e4d68bfdcd..092b6879e64d 100644 --- a/Source/Scene/DebugModelMatrixPrimitive.js +++ b/Source/Scene/DebugModelMatrixPrimitive.js @@ -5,7 +5,7 @@ define([ '../Core/defined', '../Core/destroyObject', '../Core/GeometryInstance', - '../Core/LineType', + '../Core/ArcType', '../Core/Matrix4', '../Core/PolylineGeometry', './PolylineColorAppearance', @@ -17,7 +17,7 @@ define([ defined, destroyObject, GeometryInstance, - LineType, + ArcType, Matrix4, PolylineGeometry, PolylineColorAppearance, @@ -144,7 +144,7 @@ define([ Color.RED, Color.RED ], - lineType: LineType.STRAIGHT + arcType: ArcType.NONE }), modelMatrix : Matrix4.multiplyByUniformScale(this.modelMatrix, this.length, new Matrix4()), id : this.id, @@ -162,7 +162,7 @@ define([ Color.GREEN, Color.GREEN ], - lineType: LineType.STRAIGHT + arcType: ArcType.NONE }), modelMatrix : Matrix4.multiplyByUniformScale(this.modelMatrix, this.length, new Matrix4()), id : this.id, @@ -180,7 +180,7 @@ define([ Color.BLUE, Color.BLUE ], - lineType: LineType.STRAIGHT + arcType: ArcType.NONE }), modelMatrix : Matrix4.multiplyByUniformScale(this.modelMatrix, this.length, new Matrix4()), id : this.id, diff --git a/Specs/Core/GroundPolylineGeometrySpec.js b/Specs/Core/GroundPolylineGeometrySpec.js index 9ccc1aba87a0..21ecc96c627d 100644 --- a/Specs/Core/GroundPolylineGeometrySpec.js +++ b/Specs/Core/GroundPolylineGeometrySpec.js @@ -6,7 +6,7 @@ defineSuite([ 'Core/Cartographic', 'Core/Ellipsoid', 'Core/GeographicProjection', - 'Core/LineType', + 'Core/ArcType', 'Core/Math', 'Core/WebMercatorProjection', 'Specs/createPackableSpecs' @@ -18,7 +18,7 @@ defineSuite([ Cartographic, Ellipsoid, GeographicProjection, - LineType, + ArcType, CesiumMath, WebMercatorProjection, createPackableSpecs) { @@ -376,12 +376,12 @@ defineSuite([ var rhumbGroundPolylineGeometry = new GroundPolylineGeometry({ positions : positions, granularity : 2890.0, - lineType: LineType.RHUMB + arcType: ArcType.RHUMB }); var geodesicGroundPolylineGeometry = new GroundPolylineGeometry({ positions : positions, granularity : 2890.0, - lineType: LineType.GEODESIC + arcType: ArcType.GEODESIC }); var rhumbGeometry = GroundPolylineGeometry.createGeometry(rhumbGroundPolylineGeometry); @@ -401,12 +401,12 @@ defineSuite([ rhumbGroundPolylineGeometry = new GroundPolylineGeometry({ positions : positions, granularity : 2890.0, - lineType: LineType.RHUMB + arcType: ArcType.RHUMB }); geodesicGroundPolylineGeometry = new GroundPolylineGeometry({ positions : positions, granularity : 2890.0, - lineType: LineType.GEODESIC + arcType: ArcType.GEODESIC }); rhumbGeometry = GroundPolylineGeometry.createGeometry(rhumbGroundPolylineGeometry); @@ -618,7 +618,7 @@ defineSuite([ Cartesian3.pack(positions[2], packedInstance, packedInstance.length); packedInstance.push(polyline.granularity); packedInstance.push(polyline.loop ? 1.0 : 0.0); - packedInstance.push(polyline.lineType); + packedInstance.push(polyline.arcType); Ellipsoid.pack(Ellipsoid.WGS84, packedInstance, packedInstance.length); diff --git a/Specs/Core/PolygonGeometrySpec.js b/Specs/Core/PolygonGeometrySpec.js index 1f39d2f70067..1b009ee37b8b 100644 --- a/Specs/Core/PolygonGeometrySpec.js +++ b/Specs/Core/PolygonGeometrySpec.js @@ -6,7 +6,7 @@ defineSuite([ 'Core/Ellipsoid', 'Core/GeometryOffsetAttribute', 'Core/GeometryPipeline', - 'Core/LineType', + 'Core/ArcType', 'Core/Math', 'Core/Rectangle', 'Core/VertexFormat', @@ -19,7 +19,7 @@ defineSuite([ Ellipsoid, GeometryOffsetAttribute, GeometryPipeline, - LineType, + ArcType, CesiumMath, Rectangle, VertexFormat, @@ -61,13 +61,13 @@ defineSuite([ }))).toBeUndefined(); }); - it('throws if lineType is not valid', function() { + it('throws if arcType is not valid', function() { expect(function() { return new PolygonGeometry({ positions : [Cartesian3.fromDegrees(0, 0), Cartesian3.fromDegrees(1, 0), Cartesian3.fromDegrees(1, 1)], - lineType: LineType.STRAIGHT + arcType: ArcType.NONE }); }).toThrowDeveloperError(); }); @@ -199,14 +199,14 @@ defineSuite([ -1.0, 1.0 ]), granularity : CesiumMath.RADIANS_PER_DEGREE, - lineType : LineType.RHUMB + arcType : ArcType.RHUMB })); expect(p.attributes.position.values.length).toEqual(13 * 3); // 8 around edge + 5 in the middle expect(p.indices.length).toEqual(16 * 3); //4 squares * 4 triangles per square }); - it('create geometry throws if lineType is STRAIGHT', function() { + it('create geometry throws if arcType is STRAIGHT', function() { expect(function() { PolygonGeometry.createGeometry(PolygonGeometry.fromPositions({ vertexFormat: VertexFormat.POSITION_ONLY, @@ -217,7 +217,7 @@ defineSuite([ -1.0, 1.0 ]), granularity: CesiumMath.RADIANS_PER_DEGREE, - lineType: LineType.STRAIGHT + arcType: ArcType.NONE })); }).toThrowDeveloperError(); }); @@ -233,13 +233,13 @@ defineSuite([ vertexFormat : VertexFormat.POSITION_ONLY, positions : positions, granularity : CesiumMath.RADIANS_PER_DEGREE, - lineType : LineType.GEODESIC + arcType : ArcType.GEODESIC })); var rhumb = PolygonGeometry.createGeometry(PolygonGeometry.fromPositions({ vertexFormat : VertexFormat.POSITION_ONLY, positions : positions, granularity : CesiumMath.RADIANS_PER_DEGREE, - lineType : LineType.RHUMB + arcType : ArcType.RHUMB })); expect(geodesic.attributes.position.values.length).not.toEqual(rhumb.attributes.position.values.length); @@ -258,7 +258,7 @@ defineSuite([ var p = PolygonGeometry.createGeometry(PolygonGeometry.fromPositions({ positions : positions, perPositionHeight : true, - lineType : LineType.RHUMB + arcType : ArcType.RHUMB })); expect(ellipsoid.cartesianToCartographic(Cartesian3.fromArray(p.attributes.position.values, 0)).height).toEqualEpsilon(height, CesiumMath.EPSILON6); @@ -352,7 +352,7 @@ defineSuite([ vertexFormat : VertexFormat.POSITION_ONLY, polygonHierarchy : hierarchy, granularity : CesiumMath.PI_OVER_THREE, - lineType : LineType.RHUMB + arcType : ArcType.RHUMB })); expect(p.attributes.position.values.length).toEqual(12 * 3); // 4 points * 3 rectangles @@ -1193,6 +1193,6 @@ defineSuite([ addPositions(packedInstance, holePositions1); packedInstance.push(Ellipsoid.WGS84.radii.x, Ellipsoid.WGS84.radii.y, Ellipsoid.WGS84.radii.z); packedInstance.push(1.0, 0.0, 0.0, 0.0, 0.0, 0.0); - packedInstance.push(0.0, 0.0, CesiumMath.PI_OVER_THREE, 0.0, 0.0, 1.0, 0, 1, 0, -1, LineType.GEODESIC, 54); + packedInstance.push(0.0, 0.0, CesiumMath.PI_OVER_THREE, 0.0, 0.0, 1.0, 0, 1, 0, -1, ArcType.GEODESIC, 54); createPackableSpecs(PolygonGeometry, polygon, packedInstance); }); diff --git a/Specs/Core/PolygonOutlineGeometrySpec.js b/Specs/Core/PolygonOutlineGeometrySpec.js index 1851ce1529ff..8050521db407 100644 --- a/Specs/Core/PolygonOutlineGeometrySpec.js +++ b/Specs/Core/PolygonOutlineGeometrySpec.js @@ -5,7 +5,7 @@ defineSuite([ 'Core/Cartesian3', 'Core/Ellipsoid', 'Core/GeometryOffsetAttribute', - 'Core/LineType', + 'Core/ArcType', 'Core/Math', 'Specs/createPackableSpecs' ], function( @@ -15,7 +15,7 @@ defineSuite([ Cartesian3, Ellipsoid, GeometryOffsetAttribute, - LineType, + ArcType, CesiumMath, createPackableSpecs) { 'use strict'; @@ -55,13 +55,13 @@ defineSuite([ }))).toBeUndefined(); }); - it('throws if lineType is not valid', function() { + it('throws if arcType is not valid', function() { expect(function() { return new PolygonOutlineGeometry({ positions : [Cartesian3.fromDegrees(0, 0), Cartesian3.fromDegrees(1, 0), Cartesian3.fromDegrees(1, 1)], - lineType: LineType.STRAIGHT + arcType: ArcType.NONE }); }).toThrowDeveloperError(); }); @@ -190,14 +190,14 @@ defineSuite([ -1.0, 1.0 ]), granularity : CesiumMath.RADIANS_PER_DEGREE, - lineType : LineType.RHUMB + arcType : ArcType.RHUMB })); expect(p.attributes.position.values.length).toEqual(8 * 3); // 8 around edge expect(p.indices.length).toEqual(16); // 4 squares }); - it('create geometry throws if lineType is STRAIGHT', function() { + it('create geometry throws if arcType is STRAIGHT', function() { expect(function() { PolygonOutlineGeometry.createGeometry(PolygonOutlineGeometry.fromPositions({ positions: Cartesian3.fromDegreesArray([ @@ -207,7 +207,7 @@ defineSuite([ -1.0, 1.0 ]), granularity: CesiumMath.RADIANS_PER_DEGREE, - lineType: LineType.STRAIGHT + arcType: ArcType.NONE })); }).toThrowDeveloperError(); }); @@ -222,12 +222,12 @@ defineSuite([ var geodesic = PolygonOutlineGeometry.createGeometry(PolygonOutlineGeometry.fromPositions({ positions : positions, granularity : CesiumMath.RADIANS_PER_DEGREE, - lineType : LineType.GEODESIC + arcType : ArcType.GEODESIC })); var rhumb = PolygonOutlineGeometry.createGeometry(PolygonOutlineGeometry.fromPositions({ positions : positions, granularity : CesiumMath.RADIANS_PER_DEGREE, - lineType : LineType.RHUMB + arcType : ArcType.RHUMB })); expect(geodesic.attributes.position.values.length).not.toEqual(rhumb.attributes.position.values.length); @@ -246,7 +246,7 @@ defineSuite([ var p = PolygonOutlineGeometry.createGeometry(PolygonOutlineGeometry.fromPositions({ positions : positions, perPositionHeight : true, - lineType : LineType.RHUMB + arcType : ArcType.RHUMB })); expect(ellipsoid.cartesianToCartographic(Cartesian3.fromArray(p.attributes.position.values, 0)).height).toEqualEpsilon(height, CesiumMath.EPSILON6); @@ -609,6 +609,6 @@ defineSuite([ packedInstance.push(3.0, 0.0); addPositions(packedInstance, holePositions1); packedInstance.push(Ellipsoid.WGS84.radii.x, Ellipsoid.WGS84.radii.y, Ellipsoid.WGS84.radii.z); - packedInstance.push(0.0, 0.0, CesiumMath.PI_OVER_THREE, 0.0, 1.0, LineType.GEODESIC, -1, 44); + packedInstance.push(0.0, 0.0, CesiumMath.PI_OVER_THREE, 0.0, 1.0, ArcType.GEODESIC, -1, 44); createPackableSpecs(PolygonOutlineGeometry, polygon, packedInstance); }); diff --git a/Specs/Core/PolylineGeometrySpec.js b/Specs/Core/PolylineGeometrySpec.js index da70f932a05c..fb2a43f8154c 100644 --- a/Specs/Core/PolylineGeometrySpec.js +++ b/Specs/Core/PolylineGeometrySpec.js @@ -3,7 +3,7 @@ defineSuite([ 'Core/Cartesian3', 'Core/Color', 'Core/Ellipsoid', - 'Core/LineType', + 'Core/ArcType', 'Core/VertexFormat', 'Specs/createPackableSpecs' ], function( @@ -11,7 +11,7 @@ defineSuite([ Cartesian3, Color, Ellipsoid, - LineType, + ArcType, VertexFormat, createPackableSpecs) { 'use strict'; @@ -39,14 +39,14 @@ defineSuite([ }).toThrowDeveloperError(); }); - it('constructor converts followSurface to lineType', function() { + it('constructor converts followSurface to arcType', function() { var line = new PolylineGeometry({ positions: [Cartesian3.ZERO, Cartesian3.UNIT_X, Cartesian3.UNIT_Y], followSurface: false }); expect(line._followSurface).toBe(false); - expect(line._lineType).toBe(LineType.STRAIGHT); + expect(line._arcType).toBe(ArcType.NONE); line = new PolylineGeometry({ positions: [Cartesian3.ZERO, Cartesian3.UNIT_X, Cartesian3.UNIT_Y], @@ -54,7 +54,7 @@ defineSuite([ }); expect(line._followSurface).toBe(true); - expect(line._lineType).toBe(LineType.GEODESIC); + expect(line._arcType).toBe(ArcType.GEODESIC); }); it('constructor returns undefined when line width is negative', function() { @@ -107,7 +107,7 @@ defineSuite([ vertexFormat : VertexFormat.ALL, granularity : Math.PI, ellipsoid : Ellipsoid.UNIT_SPHERE, - lineType : LineType.RHUMB + arcType : ArcType.RHUMB })); expect(line.attributes.position).toBeDefined(); @@ -170,7 +170,7 @@ defineSuite([ positions : positions, width : 10.0, vertexFormat : VertexFormat.POSITION_ONLY, - lineType : LineType.STRAIGHT + arcType : ArcType.NONE })); expect(geometry).not.toBeDefined(); }); @@ -181,47 +181,47 @@ defineSuite([ width : 10.0, colors : [Color.RED, Color.LIME, Color.BLUE], colorsPerVertex : true, - lineType : LineType.STRAIGHT, + arcType : ArcType.NONE, granularity : 11, vertexFormat : VertexFormat.POSITION_ONLY, ellipsoid : new Ellipsoid(12, 13, 14) }); - var packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 3, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 12, 13, 14, 1, 0, 0, 0, 0, 0, 10, 1, 2, 11]; + var packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 3, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 12, 13, 14, 1, 0, 0, 0, 0, 0, 10, 1, 0, 11]; createPackableSpecs(PolylineGeometry, line, packedInstance, 'per vertex colors'); line = new PolylineGeometry({ positions : positions, width : 10.0, colorsPerVertex : false, - lineType : LineType.STRAIGHT, + arcType : ArcType.NONE, granularity : 11, vertexFormat : VertexFormat.POSITION_ONLY, ellipsoid : new Ellipsoid(12, 13, 14) }); - packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 12, 13, 14, 1, 0, 0, 0, 0, 0, 10, 0, 2, 11]; + packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 12, 13, 14, 1, 0, 0, 0, 0, 0, 10, 0, 0, 11]; createPackableSpecs(PolylineGeometry, line, packedInstance, 'straight line'); line = new PolylineGeometry({ positions : positions, width : 10.0, colorsPerVertex : false, - lineType : LineType.GEODESIC, + arcType : ArcType.GEODESIC, granularity : 11, vertexFormat : VertexFormat.POSITION_ONLY, ellipsoid : new Ellipsoid(12, 13, 14) }); - packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 12, 13, 14, 1, 0, 0, 0, 0, 0, 10, 0, 0, 11]; + packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 12, 13, 14, 1, 0, 0, 0, 0, 0, 10, 0, 1, 11]; createPackableSpecs(PolylineGeometry, line, packedInstance, 'geodesic line'); line = new PolylineGeometry({ positions : positions, width : 10.0, colorsPerVertex : false, - lineType : LineType.RHUMB, + arcType : ArcType.RHUMB, granularity : 11, vertexFormat : VertexFormat.POSITION_ONLY, ellipsoid : new Ellipsoid(12, 13, 14) }); - packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 12, 13, 14, 1, 0, 0, 0, 0, 0, 10, 0, 1, 11]; + packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 12, 13, 14, 1, 0, 0, 0, 0, 0, 10, 0, 2, 11]; createPackableSpecs(PolylineGeometry, line, packedInstance, 'rhumb line'); }); diff --git a/Specs/Core/SimplePolylineGeometrySpec.js b/Specs/Core/SimplePolylineGeometrySpec.js index 68093c39d2b2..fb37d4e1f9cb 100644 --- a/Specs/Core/SimplePolylineGeometrySpec.js +++ b/Specs/Core/SimplePolylineGeometrySpec.js @@ -4,7 +4,7 @@ defineSuite([ 'Core/Cartesian3', 'Core/Color', 'Core/Ellipsoid', - 'Core/LineType', + 'Core/ArcType', 'Core/Math', 'Core/PrimitiveType', 'Specs/createPackableSpecs' @@ -14,7 +14,7 @@ defineSuite([ Cartesian3, Color, Ellipsoid, - LineType, + ArcType, CesiumMath, PrimitiveType, createPackableSpecs) { @@ -67,7 +67,7 @@ defineSuite([ positions: positions, granularity: Math.PI, ellipsoid: Ellipsoid.UNIT_SPHERE, - lineType: LineType.RHUMB + arcType: ArcType.RHUMB })); var cartesian3Array = []; @@ -165,7 +165,7 @@ defineSuite([ granularity : 11, ellipsoid : new Ellipsoid(12, 13, 14) }); - var packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 3, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 12, 13, 14, 1, 2, 11]; + var packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 3, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 12, 13, 14, 1, 0, 11]; createPackableSpecs(SimplePolylineGeometry, line, packedInstance, 'per vertex colors'); line = new SimplePolylineGeometry({ @@ -175,39 +175,39 @@ defineSuite([ granularity : 11, ellipsoid : new Ellipsoid(12, 13, 14) }); - packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 12, 13, 14, 0, 2, 11]; + packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 12, 13, 14, 0, 0, 11]; createPackableSpecs(SimplePolylineGeometry, line, packedInstance); line = new SimplePolylineGeometry({ positions : positions, width : 10.0, colorsPerVertex : false, - lineType : LineType.GEODESIC, + arcType : ArcType.GEODESIC, granularity : 11, ellipsoid : new Ellipsoid(12, 13, 14) }); - packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 12, 13, 14, 0, 0, 11]; + packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 12, 13, 14, 0, 1, 11]; createPackableSpecs(SimplePolylineGeometry, line, packedInstance, 'geodesic line'); line = new SimplePolylineGeometry({ positions : positions, width : 10.0, colorsPerVertex : false, - lineType : LineType.RHUMB, + arcType : ArcType.RHUMB, granularity : 11, ellipsoid : new Ellipsoid(12, 13, 14) }); - packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 12, 13, 14, 0, 1, 11]; + packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 12, 13, 14, 0, 2, 11]; createPackableSpecs(SimplePolylineGeometry, line, packedInstance, 'rhumb line'); line = new SimplePolylineGeometry({ positions : positions, width : 10.0, colorsPerVertex : false, - lineType : LineType.STRAIGHT, + arcType : ArcType.NONE, granularity : 11, ellipsoid : new Ellipsoid(12, 13, 14) }); - packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 12, 13, 14, 0, 2, 11]; + packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 12, 13, 14, 0, 0, 11]; createPackableSpecs(SimplePolylineGeometry, line, packedInstance, 'straight line'); }); diff --git a/Specs/DataSources/PolygonGeometryUpdaterSpec.js b/Specs/DataSources/PolygonGeometryUpdaterSpec.js index 80021cc40cfa..a42c128c747d 100644 --- a/Specs/DataSources/PolygonGeometryUpdaterSpec.js +++ b/Specs/DataSources/PolygonGeometryUpdaterSpec.js @@ -6,7 +6,7 @@ defineSuite([ 'Core/Ellipsoid', 'Core/GeometryOffsetAttribute', 'Core/JulianDate', - 'Core/LineType', + 'Core/ArcType', 'Core/Math', 'Core/CoplanarPolygonGeometry', 'Core/CoplanarPolygonOutlineGeometry', @@ -36,7 +36,7 @@ defineSuite([ Ellipsoid, GeometryOffsetAttribute, JulianDate, - LineType, + ArcType, CesiumMath, CoplanarPolygonGeometry, CoplanarPolygonOutlineGeometry, @@ -229,11 +229,11 @@ defineSuite([ expect(updater.isDynamic).toBe(true); }); - it('A time-varying lineType causes geometry to be dynamic', function() { + it('A time-varying arcType causes geometry to be dynamic', function() { var entity = createBasicPolygon(); var updater = new PolygonGeometryUpdater(entity, scene); - entity.polygon.lineType = new SampledProperty(Number); - entity.polygon.lineType.addSample(time, 1); + entity.polygon.arcType = new SampledProperty(Number); + entity.polygon.arcType.addSample(time, 1); updater._onEntityPropertyChanged(entity, 'polygon'); expect(updater.isDynamic).toBe(true); @@ -248,7 +248,7 @@ defineSuite([ perPositionHeight : false, closeTop : true, closeBottom : false, - lineType : LineType.GEODESIC + arcType : ArcType.GEODESIC }; var entity = createBasicPolygon(); @@ -262,7 +262,7 @@ defineSuite([ polygon.height = new ConstantProperty(options.height); polygon.extrudedHeight = new ConstantProperty(options.extrudedHeight); polygon.granularity = new ConstantProperty(options.granularity); - polygon.lineType = new ConstantProperty(options.lineType); + polygon.arcType = new ConstantProperty(options.arcType); var updater = new PolygonGeometryUpdater(entity, scene); @@ -277,7 +277,7 @@ defineSuite([ expect(geometry._extrudedHeight).toEqual(options.extrudedHeight); expect(geometry._closeTop).toEqual(options.closeTop); expect(geometry._closeBottom).toEqual(options.closeBottom); - expect(geometry._lineType).toEqual(options.lineType); + expect(geometry._arcType).toEqual(options.arcType); expect(geometry._offsetAttribute).toBeUndefined(); instance = updater.createOutlineGeometryInstance(time); @@ -373,7 +373,7 @@ defineSuite([ polygon.stRotation = createDynamicProperty(1); polygon.closeTop = createDynamicProperty(false); polygon.closeBottom = createDynamicProperty(false); - polygon.lineType = createDynamicProperty(LineType.RHUMB); + polygon.arcType = createDynamicProperty(ArcType.RHUMB); var entity = new Entity(); entity.polygon = polygon; @@ -392,7 +392,7 @@ defineSuite([ expect(options.stRotation).toEqual(polygon.stRotation.getValue()); expect(options.closeTop).toEqual(polygon.closeTop.getValue()); expect(options.closeBottom).toEqual(polygon.closeBottom.getValue()); - expect(options.lineType).toEqual(polygon.lineType.getValue()); + expect(options.arcType).toEqual(polygon.arcType.getValue()); expect(options.offsetAttribute).toBeUndefined(); }); diff --git a/Specs/DataSources/PolygonGraphicsSpec.js b/Specs/DataSources/PolygonGraphicsSpec.js index ad368bd4a5c2..77031302d5cc 100644 --- a/Specs/DataSources/PolygonGraphicsSpec.js +++ b/Specs/DataSources/PolygonGraphicsSpec.js @@ -2,7 +2,7 @@ defineSuite([ 'DataSources/PolygonGraphics', 'Core/Color', 'Core/DistanceDisplayCondition', - 'Core/LineType', + 'Core/ArcType', 'Core/PolygonHierarchy', 'DataSources/ColorMaterialProperty', 'DataSources/ConstantProperty', @@ -14,7 +14,7 @@ defineSuite([ PolygonGraphics, Color, DistanceDisplayCondition, - LineType, + ArcType, PolygonHierarchy, ColorMaterialProperty, ConstantProperty, @@ -43,7 +43,7 @@ defineSuite([ shadows : ShadowMode.DISABLED, distanceDisplayCondition : new DistanceDisplayCondition(), classificationType : ClassificationType.TERRAIN, - lineType: LineType.GEODESIC, + arcType: ArcType.GEODESIC, zIndex: 22 }; @@ -65,7 +65,7 @@ defineSuite([ expect(polygon.shadows).toBeInstanceOf(ConstantProperty); expect(polygon.distanceDisplayCondition).toBeInstanceOf(ConstantProperty); expect(polygon.classificationType).toBeInstanceOf(ConstantProperty); - expect(polygon.lineType).toBeInstanceOf(ConstantProperty); + expect(polygon.arcType).toBeInstanceOf(ConstantProperty); expect(polygon.zIndex).toBeInstanceOf(ConstantProperty); expect(polygon.material.color.getValue()).toEqual(options.material); @@ -85,7 +85,7 @@ defineSuite([ expect(polygon.shadows.getValue()).toEqual(options.shadows); expect(polygon.distanceDisplayCondition.getValue()).toEqual(options.distanceDisplayCondition); expect(polygon.classificationType.getValue()).toEqual(options.classificationType); - expect(polygon.lineType.getValue()).toEqual(options.lineType); + expect(polygon.arcType.getValue()).toEqual(options.arcType); expect(polygon.zIndex.getValue()).toEqual(22); }); @@ -108,7 +108,7 @@ defineSuite([ source.shadows = new ConstantProperty(ShadowMode.ENABLED); source.distanceDisplayCondition = new ConstantProperty(new DistanceDisplayCondition()); source.classificationType = new ConstantProperty(ClassificationType.TERRAIN); - source.lineType = new ConstantProperty(LineType.RHUMB); + source.arcType = new ConstantProperty(ArcType.RHUMB); source.zIndex = new ConstantProperty(30); var target = new PolygonGraphics(); @@ -131,7 +131,7 @@ defineSuite([ expect(target.shadows).toBe(source.shadows); expect(target.distanceDisplayCondition).toBe(source.distanceDisplayCondition); expect(target.classificationType).toBe(source.classificationType); - expect(target.lineType).toBe(source.lineType); + expect(target.arcType).toBe(source.arcType); expect(target.zIndex).toBe(source.zIndex); }); @@ -155,7 +155,7 @@ defineSuite([ var shadows = new ConstantProperty(); var distanceDisplayCondition = new ConstantProperty(); var classificationType = new ConstantProperty(); - var lineType = new ConstantProperty(); + var arcType = new ConstantProperty(); var zIndex = new ConstantProperty(); var target = new PolygonGraphics(); @@ -176,7 +176,7 @@ defineSuite([ target.shadows = shadows; target.distanceDisplayCondition = distanceDisplayCondition; target.classificationType = classificationType; - target.lineType = lineType; + target.arcType = arcType; target.zIndex = zIndex; target.merge(source); @@ -198,7 +198,7 @@ defineSuite([ expect(target.shadows).toBe(shadows); expect(target.distanceDisplayCondition).toBe(distanceDisplayCondition); expect(target.classificationType).toBe(classificationType); - expect(target.lineType).toBe(lineType); + expect(target.arcType).toBe(arcType); expect(target.zIndex).toBe(zIndex); }); @@ -221,7 +221,7 @@ defineSuite([ source.shadows = new ConstantProperty(); source.distanceDisplayCondition = new ConstantProperty(); source.classificationType = new ConstantProperty(); - source.lineType = new ConstantProperty(); + source.arcType = new ConstantProperty(); source.zIndex = new ConstantProperty(); var result = source.clone(); @@ -242,7 +242,7 @@ defineSuite([ expect(result.shadows).toBe(source.shadows); expect(result.distanceDisplayCondition).toBe(source.distanceDisplayCondition); expect(result.classificationType).toBe(source.classificationType); - expect(result.lineType).toBe(source.lineType); + expect(result.arcType).toBe(source.arcType); expect(result.zIndex).toBe(source.zIndex); }); @@ -272,7 +272,7 @@ defineSuite([ testDefinitionChanged(property, 'shadows', ShadowMode.ENABLED, ShadowMode.DISABLED); testDefinitionChanged(property, 'distanceDisplayCondition', new DistanceDisplayCondition(), new DistanceDisplayCondition(10.0, 100.0)); testDefinitionChanged(property, 'classificationType', ClassificationType.TERRAIN, ClassificationType.BOTH); - testDefinitionChanged(property, 'lineType', LineType.GEODESIC, LineType.RHUMB); + testDefinitionChanged(property, 'arcType', ArcType.GEODESIC, ArcType.RHUMB); testDefinitionChanged(property, 'zIndex', 54, 3); }); }); diff --git a/Specs/DataSources/PolylineGeometryUpdaterSpec.js b/Specs/DataSources/PolylineGeometryUpdaterSpec.js index c4819af3893f..b44b4dcdf94f 100644 --- a/Specs/DataSources/PolylineGeometryUpdaterSpec.js +++ b/Specs/DataSources/PolylineGeometryUpdaterSpec.js @@ -10,7 +10,7 @@ defineSuite([ 'Core/DistanceDisplayConditionGeometryInstanceAttribute', 'Core/GroundPolylineGeometry', 'Core/JulianDate', - 'Core/LineType', + 'Core/ArcType', 'Core/PolylinePipeline', 'Core/ShowGeometryInstanceAttribute', 'Core/TimeInterval', @@ -44,7 +44,7 @@ defineSuite([ DistanceDisplayConditionGeometryInstanceAttribute, GroundPolylineGeometry, JulianDate, - LineType, + ArcType, PolylinePipeline, ShowGeometryInstanceAttribute, TimeInterval, @@ -119,7 +119,7 @@ defineSuite([ expect(updater.distanceDisplayConditionProperty).toBe(undefined); expect(updater.isDynamic).toBe(false); expect(updater.clampToGround).toBe(false); - expect(updater.lineType).toBe(undefined); + expect(updater.arcType).toBe(undefined); expect(updater.zIndex).toBe(0); expect(updater.isOutlineVisible(time)).toBe(false); @@ -164,7 +164,7 @@ defineSuite([ expect(updater.distanceDisplayConditionProperty).toEqual(new ConstantProperty(new DistanceDisplayCondition())); expect(updater.isDynamic).toBe(false); expect(updater.clampToGround).toBe(false); - expect(updater.lineType).toBe(undefined); + expect(updater.arcType).toBe(undefined); expect(updater.zIndex).toEqual(new ConstantProperty(0)); }); @@ -235,11 +235,11 @@ defineSuite([ expect(updater.isDynamic).toBe(true); }); - it('A time-varying lineType causes geometry to be dynamic', function() { + it('A time-varying arcType causes geometry to be dynamic', function() { var entity = createBasicPolyline(); var updater = new PolylineGeometryUpdater(entity, scene); - entity.polyline.lineType = new SampledProperty(Number); - entity.polyline.lineType.addSample(time, 1); + entity.polyline.arcType = new SampledProperty(Number); + entity.polyline.arcType.addSample(time, 1); expect(updater.isDynamic).toBe(true); }); @@ -265,7 +265,7 @@ defineSuite([ polyline.granularity = new ConstantProperty(options.granularity); polyline.distanceDisplayCondition = options.distanceDisplayCondition; polyline.clampToGround = new ConstantProperty(clampToGround); - polyline.lineType = new ConstantProperty(options.lineType); + polyline.arcType = new ConstantProperty(options.arcType); var updater = new PolylineGeometryUpdater(entity, scene); @@ -283,8 +283,8 @@ defineSuite([ if (defined(options.followSurface)) { expect(geometry._followSurface).toEqual(options.followSurface); } - if (defined(options.lineType)) { - expect(geometry._lineType).toEqual(options.lineType); + if (defined(options.arcType)) { + expect(geometry._arcType).toEqual(options.arcType); } expect(geometry._granularity).toEqual(options.granularity); @@ -314,7 +314,7 @@ defineSuite([ followSurface : false, clampToGround : false, granularity : 1.0, - lineType : LineType.STRAIGHT + arcType : ArcType.NONE }); if (!Entity.supportsPolylinesOnTerrain(scene)) { @@ -329,7 +329,7 @@ defineSuite([ followSurface : false, clampToGround : true, granularity : 1.0, - lineType : LineType.GEODESIC + arcType : ArcType.GEODESIC }); }); @@ -342,7 +342,7 @@ defineSuite([ followSurface : true, clampToGround : false, granularity : 1.0, - lineType : LineType.GEODESIC + arcType : ArcType.GEODESIC }); }); @@ -354,7 +354,7 @@ defineSuite([ width : 3, clampToGround : false, granularity : 1.0, - lineType : LineType.RHUMB + arcType : ArcType.RHUMB }); }); @@ -366,7 +366,7 @@ defineSuite([ followSurface : true, clampToGround : false, granularity : 0.5, - lineType: LineType.GEODESIC + arcType: ArcType.GEODESIC }); if (!Entity.supportsPolylinesOnTerrain(scene)) { @@ -381,7 +381,7 @@ defineSuite([ followSurface : true, clampToGround : true, granularity : 0.5, - lineType: LineType.GEODESIC + arcType: ArcType.GEODESIC }); }); @@ -502,7 +502,7 @@ defineSuite([ polyline.material = new ColorMaterialProperty(Color.RED); polyline.followSurface = new ConstantProperty(false); polyline.granularity = new ConstantProperty(0.001); - polyline.LineType = new ConstantProperty(LineType.STRAIGHT); + polyline.ArcType = new ConstantProperty(ArcType.NONE); var updater = new PolylineGeometryUpdater(entity, scene); @@ -525,7 +525,7 @@ defineSuite([ expect(primitive.positions.length).toEqual(2); polyline.followSurface = new ConstantProperty(true); - polyline.lineType = new ConstantProperty(LineType.GEODESIC); + polyline.arcType = new ConstantProperty(ArcType.GEODESIC); dynamicUpdater.update(time3); expect(primitive.width).toEqual(3); @@ -588,16 +588,16 @@ defineSuite([ updater.destroy(); }); - it('lineType can be dynamic', function() { + it('arcType can be dynamic', function() { var entity = new Entity(); var polyline = new PolylineGraphics(); entity.polyline = polyline; var time = new JulianDate(0, 0); - var lineTypeVar = LineType.GEODESIC; - var lineType = new CallbackProperty(function() { - return lineTypeVar; + var arcTypeVar = ArcType.GEODESIC; + var arcType = new CallbackProperty(function() { + return arcTypeVar; }, false); polyline.show = new ConstantProperty(true); @@ -607,7 +607,7 @@ defineSuite([ polyline.followSurface = new ConstantProperty(true); polyline.granularity = new ConstantProperty(0.001); polyline.clampToGround = new ConstantProperty(false); - polyline.lineType = lineType; + polyline.arcType = arcType; var updater = new PolylineGeometryUpdater(entity, scene); @@ -628,7 +628,7 @@ defineSuite([ var geodesicPolylinePositionsLength = polylineObject.positions.length; - lineTypeVar = LineType.STRAIGHT; + arcTypeVar = ArcType.NONE; dynamicUpdater.update(time); expect(polylineObject.positions.length).not.toEqual(geodesicPolylinePositionsLength); @@ -868,7 +868,7 @@ defineSuite([ scene.globe = new Globe(); }); - it('lineType GEODESIC with undefined globe does not call generateCartesianArc', function() { + it('arcType GEODESIC with undefined globe does not call generateCartesianArc', function() { if (!Entity.supportsPolylinesOnTerrain(scene)) { return; } diff --git a/Specs/DataSources/PolylineGraphicsSpec.js b/Specs/DataSources/PolylineGraphicsSpec.js index ee61edc5530c..4549f4313e27 100644 --- a/Specs/DataSources/PolylineGraphicsSpec.js +++ b/Specs/DataSources/PolylineGraphicsSpec.js @@ -2,7 +2,7 @@ defineSuite([ 'DataSources/PolylineGraphics', 'Core/Color', 'Core/DistanceDisplayCondition', - 'Core/LineType', + 'Core/ArcType', 'DataSources/ColorMaterialProperty', 'DataSources/ConstantProperty', 'Scene/ClassificationType', @@ -13,7 +13,7 @@ defineSuite([ PolylineGraphics, Color, DistanceDisplayCondition, - LineType, + ArcType, ColorMaterialProperty, ConstantProperty, ClassificationType, @@ -35,7 +35,7 @@ defineSuite([ shadows : ShadowMode.DISABLED, distanceDisplayCondition : new DistanceDisplayCondition(), classificationType : ClassificationType.TERRAIN, - lineType: LineType.GEODESIC, + arcType: ArcType.GEODESIC, zIndex : 0 }; @@ -51,7 +51,7 @@ defineSuite([ expect(polyline.shadows).toBeInstanceOf(ConstantProperty); expect(polyline.distanceDisplayCondition).toBeInstanceOf(ConstantProperty); expect(polyline.classificationType).toBeInstanceOf(ConstantProperty); - expect(polyline.lineType).toBeInstanceOf(ConstantProperty); + expect(polyline.arcType).toBeInstanceOf(ConstantProperty); expect(polyline.zIndex).toBeInstanceOf(ConstantProperty); expect(polyline.material.color.getValue()).toEqual(options.material); @@ -65,7 +65,7 @@ defineSuite([ expect(polyline.shadows.getValue()).toEqual(options.shadows); expect(polyline.distanceDisplayCondition.getValue()).toEqual(options.distanceDisplayCondition); expect(polyline.classificationType.getValue()).toEqual(options.classificationType); - expect(polyline.lineType.getValue()).toEqual(options.lineType); + expect(polyline.arcType.getValue()).toEqual(options.arcType); expect(polyline.zIndex.getValue()).toEqual(options.zIndex); }); @@ -82,7 +82,7 @@ defineSuite([ source.shadows = new ConstantProperty(ShadowMode.ENABLED); source.distanceDisplayCondition = new ConstantProperty(new DistanceDisplayCondition()); source.classificationType = new ConstantProperty(ClassificationType.TERRAIN); - source.lineType = new ConstantProperty(LineType.GEODESIC); + source.arcType = new ConstantProperty(ArcType.GEODESIC); source.zIndex = new ConstantProperty(); var target = new PolylineGraphics(); @@ -98,7 +98,7 @@ defineSuite([ expect(target.shadows).toBe(source.shadows); expect(target.distanceDisplayCondition).toBe(source.distanceDisplayCondition); expect(target.classificationType).toBe(source.classificationType); - expect(target.lineType).toBe(source.lineType); + expect(target.arcType).toBe(source.arcType); expect(target.zIndex).toBe(source.zIndex); }); @@ -115,7 +115,7 @@ defineSuite([ source.shadows = new ConstantProperty(); source.distanceDisplayCondition = new ConstantProperty(); source.classificationType = new ConstantProperty(); - source.lineType = new ConstantProperty(); + source.arcType = new ConstantProperty(); source.zIndex = new ConstantProperty(); var color = new ColorMaterialProperty(); @@ -129,7 +129,7 @@ defineSuite([ var shadows = new ConstantProperty(); var distanceDisplayCondition = new ConstantProperty(); var classificationType = new ConstantProperty(); - var lineType = new ConstantProperty(); + var arcType = new ConstantProperty(); var zIndex = new ConstantProperty(); var target = new PolylineGraphics(); @@ -144,7 +144,7 @@ defineSuite([ target.shadows = shadows; target.distanceDisplayCondition = distanceDisplayCondition; target.classificationType = classificationType; - target.lineType = lineType; + target.arcType = arcType; target.zIndex = zIndex; target.merge(source); @@ -159,7 +159,7 @@ defineSuite([ expect(target.shadows).toBe(shadows); expect(target.distanceDisplayCondition).toBe(distanceDisplayCondition); expect(target.classificationType).toBe(classificationType); - expect(target.lineType).toBe(lineType); + expect(target.arcType).toBe(arcType); expect(target.zIndex).toBe(zIndex); }); @@ -176,7 +176,7 @@ defineSuite([ source.shadows = new ConstantProperty(); source.distanceDisplayCondition = new ConstantProperty(); source.classificationType = new ConstantProperty(); - source.lineType = new ConstantProperty(); + source.arcType = new ConstantProperty(); source.zIndex = new ConstantProperty(); var result = source.clone(); @@ -191,7 +191,7 @@ defineSuite([ expect(result.shadows).toBe(source.shadows); expect(result.distanceDisplayCondition).toBe(source.distanceDisplayCondition); expect(result.classificationType).toBe(source.classificationType); - expect(result.lineType).toBe(source.lineType); + expect(result.arcType).toBe(source.arcType); expect(result.zIndex).toBe(source.zIndex); }); @@ -215,7 +215,7 @@ defineSuite([ testDefinitionChanged(property, 'shadows', ShadowMode.ENABLED, ShadowMode.DISABLED); testDefinitionChanged(property, 'distanceDisplayCondition', new DistanceDisplayCondition(), new DistanceDisplayCondition(10.0, 20.0)); testDefinitionChanged(property, 'classificationType', ClassificationType.TERRAIN); - testDefinitionChanged(property, 'lineType', LineType.GEODESIC, LineType.RHUMB); + testDefinitionChanged(property, 'arcType', ArcType.GEODESIC, ArcType.RHUMB); testDefinitionChanged(property, 'zIndex', 20, 5); }); }); From 763aa700782dee4c1df568d4c3b4e40f275f38fc Mon Sep 17 00:00:00 2001 From: Shehzan Mohammed Date: Thu, 24 Jan 2019 09:29:11 -0500 Subject: [PATCH 25/26] Fix ordering of defines for ArcType --- Source/Core/GroundPolylineGeometry.js | 4 ++-- Source/Core/PolygonGeometry.js | 4 ++-- Source/Core/PolygonGeometryLibrary.js | 4 ++-- Source/Core/PolygonOutlineGeometry.js | 4 ++-- Source/Core/PolylineGeometry.js | 4 ++-- Source/Core/SimplePolylineGeometry.js | 4 ++-- Source/DataSources/GeoJsonDataSource.js | 4 ++-- Source/DataSources/PolygonGeometryUpdater.js | 4 ++-- Source/DataSources/PolylineGeometryUpdater.js | 4 ++-- Source/DataSources/PolylineGraphics.js | 4 ++-- Source/Scene/DebugModelMatrixPrimitive.js | 4 ++-- Specs/Core/GroundPolylineGeometrySpec.js | 4 ++-- Specs/Core/PolygonGeometrySpec.js | 4 ++-- Specs/Core/PolygonOutlineGeometrySpec.js | 4 ++-- Specs/Core/PolylineGeometrySpec.js | 4 ++-- Specs/Core/SimplePolylineGeometrySpec.js | 4 ++-- Specs/DataSources/PolygonGeometryUpdaterSpec.js | 4 ++-- Specs/DataSources/PolygonGraphicsSpec.js | 4 ++-- Specs/DataSources/PolylineGeometryUpdaterSpec.js | 4 ++-- Specs/DataSources/PolylineGraphicsSpec.js | 4 ++-- 20 files changed, 40 insertions(+), 40 deletions(-) diff --git a/Source/Core/GroundPolylineGeometry.js b/Source/Core/GroundPolylineGeometry.js index 3a750dfcaaa2..0e5a5bf619af 100644 --- a/Source/Core/GroundPolylineGeometry.js +++ b/Source/Core/GroundPolylineGeometry.js @@ -1,5 +1,6 @@ define([ './ApproximateTerrainHeights', + './ArcType', './arrayRemoveDuplicates', './BoundingSphere', './Cartesian3', @@ -19,7 +20,6 @@ define([ './Geometry', './GeometryAttribute', './IntersectionTests', - './ArcType', './Matrix3', './Plane', './Quaternion', @@ -27,6 +27,7 @@ define([ './WebMercatorProjection' ], function( ApproximateTerrainHeights, + ArcType, arrayRemoveDuplicates, BoundingSphere, Cartesian3, @@ -46,7 +47,6 @@ define([ Geometry, GeometryAttribute, IntersectionTests, - ArcType, Matrix3, Plane, Quaternion, diff --git a/Source/Core/PolygonGeometry.js b/Source/Core/PolygonGeometry.js index dd40f44165a7..b6cb3d35a7ee 100644 --- a/Source/Core/PolygonGeometry.js +++ b/Source/Core/PolygonGeometry.js @@ -1,4 +1,5 @@ define([ + './ArcType', './arrayFill', './BoundingRectangle', './BoundingSphere', @@ -19,7 +20,6 @@ define([ './GeometryOffsetAttribute', './GeometryPipeline', './IndexDatatype', - './ArcType', './Math', './Matrix2', './Matrix3', @@ -30,6 +30,7 @@ define([ './VertexFormat', './WindingOrder' ], function( + ArcType, arrayFill, BoundingRectangle, BoundingSphere, @@ -50,7 +51,6 @@ define([ GeometryOffsetAttribute, GeometryPipeline, IndexDatatype, - ArcType, CesiumMath, Matrix2, Matrix3, diff --git a/Source/Core/PolygonGeometryLibrary.js b/Source/Core/PolygonGeometryLibrary.js index 019dec38daaf..ceff350cb7b4 100644 --- a/Source/Core/PolygonGeometryLibrary.js +++ b/Source/Core/PolygonGeometryLibrary.js @@ -1,4 +1,5 @@ define([ + './ArcType', './arrayRemoveDuplicates', './Cartesian2', './Cartesian3', @@ -14,7 +15,6 @@ define([ './GeometryAttributes', './GeometryPipeline', './IndexDatatype', - './ArcType', './Math', './Matrix3', './PolygonPipeline', @@ -23,6 +23,7 @@ define([ './Queue', './WindingOrder' ], function( + ArcType, arrayRemoveDuplicates, Cartesian2, Cartesian3, @@ -38,7 +39,6 @@ define([ GeometryAttributes, GeometryPipeline, IndexDatatype, - ArcType, CesiumMath, Matrix3, PolygonPipeline, diff --git a/Source/Core/PolygonOutlineGeometry.js b/Source/Core/PolygonOutlineGeometry.js index a35783e1cc62..180c19e0dbec 100644 --- a/Source/Core/PolygonOutlineGeometry.js +++ b/Source/Core/PolygonOutlineGeometry.js @@ -1,4 +1,5 @@ define([ + './ArcType', './arrayFill', './arrayRemoveDuplicates', './BoundingSphere', @@ -17,7 +18,6 @@ define([ './GeometryOffsetAttribute', './GeometryPipeline', './IndexDatatype', - './ArcType', './Math', './PolygonGeometryLibrary', './PolygonPipeline', @@ -25,6 +25,7 @@ define([ './Queue', './WindingOrder' ], function( + ArcType, arrayFill, arrayRemoveDuplicates, BoundingSphere, @@ -43,7 +44,6 @@ define([ GeometryOffsetAttribute, GeometryPipeline, IndexDatatype, - ArcType, CesiumMath, PolygonGeometryLibrary, PolygonPipeline, diff --git a/Source/Core/PolylineGeometry.js b/Source/Core/PolylineGeometry.js index 6b857c38ef31..5fceeac3edde 100644 --- a/Source/Core/PolylineGeometry.js +++ b/Source/Core/PolylineGeometry.js @@ -1,4 +1,5 @@ define([ + './ArcType', './arrayRemoveDuplicates', './BoundingSphere', './Cartesian3', @@ -14,12 +15,12 @@ define([ './GeometryAttributes', './GeometryType', './IndexDatatype', - './ArcType', './Math', './PolylinePipeline', './PrimitiveType', './VertexFormat' ], function( + ArcType, arrayRemoveDuplicates, BoundingSphere, Cartesian3, @@ -35,7 +36,6 @@ define([ GeometryAttributes, GeometryType, IndexDatatype, - ArcType, CesiumMath, PolylinePipeline, PrimitiveType, diff --git a/Source/Core/SimplePolylineGeometry.js b/Source/Core/SimplePolylineGeometry.js index 67bb31740c4f..387ef34d63db 100644 --- a/Source/Core/SimplePolylineGeometry.js +++ b/Source/Core/SimplePolylineGeometry.js @@ -1,4 +1,5 @@ define([ + './ArcType', './BoundingSphere', './Cartesian3', './Color', @@ -12,11 +13,11 @@ define([ './GeometryAttribute', './GeometryAttributes', './IndexDatatype', - './ArcType', './Math', './PolylinePipeline', './PrimitiveType' ], function( + ArcType, BoundingSphere, Cartesian3, Color, @@ -30,7 +31,6 @@ define([ GeometryAttribute, GeometryAttributes, IndexDatatype, - ArcType, CesiumMath, PolylinePipeline, PrimitiveType) { diff --git a/Source/DataSources/GeoJsonDataSource.js b/Source/DataSources/GeoJsonDataSource.js index f8876fdb477c..c0f090ac9794 100644 --- a/Source/DataSources/GeoJsonDataSource.js +++ b/Source/DataSources/GeoJsonDataSource.js @@ -1,4 +1,5 @@ define([ + '../Core/ArcType', '../Core/Cartesian3', '../Core/Color', '../Core/createGuid', @@ -8,7 +9,6 @@ define([ '../Core/DeveloperError', '../Core/Event', '../Core/getFilenameFromUri', - '../Core/ArcType', '../Core/PinBuilder', '../Core/PolygonHierarchy', '../Core/Resource', @@ -28,6 +28,7 @@ define([ './PolygonGraphics', './PolylineGraphics' ], function( + ArcType, Cartesian3, Color, createGuid, @@ -37,7 +38,6 @@ define([ DeveloperError, Event, getFilenameFromUri, - ArcType, PinBuilder, PolygonHierarchy, Resource, diff --git a/Source/DataSources/PolygonGeometryUpdater.js b/Source/DataSources/PolygonGeometryUpdater.js index aabb9366ce91..dc3d160eb289 100644 --- a/Source/DataSources/PolygonGeometryUpdater.js +++ b/Source/DataSources/PolygonGeometryUpdater.js @@ -1,5 +1,6 @@ define([ '../Core/ApproximateTerrainHeights', + '../Core/ArcType', '../Core/Cartesian2', '../Core/Cartesian3', '../Core/Check', @@ -15,7 +16,6 @@ define([ '../Core/GeometryOffsetAttribute', '../Core/isArray', '../Core/Iso8601', - '../Core/ArcType', '../Core/oneTimeWarning', '../Core/OffsetGeometryInstanceAttribute', '../Core/PolygonGeometry', @@ -34,6 +34,7 @@ define([ './Property' ], function( ApproximateTerrainHeights, + ArcType, Cartesian2, Cartesian3, Check, @@ -49,7 +50,6 @@ define([ GeometryOffsetAttribute, isArray, Iso8601, - ArcType, oneTimeWarning, OffsetGeometryInstanceAttribute, PolygonGeometry, diff --git a/Source/DataSources/PolylineGeometryUpdater.js b/Source/DataSources/PolylineGeometryUpdater.js index 6ef60d4ac047..4dfbea77392d 100644 --- a/Source/DataSources/PolylineGeometryUpdater.js +++ b/Source/DataSources/PolylineGeometryUpdater.js @@ -1,4 +1,5 @@ define([ + '../Core/ArcType', '../Core/BoundingSphere', '../Core/Check', '../Core/Color', @@ -14,7 +15,6 @@ define([ '../Core/GeometryInstance', '../Core/GroundPolylineGeometry', '../Core/Iso8601', - '../Core/ArcType', '../Core/oneTimeWarning', '../Core/PolylineGeometry', '../Core/PolylinePipeline', @@ -32,6 +32,7 @@ define([ './MaterialProperty', './Property' ], function( + ArcType, BoundingSphere, Check, Color, @@ -47,7 +48,6 @@ define([ GeometryInstance, GroundPolylineGeometry, Iso8601, - ArcType, oneTimeWarning, PolylineGeometry, PolylinePipeline, diff --git a/Source/DataSources/PolylineGraphics.js b/Source/DataSources/PolylineGraphics.js index 24195c6b4266..34b07951021b 100644 --- a/Source/DataSources/PolylineGraphics.js +++ b/Source/DataSources/PolylineGraphics.js @@ -1,19 +1,19 @@ define([ + '../Core/ArcType', '../Core/defaultValue', '../Core/defined', '../Core/defineProperties', '../Core/DeveloperError', '../Core/Event', - '../Core/ArcType', './createMaterialPropertyDescriptor', './createPropertyDescriptor' ], function( + ArcType, defaultValue, defined, defineProperties, DeveloperError, Event, - ArcType, createMaterialPropertyDescriptor, createPropertyDescriptor) { 'use strict'; diff --git a/Source/Scene/DebugModelMatrixPrimitive.js b/Source/Scene/DebugModelMatrixPrimitive.js index 092b6879e64d..671be07456ec 100644 --- a/Source/Scene/DebugModelMatrixPrimitive.js +++ b/Source/Scene/DebugModelMatrixPrimitive.js @@ -1,23 +1,23 @@ define([ + '../Core/ArcType', '../Core/Cartesian3', '../Core/Color', '../Core/defaultValue', '../Core/defined', '../Core/destroyObject', '../Core/GeometryInstance', - '../Core/ArcType', '../Core/Matrix4', '../Core/PolylineGeometry', './PolylineColorAppearance', './Primitive' ], function( + ArcType, Cartesian3, Color, defaultValue, defined, destroyObject, GeometryInstance, - ArcType, Matrix4, PolylineGeometry, PolylineColorAppearance, diff --git a/Specs/Core/GroundPolylineGeometrySpec.js b/Specs/Core/GroundPolylineGeometrySpec.js index 21ecc96c627d..b41332a997f3 100644 --- a/Specs/Core/GroundPolylineGeometrySpec.js +++ b/Specs/Core/GroundPolylineGeometrySpec.js @@ -1,24 +1,24 @@ defineSuite([ 'Core/GroundPolylineGeometry', 'Core/ApproximateTerrainHeights', + 'Core/ArcType', 'Core/arraySlice', 'Core/Cartesian3', 'Core/Cartographic', 'Core/Ellipsoid', 'Core/GeographicProjection', - 'Core/ArcType', 'Core/Math', 'Core/WebMercatorProjection', 'Specs/createPackableSpecs' ], function( GroundPolylineGeometry, ApproximateTerrainHeights, + ArcType, arraySlice, Cartesian3, Cartographic, Ellipsoid, GeographicProjection, - ArcType, CesiumMath, WebMercatorProjection, createPackableSpecs) { diff --git a/Specs/Core/PolygonGeometrySpec.js b/Specs/Core/PolygonGeometrySpec.js index 1b009ee37b8b..935473324227 100644 --- a/Specs/Core/PolygonGeometrySpec.js +++ b/Specs/Core/PolygonGeometrySpec.js @@ -1,25 +1,25 @@ defineSuite([ 'Core/PolygonGeometry', + 'Core/ArcType', 'Core/arrayFill', 'Core/BoundingSphere', 'Core/Cartesian3', 'Core/Ellipsoid', 'Core/GeometryOffsetAttribute', 'Core/GeometryPipeline', - 'Core/ArcType', 'Core/Math', 'Core/Rectangle', 'Core/VertexFormat', 'Specs/createPackableSpecs' ], function( PolygonGeometry, + ArcType, arrayFill, BoundingSphere, Cartesian3, Ellipsoid, GeometryOffsetAttribute, GeometryPipeline, - ArcType, CesiumMath, Rectangle, VertexFormat, diff --git a/Specs/Core/PolygonOutlineGeometrySpec.js b/Specs/Core/PolygonOutlineGeometrySpec.js index 8050521db407..1c9965c5ae52 100644 --- a/Specs/Core/PolygonOutlineGeometrySpec.js +++ b/Specs/Core/PolygonOutlineGeometrySpec.js @@ -1,21 +1,21 @@ defineSuite([ 'Core/PolygonOutlineGeometry', + 'Core/ArcType', 'Core/arrayFill', 'Core/BoundingSphere', 'Core/Cartesian3', 'Core/Ellipsoid', 'Core/GeometryOffsetAttribute', - 'Core/ArcType', 'Core/Math', 'Specs/createPackableSpecs' ], function( PolygonOutlineGeometry, + ArcType, arrayFill, BoundingSphere, Cartesian3, Ellipsoid, GeometryOffsetAttribute, - ArcType, CesiumMath, createPackableSpecs) { 'use strict'; diff --git a/Specs/Core/PolylineGeometrySpec.js b/Specs/Core/PolylineGeometrySpec.js index fb2a43f8154c..4f85c0561f22 100644 --- a/Specs/Core/PolylineGeometrySpec.js +++ b/Specs/Core/PolylineGeometrySpec.js @@ -1,17 +1,17 @@ defineSuite([ 'Core/PolylineGeometry', + 'Core/ArcType', 'Core/Cartesian3', 'Core/Color', 'Core/Ellipsoid', - 'Core/ArcType', 'Core/VertexFormat', 'Specs/createPackableSpecs' ], function( PolylineGeometry, + ArcType, Cartesian3, Color, Ellipsoid, - ArcType, VertexFormat, createPackableSpecs) { 'use strict'; diff --git a/Specs/Core/SimplePolylineGeometrySpec.js b/Specs/Core/SimplePolylineGeometrySpec.js index fb37d4e1f9cb..193136e948e6 100644 --- a/Specs/Core/SimplePolylineGeometrySpec.js +++ b/Specs/Core/SimplePolylineGeometrySpec.js @@ -1,20 +1,20 @@ defineSuite([ 'Core/SimplePolylineGeometry', + 'Core/ArcType', 'Core/BoundingSphere', 'Core/Cartesian3', 'Core/Color', 'Core/Ellipsoid', - 'Core/ArcType', 'Core/Math', 'Core/PrimitiveType', 'Specs/createPackableSpecs' ], function( SimplePolylineGeometry, + ArcType, BoundingSphere, Cartesian3, Color, Ellipsoid, - ArcType, CesiumMath, PrimitiveType, createPackableSpecs) { diff --git a/Specs/DataSources/PolygonGeometryUpdaterSpec.js b/Specs/DataSources/PolygonGeometryUpdaterSpec.js index a42c128c747d..6b14ca626485 100644 --- a/Specs/DataSources/PolygonGeometryUpdaterSpec.js +++ b/Specs/DataSources/PolygonGeometryUpdaterSpec.js @@ -1,12 +1,12 @@ defineSuite([ 'DataSources/PolygonGeometryUpdater', 'Core/ApproximateTerrainHeights', + 'Core/ArcType', 'Core/Cartesian3', 'Core/Color', 'Core/Ellipsoid', 'Core/GeometryOffsetAttribute', 'Core/JulianDate', - 'Core/ArcType', 'Core/Math', 'Core/CoplanarPolygonGeometry', 'Core/CoplanarPolygonOutlineGeometry', @@ -31,12 +31,12 @@ defineSuite([ ], function( PolygonGeometryUpdater, ApproximateTerrainHeights, + ArcType, Cartesian3, Color, Ellipsoid, GeometryOffsetAttribute, JulianDate, - ArcType, CesiumMath, CoplanarPolygonGeometry, CoplanarPolygonOutlineGeometry, diff --git a/Specs/DataSources/PolygonGraphicsSpec.js b/Specs/DataSources/PolygonGraphicsSpec.js index 77031302d5cc..615556dbdfb7 100644 --- a/Specs/DataSources/PolygonGraphicsSpec.js +++ b/Specs/DataSources/PolygonGraphicsSpec.js @@ -1,8 +1,8 @@ defineSuite([ 'DataSources/PolygonGraphics', + 'Core/ArcType', 'Core/Color', 'Core/DistanceDisplayCondition', - 'Core/ArcType', 'Core/PolygonHierarchy', 'DataSources/ColorMaterialProperty', 'DataSources/ConstantProperty', @@ -12,9 +12,9 @@ defineSuite([ 'Specs/testMaterialDefinitionChanged' ], function( PolygonGraphics, + ArcType, Color, DistanceDisplayCondition, - ArcType, PolygonHierarchy, ColorMaterialProperty, ConstantProperty, diff --git a/Specs/DataSources/PolylineGeometryUpdaterSpec.js b/Specs/DataSources/PolylineGeometryUpdaterSpec.js index b44b4dcdf94f..9d3ec2ca8179 100644 --- a/Specs/DataSources/PolylineGeometryUpdaterSpec.js +++ b/Specs/DataSources/PolylineGeometryUpdaterSpec.js @@ -1,6 +1,7 @@ defineSuite([ 'DataSources/PolylineGeometryUpdater', 'Core/ApproximateTerrainHeights', + 'Core/ArcType', 'Core/BoundingSphere', 'Core/Cartesian3', 'Core/Color', @@ -10,7 +11,6 @@ defineSuite([ 'Core/DistanceDisplayConditionGeometryInstanceAttribute', 'Core/GroundPolylineGeometry', 'Core/JulianDate', - 'Core/ArcType', 'Core/PolylinePipeline', 'Core/ShowGeometryInstanceAttribute', 'Core/TimeInterval', @@ -35,6 +35,7 @@ defineSuite([ ], function( PolylineGeometryUpdater, ApproximateTerrainHeights, + ArcType, BoundingSphere, Cartesian3, Color, @@ -44,7 +45,6 @@ defineSuite([ DistanceDisplayConditionGeometryInstanceAttribute, GroundPolylineGeometry, JulianDate, - ArcType, PolylinePipeline, ShowGeometryInstanceAttribute, TimeInterval, diff --git a/Specs/DataSources/PolylineGraphicsSpec.js b/Specs/DataSources/PolylineGraphicsSpec.js index 4549f4313e27..993af95a53ef 100644 --- a/Specs/DataSources/PolylineGraphicsSpec.js +++ b/Specs/DataSources/PolylineGraphicsSpec.js @@ -1,8 +1,8 @@ defineSuite([ 'DataSources/PolylineGraphics', + 'Core/ArcType', 'Core/Color', 'Core/DistanceDisplayCondition', - 'Core/ArcType', 'DataSources/ColorMaterialProperty', 'DataSources/ConstantProperty', 'Scene/ClassificationType', @@ -11,9 +11,9 @@ defineSuite([ 'Specs/testMaterialDefinitionChanged' ], function( PolylineGraphics, + ArcType, Color, DistanceDisplayCondition, - ArcType, ColorMaterialProperty, ConstantProperty, ClassificationType, From 5f7a7ac78a34fda88f3bd37809ea271ebd2ec30d Mon Sep 17 00:00:00 2001 From: Shehzan Mohammed Date: Thu, 24 Jan 2019 10:29:32 -0500 Subject: [PATCH 26/26] Fixes for PR comments: Remove followSurface from doc, remove redundant check --- Source/Core/GroundPolylineGeometry.js | 2 -- Source/Core/PolygonGeometryLibrary.js | 2 -- Source/Core/PolylineGeometry.js | 1 - Source/Core/SimplePolylineGeometry.js | 1 - Source/DataSources/PolylineGraphics.js | 1 - 5 files changed, 7 deletions(-) diff --git a/Source/Core/GroundPolylineGeometry.js b/Source/Core/GroundPolylineGeometry.js index 0e5a5bf619af..d950f2296b27 100644 --- a/Source/Core/GroundPolylineGeometry.js +++ b/Source/Core/GroundPolylineGeometry.js @@ -220,8 +220,6 @@ define([ ellipsoidLine = new EllipsoidGeodesic(start, end, ellipsoid); } else if (arcType === ArcType.RHUMB) { ellipsoidLine = new EllipsoidRhumbLine(start, end, ellipsoid); - } else { - throw new DeveloperError('Unrecognized arcType. Valid options are ArcType.GEODESIC and ArcType.RHUMB'); } var surfaceDistance = ellipsoidLine.surfaceDistance; diff --git a/Source/Core/PolygonGeometryLibrary.js b/Source/Core/PolygonGeometryLibrary.js index ceff350cb7b4..5d8142a450c1 100644 --- a/Source/Core/PolygonGeometryLibrary.js +++ b/Source/Core/PolygonGeometryLibrary.js @@ -538,8 +538,6 @@ define([ tempPositions = PolygonGeometryLibrary.subdivideLine(p1, p2, minDistance, computeWallIndicesSubdivided); } else if (arcType === ArcType.RHUMB) { tempPositions = PolygonGeometryLibrary.subdivideRhumbLine(ellipsoid, p1, p2, minDistance, computeWallIndicesSubdivided); - } else { - throw new DeveloperError('Unrecognized arcType. Valid options are ArcType.GEODESIC and ArcType.RHUMB'); } var tempPositionsLength = tempPositions.length; for (var j = 0; j < tempPositionsLength; ++j, ++index) { diff --git a/Source/Core/PolylineGeometry.js b/Source/Core/PolylineGeometry.js index 5fceeac3edde..a4232b8833e4 100644 --- a/Source/Core/PolylineGeometry.js +++ b/Source/Core/PolylineGeometry.js @@ -91,7 +91,6 @@ define([ * @param {Number} [options.width=1.0] The width in pixels. * @param {Color[]} [options.colors] An Array of {@link Color} defining the per vertex or per segment colors. * @param {Boolean} [options.colorsPerVertex=false] A boolean that determines whether the colors will be flat across each segment of the line or interpolated across the vertices. - * @param {Boolean} [options.followSurface=true] A boolean that determines whether positions will be adjusted to the surface of the ellipsoid via a great arc. * @param {ArcType} [options.arcType=ArcType.GEODESIC] The type of line the polyline segments must follow. * @param {Number} [options.granularity=CesiumMath.RADIANS_PER_DEGREE] The distance, in radians, between each latitude and longitude if options.arcType is not ArcType.NONE. Determines the number of positions in the buffer. * @param {VertexFormat} [options.vertexFormat=VertexFormat.DEFAULT] The vertex attributes to be computed. diff --git a/Source/Core/SimplePolylineGeometry.js b/Source/Core/SimplePolylineGeometry.js index 387ef34d63db..65187d9d6c6c 100644 --- a/Source/Core/SimplePolylineGeometry.js +++ b/Source/Core/SimplePolylineGeometry.js @@ -87,7 +87,6 @@ define([ * @param {Cartesian3[]} options.positions An array of {@link Cartesian3} defining the positions in the polyline as a line strip. * @param {Color[]} [options.colors] An Array of {@link Color} defining the per vertex or per segment colors. * @param {Boolean} [options.colorsPerVertex=false] A boolean that determines whether the colors will be flat across each segment of the line or interpolated across the vertices. - * @param {Boolean} [options.followSurface=true] A boolean that determines whether positions will be adjusted to the surface of the ellipsoid via a great arc. * @param {ArcType} [options.arcType=ArcType.GEODESIC] The type of line the polyline segments must follow. * @param {Number} [options.granularity=CesiumMath.RADIANS_PER_DEGREE] The distance, in radians, between each latitude and longitude if options.arcType is not ArcType.NONE. Determines the number of positions in the buffer. * @param {Ellipsoid} [options.ellipsoid=Ellipsoid.WGS84] The ellipsoid to be used as a reference. diff --git a/Source/DataSources/PolylineGraphics.js b/Source/DataSources/PolylineGraphics.js index 34b07951021b..775ee15b2437 100644 --- a/Source/DataSources/PolylineGraphics.js +++ b/Source/DataSources/PolylineGraphics.js @@ -28,7 +28,6 @@ define([ * * @param {Object} [options] Object with the following properties: * @param {Property} [options.positions] A Property specifying the array of {@link Cartesian3} positions that define the line strip. - * @param {Property} [options.followSurface=true] A boolean Property specifying whether the line segments should be great arcs or linearly connected. * @param {ArcType} [options.arcType=ArcType.GEODESIC] The type of line the polyline segments must follow. * @param {Property} [options.clampToGround=false] A boolean Property specifying whether the Polyline should be clamped to the ground. * @param {Property} [options.width=1.0] A numeric Property specifying the width in pixels.