# Source: distance.js

    /**
     * @namespace WPGMZA
     * @module Distance
     * @requires WPGMZA
     */
    (function($) {

    	WPGMZA.Distance = {

    		MILES:					true,
    		KILOMETERS:				false,

    		MILES_PER_KILOMETER:	0.621371,
    		KILOMETERS_PER_MILE:	1.60934,

    		// TODO: Implement WPGMZA.settings.distance_units

    		/**
    		 * Converts a UI distance (eg from a form control) to meters,
    		 * accounting for the global units setting
    		 */
    		uiToMeters: function(uiDistance)
    		{
    			return parseFloat(uiDistance) / (WPGMZA.settings.distance_units == WPGMZA.Distance.MILES ? WPGMZA.Distance.MILES_PER_KILOMETER : 1) * 1000;
    		},

    		/**
    		 * Converts a UI distance (eg from a form control) to kilometers,
    		 * accounting for the global units setting
    		 */
    		uiToKilometers: function(uiDistance)
    		{
    			return WPGMZA.Distance.uiToMeters(uiDistance) * 0.001;
    		},

    		/**
    		 * Converts a UI distance (eg from a form control) to miles,
    		 * accounting for the global units setting
    		 */
    		uiToMiles: function(uiDistance)
    		{
    			return WPGMZA.Distance.uiToKilometers(uiDistance) * WPGMZA.Distance.MILES_PER_KILOMETER;
    		},

    		kilometersToUI: function(km)
    		{
    			if(WPGMZA.settings.distance_units == WPGMZA.Distance.MILES)
    				return km * WPGMZA.Distance.MILES_PER_KILOMETER;
    			return km;
    		}

    	};

    })(jQuery);