Exemple #1
0
        // Collect waypoints for all the controls of a certain kind.
        // The code prefix is used for controls without a code set (like start/finish)
        private void CollectWaypointsOfKind(List<Waypoint> waypointList, ControlPointKind controlKind, string noCodeName, WaypointKind kind)
        {
            int noCodeSuffix = 1;

            foreach (Id<ControlPoint> controlId in eventDB.AllControlPointIds) {
                ControlPoint control = eventDB.GetControl(controlId);
                if (IncludeControl(controlId) && control.kind == controlKind) {
                    // Get the name.
                    string name = control.code;
                    if (string.IsNullOrEmpty(name))
                        name = noCodeName + (noCodeSuffix++).ToString();
                    name = settings.CodePrefix + name;

                    // Get the latitude and longitude.
                    double latitude, longitude;
                    if (!coordinateMapper.GetLatLong(control.location, out latitude, out longitude) ||
                        double.IsNaN(latitude) || double.IsNaN(longitude))
                    {
                        throw new Exception(MiscText.GpxReprojectFailure);
                    }
                    // Create a waypoint.
                    Waypoint wp = new Waypoint() { Name = name, Kind = kind, Latitude = latitude, Longitude = longitude };
                    waypointList.Add(wp);
                    waypoints[controlId] = wp;
                }
            }
        }
Exemple #2
0
        // Collect waypoints for all the controls of a certain kind.
        // The code prefix is used for controls without a code set (like start/finish)
        private void CollectWaypointsOfKind(List <Waypoint> waypointList, ControlPointKind controlKind, string noCodeName, WaypointKind kind)
        {
            int noCodeSuffix = 1;

            foreach (Id <ControlPoint> controlId in eventDB.AllControlPointIds)
            {
                ControlPoint control = eventDB.GetControl(controlId);
                if (IncludeControl(controlId) && control.kind == controlKind)
                {
                    // Get the name.
                    string name = control.code;
                    if (string.IsNullOrEmpty(name))
                    {
                        name = noCodeName + (noCodeSuffix++).ToString();
                    }
                    name = settings.CodePrefix + name;

                    // Get the latitude and longitude.
                    double latitude, longitude;
                    if (!coordinateMapper.GetLatLong(control.location, out latitude, out longitude) ||
                        double.IsNaN(latitude) || double.IsNaN(longitude))
                    {
                        throw new Exception(MiscText.GpxReprojectFailure);
                    }
                    // Create a waypoint.
                    Waypoint wp = new Waypoint()
                    {
                        Name = name, Kind = kind, Latitude = latitude, Longitude = longitude
                    };
                    waypointList.Add(wp);
                    waypoints[controlId] = wp;
                }
            }
        }