Changeset 5938 for geovis/trunk/Util.h


Ignore:
Timestamp:
Dec 3, 2015 12:30:50 PM (8 years ago)
Author:
ldelgass
Message:

Try finding FeatureSourceIndexNodes? in scene graph to lookup global ID for a
feature ID.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • geovis/trunk/Util.h

    r5873 r5938  
    88#define GEOVIS_UTIL_H
    99
     10#include <cstring>
    1011#include <string>
    1112
     13#include <osg/NodeVisitor>
     14#include <osgEarthFeatures/FeatureIndex>
     15#include <osgEarthFeatures/FeatureSourceIndexNode>
     16
    1217namespace GeoVis {
     18
     19class FindFeatureSourceIndexNodeVisitor : public osg::NodeVisitor {
     20public:
     21    FindFeatureSourceIndexNodeVisitor() :
     22        osg::NodeVisitor(TRAVERSE_ALL_CHILDREN),
     23        source(NULL)
     24    {
     25    }
     26
     27    virtual ~FindFeatureSourceIndexNodeVisitor() {}
     28
     29    virtual void apply(osg::Node& node)
     30    {
     31        if (strcmp(node.className(), "FeatureSourceIndexNode") == 0) {
     32            osgEarth::Features::FeatureSourceIndexNode *fsin = dynamic_cast<osgEarth::Features::FeatureSourceIndexNode *>(&node);
     33            osgEarth::Features::FeatureSourceIndex *index = fsin->getIndex();
     34            if (source == NULL || index->getFeatureSource() == source) {
     35                nodes.push_back(fsin);
     36            }
     37        }
     38        traverse(node);
     39    }
     40
     41    osgEarth::Features::FeatureSource *source;
     42    std::vector<osgEarth::Features::FeatureSourceIndexNode *> nodes;
     43};
    1344
    1445extern std::string loadCSVLayer(const char *filename, const char *longitudeColName = "longitude", const char *latitudeColName = "latitude");
Note: See TracChangeset for help on using the changeset viewer.