예제 #1
0
        private async void HotelPackIconModern_MouseDown(object sender, MouseButtonEventArgs e)
        {
            int distance = 1000;

            MapPoint centerMercator = GeometryEngine.Project(new MapPoint(DetailShowItem.GetLng(), DetailShowItem.GetLat(), SpatialReferences.Wgs84),
                                                             SpatialReferences.WebMercator) as MapPoint;

            MapPoint leftTopMercator     = new MapPoint(centerMercator.X - distance, centerMercator.Y + distance, centerMercator.SpatialReference);
            MapPoint rightBottomMercator = new MapPoint(centerMercator.X + distance, centerMercator.Y - distance, centerMercator.SpatialReference);

            MapPoint leftTopWgs84     = GeometryEngine.Project(leftTopMercator, SpatialReferences.Wgs84) as MapPoint;
            MapPoint rightBottomWgs84 = GeometryEngine.Project(rightBottomMercator, SpatialReferences.Wgs84) as MapPoint;

            double minLng = leftTopWgs84.X;
            double maxLng = rightBottomWgs84.X;
            double minLat = rightBottomWgs84.Y;
            double maxLat = leftTopWgs84.Y;

            List <MapPoint> points = new List <MapPoint>();

            //API返回内容
            string jsonString = string.Empty;

            try
            {
                jsonString = (await WebServiceHelper.GetHttpResponseAsync(AppSettings["WEB_API_GET_HOTEL"] + "?minLng=" + minLng + "&maxLng=" + maxLng + "&minLat=" + minLat + "&maxLat=" + maxLat, string.Empty, RestSharp.Method.GET)).Content;
                if (jsonString == "")
                {
                    throw new Exception("");
                }

                JObject jobject = (JObject)JsonConvert.DeserializeObject(jsonString);

                JToken content = jobject["HotelInfo"];

                foreach (JToken pointToken in content)
                {
                    points.Add(WGSGCJLatLonHelper.GCJ02ToWGS84(new MapPoint(Convert.ToDouble(pointToken["Lng"].ToString()), Convert.ToDouble(pointToken["Lat"].ToString()), SpatialReferences.Wgs84)));
                }

                Dictionary <string, object> param = new Dictionary <string, object>(2)
                {
                    { "type", ViewSpotArounds.Hotel },
                    { "points", points }
                };

                ArcGISMapCommands.AddViewSpotAround.Execute(param, Application.Current.MainWindow);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                MessageboxMaster.Show(LanguageDictionaryHelper.GetString("Server_Connect_Error"), LanguageDictionaryHelper.GetString("MessageBox_Error_Title"));
                return;
            }
        }
        public void WGS84ToGCJ02Test()
        {
            LatLngPoint _gcj02PointExpected = new LatLngPoint()
            {
                LatY = 34.119651841940737,
                LonX = 115.21780492356538
            };
            LatLngPoint _gcj02PointActual = WGSGCJLatLonHelper.WGS84ToGCJ02(new LatLngPoint()
            {
                LonX = 115.21212,
                LatY = 34.121
            });
            bool _expected = true;
            bool _actual   = ModelHelper.CompletelyEqual(_gcj02PointExpected, _gcj02PointActual);

            Assert.AreEqual(_expected, _actual);
        }
        public void GCJ02ToWGS84Test()
        {
            LatLngPoint _gcj02PointExpected = new LatLngPoint()
            {
                LatY = 34.122340014975919,
                LonX = 115.20642637776433
            };
            LatLngPoint _gcj02PointActual = WGSGCJLatLonHelper.GCJ02ToWGS84(new LatLngPoint()
            {
                LonX = 115.21212,
                LatY = 34.121
            });
            bool _expected = true;
            bool _actual   = ModelHelper.CompletelyEqual(_gcj02PointExpected, _gcj02PointActual);

            Assert.AreEqual(_expected, _actual);
        }
예제 #4
0
        /// <summary>
        /// 查询按钮响应函数
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void SpotSearchBtn_ClickAsync(object sender, RoutedEventArgs e)
        {
            int selectedIndex = ModeCombox.SelectedIndex;

            string requestString = null;

            string AscOrDescString = Desc.IsChecked == true ? "desc" : "asc";

            if (selectedIndex == 0)
            {
                requestString = AppSettings["WEB_API_GET_VIEW_INFO_BY_RATING"] + "?limit=100&ascordesc=" + AscOrDescString;
            }
            else if (selectedIndex == 1)
            {
                requestString = AppSettings["WEB_API_GET_VIEW_INFO_BY_COST"] + "?limit=100&ascordesc=" + AscOrDescString;
            }
            else
            {
                MessageboxMaster.Show(LanguageDictionaryHelper.GetString("Input_Empty"), LanguageDictionaryHelper.GetString("MessageBox_Warning_Title"));
                return;
            }

            //API返回内容
            string jsonString = string.Empty;

            List <ViewSpot> viewSpotList = new List <ViewSpot>(100);

            try
            {
                jsonString = (await WebServiceHelper.GetHttpResponseAsync(requestString, string.Empty, RestSharp.Method.GET)).Content;
                if (jsonString == "")
                {
                    throw new Exception("");
                }

                JObject jobject = (JObject)JsonConvert.DeserializeObject(jsonString);

                string content_string = jobject["ViewInfo"].ToString();

                using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(content_string)))
                {
                    DataContractJsonSerializer deseralizer = new DataContractJsonSerializer(typeof(List <ViewSpot>));
                    viewSpotList = (List <ViewSpot>)deseralizer.ReadObject(ms);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                MessageboxMaster.Show(LanguageDictionaryHelper.GetString("Server_Connect_Error"), LanguageDictionaryHelper.GetString("MessageBox_Error_Title"));
                return;
            }

            //检查数据
            for (int i = 0; i < viewSpotList.Count; i++)
            {
                viewSpotList[i].CheckData();
            }

            //设置显示数据
            ViewMaster.ViewSpotList = new ObservableCollection <ViewSpot>(viewSpotList);

            //定义当前显示的面板
            CurrentGrid = CurrentPanel.List;

            //设置面板可见
            PanelVisibility = Visibility.Visible;

            //清除点图层要素
            ArcGISMapCommands.ClearFeatures.Execute(2, this);

            //绘制要素
            foreach (ViewSpot viewSpot in viewSpotList)
            {
                MapPoint gcjpoint = new MapPoint(viewSpot.lng, viewSpot.lat);
                MapPoint wgspoint = WGSGCJLatLonHelper.GCJ02ToWGS84(gcjpoint);
                viewSpot.lng = wgspoint.X;
                viewSpot.lat = wgspoint.Y;
                Dictionary <string, object> commandParams = new Dictionary <string, object>(8)
                {
                    { "Lng", viewSpot.lng },
                    { "Lat", viewSpot.lat },
                    { "IconUri", IconDictionaryHelper.IconDictionary[IconDictionaryHelper.Icons.pin_blue] },
                    { "Width", 16.0 },
                    { "Height", 24.0 },
                    { "OffsetX", 0.0 },
                    { "OffsetY", 9.5 },
                    { "Data", viewSpot }
                };

                ArcGISMapCommands.ShowFeatureOnMap.Execute(commandParams, this);
            }
        }
예제 #5
0
        /// <summary>
        /// 查询按钮响应函数
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void SpotSearchBtn_ClickAsync(object sender, RoutedEventArgs e)
        {
            if (StartPointAddress.Text == null || StartPointAddress.Text == string.Empty)
            {
                MessageboxMaster.Show(LanguageDictionaryHelper.GetString("Input_Empty"), LanguageDictionaryHelper.GetString("MessageBox_Warning_Title"));
                return;
            }

            //用户输入的内容
            string input_spot_name = StartPointAddress.Text;

            //逐一分词之后的内容
            char[] input_spot_name_spited = input_spot_name.ToCharArray();

            //模糊查询中的内容
            string sql_regexp = "%";
            {
                foreach (char siglechar in input_spot_name_spited)
                {
                    sql_regexp += siglechar + "%";
                }
            }

            //API返回内容
            string jsonString = string.Empty;

            //景点数量
            int viewCount = -1;

            try
            {
                jsonString = (await WebServiceHelper.GetHttpResponseAsync(AppSettings["WEB_API_GET_VIEW_COUNT_BY_NAME"] + "?name=" + sql_regexp, string.Empty, RestSharp.Method.GET)).Content;
                if (jsonString == "")
                {
                    throw new Exception("");
                }

                JObject jobject = (JObject)JsonConvert.DeserializeObject(jsonString);

                JToken jtoken = jobject["ViewCount"][0];

                viewCount = (int)jtoken["COUNT(*)"];
            }
            catch
            {
                MessageboxMaster.Show(LanguageDictionaryHelper.GetString("Server_Connect_Error"), LanguageDictionaryHelper.GetString("MessageBox_Error_Title"));
                return;
            }

            if (viewCount <= 0)
            {
                MessageboxMaster.Show(LanguageDictionaryHelper.GetString("SpotSearch_Null"), LanguageDictionaryHelper.GetString("MessageBox_Tip_Title"));
                return;
            }

            List <ViewSpot> viewSpotList = new List <ViewSpot>(viewCount);

            try
            {
                jsonString = (await WebServiceHelper.GetHttpResponseAsync(AppSettings["WEB_API_GET_VIEW_INFO_BY_NAME"] + "?name=" + sql_regexp, string.Empty, RestSharp.Method.GET)).Content;
                if (jsonString == "")
                {
                    throw new Exception("");
                }

                JObject jobject = (JObject)JsonConvert.DeserializeObject(jsonString);

                string content_string = jobject["ViewInfo"].ToString();

                using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(content_string)))
                {
                    DataContractJsonSerializer deseralizer = new DataContractJsonSerializer(typeof(List <ViewSpot>));
                    viewSpotList = (List <ViewSpot>)deseralizer.ReadObject(ms);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                MessageboxMaster.Show(LanguageDictionaryHelper.GetString("Server_Connect_Error"), LanguageDictionaryHelper.GetString("MessageBox_Error_Title"));
                return;
            }

            //检查数据
            for (int i = 0; i < viewSpotList.Count; i++)
            {
                viewSpotList[i].CheckData();
            }

            //设置显示数据
            ViewMaster.ViewSpotList = new ObservableCollection <ViewSpot>(viewSpotList);

            //定义当前显示的面板
            CurrentGrid = CurrentPanel.List;

            //设置面板可见
            PanelVisibility = Visibility.Visible;

            //清除点图层要素
            ArcGISMapCommands.ClearFeatures.Execute(2, this);

            //绘制要素
            foreach (ViewSpot viewSpot in viewSpotList)
            {
                MapPoint gcjpoint = new MapPoint(viewSpot.lng, viewSpot.lat);
                MapPoint wgspoint = WGSGCJLatLonHelper.GCJ02ToWGS84(gcjpoint);
                viewSpot.lng = wgspoint.X;
                viewSpot.lat = wgspoint.Y;
                Dictionary <string, object> commandParams = new Dictionary <string, object>(8)
                {
                    { "Lng", viewSpot.lng },
                    { "Lat", viewSpot.lat },
                    { "IconUri", IconDictionaryHelper.IconDictionary[IconDictionaryHelper.Icons.pin_blue] },
                    { "Width", 16.0 },
                    { "Height", 24.0 },
                    { "OffsetX", 0.0 },
                    { "OffsetY", 9.5 },
                    { "Data", viewSpot }
                };

                ArcGISMapCommands.ShowFeatureOnMap.Execute(commandParams, this);
            }
        }