gwaldron / osgearth

3D Maps for OpenSceneGraph / C++14
https://www.pelicanmapping.com/home-1/opensource
Other
1.48k stars 774 forks source link

Pick objects from OGRFeatureSource #2490

Closed gd-6 closed 5 months ago

gd-6 commented 5 months ago

Hey there, I'm trying to grab objects from an OGRFeatureSource (shapefile). For instance, in the osgearth_city example, I want to pick a road or a park and get the field values for that object from the shapefile data. I've tried using GUIEventHandler from the osg_pick example and ObjectIDPicker from osgearth_pick, but no luck with either of them. Any ideas on how to make this work?

gwaldron commented 5 months ago

Make sure you enable picking on your layer by setting the feature-indexing option. Do this before opening the layer or adding it to the map:

layer->options().featureIndexing()->enabled() = true;

Or in the earth file you can just say

pickable="true"
gd-6 commented 5 months ago

Thanks !