Can ModelSymbol (or something else) use feature attributes for model placement? #2858
-
|
When rendering a point vector dataset, is there already a way to use attributes from the feature data (for example, a model_path field and an orientation field) to determine both which model to place and how it’s positioned at each location? I came across osgEarth::ModelSymbol, but from what I can tell, I don't believe I can define it in a way that it pulls the value from the dataset itself. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
In auto* model = style.getOrCreate<ModelSymbol>();
model->url() = StringExpression("return feature.properties.model_path;");
model->heading() = NumericExpression("return parseFloat(feature.properties.heading);";Or in an earth file you would say <style>
default {
model : feature.properties.model_path;
model-heading : parseFloat(feature.properties.heading);
...See the |
Beta Was this translation helpful? Give feedback.
In
ModelSymbolmost of the properties are Expressions, so that means you can use JavaScript to access the feature data. For exampleOr in an earth file you would say
<style> default { model : feature.properties.model_path; model-heading : parseFloat(feature.properties.heading); ...See the
feature_models.earthexample in the repo tests folder.