GroundPolyline has missing segments

1. A concise explanation of the problem you're experiencing.

GroundPolylinePrimitive/GroundPolylineGeometry occasionally has missing segments. This problem occurs with both the default EllipsoidTerrainProvider and in the Cesium World Terrain provider.

2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.

var viewer = new Cesium.Viewer('cesiumContainer', {
    terrainProvider: Cesium.createWorldTerrain()
});

Cesium.GroundPolylinePrimitive.initializeTerrainHeights().then(function() {
    viewer.scene.groundPrimitives.add(new Cesium.GroundPolylinePrimitive({
        asynchronous: false,
        appearance: new Cesium.PolylineColorAppearance(),
        geometryInstances: new Cesium.GeometryInstance({
            geometry: new Cesium.GroundPolylineGeometry({
                positions: Cesium.Cartesian3.fromDegreesArray([
                    -113.27501959409855, 30.055540847137976,
                    -109.8032116749814, 36.34544121914228,
                    -105.72704919353765, 42.5125579838678,
                    -100.77203270419727, 48.49898619382741,
                    -94.52369768441382, 54.211967717643496
                ]),
                arcType: Cesium.ArcType.GEODESIC,
                width: 2
            }),
            attributes: {
                color: new Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.YELLOW)
            }
        })
    }));
});

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

I need the entire line to show and be clamped to terrain.

4. The Cesium version you're using, your operating system and browser.

Cesium 1.57, OS X 10.14.4, Chrome 74.0.3729.131 and Firefox 66.0.4

Thanks for providing a Sandcastle example! After playing around with it for a bit, it seems like lowering the granularity and making it a little thicker fixes the gaps. I posted these thoughts here https://github.com/AnalyticalGraphicsInc/cesium/issues/7783#issuecomment-490261591

Let me know if that helps.

That's nice from a debug standpoint, but that will not be an acceptable change in our application since we potentially have thousands of lines displayed at any one time.

On further inspection, I think the problem is exacerbated by the interpolation in our application. Drawing a large triangle such as [0, 0, 25, 50, 50, 0, 0, 0] in Cesium does not show the issue, but interpolating such a polygon in our application shows it repeatedly.

Here's a coordinate array (a triangle interpolated along a geodesic arc with the granularity set to 100km):

[-4.201656059806739,0.09773680780320149,-3.712263127247676,0.8485605216339565,-3.222680819064556,1.5993199444941695,-2.7327413637387528,2.3499581106786565,-2.2422766071590114,3.1004179077698666,-1.7511178323550778,3.8506420073272807,-1.2590955784804363,4.60057279507717,-0.7660394588069188,5.350152300441081,-0.27177797749627697,6.099322125240008,0.22386165508318978,6.848023371408743,0.7210537087231373,7.596196567553648,1.2199741216483453,8.343781594182644,1.720800690914577,9.09071760743484,2.2237132651423694,9.83694296113282,2.7288939397900798,10.582395126976678,3.236527255160074,11.327010612695332,3.7468003973207793,12.07072487796573,4.259903402114405,12.813472247905679,4.776029362404724,13.55518582394133,5.2953746387018485,14.29579739184453,5.8181390732800295,15.0352373267298,6.344526207880962,15.773434494795055,6.874743505067329,16.510316151583822,7.409002573259723,17.245807836540962,7.947519395453515,17.97983326362754,8.49051456157041,18.71231420775466,9.038213504351667,19.443170386789603,9.590846738644853,20.17231933888243,10.148650103874145,20.899676294855595,10.722985226085337,20.208958454819893,11.292253326131256,19.51634348975891,11.85667198286228,18.82191673711486,12.416454395982688,18.125761342101754,12.971809558904598,17.427958370421393,13.52294243177466,16.728586917154487,14.07005411428318,16.027724211990687,14.613342017927977,15.325445720963273,15.153000037461677,14.621825244852914,15.689218721301398,13.916935014424368,16.22218544072482,13.210845782659135,16.752084557716746,12.503626914144732,17.279097591366124,11.795346471779837,17.803403382745294,11.086071300952057,18.325178258231425,10.375867111342998,18.844596191255356,9.66479855651231,19.361828962485088,8.95292931141087,19.877046318470956,8.240322147969778,20.390416128796584,7.527039008910194,20.902104541795083,6.813141079915795,21.412276138903245,6.098688860308542,21.921094087737973,5.383742232364909,22.428720293989496,4.668360529408773,22.935315552234428,3.9526026028146646,23.441039695779295,3.2365268880535183,23.9460517456516,2.5201914699116656,24.450510058860633,1.803654147012125,24.954572476054626,1.0869724957663323,25.458396468704517,0.3702039338835732,25.962139285946986,-0.3465942164357614,26.465958101221347,-1.063364665497204,25.589543550072896,-1.032906336123233,24.71314580871515,-1.0022047599740347,23.836764504894017,-0.9712671730601556,22.960399250898213,-0.9401008664795967,22.084049643925454,-0.9087131847044816,21.20771526646288,-0.8771115238557741,20.331395686681027,-0.8453033299673933,19.455090458841195,-0.8132960972394727,18.578799123715815,-0.7810973662814575,17.70252120902127,-0.7487147223452695,16.826256229862956,-0.7161557935491345,15.950003689191979,-0.6834282490922021,15.073763078273247,-0.6505397974606666,14.197533877164323,-0.6174981846253473,13.321315555204778,-0.5843111922316808,12.44510757151543,-0.5509866357820243,11.568909375507102,-0.517532362810897,10.69272040739836,-0.48395625105357,9.816540098741868,-0.4502662066082621,8.940367872958618,-0.4164701620924376,8.064203145879901,-0.3825760747936471,7.188045326296127,-0.3485919248150964,6.311893816512321,-0.31452571321653977,5.435748012909496,-0.2803854601508107,4.559607306511666,-0.24617920299647267,3.6834710835576483,-0.21191499448663365,2.8073387260774787,-0.17760090083488933,1.9312096124725215,-0.14324499985825412,1.0550831180991977,-0.10885537909783238,0.1789586158552332,-0.07444013393732973,-0.6971645232315318,-0.04000736572007213,-1.5732869294128233,-0.005565179864731817,-2.449409233628323,0.02887831601981361,-3.3255320669133646,0.06331501401999162,-4.201656059806739,0.09773680780320149]

We interpolate separately from Cesium because we need the 2D (OpenLayers) representation of the polygon to be accurate when shown in that view and also when sent to remote servers for queries.

This issue only occurs when the arc type (for both our interpolation and Cesium's) is set to geodesic. Rhumb interpolation works as expected.