private IRtssc GetSelectedRtssc(bool isStartMode)
        {
            RadDropDownList ddlRoute              = isStartMode ? ddlRouteStart : ddlRouteStop;
            RadDropDownList ddlTroncon            = isStartMode ? ddlTronconStart : ddlTronconStop;
            RadDropDownList ddlSection            = isStartMode ? ddlSectionStart : ddlSectionStop;
            RadDropDownList ddlSousRoute          = isStartMode ? ddlSousRouteStart : ddlSousRouteStop;
            TextBoxBase     mtxtChainageSelection = isStartMode ? mtxtChainageSelectionStart : mtxtChainageSelectionStop;

            IRtssc rtssc = null;
            AcquisitionTriggerMode triggerMode = GetSelectedTriggerMode(isStartMode);

            if (triggerMode == AcquisitionTriggerMode.Rtssc || triggerMode == AcquisitionTriggerMode.RtsscProximity || triggerMode == AcquisitionTriggerMode.EndSection)
            {
                var ValidateControl = new Func <RadDropDownList, bool>(ddlControl => ddlControl.SelectedIndex != -1 && ddlControl.SelectedValue.ToString() == ddlControl.Text);

                if (ValidateControl(ddlRoute) && ValidateControl(ddlTroncon) && ValidateControl(ddlSection) && ValidateControl(ddlSousRoute))
                {
                    double chainage;
                    if (!double.TryParse(mtxtChainageSelection.Text, out chainage))
                    {
                        chainage = 0;
                    }

                    rtssc = new Rtssc(
                        (string)ddlRoute.SelectedValue,
                        (string)ddlTroncon.SelectedValue,
                        (string)ddlSection.SelectedValue,
                        (string)ddlSousRoute.SelectedValue,
                        chainage: chainage);
                }
            }

            return(rtssc);
        }
        private async Task <IRtssc> GetNextRTSSCFromRTSS(IRtssc rtssc)
        {
            if (rtssc == null)
            {
                throw new ArgumentNullException("rtssc");
            }

            // By default, start at a 'chaînage' value equal to 5 to increase the probability
            // that the geoCoordinate returned when querying BGR is the one we are looking for.
            // Doing the inverse operation, i.e. the RTSS obtained from the geoCoordinate,
            // should be on the same 'tronçon/section' with approximately the same 'chaînage' value
            Rtssc rtsscTemp = new Rtssc(rtssc, 5);

            GeoCoordinate coord = await AgentBroker.Instance.TryExecuteOnFirst <IBgrDirectionalAgent, GeoCoordinate>(agent => agent.GeoCodage(rtsscTemp)).GetValueOrDefault(null);

            return(await AgentBroker.Instance.TryExecuteOnFirst <IBgrDirectionalAgent, IRtssc>(agent => agent.GetNextRtsscSameDirection(coord)).GetValueOrDefault(null));
        }