Beispiel #1
0
 public void SaveLine(ELine line, EnumMapCoordinates coordinates)
 {
     switch (coordinates)
     {
         case EnumMapCoordinates.Gcj02:
             line.LinePoints = _mapService.Gcj02ToWgs84(line.LinePoints.ToObject<IList<EMapPoint>>().ToArray()).ToJson();
             break;
         default:
             break;
     }
     _rep.Save(line, p => p.Id == line.Id);
 }
Beispiel #2
0
        public ELine SaveHistoryDataToLine(int userId, string lineName, int deviceId, DateTime startTime, DateTime endTime ,EnumMapCoordinates coordinates)
        {
            var list = _positionService.GetDeviceHistoryDatas(deviceId, startTime, endTime);
            if (list.Count == 0)
            {
                throw new BusinessException("没有找到相关历史数据");
            }

            var totalMileage = _mileageService.CalcMileage(list);

            var line = new ELine()
            {
                UserId = userId,
                LineName = lineName,
                TotalMileage = totalMileage,
                LinePoints = list.Select(p => new EMapPoint(p.E, p.F)).ToList().ToJson()
            };
            _rep.Add(line);

            switch (coordinates)
            {
                case EnumMapCoordinates.Gcj02:
                    line.LinePoints = _mapService.Wgs84ToGcj02(list.Select(p => new EMapPoint(p.E, p.F)).ToArray()).ToJson();
                    break;
                case EnumMapCoordinates.Bd09:
                    line.LinePoints = _mapService.Wgs84ToBd09(list.Select(p => new EMapPoint(p.E, p.F)).ToArray()).ToJson();
                    break;
                default:
                    break;
            }
            
            return line;
        }
 /// <summary>
 /// 编辑
 /// </summary>
 /// <returns></returns>
 public ActionResult EditLine(ELine line, EnumMapCoordinates coordinates)
 {
     if (line.Id == 0)
     {
         line.UserId = Passport.User.Id;
         _lineService.AddLine(line, coordinates);
         return JsonResult(line, "添加成功!");
     }
     else
     {
         line.UserId = Passport.User.Id;
         _lineService.SaveLine(line, coordinates);
         return JsonResult(line, "保存成功!");
     }
 }