I compiled the sample application osgearth_pick.exe and loaded a WFS datasource in which different place names has different style and max_range according to the "level" attribute.
When I move the mouse pointer upon one of the three place names in the picture below, the other two place names are highlighted too and the attribute shown is mistaken.
But if I load the WFS datasource all at once without selector and max_range configurations, the picker works fine. This is really strange.
Does anyone know the reason? Do the three place names have the same ObjectID ? And why?
I found that osgEarth does not support fid_attribute configuration until version 2.8 but I am still using version 2.7.
The WFS service comes from a shapefile, so I am sure there are not duplicate FIDs in the attribute table. I traced the application in debug mode. In line 255 in FeatureSourceWFS.cpp, a feature is created using the statement below:
osg::ref_ptr<Feature> f = OgrUtils::createFeature( feat_handle, getFeatureProfile() );
Here is where I found that the cause of the problem. The fid get by the function OGR_F_GetFID is neither unique nor the same with the value of the "fid" field in the attribute table. As the function OGR_F_GetFID is an OGR API, I don't know what is done inside.
Do you have any idea?
Or is it my best choice to upgrade to version 2.8 to use fid_attribute configuration?
The picker keys off the feature ID, and it's possible that you are getting duplicate feature IDs from the WFS plugin. If you know that your data set has a unique ID field you can set it with
Where "name" is the attribute holding the unique object ID.
Hope this helps!
OGR will just return an auto-incrementing value in that case. Since WFS is tiled, each tile is a dataset and gets its own auto-incrementing FIDs. That is why you need to expressly ask to use a particular attribute as your FID. As you say, 2.7 does not support that, so you will need to upgrade to get that functionality.