osgEarth 2.1.1

/home/cube/sources/osgearth/src/osgEarthFeatures/FeatureListSource.cpp

Go to the documentation of this file.
00001 /* -*-c++-*- */
00002 /* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
00003  * Copyright 2008-2010 Pelican Mapping
00004  * http://osgearth.org
00005  *
00006  * osgEarth is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU Lesser General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public License
00017  * along with this program.  If not, see <http://www.gnu.org/licenses/>
00018  */
00019 #include <osgEarthFeatures/FeatureListSource>
00020 
00021 using namespace osgEarth::Features;
00022 
00023 FeatureListSource::FeatureListSource():
00024 FeatureSource()
00025 {
00026     _profile = new FeatureProfile(GeoExtent(osgEarth::SpatialReference::create("epsg:4326"), -180, -90, 180, 90));
00027 }
00028 
00029 FeatureCursor*
00030 FeatureListSource::createFeatureCursor( const Symbology::Query& query )
00031 {
00032     //Create a copy of all of the features before returning the cursor.
00033     //The processing filters in osgEarth can modify the features as they are operating and we don't want our original data destroyed.
00034     FeatureList cursorFeatures;
00035     for (FeatureList::iterator itr = _features.begin(); itr != _features.end(); ++itr)
00036     {
00037         Feature* feature = new osgEarth::Features::Feature(*(itr->get()), osg::CopyOp::DEEP_COPY_ALL);        
00038         cursorFeatures.push_back( feature );
00039     }    
00040     return new FeatureListCursor( cursorFeatures );
00041 }
00042 
00043 void
00044 FeatureListSource::initialize( const std::string& referenceURI )
00045 {
00046 }
00047 
00048 const FeatureProfile*
00049 FeatureListSource::createFeatureProfile()
00050 {    
00051     return _profile.get();
00052 }
00053 
00054 bool
00055 FeatureListSource::deleteFeature(FeatureID fid)
00056 {
00057     for (FeatureList::iterator itr = _features.begin(); itr != _features.end(); ++itr) 
00058     {
00059         if (itr->get()->getFID() == fid)
00060         {
00061             _features.erase( itr );
00062             dirty();
00063             return true;
00064         }
00065     }
00066     return false;
00067 }
00068 
00069 Feature*
00070 FeatureListSource::getFeature( FeatureID fid )
00071 {
00072     for (FeatureList::iterator itr = _features.begin(); itr != _features.end(); ++itr) 
00073     {
00074         if (itr->get()->getFID() == fid)
00075         {
00076             return itr->get();
00077         }
00078     }
00079     return NULL;
00080 }
00081 
00082 bool FeatureListSource::insertFeature(Feature* feature)
00083 {
00084     _features.push_back( feature );
00085     dirty();
00086     return true;
00087 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines