using OnlineUserPool.Api; using OnlineUserPool.Api.Model; using OnlineUserPool.Model; using OnlineUserPool.Unility; using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; namespace OnlineUserPool.Hander { public class MultiUserHandle : IHandle { private int _index = 0; //3600*3; private MultiUserModel model; private TurfHelper _turfHelper; private int _routeId = 12353; //5593; //1660; private int _size = 10; private int _competitionid = 0;//35; public MultiUserHandle() { Init(); } public async void Init() { #region 环台湾 //_routeId = 5593; //_competitionid = 35; //_index = 3600 * 3; #endregion #region sis _routeId = 12353; _competitionid = 0; #endregion model = await BaseApi.GetAsync($"/Map/sss?routeId={ _routeId }&size={ _size }"); double i = 0; foreach (var item in model.users) { i += 0.01; item.Distance = i; } _turfHelper = new TurfHelper(model.route.List.Select(d => d.Point)); //Debug.WriteLine(res); } public List GetVirtualUserData() { _index++; var msgModels = new List(); if(model == null) { return msgModels; } foreach (var item in model.users) { var preDistance = 0D; //item.Distance = CommonHelper.GenerateRandomInteger(0, 30) / 1000D; if (_index > 0) { preDistance = item.Distance * (_index -1); } var point = _turfHelper.Along(item.Distance * _index); var info = new MsgModel() { Exit = false, IsCompleted = false, MemberId = item.Id,//虚拟的人Id变为负数 Point = new double[] { Math.Round(point.Latitude, 6), Math.Round(point.Longitude, 6) }, //Prop = string.Join(',', prop), RouteId = _routeId, EndDistance = item.Distance * _index, //ShowVirtual = true, CommandType = 1, //IsVirtual = true, Speed = item.Speed, WeightKg = 0, PreDistance = preDistance, CompetitionId = _competitionid }; msgModels.Add(info); } return msgModels; } public void RemoveEndAndAddNewVirtualUser(int customerCount) { } } }