![]() |
In my application, I'm using a 2D (Mercator) projection, not a 3D globe. For lines, I create a LineString containing my points and add it to a Feature, and I set the geoInterp property of the Feature to osgEarth::GEOINTERP_GREAT_CIRCLE. However, the line just gets drawn as a straight line from point to point. If I switch to a 3D globe, it appears to properly subdivide using Great Circle interpolation.
So is the geoInterp() property of the Feature not used for 2D projections, or am I possibly doing something else wrong? If it's not used, is there a better solution than calculating all (some) of the intermediate points along the Great Circle line myself and adding them to the LineString? |
![]() |
Hi David.
If you set a line tessellation in the style, it will do it automatically. Code: LineSymbol* line = style.getOrCreate<LineSymbol>(); line->tessellationSize()->set(1, Units::KILOMETERS); Earth file: stroke-tessellation-size: 1km; Hope this helps!
Glenn Waldron / Pelican Mapping
|
![]() |
I'm already setting the tessellationSize, and it doesn't appear to have any effect. Here's a code snippet of where I update the style based on the selected color and width for the line. Note that the FeatureNode (mpNode2D) and geometry (LineString) have already been created, I'm just updating the style at this point.
// Get the style from the node osgEarth::Style style = mpNode2D->getStyle(); // Get or create a LineSymbol on the style and set its properties. osgEarth::Symbology::LineSymbol* lineSymbol = style.getOrCreate<osgEarth::Symbology::LineSymbol>(); lineSymbol->stroke()->color() = getLineColor(); lineSymbol->stroke()->width() = getLineWidth(); lineSymbol->stroke()->stipplePattern() = getLinePatternBits(); // Tessellation for really large line segments. lineSymbol->tessellationSize() = osgEarth::Distance(10, osgEarth::Units::NAUTICAL_MILES); // Set the style on the node mpNode2D->setStyle(style); And this is the result that I see on the map. ![]() In addition to the above style code, this is where we initialize the node, adding some additional symbols. Scene& scene = Scene::global2D(); // Style osgEarth::Symbology::Style style; // Start with a RenderSymbol to avoid z fighting between 2D lines and the map. osgEarth::Symbology::RenderSymbol* renderSymbol = style.getOrCreate<osgEarth::Symbology::RenderSymbol>(); renderSymbol->depthOffset()->enabled() = true; renderSymbol->depthOffset()->minBias() = 1000; // Geometry (will be populated later) mpLine2D = new osgEarth::Symbology::LineString(); // Feature osgEarth::Features::Feature* feature = new osgEarth::Features::Feature(mpLine2D, scene.mapSrs(), style); feature->geoInterp() = osgEarth::GEOINTERP_GREAT_CIRCLE; // Default to GC until told otherwise. // Feature Node mpNode2D = new osgEarth::Annotation::FeatureNode(scene.mapNode(), feature); mpNode2D->setStyle(style); scene.featureNode()->addChild(mpNode2D); |
![]() |
Note that our application has a 2D scene and a 3D scene. I'm doing almost the exact same thing for the lines in the 3D scene, and they are properly interpolated between points. I'm only seeing a problem with the 2D scene.
|
![]() |
David, here is my test earth file (I am using osgEarth 3.0 branch, which is soon to become the master).
<map> <options> <profile>spherical-mercator</profile> </options> <image driver="tms"> <url>http://readymap.org/readymap/tiles/1.0.0/7/</url> </image> <annotations> <feature name="DC to Rome"> <srs>wgs84</srs> <geometry> LINESTRING(-77 38.9, 12.5 41.9) </geometry> <style type="text/css"> stroke: #ffff00; stroke-width: 3; stroke-tessellation-size: 1km; stroke-stipple-pattern: 0xF0F0; render-lighting: false; render-depth-offset: auto; </style> </feature> <place text="DC"> <position lat="38.9" long="-77"/> </place> <place text="Rome"> <position lat="41.9" long="12.5"/> </place> </annotations> </map>
Glenn Waldron / Pelican Mapping
|
![]() |
Glenn,
When I copy your earth file, the line does "DC to Rome" line does not appear. I'm using osgEarth 2.7. Is there some difference between 2.7 and 3.0 that might be causing this? Also, in my 3D globe scene, the lines are properly tessellating using Great Circle interpolation. I am only seeing this problem in my 2D scene (type="projected" in the earth file). The example earth file that you included is not a projected scene. |
![]() |
Ok, if I just load your sample earth file with osgearth_viewer.exe, then I see the line and it is properly curved. I'm not sure why it doesn't show up when I add it to my earth file used in my application, but the fact that the annotations from the earth file aren't showing up and the line tessellation isn't happening seems to suggest that perhaps I'm dorking something up within my application.
I'll take a deeper dive into my own code and perhaps try to simplify it as much as possible to identify the problem. But I think it's safe to say that the original question about Great Circle interpolation in a 2D projected scene works just fine, I'm just doing something wrong. |
![]() |
Could it be that you are using map's SRS for the line feature instead of wgs84? In such case no refinement is required in 2D (since feature and map both share the same SRS) only in 3D (where map is forced to be geocentric and thus differs from the feature's one). Try setting it with wgs84 as in Glenn's sample.
|
![]() |
Valladis,
That's a really good point. I'll try that out the next chance I get. Though I still don't understand what could be causing the features I add to my .earth file not to show up, though I'm not that concerned about it since all of our features will be defined dynamically at runtime. |
Free forum by Nabble | Edit this page |