Esempio n. 1
0
        public void EncodeTest()
        {
            PES.MapService.MapSearchService.IMapService target = new PES.MapService.MapSearchService.MapService(); // TODO: 初始化为适当的值
            string latitude = "22.59300"; // TODO: 初始化为适当的值
            string longitude = "113.87087"; // TODO: 初始化为适当的值
            string expected = string.Empty; // TODO: 初始化为适当的值
            string actual;
            actual = target.Encode(latitude, longitude);
            PES.MapService.Entity.LatLon latlon = target.Decode(actual);
            if (latlon == null)
            {
                Assert.Fail("latalon为null");
            }
            else
            {
                if (latlon.Latitude != Convert.ToDecimal(latitude))
                {
                    Assert.Fail("latlon.Latitude error,result is {0}",latlon.Latitude);
                }
                if (latlon.Longitude != Convert.ToDecimal(longitude))
                {
                    Assert.Fail("latlon.Longitude error,result is {0}", latlon.Longitude);
                }

            }
           // Assert.AreNotEqual(expected, actual);
            //Assert.Inconclusive("验证此测试方法的正确性。");
        }
Esempio n. 2
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>();
     }
 }
Esempio n. 3
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;
        }
Esempio n. 4
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;
        }
Esempio n. 5
0
        public IList<VVehicleSearchResult> VehicleSearch(string maxEncodeLatLon, string minEncodeLatLon, string tenantCode, string userCode,
            string permissionCode,int rowIndex,int pageSize,ref int rowCount)
        {
            PES.MapService.MapSearchService.MapService mapService = new PES.MapService.MapSearchService.MapService();

            LatLon maxLatLon = mapService.Decode(maxEncodeLatLon);
            LatLon minLatLon = mapService.Decode(minEncodeLatLon);

            IVehicleManager vm = new VehicleManager();

            IList<EBaseVehicle> ltVehicle = vm.Get(tenantCode, userCode, permissionCode);

            Rectangle rec = new Rectangle(maxLatLon.Latitude, maxLatLon.Longitude, minLatLon.Latitude, minLatLon.Longitude);

            IGPSTrackManager trackManager = new GPSTrackManager();

            IList<EGPSCurrentInfo> ltCurrentInfo = trackManager.SearchVehicleInRectange(rec, ltVehicle.Select(s => s.Code).ToArray(), rowIndex, pageSize,ref rowCount);

            Dictionary<Guid, string> dcVehicle = ltVehicle.ToDictionary(new Func<EBaseVehicle, Guid>(c => c.Code),
                    new Func<EBaseVehicle, string>(c => c.LicenceNumber));

            IList<VVehicleSearchResult> ltResult = new List<VVehicleSearchResult>();

            if (ltCurrentInfo == null)
                return ltResult;
            foreach (EGPSCurrentInfo currentInfo in ltCurrentInfo)
            {
                string licenceNumber = dcVehicle[currentInfo.VehicleCode.Value];

                VVehicleSearchResult result = new VVehicleSearchResult(currentInfo.VehicleCode.Value, licenceNumber, currentInfo.GPSCode, currentInfo.ReportTime.ToString(),currentInfo.Latitude,currentInfo.Longitude);

                ltResult.Add(result);
            }
            SetEncodeLatLon(mapService, ltResult);

            return ltResult;
        }
Esempio n. 6
0
        public IList<Guid> VehicleSearch(string maxEncodeLatLon,string minEncodeLatLon,string tenantCode)
        {
            PES.MapService.MapSearchService.MapService mapService = new PES.MapService.MapSearchService.MapService();

            LatLon maxLatLon = mapService.Decode(maxEncodeLatLon);
            LatLon minLatLon = mapService.Decode(minEncodeLatLon);

            IGPSInstallationManager installManager = new GPSInstallationManager();
            
            IList<string> ltGPSCode = installManager.GetGPSCode(tenantCode);

            IGPSTrackManager trackManager = new GPSTrackManager();

            Rectangle rec = new Rectangle(maxLatLon.Latitude, maxLatLon.Longitude, minLatLon.Latitude, minLatLon.Longitude);

            IList<EGPSCurrentInfo> ltCurrentInfo = trackManager.SearchVehicleInRectange(rec, ltGPSCode.ToArray<string>());


            if (ltCurrentInfo == null || ltCurrentInfo.Count == 0)
                return null;

            return ltCurrentInfo.Select(s => s.VehicleCode.Value).ToList();
        }
Esempio n. 7
0
        private static string[] GetEncodeLatLon(bool isNotEncode, IList<EGPSCurrentInfo> ltCurrentInfo)
        {
            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();

            string[] arrLatLonEncode = null;
            if (!isNotEncode)
            {
                arrLatLonEncode = mapService.Encode(ltLatLon.ToArray());
            }
            return arrLatLonEncode;
        }
Esempio n. 8
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;            
        }
Esempio n. 9
0
        public void EncodeArrayTest()
        {
            PES.MapService.MapSearchService.IMapService target = new PES.MapService.MapSearchService.MapService();
            LatLon[] latlons = new LatLon[] {
                new LatLon(22.593m,113.87087m),
                new LatLon(22.97033m,113.33485m)
            };

            string[] expected = new string[] { "ISGRCFVUADRDDG", "IRAFFVXTWWTDGA" };
            string []actual;
            actual = target.Encode(latlons);
            if (expected[0] != actual[0] || expected[1] != actual[1])
            {
                Assert.Fail("Encode() failed, result:{0},{1}", actual[0], actual[1]);
            }
        }
Esempio n. 10
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;
        }
Esempio n. 11
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;
        }
Esempio n. 12
0
        public void NearSearchTest()
        {
            PES.MapService.MapSearchService.IMapService target = new PES.MapService.MapSearchService.MapService();

            MapSearchResult result = target.NearSearch("加油站", "HEUADIZVVIEDVU", "加油站", "10000", "1", "10");
            if (result == null)
            {
                Assert.Fail("null");
            }

        }
Esempio n. 13
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);
            
        }
Esempio n. 14
0
        public void PointSearchTest()
        {
            PES.MapService.MapSearchService.IMapService target = new PES.MapService.MapSearchService.MapService();

            
            string city = "深圳市"; // TODO: 初始化为适当的值
            string keyword = "饭店"; // TODO: 初始化为适当的值
            int expected = 10; // TODO: 初始化为适当的值
            MapSearchResultItem [] items = target.PointSearch(city, keyword);

            if (items.Length < expected)
            {
                Assert.Fail(string.Format("failed, result item count:{0}", items.Length));
            }

            MapSearchResult mapSearchResult = target.PointSearch(city, keyword, "2", "5");
            
            if (mapSearchResult.Items.Count != 5)
            {
                Assert.Fail(string.Format("GetMapSearchResult failed, result item count:{0}", mapSearchResult.Items.Count));
            }
            
        }
Esempio n. 15
0
        public void DecodeTest()
        {
            PES.MapService.MapSearchService.IMapService target = new PES.MapService.MapSearchService.MapService();

            string source = "ISGRCFVUADRDDG";
            LatLon latlons = new LatLon(22.593m,113.87087m);
            
            LatLon actual = target.Decode(source);
            if (latlons.Longitude != actual.Longitude || latlons.Latitude !=  latlons.Latitude)
            {
                Assert.Fail("Encode() failed, result:{0},{1}",actual.Latitude,actual.Longitude);
            }
        }
Esempio n. 16
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());
        }
Esempio n. 17
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;
        }
Esempio n. 18
0
        private double GetTotalMileageByVehicle(Guid vehicleCode, DateTime StartTime, DateTime EndTime)
        {
            EMileage Model = new EMileage();
            IReportService objReportServer = new ReportService();
            IList<VGPSInstallationInfo> installationInfoList = objReportServer.GetGpsRelationList(vehicleCode, StartTime, EndTime);
            EHistoryDataStoreConfig config = objReportServer.GetVehicleStoreTableConfig(vehicleCode);
            if (installationInfoList == null || installationInfoList.Count == 0)
            {
                Logger.Trace(string.Format("车辆编号为:{0}在时间{1}到{2}内未找到对应的GPS关联", vehicleCode, StartTime, EndTime));
                return 0;
            }
            IMapService mapService = new PES.MapService.MapSearchService.MapService();

            for (int i = 0, i_Count = installationInfoList.Count(); i < i_Count; i++)
            {
                VGPSInstallationInfo installInfo = installationInfoList[i];
                DateTime bTime = installInfo.CreateDate > StartTime ? installInfo.CreateDate : StartTime;
                DateTime eTime = EndTime;
                if (installInfo.StopDate.HasValue)
                {
                    if (installInfo.StopDate.Value < EndTime)
                    {
                        eTime = installInfo.StopDate.Value;
                    }
                }
                var first = objReportServer.GetFirstRecordInDay(config, installInfo.GpsCode, bTime, eTime, true);
                var last = objReportServer.GetLastRecordInDay(config, installInfo.GpsCode, bTime, eTime, true);
                if (first == null || last == null)
                    continue;

                Model.TotalMileage += decimal.Round((last.StarkMileage / 1000 - first.StarkMileage / 1000), 2);
            }
            return (double)Model.TotalMileage;
        }