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