SectorZone: add attribute arc_boundary
[xcsoar.git] / src / Units / Descriptor.cpp
blob199964142caf9860f501500a521588c4d8643098
1 /*
2 Copyright_License {
4 XCSoar Glide Computer - http://www.xcsoar.org/
5 Copyright (C) 2000-2013 The XCSoar Project
6 A detailed list of copyright holders can be found in the file "AUTHORS".
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #include "Units/Descriptor.hpp"
25 #include "Units/Units.hpp"
26 #include "Atmosphere/Temperature.hpp"
27 #include "Util/Macros.hpp"
29 #include <stddef.h>
31 //SI to Local Units
33 const UnitDescriptor Units::unit_descriptors[] = {
34 { nullptr, fixed(1), fixed(0) },
35 { _T("km"), fixed(0.001), fixed(0) },
36 { _T("NM"), fixed(0.000539956803), fixed(0) },
37 { _T("mi"), fixed(0.000621371192), fixed(0) },
38 { _T("km/h"), fixed(3.6), fixed(0) },
39 { _T("kt"), fixed(1.94384449), fixed(0) },
40 { _T("mph"), fixed(2.23693629), fixed(0) },
41 { _T("m/s"), fixed(1), fixed(0) },
42 { _T("fpm"), fixed(196.850394), fixed(0) },
43 { _T("m"), fixed(1), fixed(0) },
44 { _T("ft"), fixed(3.2808399), fixed(0) },
45 { _T("FL"), fixed(0.032808399), fixed(0) },
46 { _T("K"), fixed(1), fixed(0) },
47 { _T(DEG)_T("C"), fixed(1), -CELSIUS_OFFSET },
48 { _T(DEG)_T("F"), fixed(1.8), fixed(-459.67) },
49 { _T("hPa"), fixed(1), fixed(0) },
50 { _T("mb"), fixed(1), fixed(0) },
51 { _T("mmHg"), fixed(0.7500616827041698), fixed(0) },
52 { _T("inHg"), fixed(0.0295287441401431), fixed(0) },
55 static_assert(ARRAY_SIZE(Units::unit_descriptors) == (size_t)Unit::COUNT,
56 "number of unit descriptions does not match number of units");
58 const TCHAR *
59 Units::GetUnitName(Unit unit)
61 const unsigned i = (unsigned)unit;
62 assert(i < ARRAY_SIZE(unit_descriptors));
63 assert(unit_descriptors[i].name != nullptr);
65 return unit_descriptors[i].name;