osgEarth 2.1.1
|
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 00020 #include <osgEarth/Units> 00021 #include <osg/Math> 00022 00023 using namespace osgEarth; 00024 00025 Units::Units( const std::string& name, const std::string& abbr, const Units::Type& type, double toBase ) : 00026 _name ( name ), 00027 _abbr ( abbr ), 00028 _type ( type ), 00029 _toBase( toBase ) 00030 { 00031 //nop 00032 } 00033 00034 Units::Units( const std::string& name, const std::string& abbr, const Units& distance, const Units& time ) : 00035 _name ( name ), 00036 _abbr ( abbr ), 00037 _type ( TYPE_SPEED ), 00038 _distance( &distance ), 00039 _time ( &time ) 00040 { 00041 //nop 00042 } 00043 00044 const Units Units::CENTIMETERS ( "centimeters", "cm", Units::TYPE_LINEAR, 0.01 ); 00045 const Units Units::FEET ( "feet", "ft", Units::TYPE_LINEAR, 0.3048 ); 00046 const Units Units::FEET_US_SURVEY ( "feet(us)", "ft", Units::TYPE_LINEAR, 12.0/39.37 ); 00047 const Units Units::KILOMETERS ( "kilometers", "km", Units::TYPE_LINEAR, 1000.0 ); 00048 const Units Units::METERS ( "meters", "m", Units::TYPE_LINEAR, 1.0 ); 00049 const Units Units::MILES ( "miles", "mi", Units::TYPE_LINEAR, 1609.334 ); 00050 const Units Units::MILLIMETERS ( "millimeters", "mm", Units::TYPE_LINEAR, 0.001 ); 00051 const Units Units::YARDS ( "yards", "yd", Units::TYPE_LINEAR, 0.9144 ); 00052 const Units Units::NAUTICAL_MILES ( "nautical miles", "nm", Units::TYPE_LINEAR, 1852.0 ); 00053 const Units Units::DATA_MILES ( "data miles", "dm", Units::TYPE_LINEAR, 1828.8 ); 00054 const Units Units::INCHES ( "inches", "in", Units::TYPE_LINEAR, 0.0254 ); 00055 const Units Units::FATHOMS ( "fathoms", "fm", Units::TYPE_LINEAR, 1.8288 ); 00056 const Units Units::KILOFEET ( "kilofeet", "kf", Units::TYPE_LINEAR, 304.8 ); 00057 const Units Units::KILOYARDS ( "kiloyards", "ky", Units::TYPE_LINEAR, 914.4 ); 00058 00059 const Units Units::DEGREES ( "degrees", "\xb0",Units::TYPE_ANGULAR, 0.017453292519943295 ); 00060 const Units Units::RADIANS ( "radians", "rad", Units::TYPE_ANGULAR, 1.0 ); 00061 const Units Units::BAM ( "BAM", "bam", Units::TYPE_ANGULAR, 6.283185307179586476925286766559 ); 00062 const Units Units::NATO_MILS ( "mils", "mil", Units::TYPE_ANGULAR, 9.8174770424681038701957605727484e-4 ); 00063 00064 const Units Units::DAYS ( "days", "d", Units::TYPE_TEMPORAL, 1.0/86400.0 ); 00065 const Units Units::HOURS ( "hours", "hr", Units::TYPE_TEMPORAL, 1.0/3600.0 ); 00066 const Units Units::MICROSECONDS ( "microseconds", "us", Units::TYPE_TEMPORAL, 1000000.0 ); 00067 const Units Units::MILLISECONDS ( "milliseconds", "ms", Units::TYPE_TEMPORAL, 1000.0 ); 00068 const Units Units::MINUTES ( "minutes", "min", Units::TYPE_TEMPORAL, 1.0/60.0 ); 00069 const Units Units::SECONDS ( "seconds", "s", Units::TYPE_TEMPORAL, 1.0 ); 00070 const Units Units::WEEKS ( "weeks", "wk", Units::TYPE_TEMPORAL, 1.0/604800.0 ); 00071 00072 const Units Units::FEET_PER_SECOND ( "feet per second", "ft/s", Units::FEET, Units::SECONDS ); 00073 const Units Units::YARDS_PER_SECOND ( "yards per second", "yd/s", Units::YARDS, Units::SECONDS ); 00074 const Units Units::METERS_PER_SECOND ( "meters per second", "m/s", Units::METERS, Units::SECONDS ); 00075 const Units Units::KILOMETERS_PER_SECOND( "kilometers per second", "km/s", Units::KILOMETERS, Units::SECONDS ); 00076 const Units Units::KILOMETERS_PER_HOUR ( "kilometers per hour", "kmh", Units::KILOMETERS, Units::SECONDS ); 00077 const Units Units::MILES_PER_HOUR ( "miles per hour", "mph", Units::MILES, Units::HOURS ); 00078 const Units Units::DATA_MILES_PER_HOUR ( "data miles per hour", "dm/h", Units::DATA_MILES, Units::HOURS ); 00079 const Units Units::KNOTS ( "nautical miles per hour", "kts", Units::NAUTICAL_MILES, Units::HOURS );