Polyline visibility problem, data dependant

In this sample My polyline appears just fine:

In this using the same code but different data it’s barely visible. You need to move the view around and it comes and goes.

I tried making a Sandbox for this but couldn’t get it to load the data alas. But the heart of my code is simple:

          name: "Route", polyline: {
              positions: Cesium.Cartesian3.fromDegreesArray(posns),
              width: 5,
              material: Cesium.Color.RED,
              clampToGround: true, },

In the first example the polyline segments seem to be in the same plane as the ground. In the second they seem vertical to the ground which is causing the problems.

If I make the line width 100 instead of 5 it’s really odd:

Think I’ve figured it out! If I only load every 5th data point it’s fine. It seems to be a problem only if points are close together.


This is really causing a problem for us, could use some advice. On most of our pages segment lengths <25m cause the problem to show up. But we have some working ok with 5m spacing.

Hi @DataVerse,

Would you be able to provide the data which is giving you issues? Even if it’s not in Sandcastle form?

If a line is made up of segments that are truly perpendicular to the ground, it will definitely cause issues with the polyline; It’s working against what the geometry is intended to visualize. Depending on the type of data, there may be other geometry options. Or another option may be to pre-process the data and remove problematic points.


Thanks for getting back to me :slight_smile:

The polyline we’re creating is just from lat/long value clamped to ground. I’ve no idea why, but for short spacings it’s rendered perpendicular to the ground.

In the attached example there’s a point every 3-5m. If I change our Cesium script to only look at every 5th point it plots fine. The polyline is in the same plane as the ground. Plotting every point shows the problem. I’ve attached the source code.

Line 90 parsePolyLine fn loads the data into the posns variable. We store all the data, but as you can see in line 98 we’re only putting 1 in 6 records to the polyline to make things work. Line 121 creates the polyline from the posns array.

We’ve tried a lot of options for this. What we really want is to colour code the line by speed / heart rate / etc. But my research indicates we can’t do that if it’s clamped to ground.

We could get the heights for each lat/long and make a polyline using that instead of clamp to ground. But I’ve not figured out how to do that from your API yet.

We’re hoping to be live at the end of the month and we’ll take out a paid licence then.

(Attachment route.csv is missing)

Sending the file again, it was rejected by your security.

csv.zip (87.4 KB)

Ah, I see. If you have terrain turned on, the line is definitely underground. You can see it by adding the following line, although it will appear to be “floating” since you are seeing the line “through” the earth.

viewer.scene.globe.depthTestAgainstTerrain = false;

I would recommend you use the clamp to ground option, otherwise there won’t be an easy way to line it up with terrain unless your csvs include height values per position.

I’m not sure I follow why this rules out clamping to ground. Do you need to color the entire line one color, or color by position? If it’s the former, it should be straightforward to do this while clamping the polyline to the ground.

Yes, we’ve been using clamp to ground thus far. I will sort out other options in future when we start getting aircraft data with good heights into the system. For now it’s all surface stuff.

We wanted to colour code the line so that slow and fast sections were different colours. I’ve written code that worked to do that. But the line was always underground, clamp to ground had no effect. I was told on your forum that the two options are mutually exclusive.

For now the big thing is to work out why short spacing between line segments make the polyline flip into the vertical plane and display poorly.

But the line was always underground, clamp to ground had no effect. I was told on your forum that the two options are mutually exclusive.

I’m not sure what the context of the previous discussion was. It would help if you have a link.

For now the big thing is to work out why short spacing between line segments make the polyline flip into the vertical plane and display poorly.

I was not able to duplicate this with the CSV positions you sent over. See this example

(I did have to slightly truncate positions off the end of the list for the same of shortening the sharing link, but it was working similarly will all of the positions)

Link to colour issue:


I suspect my solution is to work out the terrain heights using Cesium and apply them to the data, then generate the polyline without clamp to ground. I’ve just not had time to learn how :slight_smile: I have 30 years in underwater survey software development so I’m no stranger to datum problems.

From https://terra-dv.com/sandbox2.html

I made the attached screen grab. I made the line’s material width 100 so the problem would stand out. If I reduce it to only show 1 in 5 or so of the points the line segments are longer and display normally. If you look closely you’ll see that the segments are drawn vertically, not parallel to the ground. If I zoom in any further than that the line vanishes.

Awesome, thanks for the link. There are two APIs for adding polylines: The Entity API and the Primitive API.

For the lower-level Primitive API, you won’t be able to use a GroundPolylineGeometry with per-vertex color attributes. However, you could use a regular PolylineGeometry and provide per-positions heights using sampleTerrain or another data source. clampToGround is not a valid option when using the Primitive API.

For the higher level Entity API, you will not be able to specify per-point colors. However you can break you polyline into smaller segments, and use clampToGround in order to have the liens render on top of terrain.

In https://terra-dv.com/sandbox2.html, I don’t see any lines, just the empty globe. I’d recommend prioritizing one of the above solutions, but to figure out what’s going on here, we’d need an exact code example and your hardware specs. It will also help if you take a screenshot of your results on https://webglreport.com/.

Try moving sandbox2 about a bit, one part of the problem is that it doesn’t show the line at all from some angles. I’ll have another go at making a sandbox for this. One thing, last time I tried to make a sandbox I couldn’t figure out how to save it!

HP Z800 windows 10 with an Nvidia Quadro 3000. Having my supper, will try the screen grab thing in a wee while…