Ejemplo n.º 1
0
        /// <summary>
        /// 地图
        /// </summary>
        private void ShowGeo()
        {
            var ran = new Random();

            for (int i = 0; i < 100; i++)
            {
                RedisDb.GeoAdd("GeoKey1", new Random(Guid.NewGuid().GetHashCode()).Next(10400, 10600) / 100m, new Random(Guid.NewGuid().GetHashCode()).Next(7900, 8100) / 100m, $"mem{i}");
            }

            var myPlace = (105, 80);

            RedisDb.GeoAdd("GeoKey1", myPlace.Item1, myPlace.Item2, $"myplace");

            RedisDb.Expire("GeoKey1", 5);

            var getGeo = RedisDb.GeoRadiusByMemberWithDistAndCoord("GeoKey1", "myplace", 10 * 1000);



            foreach (var item in getGeo)
            {
                WriteColorLine($"Name:{item.member},经度:{item.longitude},纬度:{item.latitude},距离:{item.dist}", ConsoleColor.White);
            }
        }