经纬度 lbs 笔记

  string Lat = objRequest.HeadLat.ToString();   纬度
                string Lng = objRequest.HeadLng.ToString();  经度
                NC.BLL.VisitLogs.UpdateUserLocation(objRequest.UID, Lat, Lng);
 
 
 UPDATE userinfo SET UserLocation= geography::Point({0}, {1}, 4326) WHERE uid={2}
 
更新经纬度
 
 ( select UserLocation from userinfo where UID=visitlog.ToUID).STDistance(visitlog.UserLocation) AS Distance
 
  经纬度 lbs 笔记
 
 
  string strDistance = NC.MSSQL.VWVisitLogs.GetDistance(userInfoHobby2User.ID);
                userHobby.Distance = strDistance != null ? (int)Math.Round(strDistance.ConvertDecimal(), 0) : 99999999;
              
 
  string Lat = objRequest.HeadLat.ToString();
                            string Lng = objRequest.HeadLng.ToString();
 
                            VisitLog objVisitLog = new VisitLog();
                            objVisitLog.FromuID = myUserId;
                            objVisitLog.ToUID = UID;
                            objVisitLog.Cretime = System.DateTime.Now;
                            NC.BLL.VisitLogs.InsertVisitLog(objVisitLog, Lat, Lng);
 
 
 
     string strsql = string.Format(" UPDATE VisitLog SET UserLocation= geography::Point({0}, {1}, 4326) WHERE id={2} ", Lat, Lng, objVisitLog.ID);
                    conn.ExecuteCommand(strsql);
 
 
 
 
     public static void UpdateUserLocation(int UID, string Lat, string Lng)
        {
            using (VIPDataContext conn = new VIPDataContext(PlatformConfig.DBConnectionString))
            {
                string strsql = string.Format(" UPDATE userinfo SET UserLocation= geography::Point({0}, {1}, 4326) WHERE uid={2} ", Lat, Lng, UID);
                    conn.ExecuteCommand(strsql);
            }
        }
 
 
 
 
 
 
 
 /// <summary>
        /// 纬度
        /// </summary>
        public decimal Lat { get; set; }
 
        /// <summary>
        /// 经度
        /// </summary>
        public decimal Lng { get; set; }
 
        /// <summary>
        /// 高德纬度
        /// </summary>
        public decimal ALat { get; set; }
 
        /// <summary>
        /// 高德经度
        /// </summary>
        public decimal ALng { get; set; }
 
 
 
 
 
 
USE [FcityDB2]
GO
 
SELECT [UserLocation]
      ,[UserLocation2]
  FROM [dbo].[Table_1]
GO
 
 
118.115196,24.49956
 
118.152884,24.632101
 
 
 
118.115959,24.500226
 
 
118.155484,24.633353
 
 UPDATE [Table_1] SET UserLocation= geography::Point(24.632101, 118.152884, 4326)
 
 
 UPDATE [Table_1] SET UserLocation2= geography::Point(24.633353, 118.155484, 4326)
 
 
  SELECT UserLocation.STDistance(UserLocation2) AS Distance from [Table_1]
 
 
  --106.876085126272
 
 
--297.540495255538
 

你可能感兴趣的:(LBS)