Reputation: 2503
I'm working on world wind, with a surface ellipse, but I want to set an altitude to this ellipse.
I try to use the method moveTo
, or to instantiate an elevation
directly in the constructor, but nothing works, and my shape is still fixed on the planet.
Here's how I create my shape :
final SurfaceEllipse shape = new SurfaceEllipse();
shape.setRadii(100000, 100000);
shape.moveTo(Position.fromDegrees(50.0, 0.0, 50*20000)); // just a test
layer.addRenderable(shape);
Upvotes: 1
Views: 750
Reputation: 7334
Position does indeed take an elevation, which is simply a double
and means the same thing as altitude (at least according to Position
's getters).
However, SurfaceEllipse implements the SurfaceObject interface which is documented to be a:
Common interface for renderables that are drawn on the Globe's surface terrain, such as SurfaceShape. SurfaceObject implements the Renderable and PreRenderable interfaces, so a surface object may be aggregated within any layer or within some arbitrary rendering code.
The key words to note there are, "drawn on the Globe's surface terrain". You can't set the elevation. It has to be the elevation of the earths surface at that position. So you can read it, but not set it.
I would suggest using another class to make your shape. Bounce around the class inheritance structure and you may find something to do what you want.
AbstractGeneralShape documents it's modelPosition as:
This shape's geographic location. The altitude is relative to this shapes altitude mode.
So any class under AbstractGeneralShape
has the concept of altitude modes.
AbstractShape also has altitudeMode
and under it is path, a class that finally documents altitude mode.
Path documents altitude mode as:
Altitudes within the path's positions are interpreted according to the path's altitude mode. If the altitude mode is WorldWind.ABSOLUTE, the altitudes are considered as height above the ellipsoid. If the altitude mode is WorldWind.RELATIVE_TO_GROUND, the altitudes are added to the elevation of the terrain at the position. If the altitude mode is WorldWind.CLAMP_TO_GROUND the altitudes are ignored.
So to do what you want you need to make sure you're not in WorldWind.CLAMP_TO_GROUND
altitude mode.
With that in mind take a look at Ellipsoid.
A general ellipsoid volume defined by a center position and the three ellipsoid axis radii. If A is the radius in the north-south direction, and b is the radius in the east-west direction, and c is the radius in the vertical direction (increasing altitude), then A == B == C defines a sphere, A == B > C defines a vertically flattened spheroid (disk-shaped), A == B < C defines a vertically stretched spheroid.
Which is a long winded way to say it's constructed like this:
Make C small enough and that approximates a two dimensional ellipse nicely.
However, it is still actually three dimensional. Most of what I found that had altitudeMode
is 3D, with the exception of Path. Path has some interesting terrain properties.
It may be that you wanted your ellipse to be open inside. In three dimensions that's called a torus. They look like this:
Unfortunately I can't find this shape in the worldwind API. However, you can haul off and create your own shape from scratch. http://goworldwind.org/developers-guide/how-to-build-a-custom-renderable/
The closest I can find to that within the API is ExtrudedPolygon which takes a polygon and lets you add a height. It'll be up to you to define the shape of the polygon. Extruded shapes look like this:
And they always remind me of play doh:
Hope it helps.
Upvotes: 2