TsUnitsOfMeasureManager.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib 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
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 // TerraLib
22 
23 // STL
24 #include <string.h>
25 
27 
29 {
30  uomA = te::common::UnitOfMeasurePtr(new te::common::UnitOfMeasure(9030, "NAUTICAL MILE", "", te::common::Length, 9001, 1852, 0, 0, 1, ""));
31  uomB = te::common::UnitOfMeasurePtr(new te::common::UnitOfMeasure(9101, "RADIAN", "", te::common::Angle, 9101, 1, 0, 0, 1, ""));
32  uomC = te::common::UnitOfMeasurePtr(new te::common::UnitOfMeasure(9102, "DEGREE", "", te::common::Angle, 9101, 3.14159265358979, 0, 0, 180, ""));
33  uomD = te::common::UnitOfMeasurePtr(new te::common::UnitOfMeasure(9201, "UNITY", "", te::common::Scale, 9201, 1, 0, 0, 1, ""));
34 
35  std::string altNameA = "AltNameA";
36  std::string altNameB = "AltNameB";
37 
38  alternativeNames.push_back(altNameA);
39  alternativeNames.push_back(altNameB);
40 
45 }
46 
48 {
50 }
51 
52 /*
53 void TsUnitsOfMeasureManager::tcFindUomById ()
54 {
55  CPPUNIT_ASSERT(uomB == te::common::UnitsOfMeasureManager::getInstance().findById(9101));
56 }
57 */
58 
60 {
61  CPPUNIT_ASSERT(uomC == te::common::UnitsOfMeasureManager::getInstance().find("degree"));
62 }
63 
65 {
66  CPPUNIT_ASSERT(uomD == te::common::UnitsOfMeasureManager::getInstance().find("AltNameA"));
67 }
68 
70 {
71  CPPUNIT_ASSERT(uomD == te::common::UnitsOfMeasureManager::getInstance().find("AltNameB"));
72  CPPUNIT_ASSERT(uomD == te::common::UnitsOfMeasureManager::getInstance().find("unity"));
73 }
74 
76 {
77  std::vector<std::string> namesOutput;
79 
80  CPPUNIT_ASSERT(namesOutput.size() == alternativeNames.size());
81 
82  for(std::size_t i = 0; i < namesOutput.size(); ++i)
83  {
84  CPPUNIT_ASSERT(namesOutput[i].compare(alternativeNames[i]));
85  }
86 }
87 
89 {
90  CPPUNIT_ASSERT(te::common::UnitsOfMeasureManager::getInstance().getConversion("DEGREE", "RADIAN") == 0.017453292519943278);
91 }
void tcFindUomByAltName()
Test Case: Find an unit of using one of it&#39;s alternative name.
te::common::UnitOfMeasurePtr uomB
void insert(UnitOfMeasurePtr &uom)
Inserts a new unit of measure to be managed.
void tcFindUomByNames()
Test Case: Find an unit of using either it&#39;s name or on e of it&#39;s alternative names.
CPPUNIT_TEST_SUITE_REGISTRATION(TsUnitsOfMeasureManager)
void clear()
Removes all units from the catalogue.
void getNames(UnitOfMeasurePtr &uom, std::vector< std::string > &names) const
Retrieves the alternative names for a unit of measure.
static UnitsOfMeasureManager & getInstance()
It returns a reference to the singleton instance.
Test suite for the Units of Measure Manager Class.
te::common::UnitOfMeasurePtr uomC
te::common::UnitOfMeasurePtr uomA
Test suite for the Units of Measure Manager class.
boost::shared_ptr< UnitOfMeasure > UnitOfMeasurePtr
void tcFindUomByName()
Test Case: Find an unit of using it&#39;s identificaton number. void tcFindUomById ();.
A class to represent units of measure.
Definition: UnitOfMeasure.h:74
std::vector< std::string > alternativeNames
te::common::UnitOfMeasurePtr uomD