Exemple #1
0
        public void CheckThatTheForwardGeoCodingRequestReturnsValidResults()
        {
            var client = Substitute.For <IApiClient>();

            var provider = new MappingDataProvider(client);
            var request  = new MapBoxForwardGeocodingRequest
            {
                Query = "BS5 6DR",
                Types = new[] { Types.postcode }
            };

            var response = new MapBoxGeocodingResponse();

            client.GetAsync(request).Returns(info => response);

            var apiResponse = provider.GetAsync(request).Result;

            Assert.That(response, Is.SameAs(apiResponse));
        }
Exemple #2
0
        public async void CheckThatTheReverseGeoCodingRequestReturnsValidResults()
        {
            var client = Substitute.For <IApiClient>();

            var provider = new MappingDataProvider(client);
            var request  = new MapBoxReverseGeocodingRequest
            {
                Latitude  = 51.4500,
                Longitude = -2.5833
            };

            var response = new MapBoxGeocodingResponse();

            client.GetAsync(request).Returns(info => response);

            var apiResponse = await provider.GetAsync(request);

            Assert.That(apiResponse, Is.SameAs(response));
        }
Exemple #3
0
        public static ForwardGeocodingResult AsMapsApiGeocodingResult(this MapBoxGeocodingResponse value)
        {
            var response = new ForwardGeocodingResult
            {
                Results = value.Features.Select(
                    f =>
                    new Result
                {
                    Boundry = new BoundingBox
                    {
                        NorthEast = new Location {
                            Latitude = f.BBox.MinX, Longitude = f.BBox.MinY
                        },
                        SouthWest = new Location {
                            Latitude = f.BBox.MaxX, Longitude = f.BBox.MaxY
                        },
                    },
                    Id       = f.Id,
                    Location = new Location
                    {
                        Latitude  = f.Center.Y,
                        Longitude = f.Center.X
                    },
                    Address = new Address
                    {
                        FullAddress = f.PlaceName,
                        PropertyId  = f.Address,
                        Street      = f.Text,
                        SubLocality = GetMapBoxAddressComponent(f.Context, "neighborhood"),
                        Locality    = GetMapBoxAddressComponent(f.Context, "locality"),
                        Town        = GetMapBoxAddressComponent(f.Context, "place"),
                        Region      = GetMapBoxAddressComponent(f.Context, "region"),
                        County      = GetMapBoxAddressComponent(f.Context, "region"),
                        Country     = GetMapBoxAddressComponent(f.Context, "country"),
                        PostalCode  = GetMapBoxAddressComponent(f.Context, "postcode"),
                    }
                }
                    )
            };

            return(response);
        }