Speed.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Measure
  17. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  18. * @license http://framework.zend.com/license/new-bsd New BSD License
  19. * @version $Id$
  20. */
  21. /**
  22. * Implement needed classes
  23. */
  24. #require_once 'Zend/Measure/Abstract.php';
  25. #require_once 'Zend/Locale.php';
  26. /**
  27. * Class for handling speed conversions
  28. *
  29. * @category Zend
  30. * @package Zend_Measure
  31. * @subpackage Zend_Measure_Speed
  32. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  33. * @license http://framework.zend.com/license/new-bsd New BSD License
  34. */
  35. class Zend_Measure_Speed extends Zend_Measure_Abstract
  36. {
  37. const STANDARD = 'METER_PER_SECOND';
  38. const BENZ = 'BENZ';
  39. const CENTIMETER_PER_DAY = 'CENTIMETER_PER_DAY';
  40. const CENTIMETER_PER_HOUR = 'CENTIMETER_PER_HOUR';
  41. const CENTIMETER_PER_MINUTE = 'CENTIMETER_PER_MINUTE';
  42. const CENTIMETER_PER_SECOND = 'CENTIMETER_PER_SECOND';
  43. const DEKAMETER_PER_DAY = 'DEKAMETER_PER_DAY';
  44. const DEKAMETER_PER_HOUR = 'DEKAMETER_PER_HOUR';
  45. const DEKAMETER_PER_MINUTE = 'DEKAMETER_PER_MINUTE';
  46. const DEKAMETER_PER_SECOND = 'DEKAMETER_PER_SECOND';
  47. const FOOT_PER_DAY = 'FOOT_PER_DAY';
  48. const FOOT_PER_HOUR = 'FOOT_PER_HOUR';
  49. const FOOT_PER_MINUTE = 'FOOT_PER_MINUTE';
  50. const FOOT_PER_SECOND = 'FOOT_PER_SECOND';
  51. const FURLONG_PER_DAY = 'FURLONG_PER_DAY';
  52. const FURLONG_PER_FORTNIGHT = 'FURLONG_PER_FORTNIGHT';
  53. const FURLONG_PER_HOUR = 'FURLONG_PER_HOUR';
  54. const FURLONG_PER_MINUTE = 'FURLONG_PER_MINUTE';
  55. const FURLONG_PER_SECOND = 'FURLONG_PER_SECOND';
  56. const HECTOMETER_PER_DAY = 'HECTOMETER_PER_DAY';
  57. const HECTOMETER_PER_HOUR = 'HECTOMETER_PER_HOUR';
  58. const HECTOMETER_PER_MINUTE = 'HECTOMETER_PER_MINUTE';
  59. const HECTOMETER_PER_SECOND = 'HECTOMETER_PER_SECOND';
  60. const INCH_PER_DAY = 'INCH_PER_DAY';
  61. const INCH_PER_HOUR = 'INCH_PER_HOUR';
  62. const INCH_PER_MINUTE = 'INCH_PER_MINUTE';
  63. const INCH_PER_SECOND = 'INCH_PER_SECOND';
  64. const KILOMETER_PER_DAY = 'KILOMETER_PER_DAY';
  65. const KILOMETER_PER_HOUR = 'KILOMETER_PER_HOUR';
  66. const KILOMETER_PER_MINUTE = 'KILOMETER_PER_MINUTE';
  67. const KILOMETER_PER_SECOND = 'KILOMETER_PER_SECOND';
  68. const KNOT = 'KNOT';
  69. const LEAGUE_PER_DAY = 'LEAGUE_PER_DAY';
  70. const LEAGUE_PER_HOUR = 'LEAGUE_PER_HOUR';
  71. const LEAGUE_PER_MINUTE = 'LEAGUE_PER_MINUTE';
  72. const LEAGUE_PER_SECOND = 'LEAGUE_PER_SECOND';
  73. const MACH = 'MACH';
  74. const MEGAMETER_PER_DAY = 'MEGAMETER_PER_DAY';
  75. const MEGAMETER_PER_HOUR = 'MEGAMETER_PER_HOUR';
  76. const MEGAMETER_PER_MINUTE = 'MEGAMETER_PER_MINUTE';
  77. const MEGAMETER_PER_SECOND = 'MEGAMETER_PER_SECOND';
  78. const METER_PER_DAY = 'METER_PER_DAY';
  79. const METER_PER_HOUR = 'METER_PER_HOUR';
  80. const METER_PER_MINUTE = 'METER_PER_MINUTE';
  81. const METER_PER_SECOND = 'METER_PER_SECOND';
  82. const MILE_PER_DAY = 'MILE_PER_DAY';
  83. const MILE_PER_HOUR = 'MILE_PER_HOUR';
  84. const MILE_PER_MINUTE = 'MILE_PER_MINUTE';
  85. const MILE_PER_SECOND = 'MILE_PER_SECOND';
  86. const MILLIMETER_PER_DAY = 'MILLIMETER_PER_DAY';
  87. const MILLIMETER_PER_HOUR = 'MILLIMETER_PER_HOUR';
  88. const MILLIMETER_PER_MINUTE = 'MILLIMETER_PER_MINUTE';
  89. const MILLIMETER_PER_SECOND = 'MILLIMETER_PER_SECOND';
  90. const MILLIMETER_PER_MICROSECOND = 'MILLIMETER_PER_MICROSECOND';
  91. const MILLIMETER_PER_100_MICROSECOND = 'MILLIMETER_PER_100_MICROSECOND';
  92. const NAUTIC_MILE_PER_DAY = 'NAUTIC_MILE_PER_DAY';
  93. const NAUTIC_MILE_PER_HOUR = 'NAUTIC_MILE_PER_HOUR';
  94. const NAUTIC_MILE_PER_MINUTE = 'NAUTIC_MILE_PER_MINUTE';
  95. const NAUTIC_MILE_PER_SECOND = 'NAUTIC_MILE_PER_SECOND';
  96. const LIGHTSPEED_AIR = 'LIGHTSPEED_AIR';
  97. const LIGHTSPEED_GLASS = 'LIGHTSPEED_GLASS';
  98. const LIGHTSPEED_ICE = 'LIGHTSPEED_ICE';
  99. const LIGHTSPEED_VACUUM = 'LIGHTSPEED_VACUUM';
  100. const LIGHTSPEED_WATER = 'LIGHTSPEED_WATER';
  101. const SOUNDSPEED_AIR = 'SOUNDSPEED_AIT';
  102. const SOUNDSPEED_METAL = 'SOUNDSPEED_METAL';
  103. const SOUNDSPEED_WATER = 'SOUNDSPEED_WATER';
  104. const YARD_PER_DAY = 'YARD_PER_DAY';
  105. const YARD_PER_HOUR = 'YARD_PER_HOUR';
  106. const YARD_PER_MINUTE = 'YARD_PER_MINUTE';
  107. const YARD_PER_SECOND = 'YARD_PER_SECOND';
  108. /**
  109. * Calculations for all speed units
  110. *
  111. * @var array
  112. */
  113. protected $_units = array(
  114. 'BENZ' => array('1', 'Bz'),
  115. 'CENTIMETER_PER_DAY' => array(array('' => '0.01', '/' => '86400'), 'cm/day'),
  116. 'CENTIMETER_PER_HOUR' => array(array('' => '0.01', '/' => '3600'), 'cm/h'),
  117. 'CENTIMETER_PER_MINUTE' => array(array('' => '0.01', '/' => '60'), 'cm/m'),
  118. 'CENTIMETER_PER_SECOND' => array('0.01', 'cd/s'),
  119. 'DEKAMETER_PER_DAY' => array(array('' => '10', '/' => '86400'), 'dam/day'),
  120. 'DEKAMETER_PER_HOUR' => array(array('' => '10', '/' => '3600'), 'dam/h'),
  121. 'DEKAMETER_PER_MINUTE' => array(array('' => '10', '/' => '60'), 'dam/m'),
  122. 'DEKAMETER_PER_SECOND' => array('10', 'dam/s'),
  123. 'FOOT_PER_DAY' => array(array('' => '0.3048', '/' => '86400'), 'ft/day'),
  124. 'FOOT_PER_HOUR' => array(array('' => '0.3048', '/' => '3600'), 'ft/h'),
  125. 'FOOT_PER_MINUTE' => array(array('' => '0.3048', '/' => '60'), 'ft/m'),
  126. 'FOOT_PER_SECOND' => array('0.3048', 'ft/s'),
  127. 'FURLONG_PER_DAY' => array(array('' => '201.1684', '/' => '86400'), 'fur/day'),
  128. 'FURLONG_PER_FORTNIGHT' => array(array('' => '201.1684', '/' => '1209600'), 'fur/fortnight'),
  129. 'FURLONG_PER_HOUR' => array(array('' => '201.1684', '/' => '3600'), 'fur/h'),
  130. 'FURLONG_PER_MINUTE' => array(array('' => '201.1684', '/' => '60'), 'fur/m'),
  131. 'FURLONG_PER_SECOND' => array('201.1684', 'fur/s'),
  132. 'HECTOMETER_PER_DAY' => array(array('' => '100', '/' => '86400'), 'hm/day'),
  133. 'HECTOMETER_PER_HOUR' => array(array('' => '100', '/' => '3600'), 'hm/h'),
  134. 'HECTOMETER_PER_MINUTE' => array(array('' => '100', '/' => '60'), 'hm/m'),
  135. 'HECTOMETER_PER_SECOND' => array('100', 'hm/s'),
  136. 'INCH_PER_DAY' => array(array('' => '0.0254', '/' => '86400'), 'in/day'),
  137. 'INCH_PER_HOUR' => array(array('' => '0.0254', '/' => '3600'), 'in/h'),
  138. 'INCH_PER_MINUTE' => array(array('' => '0.0254', '/' => '60'), 'in/m'),
  139. 'INCH_PER_SECOND' => array('0.0254', 'in/s'),
  140. 'KILOMETER_PER_DAY' => array(array('' => '1000', '/' => '86400'), 'km/day'),
  141. 'KILOMETER_PER_HOUR' => array(array('' => '1000', '/' => '3600'), 'km/h'),
  142. 'KILOMETER_PER_MINUTE' => array(array('' => '1000', '/' => '60'), 'km/m'),
  143. 'KILOMETER_PER_SECOND' => array('1000', 'km/s'),
  144. 'KNOT' => array(array('' => '1852', '/' => '3600'), 'kn'),
  145. 'LEAGUE_PER_DAY' => array(array('' => '4828.0417', '/' => '86400'), 'league/day'),
  146. 'LEAGUE_PER_HOUR' => array(array('' => '4828.0417', '/' => '3600'), 'league/h'),
  147. 'LEAGUE_PER_MINUTE' => array(array('' => '4828.0417', '/' => '60'), 'league/m'),
  148. 'LEAGUE_PER_SECOND' => array('4828.0417', 'league/s'),
  149. 'MACH' => array('340.29', 'M'),
  150. 'MEGAMETER_PER_DAY' => array(array('' => '1000000', '/' => '86400'), 'Mm/day'),
  151. 'MEGAMETER_PER_HOUR' => array(array('' => '1000000', '/' => '3600'), 'Mm/h'),
  152. 'MEGAMETER_PER_MINUTE' => array(array('' => '1000000', '/' => '60'), 'Mm/m'),
  153. 'MEGAMETER_PER_SECOND' => array('1000000', 'Mm/s'),
  154. 'METER_PER_DAY' => array(array('' => '1', '/' => '86400'), 'm/day'),
  155. 'METER_PER_HOUR' => array(array('' => '1', '/' => '3600'), 'm/h'),
  156. 'METER_PER_MINUTE' => array(array('' => '1', '/' => '60'), 'm/m'),
  157. 'METER_PER_SECOND' => array('1', 'm/s'),
  158. 'MILE_PER_DAY' => array(array('' => '1609.344', '/' => '86400'), 'mi/day'),
  159. 'MILE_PER_HOUR' => array(array('' => '1609.344', '/' => '3600'), 'mi/h'),
  160. 'MILE_PER_MINUTE' => array(array('' => '1609.344', '/' => '60'), 'mi/m'),
  161. 'MILE_PER_SECOND' => array('1609.344', 'mi/s'),
  162. 'MILLIMETER_PER_DAY' => array(array('' => '0.001', '/' => '86400'), 'mm/day'),
  163. 'MILLIMETER_PER_HOUR' => array(array('' => '0.001', '/' => '3600'), 'mm/h'),
  164. 'MILLIMETER_PER_MINUTE' => array(array('' => '0.001', '/' => '60'), 'mm/m'),
  165. 'MILLIMETER_PER_SECOND' => array('0.001', 'mm/s'),
  166. 'MILLIMETER_PER_MICROSECOND' => array('1000', 'mm/µs'),
  167. 'MILLIMETER_PER_100_MICROSECOND' => array('10', 'mm/100µs'),
  168. 'NAUTIC_MILE_PER_DAY' => array(array('' => '1852', '/' => '86400'), 'nmi/day'),
  169. 'NAUTIC_MILE_PER_HOUR' => array(array('' => '1852', '/' => '3600'), 'nmi/h'),
  170. 'NAUTIC_MILE_PER_MINUTE' => array(array('' => '1852', '/' => '60'), 'nmi/m'),
  171. 'NAUTIC_MILE_PER_SECOND' => array('1852', 'nmi/s'),
  172. 'LIGHTSPEED_AIR' => array('299702547', 'speed of light (air)'),
  173. 'LIGHTSPEED_GLASS' => array('199861638', 'speed of light (glass)'),
  174. 'LIGHTSPEED_ICE' => array('228849204', 'speed of light (ice)'),
  175. 'LIGHTSPEED_VACUUM' => array('299792458', 'speed of light (vacuum)'),
  176. 'LIGHTSPEED_WATER' => array('225407863', 'speed of light (water)'),
  177. 'SOUNDSPEED_AIT' => array('340.29', 'speed of sound (air)'),
  178. 'SOUNDSPEED_METAL' => array('5000', 'speed of sound (metal)'),
  179. 'SOUNDSPEED_WATER' => array('1500', 'speed of sound (water)'),
  180. 'YARD_PER_DAY' => array(array('' => '0.9144', '/' => '86400'), 'yd/day'),
  181. 'YARD_PER_HOUR' => array(array('' => '0.9144', '/' => '3600'), 'yd/h'),
  182. 'YARD_PER_MINUTE' => array(array('' => '0.9144', '/' => '60'), 'yd/m'),
  183. 'YARD_PER_SECOND' => array('0.9144', 'yd/s'),
  184. 'STANDARD' => 'METER_PER_SECOND'
  185. );
  186. }