I need to be able to let the user draw lines, polygons, ellipses, etc on the map. Thus I can't just define some models in my .earth file, I need to add new features at run-time using the API. I looked at the osgearth_features example and it looks like what that example does is basically:
* Define the geometry (a Ring in the example)
* Define a Style
* Define an OGRFeatureOptions object that references the geometry.
* Define a FeatureGeomModelOptions object that references the style and the geometry via the feature options.
* Define a ModelLayerOptions object that references the FeatureGeomModelOptions
* Add a ModelLayer to the map using the ModelLayerOptions.
I need to be able to create a lot of these things. Some of them will use the same style, but some won't; it will be a mix of different fill and line colors. Do I need to do all of those steps for every new feature, or can I reuse the some of the same objects? Should I try to combine models that use the same styles on the same layer? Are there other optimization tricks I should keep in mind when doing this?
That process is geared towards loading external datasets and styling them. If your user is drawing individual features, I suggest using the FeatureNode in the Annotations library. You can start with the osgearth_annotation example. You can add FeatureNodes directly to the MapNode, or you can put them under an AnnotationLayer.
Not a lot - it lets you manage the data as part of the Map model - you can toggle the visibility or the enabled state globally for the layer. Some day we might add serialization support (so you can save it to an earth file).
I got it working using just a Feature and a FeatureNode like gwaldron suggested. I realized my problem with it not showing up in my 2D (projected) map was that I wasn't converting the coordinates from (lon, lat, alt) to the projected scene's SpatialReference.
Adding new points to the end of the geometry is pretty trivial, but is there a better way to insert, remove, or update points at arbitrary positions in the geometry other than clearing it and repopulating it from scratch? I don't see any methods to update existing points in the geometry.
Yes, that's what I was looking for. It turns out my stupid intellisense just wasn't showing the methods from the MixinVector subclass so I didn't see that they existed, but if I just call them then it works as expected.
Hi, I have a couple of questions related this subject, and would be happy if you could answer them
1- Is there a practical limit on the number of AnnotationLayers that can be added to a map?
2- How to programatically add AnnotationNodes to an AnnotationLayer?
if (layerGroupNode != nullptr)
std::cout << "this is a group node";
std::cout << "this is not a group node.";
I saw my circleNode as expected.
Is this OK?