Search code examples
javafxlineworldwind

How to draw a line with elevation representation in WorldWind


I want to draw a line on the globe with elevation representation, something like this :

Elevation representation sketch

I know I can use polyline to represent a line, but how can fill the space below the line ?


Solution

  • You can use a path to draw the line. The setOutlineMaterial will draw a "curtain" similar to what you want.

    Path path = new Path(pathPositions); //Arraylist of positions
    final BasicShapeAttributes attrs = new BasicShapeAttributes();
    attrs.setInteriorOpacity(0.25);
    attrs.setInteriorMaterial(Material.BLACK);
    attrs.setOutlineMaterial(new Material(color));
    attrs.setOutlineWidth(width);
    path.setAttributes(attrs);
    path.setDrawVerticals(true);
    path.setAltitudeMode(WorldWind.ABSOLUTE);
    

    look at Path altitude mode how you want it follow the ground.