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

Make Entity API use custom ellipsoid #3543

Closed
hpinkos opened this issue Feb 10, 2016 · 4 comments · Fixed by #12000
Closed

Make Entity API use custom ellipsoid #3543

hpinkos opened this issue Feb 10, 2016 · 4 comments · Fixed by #12000

Comments

@hpinkos
Copy link
Contributor

hpinkos commented Feb 10, 2016

It looks like the Entity API only uses the default Ellipsoid.WGS84. As a result, you can't really use it if you need a custom ellipsoid. In this example, the polygon is hovering above the globe because the ellipsoid is smaller than earth:

var radius = 5e6;
var ellipsoid = new Cesium.Ellipsoid(radius, radius, radius);
var projection = new Cesium.GeographicProjection(ellipsoid);

var viewer = new Cesium.Viewer('cesiumContainer', {
    mapProjection: projection,
    baseLayerPicker: false,
    imageryProvider: new Cesium.BingMapsImageryProvider({
        url : '//dev.virtualearth.net',
        mapStyle : Cesium.BingMapsStyle.AERIAL,
        ellipsoid: ellipsoid
    })
});

var redPolygon = viewer.entities.add({
    name : 'Red polygon on surface',
    polygon : {
        hierarchy : Cesium.Cartesian3.fromDegreesArray([-115.0, 37.0,
                                                        -115.0, 32.0,
                                                        -107.0, 33.0,
                                                        -102.0, 31.0,
                                                        -102.0, 35.0]),
        material : Cesium.Color.RED
    }
});
@mramato
Copy link
Contributor

mramato commented Feb 10, 2016

The (simply by hacky) workaround for this is to actually modify WGS84 at the start of your app so that it has the custom size, then just use the default everywhere.

It might actually be a decent real solution to have Ellipsoid.default in addition to Ellipsoid.WGS84 and just have the former equal the latter by default. Then we use Ellipsoid.default everywhere we currently use Ellipsoid.WGS84.

This seems way more elegant of a solution when you only have a single custom ellipsoid in an application.

@mramato
Copy link
Contributor

mramato commented Feb 10, 2016

The actual problem here is that all of the XXXGeometryUpdater objects use the default ellipsoid value rather than getting it from the scene. Should be a straightforward fix, but I don't have the bandwidth to do it myself right now.

@ggetz
Copy link
Contributor

ggetz commented Mar 28, 2023

Also brought up for CZML in #11185.

@malaretv
Copy link
Contributor

Hi moving discussion regarding my issue above here as requested. While indeed in a similar category as this issue, my issue was more specifically looking for guidance to provide a working solution to CzmlDataSource that would follow code conventions you guys would be happy with. If not desired for the project I understand!

The suggestion by the Cesium team to overwrite Ellipsoid.WGS84 does not work in all cases. For example any call made to Cartesian3.fromRadians() (or any of the other functions like Cartesian3.fromDegrees() that use it under-the-hood) without an ellipsoid parameter ends up using the values defined here

const wgs84RadiiSquared = new Cartesian3(
6378137.0 * 6378137.0,
6378137.0 * 6378137.0,
6356752.3142451793 * 6356752.3142451793
);

So wherever internal Cesium code exists that is calling Cartesian3.fromRadians() (or any function that uses it) that does not explicitly pass an ellipsoid parameter, the proposed solution to overwrite Ellipsoid.WGS84 does not work! Hence my fishing around for how best to implement a CzmlDataSource that supports configuring the ellipsoid used.

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