Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad visualization with small geometry #3035

Closed
mramato opened this issue Sep 16, 2015 · 4 comments
Closed

Bad visualization with small geometry #3035

mramato opened this issue Sep 16, 2015 · 4 comments

Comments

@mramato
Copy link
Contributor

mramato commented Sep 16, 2015

This might be multiple bugs, or it could be one issue manifesting in multiple places.

The below code snippet as reported on the forum is not giving the intended visualization. I actually think this code is bad to begin with because the width is way to big for the proximity of the data, something like 0.1 is more realistic, but changing it produces no visualization at all.

var viewer = new Cesium.Viewer('cesiumContainer');

var segments = [
[-111.819822,33.264247,347.0125903148645,-111.819827,33.264247,347.0125903148645,-111.819828,33.264246,347.0125903148645,-111.819826,33.264248,347.0125903148645,-111.81981,33.264258,346.9642320459691]
];

for ( var iSeg = 0; iSeg < segments.length; iSeg++ ) {
    var positions = segments[ iSeg ];

    var corridor = new Cesium.GeometryInstance( {
        geometry : new Cesium.CorridorGeometry( {
            positions : Cesium.Cartesian3.fromDegreesArrayHeights( positions ),
            width : 10
        } ),
        attributes : {
            color : new Cesium.ColorGeometryInstanceAttribute.fromColor( Cesium.Color.RED )
        }
    } );

    viewer.scene.groundPrimitives.add( new Cesium.GroundPrimitive( {
        geometryInstance : corridor
    } ) );

}

viewer.camera.flyTo( {
    destination: Cesium.Cartesian3.fromDegrees( -111.820455, 33.264529, 750 )
} );

In order to get a better idea of the data, I used the below snippet. As you'll see the points do not line up with the polyline (the polyline is wrong). If you make the polyline a corridor with width: 0.1, it has a similar issue.

var viewer = new Cesium.Viewer('cesiumContainer');

var positions = Cesium.Cartesian3.fromDegreesArray(
 [-111.819822,33.264247,
 -111.819827,33.264247,
 -111.819828,33.264246,
 -111.819826,33.264248,
 -111.81981,33.264258]);

viewer.entities.add({
    polyline : {
        positions : positions,
        material : Cesium.Color.RED
    }
});

positions.forEach(function(pos) {
    viewer.entities.add({
        position: pos,
        point : {
            pixelSize : 10
        }
    });
});

viewer.zoomTo(viewer.entities);

So there's definitely something wrong going on, but I have no idea what it is at this point.

@slozier
Copy link
Contributor

slozier commented Sep 17, 2015

PolylineGeometry.createGeometry calls PolylinePipeline.removeDuplicates which decided which points are duplicates by calling Cartesian3.equalsEpsilon on consecutive points with an epsilon of 1e-7 which return true if each coordinates are equal using CesiumMath.equalsEpsilon and the same epsilon.

In my opinion Cartesian3.equalsEpsilon isn't a very good test for deciding if points are duplicates since its results can be greatly affected by the coordinates.

For example:

a = Cesium.Cartesian3.fromDegreesArray([0,0,0.00000000001,0]);
Cesium.Cartesian3.equalsEpsilon(a[0],a[1], 1e-7); // = false
Cesium.Cartesian3.distance(a[0],a[1]); // = 0.00000111319...

b = Cesium.Cartesian3.fromDegreesArray([45,0,45.000001,0]);
Cesium.Cartesian3.equalsEpsilon(b[0],b[1], 1e-7); // = true
Cesium.Cartesian3.distance(b[0],b[1]); // = 0.111319...

If you try your second example with the following positions, then it works.

var positions = Cesium.Cartesian3.fromDegreesArray(
 [-1.819822,33.264247,
 -1.819827,33.264247,
 -1.819828,33.264246,
 -1.819826,33.264248,
 -1.81981,33.264258]);

@denverpierce
Copy link
Contributor

@hpinkos
Copy link
Contributor

hpinkos commented Jan 3, 2019

This is fixed

image

@hpinkos hpinkos closed this as completed Jan 3, 2019
@cesium-concierge
Copy link

Congratulations on closing the issue! I found these Cesium forum links in the comments above:

https://groups.google.com/d/msg/cesium-dev/hoObR5ChpHQ/K3rrDe8lAQAJ
https://groups.google.com/forum/#!searchin/cesium-dev/Disabling$20vertex$20compression$20on$20a$20datasource/cesium-dev/pwl1UbCynwo/vq-3sA9oAgAJ

If this issue affects any of these threads, please post a comment like the following:

The issue at #3035 has just been closed and may resolve your issue. Look for the change in the next stable release of Cesium or get it now in the master branch on GitHub https://github.com/AnalyticalGraphicsInc/cesium.


I am a bot who helps you make Cesium awesome! Contributions to my configuration are welcome.

🌍 🌎 🌏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants