LCOV - code coverage report
Current view: top level - atmosphere/ATM - ATMLength.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 45 63 71.4 %
Date: 2024-11-06 17:42:47 Functions: 10 11 90.9 %

          Line data    Source code
       1             : /*******************************************************************************
       2             :  * ALMA - Atacama Large Millimiter Array
       3             :  * (c) Instituto de Estructura de la Materia, 2009
       4             :  *
       5             :  * This library is free software; you can redistribute it and/or
       6             :  * modify it under the terms of the GNU Lesser General Public
       7             :  * License as published by the Free Software Foundation; either
       8             :  * version 2.1 of the License, or (at your option) any later version.
       9             :  *
      10             :  * This library is distributed in the hope that it will be useful,
      11             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      12             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      13             :  * Lesser General Public License for more details.
      14             :  *
      15             :  * You should have received a copy of the GNU Lesser General Public
      16             :  * License along with this library; if not, write to the Free Software
      17             :  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
      18             :  *
      19             :  * "@(#) $Id: ATMLength.cpp Exp $"
      20             :  *
      21             :  * who       when      what
      22             :  * --------  --------  ----------------------------------------------
      23             :  * pardo     24/03/09  created
      24             :  */
      25             : 
      26             : 
      27             : #include "ATMLength.h"
      28             : #include <stdio.h>
      29             : 
      30             : 
      31             : 
      32             : ATM_NAMESPACE_BEGIN
      33             : 
      34       20590 : Length::Length() :
      35       20590 :   valueIS_(0.0)
      36             : {
      37       20590 : }
      38             : 
      39    32062196 : Length::Length(double length) :
      40    32062196 :   valueIS_(length)
      41             : {
      42    32062196 : }
      43             : 
      44         828 : Length::Length(double length, const std::string &units)
      45             : {
      46         828 :   valueIS_ = sput(length, units);
      47         828 : }
      48             : 
      49   427560073 : Length::Length(double length, Length::Units units)
      50             : {
      51   427560073 :   valueIS_ = sput(length, units);
      52   427560073 : }
      53             : 
      54    32085124 : Length::Length(const Length &length) :
      55    32085124 :   valueIS_(length.valueIS_)
      56             : {
      57    32085124 : }
      58             : 
      59   491728811 : Length::~Length()
      60             : {
      61   491728811 : }
      62             : 
      63         444 : double Length::sget(double value, const std::string &units)
      64             : {
      65         444 :   if(units == "km" || units == "KM") {
      66          10 :     return 1.0E-3 * value;
      67         434 :   } else if(units == "m" || units == "M") {
      68         292 :     return value;
      69         142 :   } else if(units == "mm" || units == "MM") {
      70         142 :     return 1.0E+3 * value;
      71           0 :   } else if(units == "micron" || units == "MICRON") {
      72           0 :     return 1.0E+6 * value;
      73           0 :   } else if(units == "microns" || units == "MICRONS") {
      74           0 :     return 1.0E+6 * value;
      75           0 :   } else if(units == "nm" || units == "NM") {
      76           0 :     return 1.0E+9 * value;
      77             :   } else {
      78           0 :     return value;
      79             :   }
      80             : }
      81             : 
      82         828 : double Length::sput(double value, const std::string &units)
      83             : {
      84         828 :   if(units == "km" || units == "KM") {
      85          11 :     return 1.0E+3 * value;
      86         817 :   } else if(units == "m" || units == "M") {
      87           6 :     return value;
      88         811 :   } else if(units == "mm" || units == "MM") {
      89         811 :     return 1.0E-3 * value;
      90           0 :   } else if(units == "micron" || units == "MICRON") {
      91           0 :     return 1.0E-6 * value;
      92           0 :   } else if(units == "nm" || units == "NM") {
      93           0 :     return 1.0E-9 * value;
      94             :   } else {
      95           0 :     return value;
      96             :   }
      97             : }
      98             : 
      99       78960 : double Length::sget(double value, Length::Units units)
     100             : {
     101       78960 :   if(units == Length::UnitKiloMeter) {
     102       34582 :     return 1.0E-3 * value;
     103       44378 :   } else if(units == Length::UnitMeter) {
     104         973 :     return value;
     105       43405 :   } else if(units == Length::UnitMilliMeter) {
     106       43405 :     return 1.0E+3 * value;
     107             :   } else if(units == Length::UnitMicron || Length::UnitMicrons) {
     108           0 :     return 1.0E+6 * value;
     109             :   } else if(units == Length::UnitNanoMeter) {
     110             :     return 1.0E+9 * value;
     111             :   } else {
     112             :     return value;
     113             :   }
     114             : }
     115             : 
     116   427560073 : double Length::sput(double value, Length::Units units)
     117             : {
     118   427560073 :   if(units == Length::UnitKiloMeter) {
     119       30813 :     return 1.0E+3 * value;
     120   427529260 :   } else if(units == Length::UnitMeter) {
     121   427502814 :     return value;
     122       26446 :   } else if(units == Length::UnitMilliMeter) {
     123       26446 :     return 1.0E-3 * value;
     124           0 :   } else if(units == Length::UnitMicron || units == Length::UnitMicrons) {
     125           0 :     return 1.0E-6 * value;
     126           0 :   } else if(units == Length::UnitNanoMeter) {
     127           0 :     return 1.0E-9 * value;
     128             :   } else {
     129           0 :     return value;
     130             :   }
     131             : }
     132             : 
     133             : 
     134             : /*
     135             : std::string Length::get(const std::string &form, const std::string &units) const
     136             :   {
     137             :     char myString[18];
     138             : 
     139             :     sprintf(myString, "%f %s", get(units), units.c_str());
     140             : 
     141             : 
     142             :     return std::string(myString);
     143             :     }
     144             : */
     145             : 
     146             : ATM_NAMESPACE_END

Generated by: LCOV version 1.16