powerfun-new-net/Unility/CommonHelper.cs
andy 0e931a3ac9 一些功能调整
增加tcp协议支持;
增加模拟多用户的功能;
2021-01-18 20:24:19 +08:00

28 lines
869 B
C#

using System;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Text;
using TurfCS;
namespace OnlineUserPool.Unility
{
public class CommonHelper
{
public static double GetDistances(double lon, double lat, double lon1, double lat1)
{
var pt1 = Turf.Point(new double[] { lon, lat });
var pt2 = Turf.Point(new double[] { lon1, lat1 });
var value = Turf.Distance(pt1, pt2, "kilometers") * 1000;
return Math.Round(value, 2);
}
public static int GenerateRandomInteger(int min = 0, int max = int.MaxValue)
{
var randomNumberBuffer = new byte[10];
new RNGCryptoServiceProvider().GetBytes(randomNumberBuffer);
return new Random(BitConverter.ToInt32(randomNumberBuffer, 0)).Next(min, max);
}
}
}