public async Task LocationInformationRequest_Test() { //Arrange var client = new TriasServiceClient(ConfigHelper.TriasServiceUrl, ConfigHelper.TriasServiceRef); var input = new LocationInformationRequestStructure() .WithGeoRestriction(new GeoPositionStructure { Longitude = 8.675760m, Latitude = 49.404274m }, 100) .WithTypeRestriction(LocationTypeEnumeration.stop); //Act var result = await client.Request(input); //Assert Assert.That(result, Is.Not.Null); Assert.That(result.ErrorMessage, Is.Null); Assert.That(result.Location, Is.Not.Null); Assert.That(result.Location.Length, Is.GreaterThan(0)); Assert.IsInstanceOf <StopPointStructure>(result.Location[0].Location.Item); Assert.IsTrue(result.Location.Any(l => ((StopPointStructure)l.Location.Item).StopPointRef.Value == KnownStationId)); }
/// <summary> /// Defines location type restriction /// </summary> /// <param name="input"></param> /// <param name="types">Types to be included in the search result</param> /// <returns></returns> public static LocationInformationRequestStructure WithTypeRestriction( this LocationInformationRequestStructure input, params LocationTypeEnumeration[] types) { input.Restrictions = new LocationParamStructure { Type = types }; return(input); }
/// <summary> /// Specifies search stop point reference /// </summary> /// <param name="input"></param> /// <param name="stopPointRef">Id of the stop</param> /// <returns></returns> public static LocationInformationRequestStructure SearchByStopPointRef(this LocationInformationRequestStructure input, string stopPointRef) { input.Item = new LocationRefStructure() { Item = new StopPointRefStructure() { Value = stopPointRef } }; return(input); }
/// <summary> /// Defines geo restriction for request /// </summary> /// <param name="input"></param> /// <param name="geoPosition">Geo coordinates of the point to search around</param> /// <param name="radius">Radius restriction</param> /// <returns></returns> public static LocationInformationRequestStructure WithGeoRestriction( this LocationInformationRequestStructure input, GeoPositionStructure geoPosition, int radius) { input.Item = new InitialLocationInputStructure { GeoRestriction = new GeoRestrictionsStructure { Item = new GeoCircleStructure { Center = geoPosition, Radius = radius.ToString() } } }; return(input); }
/// <inheritdoc cref="ITriasCommunicator" /> public async Task <LocationInformationStopResponse> LocationInformationStopRequest(string idStopPoint) { var locationInformationRequest = new LocationInformationRequestStructure { Item = new LocationRefStructure { Item = new StopPointRefStructure1 { Value = idStopPoint } }, Restrictions = new LocationParamStructure { Type = new[] { LocationTypeEnumeration.stop }, IncludePtModes = true } }; var response = await _triasHttpClient.BaseTriasCall <LocationInformationResponseStructure>(locationInformationRequest).ConfigureAwait(false); var locationResult = response.LocationResult?.FirstOrDefault(); if (response.LocationResult?.Length != 1 || locationResult == null || ((StopPointStructure)locationResult.Location.Item).StopPointRef.Value != idStopPoint) { var errorCodes = response.ErrorMessage?.SelectMany(x => x.Text).Select(x => x.Text) ?? new List <string>(); throw new LocationInformationException($"No location could be found. {string.Join('-', errorCodes)}"); } var stopPoint = (StopPointStructure)locationResult.Location.Item; var stopPointName = stopPoint.StopPointName.FirstOrDefault(x => x.Language == "de")?.Text ?? "???"; var locationName = locationResult.Location.LocationName.FirstOrDefault(x => x.Language == "de")?.Text ?? "???"; return(new LocationInformationStopResponse { IdStopPoint = stopPoint.StopPointRef.Value, StopPointName = $"{locationName}, {stopPointName}", Latitude = locationResult.Location.GeoPosition.Latitude, Longitude = locationResult.Location.GeoPosition.Longitude }); }
public async Task <LocationInformationResponseStructure> Request(LocationInformationRequestStructure input) { return(await Request <LocationInformationResponseStructure>(input)); }