Beispiel #1
0
        public List<string> GetPositions(LatLon[] array) 
        {
            List<string> lsLocation = new List<string>();
            try
            {
                var mapService = new PES.GPS.MapService.MapSearchService.MapService();
                IList<LocationInfo> list = mapService.InverseGeocoding(array);
                if (list.Count == 0)
                {
                    Logger.Error(string.Format("PositionService.GetPositions(LatLon[] array)获取位置失败"));
                }
                else
                {
                    for (int i = 0; i < list.Count;i++ )
                    {
                        lsLocation.Add(list[i].ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error(string.Format("PositionService.GetPositions(LatLon[] array)获取位置失败,error:{0}", ex.Message), ex);
            }

            return lsLocation;            
        }
Beispiel #2
0
        public string Encode(LatLon[] latlons)
        {
            string postString = string.Format("latlon={0}&customer=1", LatLon.ToParasString(latlons));

            string responseText = WebRequestHelper.UploadData(URL_ENCODE, postString, TIMEOUT, Encoding.UTF8);

            return responseText;
        }
Beispiel #3
0
        public bool IsInArea(LatLon max, LatLon min)
        {
            bool inArea = true;
            if (_latitude > max.Latitude || _latitude < min.Latitude)
            {
                inArea = false;
            }
            else if (_longitude > max.Longitude || _longitude < min.Longitude)
            {
                inArea = false;
            }

            return inArea;
        }
Beispiel #4
0
        public static string ToParasString(LatLon[] arrLatLon, EnumLotLonParasStringType type)
        {
            if (arrLatLon == null || arrLatLon.Length == 0)
                return string.Empty;

            StringBuilder sb = new StringBuilder();
            foreach (LatLon latlon in arrLatLon)
            {
                if (type == EnumLotLonParasStringType.LatitudeFirst)
                {
                    sb.AppendFormat("{0},{1};", latlon.Latitude, latlon.Longitude);
                }
                else
                {
                    sb.AppendFormat("{0},{1};", latlon.Longitude, latlon.Latitude);
                }
            }
            return sb.ToString().TrimEnd(';');
        }
Beispiel #5
0
 private bool IsAllIn(LatLon[] arr, out IList<LocationInfo> ltLocationInfo)
 {
     ltLocationInfo = new List<LocationInfo>();
     foreach (var item in arr)
     {
         LocationInfo temp;
         if (!InArea(item.Latitude, item.Longitude, out temp))
             return false;
         ltLocationInfo.Add(temp);
     }
     return true;
 }
        private List<AreaLocusViewModel> GetSectionLocus(EMVehicle vehicle, DateTime beginTime, DateTime endTime, LatLon max, LatLon min, EnumMapType mapType) 
        {
            List<AreaLocusViewModel> listAreaLocus = new List<AreaLocusViewModel>();

            IList<HistoryLocusViewModel> list = GetHistoryLocus(vehicle.VehicleCode, beginTime, endTime,mapType);
            if (list.Count > 0) 
            {
                bool hasInPoint = false;
                AreaLocusViewModel locus = null;

                //第一个点
                HistoryLocusViewModel first = list[0];
                LatLon lFirst = new LatLon(first.Latitude, first.Longitude);
                if (lFirst.IsInArea(max, min)) 
                {
                    locus = GetAreaLocus(vehicle);
                    locus.InTime = first.ReportTime;
                    locus.InType = "启动";
                    locus.InDirection = first.Direction;
                    locus.HistoryLocus.Add(first);

                    hasInPoint = true;
                }

                for (int i = 1; i < list.Count-1; i++) 
                {
                    HistoryLocusViewModel point = list[i];
                    LatLon ll = new LatLon(point.Latitude, point.Longitude);
                    if (ll.IsInArea(max, min) && !hasInPoint)
                    {
                        HistoryLocusViewModel before = list[i - 1];
                        locus = GetAreaLocus(vehicle);
                        locus.InTime = before.ReportTime;
                        locus.InType = "驶入";
                        locus.InDirection = before.Direction;
                        hasInPoint = true;

                        locus.HistoryLocus.Add(before);
                        locus.HistoryLocus.Add(point);

                    }
                    else if (!ll.IsInArea(max, min) && hasInPoint)
                    {
                        locus.OutTime = point.ReportTime;
                        locus.OutType = "驶出";
                        listAreaLocus.Add(locus);
                        locus.OutDirection = point.Direction;
                        hasInPoint = false;
                        
                        locus.HistoryLocus.Add(point);

                        locus = null;
                    }
                    else
                    {
                        if (hasInPoint && ll.IsInArea(max, min))
                        {
                            locus.HistoryLocus.Add(point);
                        }
                    }
                }
                //最后一个点
                HistoryLocusViewModel last = list[list.Count-1];
                LatLon lLast = new LatLon(last.Latitude, last.Longitude);
                if (lLast.IsInArea(max, min) && hasInPoint)
                {
                    locus.OutTime = last.ReportTime;
                    locus.OutType = "停止";
                    locus.OutDirection = last.Direction;
                    listAreaLocus.Add(locus);
                    hasInPoint = false;
                                        
                    locus.HistoryLocus.Add(last);
                }
            }

            return listAreaLocus;
        }