Example #1
0
        /// <summary>
        /// 从提供的网点id中,筛选出指定范围内的网点
        /// </summary>
        /// <param name="id">网点的id数组</param>
        /// <param name="leftTop">地理范围的左上角经纬度</param>
        /// <param name="rightBottom">地理范围的右下角经纬度</param>
        /// <param name="points">网点集</param>
        /// <returns></returns>
        public static void GetPoints(int[] id, LatLngCoordinate leftTop, LatLngCoordinate rightBottom, out List <GeoPoint> points)
        {
            points = new List <GeoPoint>();

            var sql =
                new StringBuilder(
                    "SELECT GeoID,Name,FormattedAddress,Latitude,Longitude,Phone FROM ipvt_geoinfotable WHERE Latitude>?latStart AND Latitude<?latEnd AND Longitude>?lngStart AND Longitude<?lngEnd");

            if (id.Length > 0)
            {
                sql.Append(" AND GeoID IN (");

                foreach (int i in id)
                {
                    sql.Append(i);
                    sql.Append(",");
                }

                sql.Remove(sql.Length - 1, 1);
                sql.Append(")");
            }

            var parameters = new MySqlParameter[4];

            parameters[0] = new MySqlParameter("?latStart", rightBottom.Latitude);
            parameters[0] = new MySqlParameter("?latEnd", leftTop.Latitude);
            parameters[0] = new MySqlParameter("?lngStart", leftTop.Longitude);
            parameters[0] = new MySqlParameter("?lngEnd", rightBottom.Longitude);

            try
            {
                DataSet set = CustomMySqlHelper.ExecuteDataSet(sql.ToString(), parameters);
                if (set.Tables.Count > 0)
                {
                    DataRowCollection rows = set.Tables[0].Rows;
                    if (rows != null)
                    {
                        foreach (DataRow row in rows)
                        {
                            GeoPoint pnt = new GeoPoint();
                            pnt.Id      = EvaluationHelper.ObjectToInt(row["GeoID"]);
                            pnt.Name    = Convert.ToString(row["Name"]);
                            pnt.Address = Convert.ToString(row["FormattedAddress"]);
                            //pnt.Ip = Convert.ToString(row["ip"]);
                            pnt.Phone     = Convert.ToString(row["phone"]);
                            pnt.Latitude  = EvaluationHelper.ObjectToDouble(row["Latitude"]);
                            pnt.Longitude = EvaluationHelper.ObjectToDouble(row["Longitude"]);
                            points.Add(pnt);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.MainLog("GeoPointManager.GetPoints error!" + ex);
            }
        }
Example #2
0
        public static void Get(LatLngCoordinate leftTop, LatLngCoordinate rightBottom, out List <GeoPoint> points)
        {
            points = new List <GeoPoint>();


            string sql =
                "SELECT GeoID,Name,FormattedAddress,Latitude,Longitude,Phone,Note FROM ipvt_geoinfotable WHERE Latitude>?latStart and Latitude<?latEnd and Longitude>?lngStart and Longitude<?lngEnd";

            var parameters = new MySqlParameter[4];

            parameters[0] = new MySqlParameter("?latStart", rightBottom.Latitude);
            parameters[1] = new MySqlParameter("?latEnd", leftTop.Latitude);
            parameters[2] = new MySqlParameter("?lngStart", leftTop.Longitude);
            parameters[3] = new MySqlParameter("?lngEnd", rightBottom.Longitude);

            try
            {
                DataSet set = CustomMySqlHelper.ExecuteDataSet(sql, parameters);
                if (set.Tables.Count > 0)
                {
                    DataRowCollection rows = set.Tables[0].Rows;
                    if (rows != null)
                    {
                        foreach (DataRow row in rows)
                        {
                            var pnt = new GeoPoint();
                            pnt.Id        = EvaluationHelper.ObjectToInt(row["GeoID"]);
                            pnt.Name      = Convert.ToString(row["Name"]);
                            pnt.Address   = Convert.ToString(row["FormattedAddress"]);
                            pnt.Note      = Convert.ToString(row["Note"]);
                            pnt.Phone     = Convert.ToString(row["Phone"]);
                            pnt.Latitude  = EvaluationHelper.ObjectToDouble(row["Latitude"]);
                            pnt.Longitude = EvaluationHelper.ObjectToDouble(row["Longitude"]);
                            points.Add(pnt);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.MainLog("GeoPointManager.Get error!" + ex);
            }
        }