Exemplo n.º 1
0
        public void GetResponse_Result_ByStreetAddress()
        {
            GeocodingRequest  request  = new GeocodingRequest("Alice Springs, Northern Territory, 0870, Australia", _context);
            GeocodingResponse response = request.GetResponse();

            Assert.IsNotNull(response);
            Assert.AreEqual(GeocodingResponseStatus.OK, response.Status);

            request.Address = "4 Cassia Ct, Alice Springs, Northern Territory, 0870, Australia";
            response        = request.GetResponse();

            Assert.IsNotNull(response);
            Assert.AreEqual(GeocodingResponseStatus.OK, response.Status);
        }
Exemplo n.º 2
0
        public void Issues_Issue11898()
        {
            GeocodingRequest  request  = new GeocodingRequest("4 Cassia Ct, Alice Springs, Northern Territory, 0870, Australia");
            GeocodingResponse response = request.GetResponse();

            Assert.AreEqual(GeocodingResponseStatus.OK, response.Status);
        }
Exemplo n.º 3
0
        public void Issues_Issue13038()
        {
            GeocodingRequest  request  = new GeocodingRequest("Yonge and Finch Toronto Canada Ontario");
            GeocodingResponse response = request.GetResponse();

            Assert.AreEqual(GeocodingResponseStatus.OK, response.Status);
        }
Exemplo n.º 4
0
        public void Issues_Issue14376()
        {
            var request  = new GeocodingRequest("BH5 1DP");
            var response = request.GetResponse();

            Assert.AreEqual(GeocodingResponseStatus.OK, response.Status);
        }
Exemplo n.º 5
0
        public void GetResponse_Fail_WithAddressAndLatLng()
        {
            var request = new GeocodingRequest(42.1354079, 24.7452904, _context);

            request.Address = "plovdiv bulgaria";

            Assert.Throws <InvalidOperationException>(() => request.GetResponse());
        }
Exemplo n.º 6
0
        public void GetResponse_Result()
        {
            GeocodingRequest  request  = new GeocodingRequest("plovdiv bulgaria", _context);
            GeocodingResponse response = request.GetResponse();

            Assert.IsNotNull(response);
            Assert.AreEqual(GeocodingResponseStatus.OK, response.Status);
        }
Exemplo n.º 7
0
        public void GetResponse_Result_ByLocationPair()
        {
            GeocodingRequest  request  = new GeocodingRequest(42.1354079, 24.7452904, _context);
            GeocodingResponse response = request.GetResponse();

            Assert.IsNotNull(response);
            Assert.AreEqual(GeocodingResponseStatus.OK, response.Status);

            string actual   = response.Results?[0].FormattedAddress;
            string expected = @"bul. ""Hristo Botev"" 56, 4000 Plovdiv, Bulgaria";

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 8
0
        public void GetResponse_Result_ByAddress()
        {
            GeocodingRequest  request  = new GeocodingRequest("plovdiv bulgaria", _context);
            GeocodingResponse response = request.GetResponse();

            Assert.IsNotNull(response);
            Assert.AreEqual(GeocodingResponseStatus.OK, response.Status);

            LatLng actual   = response.Results?[0].Geometry.Location;
            LatLng expected = new LatLng(42.1354079, 24.7452904);

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 9
0
        public void GetResponse_With_Language()
        {
            GeocodingRequest request = new GeocodingRequest(42.1354079, 24.7452904, _context)
            {
                Language = "bg-BG"
            };
            GeocodingResponse response = request.GetResponse();

            Assert.IsNotNull(response);
            Assert.AreEqual(GeocodingResponseStatus.OK, response.Status);

            string actual   = response.Results?[0].FormattedAddress;
            string expected = "бул. „Христо Ботев“ 56, 4000 Пловдив, България";

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 10
0
        public GeoObject GetGeoObject(string address)
        {
            GeocodingRequest request = new GeocodingRequest(address);//store.Address+store.City

            request.IsSensor = false;
            GeocodingResponse response = request.GetResponse();
            var result = response.Results.First();

            LatLng location  = result.Geometry.Location;
            double latitude  = location.Latitude;
            double longitude = location.Longitude;

            System.Diagnostics.Debug.WriteLine("---------------  " + latitude);
            System.Diagnostics.Debug.WriteLine("+++++++++++  " + longitude);
            GeoObject obj = new GeoObject
            {
                Latitude  = latitude,
                Longitude = longitude
            };

            return(obj);
        }
Exemplo n.º 11
0
        public string CheckZip(string address, string city, string zip)
        {
            GeocodingRequest request = new GeocodingRequest(address + " " + city);//store.Address+store.City

            request.IsSensor = false;
            GeocodingResponse response = request.GetResponse();
            var result = response.Results.First();
            IEnumerable <AddressComponent> items = result.AddressComponents;

            foreach (AddressComponent item in items)
            {
                if (item.Types[0].Equals("postal_code"))
                {
                    string long_name = item.LongName.Replace(" ", "");
                    System.Diagnostics.Debug.WriteLine(long_name.Trim());
                    if (long_name.Equals(zip))
                    {
                        return("");
                    }
                }
            }
            return("zip number is invalid!");
        }
Exemplo n.º 12
0
        public void Issues_GitHub_Issue10()
        {
            GeocodingRequest  request  = new GeocodingRequest("1 Microsoft Way, Redmond, CA");
            GeocodingResponse response = request.GetResponse();

            Assert.AreEqual(GeocodingResponseStatus.OK, response.Status);

            foreach (var r in response.Results)
            {
                Assert.NotNull(r.Geometry);
                Assert.NotNull(r.Geometry.Location);
                Assert.NotNull(r.FormattedAddress);

                Assert.AreEqual(47.6393225, r.Geometry.Location.Latitude);
                Assert.AreEqual(-122.1283833, r.Geometry.Location.Longitude);

                foreach (var ac in r.AddressComponents)
                {
                    Assert.NotNull(ac.ShortName);
                    Assert.NotNull(ac.LongName);
                }
            }
        }
Exemplo n.º 13
0
        public void GetResponse_Fail_WithoutAddressAndLatLng()
        {
            var request = new GeocodingRequest();

            Assert.Throws <InvalidOperationException>(() => request.GetResponse());
        }