source: geovis/branches/1.0/Util.h @ 6716

Last change on this file since 6716 was 5941, checked in by ldelgass, 9 years ago

Fix for feature highlight

  • Property svn:eol-style set to native
File size: 1.4 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * Copyright (C) 2015  HUBzero Foundation, LLC
4 *
5 * Author: Leif Delgass <ldelgass@purdue.edu>
6 */
7#ifndef GEOVIS_UTIL_H
8#define GEOVIS_UTIL_H
9
10#include <cstring>
11#include <string>
12
13#include <osg/NodeVisitor>
14#include <osgEarthFeatures/FeatureIndex>
15#include <osgEarthFeatures/FeatureSourceIndexNode>
16
17namespace GeoVis {
18
19class FindFeatureSourceIndexNodeVisitor : public osg::NodeVisitor {
20public:
21    FindFeatureSourceIndexNodeVisitor() :
22        osg::NodeVisitor(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};
44
45extern std::string loadCSVLayer(const char *filename, const char *longitudeColName = "longitude", const char *latitudeColName = "latitude");
46
47}
48
49#endif
Note: See TracBrowser for help on using the repository browser.