Ejemplo n.º 1
0
 public IList<LocationInfo> GetPosition(IList<LatLon> ltLatLon)
 {
     try
     {
         IMapService mapService = new PES.MapService.MapSearchService.MapService();
         return mapService.InverseGeocoding(ltLatLon.ToArray());
     }
     catch (Exception ex)
     {
         Logger.Error(string.Format("获取位置失败,error:{0}",  ex.Message));
         return new List<LocationInfo>();
     }
 }
Ejemplo n.º 2
0
        public string GetPosition(string latlon)
        {
            string position = string.Empty;
            try
            {

                IMapService mapService = new PES.MapService.MapSearchService.MapService();
                var locationInfo = mapService.InverseGeocoding(latlon);
                if (locationInfo == null)
                {
                    Logger.Error(string.Format("latlon:{0}获取位置失败", latlon));
                }
                else
                {
                    position = locationInfo.ToString();
                }
            }
            catch (Exception ex)
            {
                Logger.Error(string.Format("latlon:{0}获取位置失败,error:{1}", latlon, ex.Message));
            }

            return position;
        }
Ejemplo n.º 3
0
        public IList<VRealTimeInfo> GetVehicleRealTimeInfo(string username, string password, string[] arrLicenceNumber)
        {

            Logger.Error(string.Format("{0},{1}", username, password));

            ////password = EncodeStr.EncodePassword(password);
            ////EUser user = null;
            ////try
            ////{
            ////    user = SSOProxy.LogonUser(username, password, PES.Guanaco.Entity.EnumLoginType.UserName, "127.0.0.1");

            ////    if (user == null || user.TenantList.Count == 0)
            ////    {
            ////        throw new Exception("User name or password error!");
            ////    }
            ////}
            ////catch (Exception ex)
            ////{
            ////    Logger.Error(ex);
            ////    throw new Exception("User name or password error!");
            ////}
            try
            {
                UserEntity user = GuanacoServiceFacade.Tenant.GetUser(username, EncodeStr.EncodePassword(password), EnumLoginType.UserName);
                if (user == null || GuanacoServiceFacade.Tenant.GetUserTenants(user.UserCode).Count == 0)
                {
                    throw new Exception("User name or password error!");
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new Exception("User name or password error!");
            }

            IVehicleManager vm = new VehicleManager();

            IList<VRealTimeInfo> ltCurrentInfo = new List<VRealTimeInfo>();

            IList<LatLon> ltLatLon = new List<LatLon>();

            foreach (string licenceNumber in arrLicenceNumber)
            {
                Guid vehicleCode = vm.GetVehicleCodeByLicenceNumber(licenceNumber);

                IGPSTrackManager trackManager = new GPSTrackManager();

                EGPSCurrentInfo currentInfo;

                try
                {
                    currentInfo = trackManager.GetCurrentInfo(vehicleCode);

                    ltLatLon.Add(new LatLon(currentInfo.Latitude, currentInfo.Longitude));

                    VRealTimeInfo realtimeInfo = new VRealTimeInfo();

                    realtimeInfo.CurrentGPSInfo = currentInfo;

                    EBaseVehicle vehicle = new EVehicle();

                    vehicle.LicenceNumber = licenceNumber;

                    realtimeInfo.VehicleInfo = vehicle;

                    ltCurrentInfo.Add(realtimeInfo);
                }
                catch (GPSCurrentInfoNullException ex)
                {
                    Logger.Error(ex);
                    throw ex;
                }
            }

            IMapService mapService = new PES.MapService.MapSearchService.MapService();

            IList<LocationInfo> ltLocationInfo = mapService.InverseGeocoding(ltLatLon.ToArray());

            for (int i = 0; i < ltCurrentInfo.Count; i++)
            {
                ltCurrentInfo[i].LocationInfo = ltLocationInfo[i];
            }

            return ltCurrentInfo;
        }
Ejemplo n.º 4
0
        public string GetVehicleLocationInfo(string vehicleCode)
        {
            IGPSTrackManager trackManager = new GPSTrackManager();

            EGPSCurrentInfo currentInfo;

            try
            {
                currentInfo = trackManager.GetCurrentInfo(new Guid(vehicleCode));
            }
            catch (GPSCurrentInfoNullException ex)
            {
                Logger.Error(ex);
                throw ex;
            }

            IMapService ms = new PES.MapService.MapSearchService.MapService();

            string encode = ms.Encode(currentInfo.Latitude.ToString(), currentInfo.Longitude.ToString());

            LocationInfo locationInfo = ms.InverseGeocoding(currentInfo.Latitude.ToString(), currentInfo.Longitude.ToString());

            return string.Format("{0},{1}", encode, locationInfo.ToString());
        }
Ejemplo n.º 5
0
        public IList<VVehicleLocationInfo> GetVehicleLoationInfo(string[] arrVehicleCode, SessionContext sessionContext)
        {
            IList<EGPSCurrentInfo> ltCurrentInfo = this.GetCurrentInfo(arrVehicleCode);

            IList<LatLon> ltLatLon = new List<LatLon>();

            foreach (EGPSCurrentInfo currentInfo in ltCurrentInfo)
            {
                ltLatLon.Add(new LatLon(currentInfo.Latitude, currentInfo.Longitude));
            }

            IMapService mapService = new PES.MapService.MapSearchService.MapService();

            IList<LocationInfo> ltLocationInfo  = mapService.InverseGeocoding(ltLatLon.ToArray());

            IList<VVehicleLocationInfo> ltVehicleLocationInfo = new List<VVehicleLocationInfo>();

            for(int i=0;i<ltCurrentInfo.Count;i++)
            {
                ltVehicleLocationInfo.Add(new VVehicleLocationInfo(ltCurrentInfo[i].VehicleCode.Value, ltLocationInfo[i]));
            }

            return ltVehicleLocationInfo;
        }
Ejemplo n.º 6
0
        public List<string> GetPositions(LatLon[] array) 
        {
            List<string> lsLocation = new List<string>();
            try
            {

                IMapService mapService = new PES.MapService.MapSearchService.MapService();
                IList<LocationInfo> list = mapService.InverseGeocoding(array);
                if (list.Count == 0)
                {
                    Logger.Error(string.Format("获取位置失败"));
                }
                else
                {
                    for (int i = 0; i < list.Count;i++ )
                    {
                        lsLocation.Add(list[i].ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error(string.Format("获取位置失败,error:{2}", ex.Message));
            }

            return lsLocation;            
        }
Ejemplo n.º 7
0
        private LocationInfo GetLocationByLatitudeLongitude(decimal longtitude, decimal latitude)
        {
            IMapService mapService = new PES.MapService.MapSearchService.MapService();

            string encodeLatLon = mapService.Encode(latitude.ToString(), longtitude.ToString());

            LocationInfo locationInfo = mapService.InverseGeocoding(encodeLatLon);
            return locationInfo;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 车辆 满足条件 发送信息内容组合
        /// </summary>
        /// <param name="ds"></param>
        /// <returns></returns>
        protected virtual List<string> GpsVehicleMsg(DataSet ds)
        {
           
            List<string> lsMsg = new List<string>();
            List<string> lsCode = new List<string>();
            Dictionary<string, string> dic = null;
            IMapService IMapService = null;
            DataTable dt = null; 
            try
            {
                IMapService = new PES.MapService.MapSearchService.MapService(); 
            }
            catch(Exception ex)
            {
                Logger.Fatal(ex);
            }
            if (IMapService != null)
            {                
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    dic = ViehicleList(ds);
                    lsCode = dic.Keys.ToList();
                }

                dt = QueryVehicleCurrentInfo(ListToString(lsCode));
                if (dt != null && dt.Rows.Count > 0)
                {
                    Logger.Info("记录条数"+dt.Rows.Count);
                    foreach (DataRow r in dt.Rows)
                    {
                        string strmap = IMapService.InverseGeocoding(r["latitude"].ToString(), r["longitude"].ToString()).ToString();
                        if (string.IsNullOrEmpty(strmap))
                        {
                            strmap = IMapService.InverseGeocoding(r["latitude"].ToString(), r["longitude"].ToString()).ToString();
                        }
                        if (string.IsNullOrEmpty(strmap))
                        {
                            continue;
                        }                        
                        Logger.Info(string.Format("{0},{1}{2},{3}公里/小时。", dic[r["vehiclecode"].ToString()], r["reporttime"].ToString(), strmap, r["speed"].ToString()));

                        lsMsg.Add(string.Format("{0},{1}{2},{3}公里/小时。", dic[r["vehiclecode"].ToString()], r["reporttime"].ToString(), strmap, r["speed"].ToString()));
                    }
                }
                //else   //查询不到经纬度
                //{
                //    lsMsg.Add("");
                //}
            }
            return lsMsg;
        }
Ejemplo n.º 9
0
        public void InverseGeocodingTest()
        {
            PES.MapService.MapSearchService.IMapService target = new PES.MapService.MapSearchService.MapService();

            string latitude = "22.59300"; 
            string longitude = "113.87087";
            string encodeLatLon = "ISGRCFVUADRDDG"; 
            
            string location1 = target.InverseGeocoding(latitude, longitude);
            string location2 = target.InverseGeocoding(encodeLatLon);
            if (string.IsNullOrEmpty(location1) || location1 == "()")
            {
                Assert.Fail("InverseGeocoding({0},{1}) failed",latitude,longitude);
            }
            if (string.IsNullOrEmpty(location2) || location2 == "()")
            {
                Assert.Fail("InverseGeocoding({0}) failed",encodeLatLon);
            }
            Assert.AreEqual(location1, location2,"location1为{0},location2为{1}",location1,location2);
            
        }