Exemplo n.º 1
0
 public void SaveRoute(Route route)
 {
       CreateUserEnum  result =  TDS.DAL.RoutesDB.SaveRoute(route);            
 }
Exemplo n.º 2
0
        public  async Task<typRoute> CreateRoute(double StartX, double StartY, double ReferencePointX, double ReferencePointY, string RouteGuid)
        {

            try
            {
                List<DPoint> Result = new List<DPoint>();

                Route route = TDS.DAL.RoutesDB.GetRouteByGuid(RouteGuid);
                DPoint ReferPoint = new DPoint(ReferencePointX, ReferencePointY);

                shPath Path = await clsRoadRoutingWebApi.FindShortPath("0", StartX, StartY, ReferencePointX, ReferencePointY, false);
                if (Path != null && Path.Points.Count > 0)
                {
                    shPoint refPoint = Path.Points[Path.Points.Count - 1];
                    ReferPoint = new DPoint(refPoint.x, refPoint.y);
                   
                    foreach(shPoint p in Path.Points)
                    {
                        Result.Add(new DPoint(p.x, p.y));
                    }

                }

                if(Result.Count==0)
                {
                    Result.Add(new DPoint(StartX, StartY));
                }
                else
                {
                    if (Result[0].x != StartX || Result[0].y != StartY)
                    {
                        Result.Insert(0, new DPoint(StartX, StartY));
                    }
                }

                int leg = 0;
                DPoint minP = null;
                double mainDist = double.MaxValue;
                int i = -1;
                foreach (DPoint p in route.Points)
                {
                    i++;
                   // double dist = MathEngine.CalcDistanceForCompare(ReferPoint.x, ReferPoint.y, p.x, p.y);
                    double dist = MathEngine.GreatCircleDistance(ReferPoint.x, ReferPoint.y, p.x, p.y);
                    if (dist < mainDist)
                    {
                        mainDist = dist;
                        minP = p;
                        leg = i;
                    }
                }
                if(mainDist!=0.0)
                {
                    List<DPoint> R = route.Points.ToList<DPoint>().GetRange(leg, route.Points.Count() - leg);
                    Result.AddRange(R);
                }
                else
                {
                    if(leg<route.Points.Count()-1) // Not Last element
                    {
                        List<DPoint> R = route.Points.ToList<DPoint>().GetRange(leg+1, route.Points.Count() - (leg+1));
                        Result.AddRange(R);
                    }
                }

                Route routeResult = new Route();
                routeResult.Points = Result;


                typRoute tRoute = new typRoute(routeResult);
                return tRoute;
            }
            catch(Exception ex)
            {

            }

          

            return null;
        }
Exemplo n.º 3
0
        public typRoute(Route pathpoints)
        {
            arr_legs = new List<typLegSector>();

            
            DPoint[] points = pathpoints.Points.ToArray<DPoint>();

            for (int i = 0; i < points.Length-1; i++)
            {
                typLegSector leg = new typLegSector();
                leg.FromLongn = points[i].x;
                leg.FromLatn = points[i].y;
                leg.ToLongn = points[i+1].x;
                leg.ToLatn = points[i+1].y;
                leg.LegDistance = (float)TerrainService.MathEngine.CalcDistance(leg.FromLongn, leg.FromLatn, leg.ToLongn, leg.ToLatn) / 1000f;
                if (leg.LegDistance == 0.0)
                {
                    continue;
                }
                arr_legs.Add(leg);
            }
        } 
Exemplo n.º 4
0
		// Yinon Douchan: Only find the shortest path between two points.
        public async Task<typRoute> createRouteByShortestPathOnly(double StartX, double StartY, double ReferencePointX, double ReferencePointY)
        {
            List<DPoint> Result = new List<DPoint>();

            DPoint ReferPoint = new DPoint(ReferencePointX, ReferencePointY);
            shPath Path = await clsRoadRoutingWebApi.FindShortPath("0", StartX, StartY, ReferencePointX, ReferencePointY, false);

            if (Path != null && Path.Points.Count > 0)
            {
                shPoint refPoint = Path.Points[Path.Points.Count - 1];
                ReferPoint = new DPoint(refPoint.x, refPoint.y);

                foreach (shPoint p in Path.Points)
                {
                    Result.Add(new DPoint(p.x, p.y));
                }

            }

            if (Result.Count == 0)
            {
                Result.Add(new DPoint(StartX, StartY));
            }
            else
            {
                if (Result[0].x != StartX || Result[0].y != StartY)
                {
                    Result.Insert(0, new DPoint(StartX, StartY));
                }
            }

            Route routeResult = new Route();
            routeResult.Points = Result;


            typRoute tRoute = new typRoute(routeResult);

            return tRoute;
        }