码迷,mamicode.com
首页 > 其他好文 > 详细

经纬度 lbs 笔记

时间:2014-12-03 00:24:15      阅读:208      评论:0      收藏:0      [点我收藏+]

标签:blog   http   io   ar   os   sp   for   on   div   

  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
 
 bubuko.com,布布扣
 
bubuko.com,布布扣
 
  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 笔记

标签:blog   http   io   ar   os   sp   for   on   div   

原文地址:http://www.cnblogs.com/lyl6796910/p/4138949.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!