public void GetCitiesByNameSearchString()
        {
            ICoordinateSystem     coordinateSystemRt90           = new CoordinateSystem(CoordinateSystemId.Rt90_25_gon_v);
            ICoordinateSystem     coordinateSystemGoogleMercator = new CoordinateSystem(CoordinateSystemId.GoogleMercator);
            IStringSearchCriteria criteria = new StringSearchCriteria()
            {
                SearchString = "Uppsala%"
            };

            // Get cities in RT90
            CityInformationList citiesRt90 =
                GetGeoReferenceManager(true).GetCitiesByNameSearchString(GetUserContext(),
                                                                         criteria,
                                                                         coordinateSystemRt90);

            Assert.IsTrue(citiesRt90.IsNotEmpty());


            // Get cities in Google Mercator
            CityInformationList citiesGoogleMercator =
                GetGeoReferenceManager(true).GetCitiesByNameSearchString(GetUserContext(),
                                                                         criteria,
                                                                         coordinateSystemGoogleMercator);

            Assert.IsTrue(citiesGoogleMercator.IsNotEmpty());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get a CityInformationList from a List of WebCityInformation
        /// </summary>
        /// <param name="userContext">The user context</param>
        /// <param name="cityInformations">The list of WebCityInformations to "convert"</param>
        /// <returns></returns>
        private CityInformationList GetCityInformationList(IUserContext userContext, List <WebCityInformation> cityInformations)
        {
            CityInformationList cityInformationList = new CityInformationList();

            foreach (WebCityInformation cityInformation in cityInformations)
            {
                cityInformationList.Add(GetCityInformation(userContext, cityInformation));
            }
            return(cityInformationList);
        }
Exemplo n.º 3
0
        private static async Task <CityInformationList> GetCityList()
        {
            var NoWeatherRequest = new CityInformationList();

            try
            {
                var        url      = "https://cdn.heweather.com/china-city-list.json";
                HttpClient http     = new HttpClient();
                var        response = await http.GetAsync(url);

                var Message = await response.Content.ReadAsStringAsync();

                var MessageProcess = "{\"root\":" + Message + "}";
                var serializer     = new DataContractJsonSerializer(typeof(CityInformationList));
                var ms             = new MemoryStream(Encoding.UTF8.GetBytes(MessageProcess));
                var result         = (CityInformationList)serializer.ReadObject(ms);
                return(result);
            }
            catch (Exception)
            {
                return(NoWeatherRequest);
            }
        }