Esempio n. 1
0
        public void RouteSegment_ShouldSetInitialValues_OnConstruction()
        {
            var coord           = Convert.FromBase64String("23022322/3232022");
            var mrid            = Guid.Parse("053dc6c7-9210-4fbd-b564-f1357bcaf952");
            var username        = "******";
            var workTaskMrid    = Guid.Parse("8b97d7e6-7d45-4112-b3f3-2209fc3f27d5");
            var applicationName = "gdb-integrator";
            var applicationInfo = "Info text";
            var markAsDeleted   = false;

            var routeSegment = new RouteSegment
            {
                Coord           = coord,
                Mrid            = mrid,
                Username        = username,
                WorkTaskMrid    = workTaskMrid,
                ApplicationName = applicationName,
                ApplicationInfo = applicationInfo,
                MarkAsDeleted   = markAsDeleted,
            };

            using (new AssertionScope())
            {
                routeSegment.Coord.Should().BeEquivalentTo(coord);
                routeSegment.Mrid.Should().Be(mrid);
                routeSegment.Username.Should().Be(username);
                routeSegment.WorkTaskMrid.Should().Be(workTaskMrid);
                routeSegment.ApplicationName.Should().Be(applicationName);
                routeSegment.ApplicationInfo.Should().Be(applicationInfo);
                routeSegment.MarkAsDeleted.Should().Be(markAsDeleted);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the action context.
        /// </summary>
        /// <param name="method">The method.</param>
        /// <param name="ctrlCtx">The control context.</param>
        /// <returns></returns>
        protected virtual ActionContext GetActionContext(MethodInfo method, ControllerContext ctrlCtx)
        {
            string methodName   = method.Name.ToLowerInvariant();
            var    segmentsAttr = method.GetCustomAttribute <ActionRouteAttribute>();

            RouteSegment[] segments = new RouteSegment[0];
            if (!ctrlCtx.IsRestful)
            {
                segments = new[] { new RouteSegment(methodName) };
            }
            if (segmentsAttr != null)
            {
                segments = segmentsAttr.RouteSegments.ToArray();
            }

            var actionCtx = new ActionContext
            {
                HttpMethod       = GetHttpAttribute(method).Method,
                Method           = method,
                ParentController = ctrlCtx,
                RouteSegments    = segments
            };

            actionCtx.Parameters = _parameterDiscoverer.GetParameters(actionCtx);
            return(actionCtx);
        }
        public async Task Create_ShouldReturnRouteSegmentInfoUpdated_OnUpdatedSegmentInfo()
        {
            var geoDatabase = A.Fake <IGeoDatabase>();
            var before      = new RouteSegment();
            var after       = new RouteSegment
            {
                RouteSegmentInfo = new RouteSegmentInfo
                {
                    Height = "10",
                    Kind   = RouteSegmentKindEnum.Indoor,
                    Width  = "20"
                }
            };

            var factory = new RouteSegmentInfoCommandFactory(geoDatabase);
            var result  = await factory.Create(before, after);

            var infoUpdated = (RouteSegmentInfoUpdated)result.First();

            using (var scope = new AssertionScope())
            {
                result.Count().Should().Be(1);
                infoUpdated.RouteSegment.Should().BeEquivalentTo(after);
            }
        }
Esempio n. 4
0
        private void HandleEvent(RouteSegmentAdded request, ITransaction transaction)
        {
            _logger.LogDebug($"Handler got {request.GetType().Name} event seq no: {request.EventSequenceNumber}");

            if (AlreadyProcessed(request.EventId))
            {
                return;
            }


            if (!(_networkState.GetRouteNetworkElement(request.FromNodeId) is RouteNode fromNode))
            {
                _logger.LogError($"Route network event stream seems to be broken! RouteSegmentAdded event with id: {request.EventId} and segment id: {request.SegmentId} has a FromNodeId: {request.FromNodeId} that don't exists in the current state.");
                return;
            }


            if (!(_networkState.GetRouteNetworkElement(request.ToNodeId) is RouteNode toNode))
            {
                _logger.LogError($"Route network event stream seems to be broken! RouteSegmentAdded event with id: {request.EventId} and segment id: {request.SegmentId} has a ToNodeId: {request.ToNodeId} that don't exists in the current state.");
                return;
            }

            var routeSegment = new RouteSegment(request.SegmentId, request.Geometry, fromNode, toNode)
            {
                RouteSegmentInfo = request.RouteSegmentInfo,
                NamingInfo       = request.NamingInfo,
                MappingInfo      = request.MappingInfo,
                LifecycleInfo    = request.LifecyleInfo,
                SafetyInfo       = request.SafetyInfo
            };

            transaction.Add(routeSegment, ignoreDublicates: true);
        }
Esempio n. 5
0
        public void Create_ShouldReturnEnvelope_OnBeingPassedSingleRouteNodesAndSingleRouteSegments()
        {
            var routeSegment = new RouteSegment
            {
                Coord = Convert.FromBase64String("AQIAACDoZAAABgAAALx5ruNWRSFBsc8ScAykV0HZ6xJ8lEUhQYU+y98RpFdBILoYecJFIUEVfnDVB6RXQZH1zbVhRSFBTFhvegSkV0G/QerRbkUhQYWC7LEKpFdB/e8AFj1FIUG8d8O9BqRXQQ=="),
            };

            var routeNode = new RouteNode
            {
                Coord = Convert.FromBase64String("AQEAAAC8ea7jVkUhQbHPEnAMpFdB")
            };

            var routeNodes = new List <RouteNode> {
                routeNode
            };
            var routeSegments = new List <RouteSegment> {
                routeSegment
            };


            var envelopeFactory = new EnvelopeFactory();
            var result          = envelopeFactory.Create(routeNodes, routeSegments);


            using (var scope = new AssertionScope())
            {
                result.MinX.Should().Be(565918.5429759022);
                result.MaxX.Should().Be(565985.2365167774);
                result.MinY.Should().Be(6197265.913045954);
                result.MaxY.Should().Be(6197319.496780043);
            }
        }
Esempio n. 6
0
        public MappingInfoModified CreateMappingInfoModified(RouteSegment routeSegment)
        {
            if (routeSegment is null)
            {
                throw new ArgumentNullException($"{nameof(RouteNode)} cannot be passsed in as null.");
            }

            return(new MappingInfoModified(
                       nameof(MappingInfoModified),
                       Guid.NewGuid(),
                       DateTime.UtcNow,
                       routeSegment.ApplicationName,
                       routeSegment.ApplicationInfo,
                       routeSegment.Mrid,
                       ROUTE_SEGMENT,
                       new MappingInfo
            {
                HorizontalAccuracy = string.IsNullOrEmpty(routeSegment.MappingInfo?.HorizontalAccuracy) ? null : routeSegment.MappingInfo.HorizontalAccuracy,
                Method = routeSegment.MappingInfo?.Method,
                SourceInfo = string.IsNullOrEmpty(routeSegment.MappingInfo?.SourceInfo) ? null : routeSegment.MappingInfo.SourceInfo,
                SurveyDate = routeSegment.MappingInfo?.SurveyDate,
                VerticalAccuracy = string.IsNullOrEmpty(routeSegment.MappingInfo?.VerticalAccuracy) ? null : routeSegment.MappingInfo.VerticalAccuracy
            }
                       ));
        }
Esempio n. 7
0
        public void Import()
        {
            ImportResult = new ImportResult();
            if (BeginWork != null)
            {
                BeginWork(this, new EventArgs());
            }

            try
            {
                using (var stream = new FileStream(FileName, FileMode.Open, FileAccess.Read))
                {
                    using (var reader = new BinaryReader(stream))
                    {
                        var header = new Header(reader);
                        var data   = new Data(reader, header.DataSize);

                        // route
                        var routeSegment = new RouteSegment();
                        foreach (var w in data.Waypoints)
                        {
                            if (routeSegment.Waypoints.Count == 0 || routeSegment.LastWaypoint.Time < w.Time)
                            {
                                routeSegment.Waypoints.Add(new Waypoint(w.Time, new LongLat(w.Longitude, w.Latitude), w.Altitude, w.HeartRate, null));
                            }
                        }
                        ImportResult.Route = new Route(new List <RouteSegment>()
                        {
                            routeSegment
                        });

                        // laps
                        if (routeSegment.Waypoints.Count > 1)
                        {
                            ImportResult.Laps = new LapCollection();
                            ImportResult.Laps.Add(new Lap(routeSegment.FirstWaypoint.Time, LapType.Start));
                            foreach (var l in data.Laps)
                            {
                                if (l.Time > routeSegment.FirstWaypoint.Time && l.Time < routeSegment.LastWaypoint.Time)
                                {
                                    ImportResult.Laps.Add(new Lap(l.Time, LapType.Lap));
                                }
                            }
                            ImportResult.Laps.Add(new Lap(routeSegment.LastWaypoint.Time, LapType.Stop));
                        }

                        ImportResult.Succeeded = true;
                    }
                }
            }
            catch (Exception ex)
            {
                ImportResult.Exception = ex;
            }
            if (EndWork != null)
            {
                EndWork(this, new EventArgs());
            }
        }
Esempio n. 8
0
        private bool splitRoute(GENERIC_SYSTEM_PARAMETERS.ROUTES.ROUTE route)
        {
            if (null == route)
            {
                return(false);
            }
            int startSigID = route.Origin_Signal_ID;
            List <GENERIC_SYSTEM_PARAMETERS.BLOCKS.BLOCK> blkList = new List <GENERIC_SYSTEM_PARAMETERS.BLOCKS.BLOCK>();
            List <int> dstSigIDs = new List <int>();

            dstSigIDs.AddRange(route.Spacing_Signal_ID_List.Signal_ID.Cast <int>());
            dstSigIDs.Add(route.Destination_Signal_ID);
            foreach (int blkID in route.Block_ID_List.Block_ID)
            {
                var blk = (GENERIC_SYSTEM_PARAMETERS.BLOCKS.BLOCK)Sys.GetNode(blkID, Sydb.blockInfoList.Cast <Node>().ToList());

                int dstSigID = SyDB.GetSigIDInBlock(blkID, dstSigIDs);
                if (0 < dstSigID && dstSigIDs.Exists(x => x == dstSigID))
                {
                    List <GENERIC_SYSTEM_PARAMETERS.BLOCKS.BLOCK> newBlkList = new List <GENERIC_SYSTEM_PARAMETERS.BLOCKS.BLOCK>();
                    newBlkList.AddRange(blkList);
                    newBlkList.Add(blk);
                    try
                    {
                        RouteSegment split_rs = new RouteSegment(startSigID, dstSigID, newBlkList, route);

                        //update info for new split route
                        {
                            blkList.Clear();
                            dstSigIDs.Remove(dstSigID);
                            startSigID = dstSigID;
                        }

                        if (route.Origin_Signal_ID == split_rs.m_OrgSig.ID)//route_spacing signal route
                        {
                            AddNewRoute(false, split_rs);
                        }
                        else//spacing signal route
                        {
                            AddNewRoute(true, split_rs);
                        }
                    }
                    catch (Exception ex)
                    {
                        TraceMethod.RecordInfo(ex.Message);
                    }
                }
                else
                {
                    blkList.Add(blk);
                }
            }//end of foreach (int blkID in route.BlockIDList)
            if (0 != dstSigIDs.Count)
            {
                TraceMethod.RecordInfo($"route {route.Info} split error, some signal can't get splited route, such as signalID[{dstSigIDs[0]}]\n");
                return(false);
            }
            return(true);
        }
Esempio n. 9
0
 private bool AlreadyUpdated(RouteSegment after, RouteSegment shadowTableRouteSegment)
 {
     return(!IsNamingInfoModified(after, shadowTableRouteSegment) &&
            !IsMappingInfoModified(after, shadowTableRouteSegment) &&
            !IsLifecycleInfoModified(after, shadowTableRouteSegment) &&
            !IsRouteSegmentInfoModified(after, shadowTableRouteSegment) &&
            !IsSafetyInfoModified(after, shadowTableRouteSegment));
 }
        public void CreateNamingInfoModified_ShouldThrowArgumentNullException_OnBeingPassedNullRouteSegment()
        {
            var          modifiedEventFactory = new ModifiedEventFactory();
            RouteSegment routeSegment         = null;

            modifiedEventFactory
            .Invoking(x => x.CreateNamingInfoModified(routeSegment)).Should().Throw <ArgumentNullException>();
        }
Esempio n. 11
0
 /// <summary>
 /// Pusht das übergebene RouteSegment auf den route-Stack und aktualisiert die Kosten und Anzahl benötigter Spurwechsel
 /// </summary>
 /// <param name="rs">einzufügendes RouteSegment</param>
 public void Push(RouteSegment rs)
 {
     route.AddFirst(rs);
     costs += rs.costs;
     if (rs.lineChangeNeeded)
     {
         ++countOfLineChanges;
     }
 }
 private ExistingRouteSegmentSplitted CreateExistingRouteSegmentSplitted(RouteSegment routeSegment, RouteNode routeNode, bool insertRouteNode)
 {
     return(new ExistingRouteSegmentSplitted
     {
         RouteNode = routeNode,
         RouteSegmentDigitizedByUser = routeSegment,
         InsertNode = insertRouteNode
     });
 }
Esempio n. 13
0
        private bool IsSafetyInfoModified(RouteSegment before, RouteSegment after)
        {
            if (before.SafetyInfo?.Classification != after.SafetyInfo?.Classification ||
                before.SafetyInfo?.Remark != after.SafetyInfo?.Remark)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 14
0
        private bool IsNamingInfoModified(RouteSegment before, RouteSegment after)
        {
            if (before.NamingInfo?.Description != after.NamingInfo?.Description ||
                before.NamingInfo?.Name != after.NamingInfo?.Name)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 15
0
        private bool IsRouteSegmentInfoModified(RouteSegment before, RouteSegment after)
        {
            if (before.RouteSegmentInfo?.Height != after.RouteSegmentInfo?.Height ||
                before.RouteSegmentInfo?.Kind != after.RouteSegmentInfo?.Kind ||
                before.RouteSegmentInfo?.Width != after.RouteSegmentInfo?.Width)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 16
0
        private bool IsLifecycleInfoModified(RouteSegment before, RouteSegment after)
        {
            if (before.LifeCycleInfo?.DeploymentState != after.LifeCycleInfo?.DeploymentState ||
                before.LifeCycleInfo?.InstallationDate != after.LifeCycleInfo?.InstallationDate ||
                before.LifeCycleInfo?.RemovalDate != after.LifeCycleInfo?.RemovalDate)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 17
0
 public RouteSegmentTest()
 {
     this.segment = new RouteSegment(
         "FOO",
         new Point("BIG"),
         new Point("LAM"),
         DefinitionFactory.Make(),
         DocblockFactory.Make(),
         CommentFactory.Make()
         );
 }
        public void Import()
        {
            _importResult = new ImportResult();
            if (BeginWork != null)
            {
                BeginWork(this, new EventArgs());
            }

            // The trackpoints
            var      routeSegments = new List <RouteSegment>();
            var      rs            = new RouteSegment();
            var      current       = 0;
            var      total         = _trackToImport.GetTrackInfo().NumbetOfTrackPoints;
            var      elapsedTimes  = new List <double>();
            DateTime startTime     = DateTime.MinValue;

            foreach (var tp in _trackToImport.GetTrackPoints())
            {
                var waypoint = new Waypoint
                {
                    Time     = tp.Time,
                    LongLat  = new LongLat((double)tp.Longitude, (double)tp.Latitude),
                    Altitude = tp.Altitude
                };

                if (tp.HasMark(RegSEPointType.WayPoint))
                {
                    elapsedTimes.Add((tp.Time - startTime).TotalSeconds);
                }

                rs.Waypoints.Add(waypoint);
                current++;
                if (WorkProgress != null && current % 10 == 0)
                {
                    WorkProgress(this, new WorkProgressEventArgs((double)current / total));
                }
            }
            if (rs.Waypoints.Count > 0)
            {
                routeSegments.Add(rs);
            }
            _importResult.Route = new Route(routeSegments);

            // create one lap (from start to finish)
            LapCollection laps = RouteImporterUtil.CreateLapsFromElapsedTimes(startTime, elapsedTimes, routeSegments);

            _importResult.Laps = laps;

            _importResult.Succeeded = true;
            if (EndWork != null)
            {
                EndWork(this, new EventArgs());
            }
        }
Esempio n. 19
0
        public void GetLineString_ShouldReturnLineString_OnBeingPassedLineString()
        {
            var routeSegment = new RouteSegment
            {
                Coord = Convert.FromBase64String("AQIAACDoZAAAAgAAAEu6uBZURSFBSjSrSRikV0HVZEzDYkUhQZKMQUgZpFdB")
            };

            var result = routeSegment.GetLineString();

            result.AsText().Should().BeEquivalentTo("LINESTRING (565930.04437811056 6197345.1510744784, 565937.381442214 6197349.1290008)");
        }
Esempio n. 20
0
        public void GetGeoJsonCoordinate_ShouldReturnGeoJsonCoordinate_OnBeingCalled(string coord, string expected)
        {
            var routeSegment = new RouteSegment
            {
                Coord = Convert.FromBase64String(coord),
            };

            var geoJson = routeSegment.GetGeoJsonCoordinate();

            geoJson.Should().BeEquivalentTo(expected);
        }
        private static bool IsAdjacent(RouteSegment segment1, RouteSegment segment2, long versionId)
        {
            foreach (var neighboor in segment1.NeighborElements(versionId))
            {
                if (neighboor.NeighborElements(versionId).Contains(segment2))
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 22
0
        public RouteSegmentMarkedForDeletion CreateMarkedForDeletion(RouteSegment routeSegment, bool useApplicationName = false)
        {
            _modifiedGeometries.InsertRouteSegment(routeSegment);

            return(new RouteSegmentMarkedForDeletion(
                       nameof(RouteSegmentMarkedForDeletion),
                       Guid.NewGuid(),
                       DateTime.UtcNow,
                       useApplicationName ? _applicationSettings.ApplicationName : routeSegment?.ApplicationName,
                       routeSegment.ApplicationInfo,
                       routeSegment.Mrid));
        }
Esempio n. 23
0
        public void Deserialize_ShouldReturnDeserializedSegmentMessage_(string fileData)
        {
            var serializationMapper    = A.Fake <IInfoMapper>();
            var routeSegmentSerializer = new RouteNetworkSerializer(serializationMapper);

            var position = new Position(string.Empty, 0, 0);
            var headers  = new Dictionary <string, string>();
            var body     = Encoding.UTF8.GetBytes(fileData);

            var receivedTransportMessage = new ReceivedTransportMessage(position, headers, body);

            var expectedRouteSegmentBefore = new RouteSegment
            {
                Mrid             = new Guid("57fb87f5-093c-405d-b619-755e3f39073f"),
                Coord            = Convert.FromBase64String("AQIAACDoZAAAAgAAAO79HyV51h/B6DWfEXKJVEGgwmxDUMkfwXuWw252iVRB"),
                WorkTaskMrid     = Guid.Empty,
                ApplicationName  = string.Empty,
                Username         = string.Empty,
                MarkAsDeleted    = false,
                ApplicationInfo  = string.Empty,
                DeleteMe         = false,
                LifeCycleInfo    = null,
                MappingInfo      = null,
                NamingInfo       = null,
                RouteSegmentInfo = null,
                SafetyInfo       = null
            };

            var expectedRouteSegmentAfter = new RouteSegment
            {
                Mrid             = new Guid("57fb87f5-093c-405d-b619-755e3f39073f"),
                Coord            = null,
                WorkTaskMrid     = Guid.Empty,
                ApplicationName  = string.Empty,
                Username         = string.Empty,
                MarkAsDeleted    = true,
                ApplicationInfo  = string.Empty,
                DeleteMe         = false,
                LifeCycleInfo    = null,
                MappingInfo      = null,
                NamingInfo       = null,
                RouteSegmentInfo = null,
                SafetyInfo       = null
            };

            var expectedBody           = new RouteSegmentMessage(expectedRouteSegmentBefore, expectedRouteSegmentAfter);
            var expectedInvalidMessage = new InvalidMessage(expectedBody);

            var expected = new ReceivedLogicalMessage(headers, expectedInvalidMessage, position);
            var result   = routeSegmentSerializer.Deserialize(receivedTransportMessage);

            result.Should().BeEquivalentTo(expected);
        }
        private RouteNode FindSharedNode(RouteSegment segment1, RouteSegment segment2, long versionId)
        {
            foreach (var neighborNode in segment1.NeighborElements(versionId))
            {
                if (segment2.NeighborElements(versionId).Contains(neighborNode))
                {
                    return((RouteNode)neighborNode);
                }
            }

            throw new ApplicationException("FindSharedNode should never be called on an unvalidated pair of segments.");
        }
Esempio n. 25
0
        private bool IsMappingInfoModified(RouteSegment before, RouteSegment after)
        {
            if (before.MappingInfo?.HorizontalAccuracy != after.MappingInfo?.HorizontalAccuracy ||
                before.MappingInfo?.Method != after.MappingInfo?.Method ||
                before.MappingInfo?.SourceInfo != after.MappingInfo?.SourceInfo ||
                before.MappingInfo?.SurveyDate != after.MappingInfo?.SurveyDate ||
                before.MappingInfo?.VerticalAccuracy != after.MappingInfo?.VerticalAccuracy)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 26
0
        public RouteSegmentGeometryModified CreateGeometryModified(RouteSegment routeSegment, bool useApplicationName = false)
        {
            _modifiedGeometries.InsertRouteSegment(routeSegment);

            return(new RouteSegmentGeometryModified(
                       nameof(RouteSegmentGeometryModified),
                       Guid.NewGuid(),
                       DateTime.UtcNow,
                       useApplicationName ? _applicationSettings.ApplicationName : routeSegment?.ApplicationName,
                       routeSegment?.ApplicationInfo,
                       routeSegment.Mrid,
                       routeSegment.GetGeoJsonCoordinate()));
        }
Esempio n. 27
0
        public RouteSegmentRemoved CreateRemoved(RouteSegment routeSegment, IEnumerable <Guid> replacedBySegments, bool useApplicationName = false)
        {
            _modifiedGeometries.InsertRouteSegment(routeSegment);

            return(new Events.RouteNetwork.RouteSegmentRemoved(
                       nameof(Events.RouteNetwork.RouteSegmentRemoved),
                       Guid.NewGuid(),
                       DateTime.UtcNow,
                       useApplicationName ? _applicationSettings.ApplicationName : routeSegment?.ApplicationName,
                       routeSegment?.ApplicationInfo,
                       routeSegment.Mrid,
                       replacedBySegments.ToArray()));
        }
Esempio n. 28
0
        private void btnRollback_Click(object sender, EventArgs e)
        {
            ClearRoadOverlay();

            // Recover the route segment information
            if (routingSource.IsInTransaction)
            {
                routingSource.Open();
                routingSource.RollbackTransaction();
                editRouteSegment = routingSource.GetRouteSegmentByFeatureId(editFeature.Id);
                isInEditMode     = true;
            }
        }
Esempio n. 29
0
        public void Import()
        {
            _importResult = new ImportResult();
            if (BeginWork != null)
            {
                BeginWork(this, new EventArgs());
            }

            // The trackpoints
            var routeSegments = new List <RouteSegment>();
            var rs            = new RouteSegment();
            var current       = 0;
            var total         = _trackToImport.TrackPointsCount;
            var track         = _gsGH615MReader.GetTrack(_trackToImport);

            foreach (var tp in track.GetTrackPoints())
            {
                var waypoint = new Waypoint
                {
                    Time      = tp.Time,
                    LongLat   = new LongLat((double)tp.Longitude, (double)tp.Latitude),
                    Altitude  = tp.Altitude,
                    HeartRate = tp.Pulse
                };

                rs.Waypoints.Add(waypoint);
                current++;
                if (WorkProgress != null && current % 10 == 0)
                {
                    WorkProgress(this, new WorkProgressEventArgs((double)current / total));
                }
            }
            if (rs.Waypoints.Count > 0)
            {
                routeSegments.Add(rs);
            }
            _importResult.Route = new Route(routeSegments);

            // create one lap (from start to finish)
            DateTime      startTime = DateTime.MinValue;
            LapCollection laps      = RouteImporterUtil.CreateLapsFromElapsedTimes(startTime, new List <double>(), routeSegments);

            _importResult.Laps = laps;

            _importResult.Succeeded = true;
            if (EndWork != null)
            {
                EndWork(this, new EventArgs());
            }
        }
        /**
         * Process an individual SID/STARs worth of lines
         */
        private void ProcessSidStar(List <SectorData> lines)
        {
            // Get the name out and remove it from the array
            int firstLineFirstCoordinateIndex = this.GetFirstPointIndex(lines[0]);

            if (firstLineFirstCoordinateIndex == -1)
            {
                this.errorLog.AddEvent(
                    new SyntaxError("Invalid SID/STAR route segment coordinates", lines[0])
                    );
                return;
            }

            string sidStarName = string.Join(" ", lines[0].dataSegments.GetRange(0, firstLineFirstCoordinateIndex));

            lines[0].dataSegments.RemoveRange(0, firstLineFirstCoordinateIndex);
            List <RouteSegment> segments = new List <RouteSegment>();


            for (int i = 0; i < lines.Count; i++)
            {
                segments.Add(
                    new RouteSegment(
                        sidStarName,
                        PointParser.Parse(lines[i].dataSegments[0], lines[i].dataSegments[1]),
                        PointParser.Parse(lines[i].dataSegments[2], lines[i].dataSegments[3]),
                        lines[i].definition,
                        lines[i].docblock,
                        lines[i].inlineComment,
                        lines[i].dataSegments.Count == 5 ? lines[i].dataSegments[4] : null
                        )
                    );
            }

            RouteSegment initialSegment = segments.ElementAt(0);

            segments.RemoveAt(0);

            this.sectorElements.Add(
                new SidStarRoute(
                    this.Type,
                    sidStarName,
                    initialSegment,
                    segments,
                    lines[0].definition,
                    lines[0].docblock,
                    lines[0].inlineComment
                    )
                );
        }
        public void Import()
        {
            _importResult = new ImportResult();
              if (BeginWork != null) BeginWork(this, new EventArgs());

              // The trackpoints
              var routeSegments = new List<RouteSegment>();
              var rs = new RouteSegment();
              var current = 0;
              var total = _trackToImport.GetTrackInfo().NumbetOfTrackPoints;
              var elapsedTimes = new List<double>();
              DateTime startTime = DateTime.MinValue;
              foreach (var tp in _trackToImport.GetTrackPoints())
              {
            var waypoint = new Waypoint
                           {
                             Time = tp.Time,
                             LongLat = new LongLat((double)tp.Longitude, (double)tp.Latitude),
                             Altitude = tp.Altitude
                           };

            if (tp.HasMark(RegSEPointType.WayPoint))
            {
              elapsedTimes.Add((tp.Time - startTime).TotalSeconds);
            }

            rs.Waypoints.Add(waypoint);
            current++;
            if (WorkProgress != null && current % 10 == 0)
            {
              WorkProgress(this, new WorkProgressEventArgs((double)current / total));
            }
              }
              if (rs.Waypoints.Count > 0)
              {
            routeSegments.Add(rs);
              }
              _importResult.Route = new Route(routeSegments);

              // create one lap (from start to finish)
              LapCollection laps = RouteImporterUtil.CreateLapsFromElapsedTimes(startTime, elapsedTimes, routeSegments);
              _importResult.Laps = laps;

              _importResult.Succeeded = true;
              if (EndWork != null) EndWork(this, new EventArgs());
        }
        public void Import()
        {
            _importResult = new ImportResult();
            if (BeginWork != null) BeginWork(this, new EventArgs());

            // The trackpoints
            var routeSegments = new List<RouteSegment>();
            var rs = new RouteSegment();
            var current = 0;
            var total = _trackToImport.TrackPointsCount;
            var track = _gsGH615MReader.GetTrack(_trackToImport);

            foreach (var tp in track.GetTrackPoints())
            {
                var waypoint = new Waypoint
                   {
                       Time = tp.Time,
                       LongLat = new LongLat((double) tp.Longitude, (double) tp.Latitude),
                       Altitude = tp.Altitude,
                       HeartRate = tp.Pulse
                   };

                rs.Waypoints.Add(waypoint);
                current++;
                if (WorkProgress != null && current % 10 == 0)
                {
                    WorkProgress(this, new WorkProgressEventArgs((double)current / total));
                }
            }
            if (rs.Waypoints.Count > 0)
            {
                routeSegments.Add(rs);
            }
            _importResult.Route = new Route(routeSegments);

            // create one lap (from start to finish)
            DateTime startTime = DateTime.MinValue;
            LapCollection laps = RouteImporterUtil.CreateLapsFromElapsedTimes(startTime, new List<double>(), routeSegments);
            _importResult.Laps = laps;

            _importResult.Succeeded = true;
            if (EndWork != null) EndWork(this, new EventArgs());
        }