Skip to content

Commit

Permalink
Merge pull request #7582 from shehzan10/fix-followsurface-arctype
Browse files Browse the repository at this point in the history
Change usage of followSurface to arcType. Add CZML property for it.
  • Loading branch information
Hannah authored Feb 21, 2019
2 parents 62a70de + 0cbd2d3 commit 0fda487
Show file tree
Hide file tree
Showing 20 changed files with 70 additions and 34 deletions.
6 changes: 3 additions & 3 deletions Apps/SampleData/simple.czml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
}
}
},
"followSurface":false,
"arcType":"NONE",
"positions":{
"references":[
"Satellite/Geoeye1#position","Satellite/ISS#position"
Expand Down Expand Up @@ -207,7 +207,7 @@
}
}
},
"followSurface":false,
"arcType":"NONE",
"positions":{
"references":[
"Facility/AGI#position","Satellite/ISS#position"
Expand All @@ -232,7 +232,7 @@
}
}
},
"followSurface":false,
"arcType":"NONE",
"positions":{
"references":[
"Facility/AGI#position","Satellite/Geoeye1/Sensor/Sensor#position"
Expand Down
2 changes: 1 addition & 1 deletion Apps/Sandcastle/gallery/CZML Polyline.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
}
}
},
"followSurface" : false,
"arcType" : "NONE",
"width" : 10
}
}, {
Expand Down
2 changes: 1 addition & 1 deletion Apps/Sandcastle/gallery/Clamp to Terrain.html
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
viewer.entities.add({
polyline : {
positions : Cesium.Ellipsoid.WGS84.cartographicArrayToCartesianArray(samples),
followSurface : false,
arcType : Cesium.ArcType.NONE,
width : 5,
material : new Cesium.PolylineOutlineMaterialProperty({
color : Cesium.Color.ORANGE,
Expand Down
2 changes: 1 addition & 1 deletion Apps/Sandcastle/gallery/Custom DataSource.html
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@
var polyline = new Cesium.PolylineGraphics();
polyline.material = new Cesium.ColorMaterialProperty(color);
polyline.width = new Cesium.ConstantProperty(2);
polyline.followSurface = new Cesium.ConstantProperty(false);
polyline.arcType = new Cesium.ConstantProperty(Cesium.ArcType.NONE);
polyline.positions = new Cesium.ConstantProperty([surfacePosition, heightPosition]);

//The polyline instance itself needs to be on an entity.
Expand Down
2 changes: 1 addition & 1 deletion Apps/Sandcastle/gallery/Sample Height from 3D Tiles.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
viewer.entities.add({
polyline : {
positions : clampedCartesians,
followSurface : false,
arcType : Cesium.ArcType.NONE,
width : 2,
material : new Cesium.PolylineOutlineMaterialProperty({
color : Cesium.Color.YELLOW
Expand Down
2 changes: 1 addition & 1 deletion Apps/Sandcastle/gallery/Star Burst.html
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@
instances.push(new Cesium.GeometryInstance({
geometry : new Cesium.SimplePolylineGeometry({
positions : [starBurstState.center, lines[i]],
followSurface : false,
arcType : Cesium.ArcType.NONE,
granularity : Cesium.Math.PI_OVER_FOUR
}),
attributes : {
Expand Down
2 changes: 1 addition & 1 deletion Apps/Sandcastle/gallery/development/Pick From Ray.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
polyline : {
positions : arrowPositions,
width : 10,
followSurface : false,
arcType : Cesium.ArcType.NONE,
material : new Cesium.PolylineArrowMaterialProperty(Cesium.Color.YELLOW)
}
});
Expand Down
4 changes: 2 additions & 2 deletions Apps/Sandcastle/gallery/development/Polyline.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

// Example 2: Draw a straight blue polyline

// Setting the followSurface option to false will allow
// Setting the arcType option to ArcType.NONE will allow
// you to draw a straight polyline. Otherwise, it will
// curve to the globe surface.
scene.primitives.add(new Cesium.Primitive({
Expand All @@ -64,7 +64,7 @@
]),
width : 5.0,
vertexFormat : Cesium.PolylineColorAppearance.VERTEX_FORMAT,
followSurface: false
arcType: Cesium.ArcType.NONE
}),
attributes: {
color: Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.BLUE)
Expand Down
4 changes: 2 additions & 2 deletions Apps/Sandcastle/gallery/development/Simple Polyline.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@
}
// For per segment coloring, provide the colors options with an
// array of colors where the length is equal to the number of positions.
// Setting followSurface to false will draw straight lines.
// Setting arcType to ArcType.NONE will draw straight lines.
// Otherwise, the polyline curves to the surface of the globe.
var perSegmentPolyline = new Cesium.GeometryInstance({
geometry : new Cesium.SimplePolylineGeometry({
positions : positions,
colors : colors,
followSurface: false
arcType: Cesium.ArcType.NONE
})
});

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/PolylineGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ 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.arcType instead.');
deprecationWarning('PolylineGeometry.followSurface', 'PolylineGeometry.followSurface is deprecated and will be removed in Cesium 1.57. Use PolylineGeometry.arcType instead.');
options.arcType = options.followSurface ? ArcType.GEODESIC : ArcType.NONE;
}
this._arcType = defaultValue(options.arcType, ArcType.GEODESIC);
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/SimplePolylineGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ 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.arcType instead.');
deprecationWarning('PolylineGeometry.followSurface', 'PolylineGeometry.followSurface is deprecated and will be removed in Cesium 1.57. Use PolylineGeometry.arcType instead.');
options.arcType = options.followSurface ? ArcType.GEODESIC : ArcType.NONE;
}
this._arcType = defaultValue(options.arcType, ArcType.GEODESIC);
Expand Down
19 changes: 18 additions & 1 deletion Source/DataSources/CzmlDataSource.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
define([
'../Core/ArcType',
'../Core/BoundingRectangle',
'../Core/Cartesian2',
'../Core/Cartesian3',
Expand Down Expand Up @@ -86,6 +87,7 @@ define([
'./VelocityVectorProperty',
'./WallGraphics'
], function(
ArcType,
BoundingRectangle,
Cartesian2,
Cartesian3,
Expand Down Expand Up @@ -501,6 +503,8 @@ define([
} else if (czmlInterval.hasOwnProperty('rgba') ||
czmlInterval.hasOwnProperty('rgbaf')) {
return Color;
} else if (czmlInterval.hasOwnProperty('arcType')) {
return ArcType;
} else if (czmlInterval.hasOwnProperty('colorBlendMode')) {
return ColorBlendMode;
} else if (czmlInterval.hasOwnProperty('cornerType')) {
Expand Down Expand Up @@ -546,6 +550,8 @@ define([
// The associations in this function need to be kept in sync with the
// associations in getPropertyType
switch (type) {
case ArcType:
return ArcType[defaultValue(czmlInterval.arcType, czmlInterval)];
case Array:
return czmlInterval.array;
case Boolean:
Expand Down Expand Up @@ -1765,6 +1771,7 @@ define([
processPacketData(Boolean, polygon, 'perPositionHeight', polygonData.perPositionHeight, interval, sourceUri, entityCollection);
processPacketData(Boolean, polygon, 'closeTop', polygonData.closeTop, interval, sourceUri, entityCollection);
processPacketData(Boolean, polygon, 'closeBottom', polygonData.closeBottom, interval, sourceUri, entityCollection);
processPacketData(ArcType, polygon, 'arcType', polygonData.arcType, interval, sourceUri, entityCollection);
processPacketData(ShadowMode, polygon, 'shadows', polygonData.shadows, interval, sourceUri, entityCollection);
processPacketData(DistanceDisplayCondition, polygon, 'distanceDisplayCondition', polygonData.distanceDisplayCondition, interval, sourceUri, entityCollection);
processPacketData(Number, polygon, 'zIndex', polygonData.zIndex, interval, sourceUri, entityCollection);
Expand Down Expand Up @@ -1794,7 +1801,17 @@ define([
processPacketData(Number, polyline, 'granularity', polylineData.granularity, interval, sourceUri, entityCollection);
processMaterialPacketData(polyline, 'material', polylineData.material, interval, sourceUri, entityCollection);
processMaterialPacketData(polyline, 'depthFailMaterial', polylineData.depthFailMaterial, interval, sourceUri, entityCollection);
processPacketData(Boolean, polyline, 'followSurface', polylineData.followSurface, interval, sourceUri, entityCollection);
// Don't want to break CZML spec to keep this workaround even after followSurface has been deprecated from geometry.
// See https://github.com/AnalyticalGraphicsInc/cesium/pull/7582#discussion_r258695385
if (defined(polylineData.followSurface) && !defined(polylineData.arcType)) {
if (polyline.followSurface) {
processPacketData(ArcType, polyline, 'arcType', ArcType.GEODESIC, interval, sourceUri, entityCollection);
} else {
processPacketData(ArcType, polyline, 'arcType', ArcType.NONE, interval, sourceUri, entityCollection);
}
} else {
processPacketData(ArcType, polyline, 'arcType', polylineData.arcType, interval, sourceUri, entityCollection);
}
processPacketData(Boolean, polyline, 'clampToGround', polylineData.clampToGround, interval, sourceUri, entityCollection);
processPacketData(ShadowMode, polyline, 'shadows', polylineData.shadows, interval, sourceUri, entityCollection);
processPacketData(DistanceDisplayCondition, polyline, 'distanceDisplayCondition', polylineData.distanceDisplayCondition, interval, sourceUri, entityCollection);
Expand Down
4 changes: 3 additions & 1 deletion Source/DataSources/KmlDataSource.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
define([
'../Core/ArcType',
'../Core/AssociativeArray',
'../Core/BoundingRectangle',
'../Core/Cartesian2',
Expand Down Expand Up @@ -64,6 +65,7 @@ define([
'./TimeIntervalCollectionProperty',
'./WallGraphics'
], function(
ArcType,
AssociativeArray,
BoundingRectangle,
Cartesian2,
Expand Down Expand Up @@ -1287,7 +1289,7 @@ define([
entity.polyline = polyline;
polyline.positions = createPositionPropertyArrayFromAltitudeMode(coordinates, altitudeMode, gxAltitudeMode, ellipsoid);
if (!tessellate || canExtrude) {
polyline.followSurface = false;
polyline.arcType = ArcType.NONE;
}
}

Expand Down
10 changes: 5 additions & 5 deletions Specs/Core/SimplePolylineGeometrySpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ defineSuite([
var positions = [new Cartesian3(), new Cartesian3(1.0, 0.0, 0.0), new Cartesian3(2.0, 0.0, 0.0)];
var line = SimplePolylineGeometry.createGeometry(new SimplePolylineGeometry({
positions : positions,
followSurface: false
arcType: ArcType.NONE
}));

expect(line.attributes.position.values).toEqual([0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 2.0, 0.0, 0.0]);
Expand All @@ -131,7 +131,7 @@ defineSuite([
var line = SimplePolylineGeometry.createGeometry(new SimplePolylineGeometry({
positions : positions,
colors : colors,
followSurface: false
arcType : ArcType.NONE
}));

expect(line.attributes.color).toBeDefined();
Expand All @@ -147,7 +147,7 @@ defineSuite([
positions : positions,
colors : colors,
colorsPerVertex : true,
followSurface: false
arcType : ArcType.NONE
}));

expect(line.attributes.color).toBeDefined();
Expand All @@ -161,7 +161,7 @@ defineSuite([
positions : positions,
colors : [Color.RED, Color.LIME, Color.BLUE],
colorsPerVertex : true,
followSurface : false,
arcType : ArcType.NONE,
granularity : 11,
ellipsoid : new Ellipsoid(12, 13, 14)
});
Expand All @@ -171,7 +171,7 @@ defineSuite([
line = new SimplePolylineGeometry({
positions : positions,
colorsPerVertex : false,
followSurface : false,
arcType : ArcType.NONE,
granularity : 11,
ellipsoid : new Ellipsoid(12, 13, 14)
});
Expand Down
9 changes: 8 additions & 1 deletion Specs/Data/CZML/ValidationDocument.czml
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@
"perPositionHeight":true,
"closeTop":true,
"closeBottom":true,
"arcType":"GEODESIC",
"shadows":"CAST_ONLY",
"distanceDisplayCondition":{
"distanceDisplayCondition":[
Expand All @@ -474,7 +475,7 @@
}
}
},
"followSurface":true,
"arcType":"GEODESIC",
"shadows":"CAST_ONLY",
"depthFailMaterial":{
"solidColor":{
Expand Down Expand Up @@ -6281,6 +6282,9 @@
"closeBottom":{
"reference":"Constant#polygon.closeBottom"
},
"arcType":{
"reference":"Constant#polygon.arcType"
},
"shadows":{
"reference":"Constant#polygon.shadows"
},
Expand Down Expand Up @@ -6313,6 +6317,9 @@
"followSurface":{
"reference":"Constant#polyline.followSurface"
},
"arcType":{
"reference":"Constant#polyline.arcType"
},
"shadows":{
"reference":"Constant#polyline.shadows"
},
Expand Down
6 changes: 4 additions & 2 deletions Specs/DataSources/CzmlDataSourceSpec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
defineSuite([
'DataSources/CzmlDataSource',
'Core/ArcType',
'Core/BoundingRectangle',
'Core/Cartesian2',
'Core/Cartesian3',
Expand Down Expand Up @@ -38,6 +39,7 @@ defineSuite([
'ThirdParty/when'
], function(
CzmlDataSource,
ArcType,
BoundingRectangle,
Cartesian2,
Cartesian3,
Expand Down Expand Up @@ -3775,7 +3777,7 @@ defineSuite([
expect(e.polyline.width.getValue(date)).toEqual(14667.0);
expect(e.polyline.granularity.getValue(date)).toEqual(53395.0);
expect(e.polyline.material.color.getValue(date)).toEqual(Color.fromBytes(88, 0, 232, 230));
expect(e.polyline.followSurface.getValue(date)).toEqual(true);
expect(e.polyline.arcType.getValue(date)).toEqual(ArcType.GEODESIC);
expect(e.polyline.shadows.getValue(date)).toEqual(ShadowMode.CAST_ONLY);
expect(e.polyline.depthFailMaterial.color.getValue(date)).toEqual(Color.fromBytes(197, 195, 115, 198));
expect(e.polyline.distanceDisplayCondition.getValue(date)).toEqual(new DistanceDisplayCondition(5807, 30486));
Expand Down Expand Up @@ -4584,7 +4586,7 @@ defineSuite([
expect(e.polyline.width.getValue(date)).toEqual(constant.polyline.width.getValue(date));
expect(e.polyline.granularity.getValue(date)).toEqual(constant.polyline.granularity.getValue(date));
expect(e.polyline.material.color.getValue(date)).toEqual(constant.polyline.material.color.getValue(date));
expect(e.polyline.followSurface.getValue(date)).toEqual(constant.polyline.followSurface.getValue(date));
expect(e.polyline.arcType.getValue(date)).toEqual(constant.polyline.arcType.getValue(date));
expect(e.polyline.shadows.getValue(date)).toEqual(constant.polyline.shadows.getValue(date));
expect(e.polyline.depthFailMaterial.color.getValue(date)).toEqual(constant.polyline.depthFailMaterial.color.getValue(date));
expect(e.polyline.distanceDisplayCondition.getValue(date)).toEqual(constant.polyline.distanceDisplayCondition.getValue(date));
Expand Down
12 changes: 7 additions & 5 deletions Specs/DataSources/KmlDataSourceSpec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
defineSuite([
'DataSources/KmlDataSource',
'Core/ArcType',
'Core/BoundingRectangle',
'Core/Cartesian2',
'Core/Cartesian3',
Expand Down Expand Up @@ -38,6 +39,7 @@ defineSuite([
'ThirdParty/when'
], function(
KmlDataSource,
ArcType,
BoundingRectangle,
Cartesian2,
Cartesian3,
Expand Down Expand Up @@ -2161,7 +2163,7 @@ defineSuite([
expect(polyline).toBeDefined();

expect(polyline.positions).toBeUndefined();
expect(polyline.followSurface).toBeUndefined();
expect(polyline.arcType).toBeUndefined();
expect(polyline.width).toBeUndefined();
expect(polyline.show).toBeUndefined();
expect(polyline.material).toBeUndefined();
Expand Down Expand Up @@ -2899,7 +2901,7 @@ defineSuite([
var entity = entities[0];
expect(entity.wall).toBeUndefined();
expect(entity.polyline).toBeDefined();
expect(entity.polyline.followSurface.getValue()).toEqual(false);
expect(entity.polyline.arcType.getValue()).toEqual(ArcType.NONE);
});
});

Expand All @@ -2923,7 +2925,7 @@ defineSuite([

var positions = entity.polyline.positions.getValue(Iso8601.MINIMUM_VALUE);
expect(positions).toEqualEpsilon([Cartesian3.fromDegrees(1, 2), Cartesian3.fromDegrees(4, 5)], CesiumMath.EPSILON10);
expect(entity.polyline.followSurface.getValue()).toEqual(false);
expect(entity.polyline.arcType.getValue()).toEqual(ArcType.NONE);
});
});

Expand Down Expand Up @@ -2968,7 +2970,7 @@ defineSuite([
expect(entities.length).toEqual(1);

var entity = entities[0];
expect(entity.polyline.followSurface).toBeUndefined();
expect(entity.polyline.arcType).toBeUndefined();
var positions = entity.polyline.positions.getValue(Iso8601.MINIMUM_VALUE);
expect(positions).toEqualEpsilon([Cartesian3.fromDegrees(1, 2), Cartesian3.fromDegrees(4, 5)], CesiumMath.EPSILON10);
});
Expand All @@ -2991,7 +2993,7 @@ defineSuite([
expect(entities.length).toEqual(1);

var entity = entities[0];
expect(entity.polyline.followSurface).toBeUndefined();
expect(entity.polyline.arcType).toBeUndefined();
var positions = entity.polyline.positions.getValue(Iso8601.MINIMUM_VALUE);
expect(positions).toEqualEpsilon([Cartesian3.fromDegrees(1, 2), Cartesian3.fromDegrees(4, 5)], CesiumMath.EPSILON10);
});
Expand Down
Loading

0 comments on commit 0fda487

Please sign in to comment.