当前位置: 首页>>代码示例>>C#>>正文


C# DistanceType类代码示例

本文整理汇总了C#中DistanceType的典型用法代码示例。如果您正苦于以下问题:C# DistanceType类的具体用法?C# DistanceType怎么用?C# DistanceType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DistanceType类属于命名空间,在下文中一共展示了DistanceType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Name

 /// <summary>
 /// Returns the full unit name (in English) for a particular distance span (kilometer, feet, mile)
 /// </summary>
 /// <param name="distance">Distance value to get name for</param>
 /// <param name="distanceType">Distance type to get name for</param>
 /// <returns>Lower case full name for a distance type</returns>
 public static string Name(DistanceSpan distance, DistanceType distanceType)        
 {            
     return (Math.Abs(distance._meters)<1)?_nameSingular[(int)distanceType]:_namePlural[(int)distanceType];
 }
开发者ID:drio4321,项目名称:ScrimpNet.Core,代码行数:10,代码来源:DistanceSpan.cs

示例2: ToMetric

 public static double ToMetric(double value, DistanceType inputDistanceType)
 {
     double _meters = 0D;
     switch (inputDistanceType)
     {
         case DistanceType.MileNautical: _meters = value * GeoConstant.METERSINNMILE;
             break;
         case DistanceType.Mile: _meters = value * GeoConstant.METERSINMILE;
             break;
         case DistanceType.Yard: _meters = value * GeoConstant.METERSINYARD;
             break;
         case DistanceType.Inch: _meters = value * GeoConstant.METERSININCH;
             break;
         case DistanceType.Foot: _meters = value * GeoConstant.METERSINFOOT;
             break;
         case DistanceType.Kilometer: _meters = value * 1000D;
             break;
         case DistanceType.Meter: _meters = value;
             break;
         case DistanceType.Centimeter: _meters = value / 100D;
             break;
         case DistanceType.Millimeter: _meters = value / 1000D;
             break;
         default:
             throw new ArgumentException("DistanceType not supported");
     }
     return _meters;
 }
开发者ID:drio4321,项目名称:ScrimpNet.Core,代码行数:28,代码来源:DistanceSpan.cs

示例3: GetDistance

        /// <summary>
        /// Calculate and returns the distance between to points in KM
        /// </summary>
        /// <param name="lat1">latitude of 1st point</param>
        /// <param name="lat2">latitude of 2nd point</param>
        /// <param name="long1">longitude of 1st point</param>
        /// <param name="long2">longitude of 2nd point</param>
        /// <returns>Distance in KM</returns>
        public double GetDistance(double lat1, double lat2, double long1, double long2, DistanceType type)
        {
            double radius = (type == DistanceType.Miles) ? earthRadiusKM : earthRadiusM;
            // Declare local variables
            double lat1Rad;
            double lat2Rad;
            double long1Rad;
            double long2Rad;
            double dlat;
            double dlong;
            // Convert angles to Radian
            lat1Rad = DegreeToRadian(lat1);
            lat2Rad = DegreeToRadian(lat2);
            long1Rad = DegreeToRadian(long1);
            long2Rad = DegreeToRadian(long2);
            dlat = lat2Rad - lat1Rad;
            dlong = long2Rad - long1Rad;
            double a = Math.Pow(Math.Sin(dlat / 2.0), 2.0) +
                   Math.Cos(lat1Rad) * Math.Cos(lat2Rad) *
                   Math.Pow(Math.Sin(dlong / 2.0), 2.0);

            // Calculate c - great circle distance in Radians
            double c = 2.0 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1.0 - a));
            // Calculate Distance
            distance = radius * c;

            return distance;
        }
开发者ID:aolien,项目名称:noIdeas,代码行数:36,代码来源:GPSDistanceCalculator.cs

示例4: GetPOIList

        public POICollection GetPOIList(double latitude, double longitude, int distance, DistanceType distanceType)
        {
            double calculatedDistance;

            //convert it back to kilometers
            switch (distanceType)
            {
                case DistanceType.Meters:
                    calculatedDistance = Convert.ToDouble((double)distance / 1000);
                    break;
                case DistanceType.Miles:
                    calculatedDistance = distance / 0.621371192;
                    break;
                default:
                    calculatedDistance = distance;
                    break;
            }

            GeoLocation myLocation = GeoLocation.FromDegrees(latitude, longitude);

            GeoLocation[] coordinates = myLocation.BoundingCoordinates(calculatedDistance);

            double north = coordinates[1].getLatitudeInDegrees();
            double south = coordinates[0].getLatitudeInDegrees();
            double east = coordinates[1].getLongitudeInDegrees();
            double west = coordinates[0].getLongitudeInDegrees();

            return GetPOIList(north, south, east, west);
        }
开发者ID:anthonyvscode,项目名称:LonelySharp,代码行数:29,代码来源:POI.cs

示例5: BoolAStar

 public BoolAStar(ref byte[,] byteArray, Point start, Point end, DistanceType distanceType)
 {
     this.start = start;
     this.end = end;
     this.distanceType = distanceType;
     CreateMap(ref byteArray);
 }
开发者ID:MaxPlay,项目名称:GameEngine,代码行数:7,代码来源:BoolAStar.cs

示例6: GetLookupTable

 public List<Distancing.Distance> GetLookupTable(DistanceType Type)
 {
     if(Type.Equals(DistanceType.AVG))
         return GetLookupTable_AVG();
     else
         return GetLookupTable_DFT();
 }
开发者ID:r0n22,项目名称:RFID_Distance,代码行数:7,代码来源:Repo.cs

示例7: Create

 public static AStar Create(ref byte[,] byteArray, Point start, Point end, bool asBool, DistanceType distanceType = DistanceType.Chebyshev)
 {
     if (asBool)
         return new BoolAStar(ref byteArray, start, end, distanceType);
     else
         return Create(ref byteArray, start, end, distanceType);
 }
开发者ID:MaxPlay,项目名称:GameEngine,代码行数:7,代码来源:AStar.cs

示例8: Classify

        /// <summary>
        /// Given an input feature, a feature space and its associated labels, and a positive integer 'k',
        /// Determines the 'k' nearest neighbor label for the input feature. The 'k' value corresponds
        /// to the number of nearest neighbors to use in the voting process.
        /// 
        /// <remarks> 
        /// "When I have this grid of data points, and I provide one additional example row, find the 'k' number
        /// of rows that are most similar, count up the number of occurrences of each label for each row (1 to 'k'), 
        /// and choose the label with the highest occurrence."
        /// </remarks> 
        /// <see href="http://en.wikipedia.org/wiki/K-nearest_neighbor_algorithm" />
        /// </summary>
        /// <param name="distanceType">The type of equation to use when measuring the distance between each data point</param>
        /// <param name="input">The matrix row to input; must have the same number of columns as the feature space</param>
        /// <param name="featureSpace">The feature space matrix; everything we know</param>
        /// <param name="labels">The results for each feature space row; what we call each collection of data points</param>
        /// <param name="k">The number of nearest neighbors to include in the voting; the label with the most occurrences in 'k' neighbors wins</param>
        /// <returns></returns>
        public static string Classify(DistanceType distanceType, Number[] input, Matrix featureSpace, IList<string> labels, int k)
        {
            if (labels.Count() != featureSpace.Rows)
            {
                throw new ArgumentException("The number of labels must match the number of rows of data in the feature space", "labels");
            }

            var distances = CalculateDistances(distanceType, featureSpace, input);

            var nearestNeighbors = distances.OrderByDescending(d => d.Value).Take(k);

            var votes = new Dictionary<string, int>(k);

            foreach (var label in nearestNeighbors.Select(neighbor => labels[neighbor.Key]))
            {
                if (votes.ContainsKey(label))
                {
                    votes[label]++;
                }
                else
                {
                    votes.Add(label, 1);
                }
            }

            var nearest = votes.OrderByDescending(v => v.Value).First().Key;

            return nearest;
        }
开发者ID:modulexcite,项目名称:graveyard,代码行数:47,代码来源:KNearestNeighbor.cs

示例9: Clustering

 /// <summary>
 /// Khởi tạo cho thuật toán, dùng khi xây dựng cluster từ tập mẫu
 /// </summary>
 /// <param name="numCluster">Số cluster muốn tạo</param>
 /// <param name="samples">Các vector mẫu</param>
 /// <param name="distType">Loại khoảng cách</param>
 public Clustering(int numCluster, double[][] samples, DistanceType distType)
 {
     SampleData = new SampleSet(samples, distType);
     Clusters = new Cluster[numCluster];
     for (int i = 0; i < numCluster; i++)
     {
         Clusters[i] = new Cluster(samples[0].Length);
     }
     HasClusterChanged = true;
 }
开发者ID:mylgoehy,项目名称:stocktrendresearch,代码行数:16,代码来源:Clustering.cs

示例10: DistanceBetween

 /// <summary>  
 /// Returns the distance in miles or kilometers of any two  
 /// latitude / longitude points.  
 /// </summary>  
 public static double DistanceBetween(XLocation pos1, XLocation pos2, DistanceType type)
 {
     double R = (type == DistanceType.Miles) ? 3960 : 6371;
     double dLat = _toRadian(pos2.Latitude - pos1.Latitude);
     double dLon = _toRadian(pos2.Longitude - pos1.Longitude);
     double a = Math.Sin(dLat/2)*Math.Sin(dLat/2) +
                Math.Cos(_toRadian(pos1.Latitude))*Math.Cos(_toRadian(pos2.Latitude))*
                Math.Sin(dLon/2)*Math.Sin(dLon/2);
     double c = 2*Math.Asin(Math.Min(1, Math.Sqrt(a)));
     double d = R*c;
     return d;
 }
开发者ID:jakkaj,项目名称:Xamling-Core,代码行数:16,代码来源:DistanceHelper.cs

示例11: SampleSet

 public SampleSet(double[][] input, DistanceType type)
 {
     Samples = input;
     DistanceToClusters = new double[input.Length];
     ClusterIndices = new int[input.Length];
     for(int i = 0;i < DistanceToClusters.Length;i++)
     {
         DistanceToClusters[i] = -1;
         ClusterIndices[i] = -1;
     }
     DistType = type;
 }
开发者ID:mylgoehy,项目名称:stocktrendresearch,代码行数:12,代码来源:SampleSet.cs

示例12: Distance

 /// <summary>
 /// Returns the distance in miles or kilometers of any two
 /// latitude / longitude points.
 /// </summary>
 /// <param name=”pos1″></param>
 /// <param name=”pos2″></param>
 /// <param name=”type”></param>
 /// <returns>Distance</returns>
 public double Distance(Position pos1, Position pos2, DistanceType type)
 {
     double R = (type == DistanceType.Miles) ? 3960 : 6371;
     double dLat = this.toRadian(pos2.Latitude - pos1.Latitude);
     double dLon = this.toRadian(pos2.Longitude - pos1.Longitude);
     double a = Math.Sin(dLat / 2) * Math.Sin(dLat / 2) +
         Math.Cos(this.toRadian(pos1.Latitude)) * Math.Cos(this.toRadian(pos2.Latitude)) *
         Math.Sin(dLon / 2) * Math.Sin(dLon / 2);
     double c = 2 * Math.Asin(Math.Min(1, Math.Sqrt(a)));
     double d = R * c;
     return d;
 }
开发者ID:johnjelinek,项目名称:ggj2013-heartseeker,代码行数:20,代码来源:Haversine.cs

示例13: Distance

		public static float Distance(float latA, float lonA, float latB, float lonB, DistanceType type)
		{
			float R = (type == DistanceType.Miles) ? 3960 : 6371;

			float fLat = toRadian(latB - latA);
			float fLon = toRadian(lonB - lonA);

			float a = Mathf.Sin(fLat / 2) * Mathf.Sin(fLat / 2) + Mathf.Cos(toRadian(latA)) * Mathf.Cos(toRadian(latB)) * Mathf.Sin(fLon / 2) * Mathf.Sin(fLon / 2);
			float c = 2 * Mathf.Asin(Mathf.Min(1, Mathf.Sqrt(a)));
			float d = R * c;

			return d;
		}
开发者ID:odasaburo,项目名称:ActiveLife,代码行数:13,代码来源:HaversineCalc.cs

示例14: Distance

        /// <summary>
        /// Returns the distance in miles or kilometers of any two
        /// latitude / longitude points.
        /// </summary>
        /// <param name="pos1">The pos1.</param>
        /// <param name="pos2">The pos2.</param>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public static double Distance(Position pos1, Position pos2,DistanceType type)
        {
            double r = (type == DistanceType.Miles) ? 3960 : 6371;

            var dLat = ToRadian(pos2.Latitude - pos1.Latitude);
            var dLon = ToRadian(pos2.Longitude - pos1.Longitude);

            var a = Math.Sin(dLat / 2) * Math.Sin(dLat / 2) +
                Math.Cos(ToRadian(pos1.Latitude)) *Math.Cos(ToRadian(pos2.Latitude)) *
                Math.Sin(dLon / 2) * Math.Sin(dLon / 2);
            var c = 2 * Math.Asin(Math.Min(1, Math.Sqrt(a)));
            var d = r * c;

            return d;
        }
开发者ID:benpowell,项目名称:RavenLocal,代码行数:23,代码来源:Haversine.cs

示例15: Directions

        public static DirectionsResponse Directions(double[] origin, double[] destination, DistanceType type, DistanceUnit unit, bool sensor)
        {
            string url = APIUrl + "directions/json";
            string[] parameters = { "origin", "destination", "mode", "units", "sensor" };
            string[] values = {
                                        origin[0].ToString() + "," + origin[1].ToString() ,
                                        destination[0].ToString() + "," + destination[1].ToString(),
                                        type.ToString(),
                                        unit.ToString(),
                                        ((sensor) ? "true" : "false")
                                    };
            ArrayList headers = new ArrayList();
            string response = Utils.Request.ReadResponse(Utils.Request.Get(url, Encoding.UTF8, parameters, values, headers), Encoding.UTF8);
            DirectionsResponse dr = jss.Deserialize<DirectionsResponse>(response);

            return dr;
        }
开发者ID:webitpro,项目名称:WolfWeb,代码行数:17,代码来源:GMap.cs


注:本文中的DistanceType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。