Click here to Skip to main content
15,896,063 members
Articles / Mobile Apps / Windows Mobile

My Experience with the Windows Marketplace for Mobile and Windows Mobile 6

Rate me:
Please Sign up or sign in to vote.
4.89/5 (12 votes)
22 Mar 2010CPOL27 min read 27.8K   193   14  
My experience with the Windows Marketplace for Mobile for 6.x devices and the certification process.
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using SpeedTracker.Common;

namespace SpeedTracker
{
    class Utility
    {


        public delegate float SpeedConversionDelegate(float sourceSpeed);




        public const double EarthRadiusInMiles = 3956.0;
        public const double EarthRadiusInKilometers = 6367.0;
        public const double EarthRadiusInNauticleMiles = 3437.67;


        public static double ToRadian(double val) { return val * (Math.PI / 180); }
        public static double ToDegree(double val) { return val * 180 / Math.PI; }
        public static double DiffRadian(double val1, double val2) { return ToRadian(val2) - ToRadian(val1); }

        /// <summary> 
        /// Calculate the distance between two geocodes. Defaults to using Miles. 
        /// </summary> 

        /// <summary> 
        /// Calculate the distance between two geocodes. 
        /// </summary> 
        public static double CalcDistance(double lat1, double lng1, double lat2, double lng2, double radius)
        {
            return radius * 2 * Math.Asin(Math.Min(1, Math.Sqrt((Math.Pow(Math.Sin((DiffRadian(lat1, lat2)) / 2.0), 2.0) + Math.Cos(ToRadian(lat1)) * Math.Cos(ToRadian(lat2)) * Math.Pow(Math.Sin((DiffRadian(lng1, lng2)) / 2.0), 2.0)))));
        }

        public static double CalcDistance(Location loc1, Location loc2, DistanceUnit unit)
        {
            double radius=0d;
            switch (unit)
            {
                case DistanceUnit.Kilometers:
                    radius = EarthRadiusInKilometers;
                    break;
                case DistanceUnit.Miles:
                    radius = EarthRadiusInNauticleMiles;
                    break;
                case DistanceUnit.Knots:
                    radius = EarthRadiusInNauticleMiles;
                    break;
            }
            return CalcDistance(loc1.Latitude, loc1.Longitude, loc2.Latitude, loc2.Longitude, radius);
        }

        public static double CalcSpeed(Location loc1, Location loc2, DistanceUnit unit)
        {
            double distance = CalcDistance(loc1, loc2, unit);
            var ts = loc1.TimeStamp.Subtract(loc2.TimeStamp);
            return Math.Abs(distance/ts.TotalHours);
        }


        public static float KnotsToMph(float knots)
        {
            return knots*1.15077945f;
        }

        public static float KnotsToKmph(float knots)
        {
            return knots*1.852f;
        }

        public static float NoConversion(float knots)
        {
            return knots;
        }


    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
United States United States
I attended Southern Polytechnic State University and earned a Bachelors of Science in Computer Science and later returned to earn a Masters of Science in Software Engineering. I've largely developed solutions that are based on a mix of Microsoft technologies with open source technologies mixed in. I've got an interest in astronomy and you'll see that interest overflow into some of my code project articles from time to time.



Twitter:@j2inet

Instagram: j2inet


Comments and Discussions