예제 #1
0
        public void Split(Guid nodeId, IRouteNetworkState routeQueryService)
        {
            var segmentInfo = routeQueryService.GetRouteSegmentInfo(this.Id);

            var nodeInfo = routeQueryService.GetRouteNodeInfo(nodeId);

            // Check that split node is close enough to the segment to be splitted
            var line = ConvertFromLineGeoJson(segmentInfo.Geometry.GeoJsonCoordinates);

            var nodePoint = ConvertFromPointGeoJson(nodeInfo.Geometry.GeoJsonCoordinates);

            var test = line.Distance(nodePoint);

            if (test > 0.000001)
            {
                throw new ArgumentException("Coordinate of node used for splitting the segment is not within allowed distance to segment. The distance is greather than 0.000001 decimal degress (around 5-10 cm) which is not allowed.");
            }

            PlannedRouteSegmentSplitByNode segmentSplitEvent = new PlannedRouteSegmentSplitByNode()
            {
                Id = this.Id, SplitNodeId = nodeId
            };

            RaiseEvent(segmentSplitEvent);
        }
예제 #2
0
        public void SplitRouteSegment(Guid routeSegmentId, Guid splittingNodeId)
        {
            // Id check
            if (routeSegmentId == null || routeSegmentId == Guid.Empty)
            {
                throw new ArgumentException("Id cannot be null or empty");
            }

            // Check that segment exists
            if (!routeNetworkState.CheckIfRouteSegmentIdExists(routeSegmentId))
            {
                throw new ArgumentException("Cannot find any segment in the network with id:" + routeSegmentId);
            }

            // Check that node exists
            if (!routeNetworkState.CheckIfRouteNodeIdExists(splittingNodeId))
            {
                throw new ArgumentException("Cannot find any node in the network with id: " + splittingNodeId);
            }

            var segmentInfo = routeNetworkState.GetRouteSegmentInfo(routeSegmentId);

            var nodeInfo = routeNetworkState.GetRouteNodeInfo(splittingNodeId);

            // Check that split node is close enough to the segment to be splitted
            var line = GeometryConversionHelper.ConvertFromLineGeoJson(segmentInfo.Geometry.GeoJsonCoordinates);

            var nodePoint = GeometryConversionHelper.ConvertFromPointGeoJson(nodeInfo.Geometry.GeoJsonCoordinates);

            var test = line.Distance(nodePoint);

            if (test > 0.000001)
            {
                throw new ArgumentException("Coordinate of node used for splitting the segment is not within allowed distance to segment. The distance is greather than 0.000001 decimal degress (around 5-10 cm) which is not allowed.");
            }

            PlannedRouteSegmentSplitByNode segmentSplitEvent = new PlannedRouteSegmentSplitByNode()
            {
                Id = routeSegmentId, SplitNodeId = splittingNodeId
            };

            RaiseEvent(segmentSplitEvent, false);
        }
예제 #3
0
 private void Apply(PlannedRouteSegmentSplitByNode @event)
 {
 }