/// <summary>
        /// Analyzes a lane to find the closest point to the coordinate passed in
        /// </summary>
        /// <param name="coordinate">coordinate to analyze the lane against</param>
        /// <param name="lane">lane to reference the coordinate to</param>
        /// <returns>vector consisting of relative and absolute rndf localization information</returns>
        public static LocationAnalysis ClosestPartitionOnLane(Coordinates coordinate, LaneID laneId, RndfNetwork rndfNetwork)
        {
            // get the lane
            Lane lane = rndfNetwork.Segments[laneId.WayID.SegmentID].Ways[laneId.WayID].Lanes[laneId];

            // set the value to return
            LocationAnalysis closest = null;

            // values for comparing partitions
            double offsetMin = Double.MaxValue;

            // iterate over lanePartitions within the lane
            foreach (LanePartition lanePartition in lane.LanePartitions)
            {
                // if there are user partitions, operate over them
                if (lanePartition.UserPartitions != null && lanePartition.UserPartitions.Count > 1)
                {
                    foreach (UserPartition userPartiton in lanePartition.UserPartitions)
                    {
                        throw new Exception("user partition relation to vehicle absolute coordinates not implemented yet");
                    }
                }
                // otherwise look at how close lane partition is
                else
                {
                    // analyze the partition
                    LocationAnalysis partitionAnalysis = AnalyzePartition(coordinate, (IWaypoint)lanePartition.InitialWaypoint, (IWaypoint)lanePartition.FinalWaypoint);

                    // if this partition has less of an offset from the vehicle than the current best, set as current
                    if (partitionAnalysis.Offset < offsetMin)
                    {
                        offsetMin = partitionAnalysis.Offset;
                        closest   = partitionAnalysis;

                        // set partition of result
                        closest.Partition = lanePartition;
                    }
                    // otherwise, if the vehicle is relatively close to this partition
                    // and the closest Coordinates are not those of the initial final waypoitns of the lane
                    // and this error is less than the current best offset
                    else if (partitionAnalysis.Offset == 1234567 &&
                             (partitionAnalysis.RelativeRndfPosition != lane.LanePartitions[0].InitialWaypoint.Position) &&
                             (partitionAnalysis.RelativeRndfPosition != lane.LanePartitions[lane.LanePartitions.Count - 1].FinalWaypoint.Position) &&
                             (partitionAnalysis.Error < offsetMin))
                    {
                        offsetMin = partitionAnalysis.Error;
                        closest   = partitionAnalysis;

                        // set partition of result
                        closest.Partition = lanePartition;
                    }
                }
            }

            // return closest value found
            return(closest);
        }
Beispiel #2
0
    static void Main(string[] args)
    {
        //RemoveSerialization();

        if (args.Length > 0)
        {
            s_ExistingContracts = args[0];
        }

        //s_ExistingContracts = @"C:\Users\Krzysztof\Desktop\ExistingContracts";

        if (!Directory.Exists(s_ExistingContracts))
        {
            WriteMessage(ConsoleColor.Red, "Existing contract folder {0} does not exist", s_ExistingContracts);
        }
        else
        {
            FxRedist redist;
            using (var reportWriter = new ReportWriter(s_ReportPath)) {
                if (RefactorAssemblies(reportWriter, out redist))
                {
                    if (s_ExistingContracts != null)
                    {
                        LocationAnalysis.CompareFactorings(s_ExistingContracts, s_OutputDlls, reportWriter);
                    }
                }

                // Orphaned types are types in the specifications that don't exist in master source.
                PrintOrphanedTypes(redist, reportWriter);

                if (redist.Leftover.Count > 0)
                {
                    reportWriter.WriteListStart("TYPES_NOT_IN_ANY_ASSEMBLY", "total", redist.Leftover.CountOfTypes, "description", "types that are not in specification files");

                    foreach (var ns in redist.Leftover)
                    {
                        var nsName = ns.Key;
                        foreach (var type in ns.Value)
                        {
                            reportWriter.WriteListItem(type.Symbol.GetDocumentationCommentId().Substring(2));
                        }
                    }
                    reportWriter.WriteListEnd();
                }

                AnalyzeLayers(redist, reportWriter);
            }
        }

        if (args.Length == 0)
        {
            Console.WriteLine("\nPress ENTER to exit ...");
            Console.ReadLine();
        }
    }
Beispiel #3
0
        public void TestGetDistanceKm()
        {
            var result = LocationAnalysis.GetDistanceKm(
                new Location(20, 20),
                new Location(20, 20));

            Assert.IsFalse(result != 0);

            result = LocationAnalysis.GetDistanceKm(
                new Location(20, 20),
                new Location(20, 20));
            Assert.IsTrue(result == 0);
        }
Beispiel #4
0
        public void TestAreMeeting()
        {
            var result = LocationAnalysis.AreMeeting(new WhereWhen(20, 20, DateTime.Now),
                                                     new WhereWhen(20, 20, DateTime.Now),
                                                     1, new TimeSpan(10000));

            Assert.IsTrue(result);

            result = LocationAnalysis.AreMeeting(new WhereWhen(20, 20, DateTime.Now),
                                                 new WhereWhen(10, 10, DateTime.Now),
                                                 1, new TimeSpan(10000));
            Assert.IsFalse(result);

            result = LocationAnalysis.AreMeeting(new WhereWhen(20, 20, DateTime.Now),
                                                 new WhereWhen(20, 20, DateTime.Now.AddDays(1)),
                                                 1, new TimeSpan(10000));
            Assert.IsFalse(result);
        }
        /// <summary>
        /// gets position on a generic partition
        /// </summary>
        /// <param name="coordinate"></param>
        /// <param name="laneParition"></param>
        /// <returns></returns>
        private static LocationAnalysis getPartitionState(Coordinates coordinate, IConnectWaypoints lanePartition)
        {
            // analyze the partition
            LocationAnalysis partitionAnalysis = AnalyzePartition(coordinate, (IWaypoint)lanePartition.InitialWaypoint, (IWaypoint)lanePartition.FinalWaypoint);

            // set the value to return
            LocationAnalysis closest = null;

            // values for comparing partitions
            double offsetMin = Double.MaxValue;

            // if this partition has less of an offset from the vehicle than the current best, set as current
            if (partitionAnalysis.Offset < offsetMin)
            {
                offsetMin = partitionAnalysis.Offset;
                closest   = partitionAnalysis;

                // set partition of result
                closest.Partition = lanePartition;
            }
            // otherwise, if the vehicle is relatively close to this partition
            // and the closest Coordinates are not those of the initial final waypoitns of the lane
            // and this error is less than the current best offset
            else if (partitionAnalysis.Offset == 1234567 &&
                     (partitionAnalysis.Error < offsetMin))
            {
                offsetMin = partitionAnalysis.Error;
                closest   = partitionAnalysis;

                // set partition of result
                closest.Partition = lanePartition;
            }

            // return estimate
            return(partitionAnalysis);
        }
Beispiel #6
0
 public ActionResult <double> GetDistanceKm([FromBody] GetDistanceKmRequest request4)
 {
     return(LocationAnalysis.GetDistanceKm(request4.a, request4.b));
 }
Beispiel #7
0
 public ActionResult <List <Location> > checkAlibi([FromBody] checkAlibiRequest request3)
 {
     return(LocationAnalysis.checkAlibi(request3.person, request3.startTime, request3.endTime));
 }
Beispiel #8
0
 public ActionResult <WhereWhen> HaveWeMet([FromBody] HaveWeMetRequest request2)
 {
     return(LocationAnalysis.HaveWeMet(request2.person1, request2.person2, request2.distanceMeter, request2.timeSpan));
 }
Beispiel #9
0
 public ActionResult <bool> AreMeeting([FromBody] AreMeetingRequest request)
 {
     return(LocationAnalysis.AreMeeting(request.a, request.b, request.distanceMeter, request.timeSpan));
 }