LCOV - code coverage report
Current view: top level - atmosphere/ATM - ATMLength.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 44 63 69.8 %
Date: 2024-10-28 15:53:10 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          72 : Length::Length() :
      35          72 :   valueIS_(0.0)
      36             : {
      37          72 : }
      38             : 
      39       11477 : Length::Length(double length) :
      40       11477 :   valueIS_(length)
      41             : {
      42       11477 : }
      43             : 
      44          23 : Length::Length(double length, const std::string &units)
      45             : {
      46          23 :   valueIS_ = sput(length, units);
      47          23 : }
      48             : 
      49       48550 : Length::Length(double length, Length::Units units)
      50             : {
      51       48550 :   valueIS_ = sput(length, units);
      52       48550 : }
      53             : 
      54       55025 : Length::Length(const Length &length) :
      55       55025 :   valueIS_(length.valueIS_)
      56             : {
      57       55025 : }
      58             : 
      59      115147 : Length::~Length()
      60             : {
      61      115147 : }
      62             : 
      63         239 : double Length::sget(double value, const std::string &units)
      64             : {
      65         239 :   if(units == "km" || units == "KM") {
      66          10 :     return 1.0E-3 * value;
      67         229 :   } else if(units == "m" || units == "M") {
      68          92 :     return value;
      69         137 :   } else if(units == "mm" || units == "MM") {
      70         137 :     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          23 : double Length::sput(double value, const std::string &units)
      83             : {
      84          23 :   if(units == "km" || units == "KM") {
      85          11 :     return 1.0E+3 * value;
      86          12 :   } else if(units == "m" || units == "M") {
      87           6 :     return value;
      88           6 :   } else if(units == "mm" || units == "MM") {
      89           6 :     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       46105 : double Length::sget(double value, Length::Units units)
     100             : {
     101       46105 :   if(units == Length::UnitKiloMeter) {
     102        2905 :     return 1.0E-3 * value;
     103       43200 :   } else if(units == Length::UnitMeter) {
     104           0 :     return value;
     105       43200 :   } else if(units == Length::UnitMilliMeter) {
     106       43200 :     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       48550 : double Length::sput(double value, Length::Units units)
     117             : {
     118       48550 :   if(units == Length::UnitKiloMeter) {
     119        2530 :     return 1.0E+3 * value;
     120       46020 :   } else if(units == Length::UnitMeter) {
     121       43854 :     return value;
     122        2166 :   } else if(units == Length::UnitMilliMeter) {
     123        2166 :     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