经纬度 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
 
 
 
 
  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
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值