CesiumGS / cesium

An open-source JavaScript library for world-class 3D globes and maps :earth_americas:
https://cesium.com/cesiumjs/
Apache License 2.0
12.74k stars 3.45k forks source link

KML Polylines have ArcType value as either undefined or ArcType.NONE after import #9555

Open JoshuaKahn opened 3 years ago

JoshuaKahn commented 3 years ago

Sandcastle example: None Specifically

Browser: Chrome

Operating System: Linux (Kubuntu) 20.04

When importing a KML into Cesium, polylines will either have their ArcType value set as undefined or ArcType.NONE.

Here's a polyline printed to the log after import.

I discovered this when trying to force polylines from Cesium to be clamped to terrain upon import. Often without the right ArcType value the engine will crash trying to get the line to clamp, with the error:

CesiumWidget.js?d9c1:690 An error occurred while rendering.  Rendering has stopped.
DeveloperError: Valid options for arcType are ArcType.GEODESIC and ArcType.RHUMB.

I think whether or not the line has tessellate in the KML file determines what ArcType is chosen. If tessellate is present, then ArcType will be undefined; if it's not, then ArcType will be ArcType.NONE.

An example KML file can be located here.

ebogo1 commented 3 years ago

@JoshuaKahn - are you forcing the polyline to clamp with the clampToGround option? Currently we ignore this option if the tesselate flag is missing.

I think whether or not the line has tessellate in the KML file determines what ArcType is chosen.

This seems accurate - see these lines in KmlDataSource.js:

if (!tessellate || canExtrude) {
    polyline.arcType = ArcType.NONE;
}

@lilleyse Do you know what the correct behavior should be between ArcType and tesselate?

JoshuaKahn commented 3 years ago

@JoshuaKahn - are you forcing the polyline to clamp with the clampToGround option? Currently we ignore this option if the tesselate flag is missing.

I think whether or not the line has tessellate in the KML file determines what ArcType is chosen.

This seems accurate - see these lines in KmlDataSource.js:

if (!tessellate || canExtrude) {
    polyline.arcType = ArcType.NONE;
}

@lilleyse Do you know what the correct behavior should be between ArcType and tesselate?

@ebogo1 Yes I am forcing the polyline to clamp as I've run into circumstances in the pass where KMLs I have been sent do not have tessellate enabled, meaning them easily clip into terrain. The tool I'm developing Cesium with will be used by other users, and I'm hoping that I can enable KML import into the application such that they don't have to edit any KML file they are given to have polylines clamp to terrain.

Right now I'm avoiding the resulting error mentioned above by setting polylines to use ArcType.GEODESIC, then setting their clamp to ground value to true.

ebogo1 commented 3 years ago

@JoshuaKahn For now your approach might be best. We'll leave this issue open to revisit in the future - the end goal might be to add an option to KmlDataSource that overrides clampToGround behavior, but I'm unsure when we'll get to resolving this.