problem with osgearth_pick.exe

classic Classic list List threaded Threaded
5 messages Options
JimmyCrazy JimmyCrazy
Reply | Threaded
Open this post in threaded view
|

problem with osgearth_pick.exe

Hello everyone,

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?
Thanks.

Jimmy

gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: problem with osgearth_pick.exe

Jimmy,
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

<fid_attribute>name</fid_attribute>

Where "name" is the attribute holding the unique object ID.
Hope this helps!
Glenn Waldron / Pelican Mapping
JimmyCrazy JimmyCrazy
Reply | Threaded
Open this post in threaded view
|

Re: problem with osgearth_pick.exe

Thanks,

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() );

which calls this funstion below in OgrUtils.cpp

Feature*
OgrUtils::createFeature( OGRFeatureH handle, const SpatialReference* srs )
{
    long fid = OGR_F_GetFID( handle );
    ……
}

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?

gwaldron wrote
Jimmy,
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

<fid_attribute>name</fid_attribute>

Where "name" is the attribute holding the unique object ID.
Hope this helps!
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: problem with osgearth_pick.exe

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.
Glenn Waldron / Pelican Mapping
JimmyCrazy JimmyCrazy
Reply | Threaded
Open this post in threaded view
|

Re: problem with osgearth_pick.exe

Thank you, problem solved !