osgEarth 2.1.1

/home/cube/sources/osgearth/src/osgEarthDrivers/kml/KML_Feature.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 "KML_Feature"
00020 #include "KML_Style"
00021 #include <osgEarthUtil/Viewpoint>
00022 
00023 using namespace osgEarth::Util;
00024 
00025 void
00026 KML_Feature::scan( const Config& conf, KMLContext& cx )
00027 {
00028     KML_Object::scan(conf, cx);
00029     for_many( Style, scan, conf, cx );
00030 }
00031 
00032 void
00033 KML_Feature::scan2( const Config& conf, KMLContext& cx )
00034 {
00035     KML_Object::scan2(conf, cx);
00036     for_many( Style, scan2, conf, cx );
00037 }
00038 
00039 void
00040 KML_Feature::build( const Config& conf, KMLContext& cx, osg::Node* working )
00041 {
00042     KML_Object::build(conf, cx, working);
00043 
00044     // subclass feature is built; now add feature level data if available
00045     if ( working )
00046     {
00047         // parse the visibility to show/hide the item by default:
00048         if ( conf.hasValue("visibility") )
00049             working->setNodeMask( conf.value<bool>("visibility",true) == true ? ~0 : 0 );
00050 
00051         // parse a "LookAt" element (stores a viewpoint)
00052         AnnotationData* anno = getOrCreateAnnotationData(working);
00053         
00054         anno->setName( conf.value("name") );
00055         anno->setDescription( conf.value("description") );
00056 
00057         const Config& lookat = conf.child("lookat");
00058         if ( !lookat.empty() )
00059         {
00060             Viewpoint vp(
00061                 lookat.value<double>("longitude", 0.0),
00062                 lookat.value<double>("latitude", 0.0),
00063                 lookat.value<double>("altitude", 0.0),
00064                 lookat.value<double>("heading", 0.0),
00065                 -lookat.value<double>("tilt", 45.0),
00066                 lookat.value<double>("range", 10000.0) );
00067 
00068             anno->setViewpoint( vp );
00069         }
00070     }
00071 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines