Clamping and linestring altitude question.

classic Classic list List threaded Threaded
2 messages Options
sonnysan sonnysan
Reply | Threaded
Open this post in threaded view

Clamping and linestring altitude question.

This post was updated on .

I have to draw paths on a globe and want them to "respect" the Z/Altitude values as relative to the earth ellipsoid.

Say I make a straight path from, e.g., NY to Tokio, with some points in between to change the altitude. I wanted the line to make a smooth curve around the earth, with correct distance from ellipsoid. If any part of said path had a Z level of 0, it would be drawn properly on the terrain without going through the earth ellipsoid.

Using annotations, my code is something like this:

osgEarth::Annotation::Geometry* path = new osgEarth::Annotation::LineString();

for(LatLonAlt lla : latLonAltVector) // <- this is a vector of a p.o.d. struct
    path->push_back(lla.lon,, lla.alt);

osgEarth::Features::Feature* pathFeature = new osgEarth::Features::Feature(path, srs);
pathFeature->geoInterp() = osgEarth::GeoInterpolation::GEOINTERP_GREAT_CIRCLE;

osgEarth::Symbology::Style s;
s.getOrCreate<osgEarth::Annotation::LineSymbol>()->stroke()->color() = osgEarth::Annotation::Color::Blue;
s.getOrCreate<osgEarth::Annotation::LineSymbol>()->stroke()->width() = 3.0f;
s.getOrCreate<osgEarth::Annotation::LineSymbol>()->stroke()->smooth() = true;
s.getOrCreate<osgEarth::Annotation::AltitudeSymbol>()->clamping() = osgEarth::Annotation::AltitudeSymbol::CLAMP_NONE; // <- ??

mapNode->addChild(new osgEarth::Annotation::FeatureNode(pathFeature, s));

I think I need to set the correct clamping, but my issue is that I don't know which clamping to use. Reading the Clamping enum comments sounds like I need to use CLAMP_ABSOLUTE, but the line goes through the earth when using anything other than CLAMP_TO_TERRAIN.

Is there some sort of configuration needed to use CLAMP_ABSOLUTE so that it draws the entire line at a certain fixed altitude? Do I have to manually break the line into small steps to avoid said issue?

Better indication of question objective.
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view

Re: Clamping and linestring altitude question.


You need to tessellate the line string with the LineSymbol::tessellationSize() property. This will set a maximum length for the individual line segments that comprise the line string.
Glenn Waldron / Pelican Mapping