Exemplo n.º 1
0
 private RoutingStepBuilder(string destinationPath)
 {
     _destinationStep = new RoutingStep()
     {
         DestinationPath = destinationPath
     };
 }
Exemplo n.º 2
0
        public RoutingStepBuilder WithCompensatingStep(string destinationPath)
        {
            _compensationStep = new RoutingStep()
            {
                DestinationPath = destinationPath
            };

            return(this);
        }
Exemplo n.º 3
0
        private RoutingPath getRoutingPathFromDataGraphItems(ApplicationDbContext db, Point3D source, Point3D target, IEnumerable <GraphDataItem> result, bool isAllEdges)
        {
            RoutingPath toReturn = new RoutingPath {
                Routingsteps = new List <RoutingStep>(), Source = source, Destination = target
            };

            foreach (var step in result)
            {
                Point3D       from = null;
                LineStringDTO ls   = db.LineStrings.ToList().Where(x => x.Id == step.EdgeID).FirstOrDefault();

                RoutingStep next = new RoutingStep();
                if (ls != null)
                {
                    // if (ls.connectorType != ConnectorType.PATH)
                    //   System.Diagnostics.Debugger.Break();
                    next = ls.toGeneric().toRoutingStep();
                }
                if (step.SourceVertexID == source.Id | step.SourceVertexID == target.Id)
                {
                    //step.EdgeID == sourceToNearestPath.Id ? lineDTO = sourceToNearestPath.toDTO() : lineDTO = targetToNearestPath.toDTO();
                    from = step.SourceVertexID == source.Id ? source : target;
                }
                else
                {
                    from = db.Points.Find(step.SourceVertexID);
                }
                Point3D to = null;
                if (step.TargetVertexID == source.Id | step.TargetVertexID == target.Id)
                {
                    //step.EdgeID == sourceToNearestPath.Id ? lineDTO = sourceToNearestPath.toDTO() : lineDTO = targetToNearestPath.toDTO();
                    to = step.TargetVertexID == source.Id ? source : target;
                }
                else
                {
                    to = db.Points.Find(step.TargetVertexID);
                }
                //Point3D to = db.Points.Find(step.TargetVertexID);
                //Point3D from = pathPoints.Where(x => x.Id == step.TargetVertexID).FirstOrDefault();
                //Point3D to = pathPoints.Where(x=>x.Id == step.TargetVertexID).FirstOrDefault();
                if (from == null | to == null)
                {
                    System.Diagnostics.Debugger.Break();
                }
                //LineStringDTO lineDTO = null;
                //if (step.EdgeID == sourceToNearestPath.Id | step.EdgeID == targetToNearestPath.Id)
                //{
                //    //step.EdgeID == sourceToNearestPath.Id ? lineDTO = sourceToNearestPath.toDTO() : lineDTO = targetToNearestPath.toDTO();
                //    lineDTO = step.EdgeID == sourceToNearestPath.Id ? sourceToNearestPath.toDTO() : targetToNearestPath.toDTO();
                //}
                //else
                //    lineDTO = db.LineStrings.Find(step.EdgeID);
                //totalPath2.Routingsteps.Add(lineDTO.toGeneric().toRoutingStep());
                //RoutingStep next = null;
                if (toReturn.Routingsteps.Count == 0)
                {
                    if (step.SourceVertexID == source.Id)
                    {
                        next.setSourceTargetDistance(from, to, step.Cost);
                    }
                    else if (step.TargetVertexID == source.Id)
                    {
                        next.setSourceTargetDistance(to, from, step.Cost);
                    }
                    else
                    if (isAllEdges)
                    {
                        next.setSourceTargetDistance(from, to, step.Cost);
                    }
                }
                else
                {
                    if (step.SourceVertexID == toReturn.Routingsteps[toReturn.Routingsteps.Count - 1].Destination.Id)
                    {
                        next.setSourceTargetDistance(from, to, step.Cost);
                    }
                    else if (step.TargetVertexID == toReturn.Routingsteps[toReturn.Routingsteps.Count - 1].Destination.Id)
                    {
                        next.setSourceTargetDistance(to, from, step.Cost);
                    }
                    else
                    if (isAllEdges)
                    {
                        next.setSourceTargetDistance(from, to, step.Cost);
                    }
                }
                toReturn.Routingsteps.Add(next);
                toReturn.Distance += step.Cost;
            }
            return(toReturn);
        }