Beispiel #1
0
        public static Item FindPotentialNewOwner(LocationReport lr, Item luggageItem)
        {
            // for a given luggage find the owner that is nearest to it
            Item   passenger   = null;
            double distanceMin = Int32.MaxValue;

            foreach (Item item in lr.Items)
            {
                if (item.Type.Equals("P"))
                {
                    String who = item.AssetId;
                    if (luggageItem.AssetIdPassenger.Equals(who))
                    {
                        continue;
                    }

                    double distance = LRUtil.Distance(luggageItem.Location.X, luggageItem.Location.Y,
                                                      item.Location.X, item.Location.Y);

                    if (passenger == null || distance < distanceMin)
                    {
                        passenger   = item;
                        distanceMin = distance;
                    }
                }
            }
            return(passenger);
        }
Beispiel #2
0
        /// <summary>Return all luggages separated from the owner. </summary>
        /// <param name="lr">event</param>
        /// <returns>list</returns>
        public static IList <Item> FindSeparatedLuggage(LocationReport lr)
        {
            // loop over all luggages
            // find the location of the owner of the luggage
            // Compute distance luggage to owner
            // if distance > 10 add original-owner

            var result = new List <Item>();

            foreach (Item item in lr.Items)
            {
                if (item.Type.Equals("L"))
                {
                    String belongTo = item.AssetIdPassenger;

                    Item owner = null;
                    foreach (Item ownerItem in lr.Items)
                    {
                        if (ownerItem.Type.Equals("P"))
                        {
                            if (ownerItem.AssetId.Equals(belongTo))
                            {
                                owner = ownerItem;
                            }
                        }
                    }

                    if (owner == null)
                    {
                        continue;
                    }

                    double distanceOwner = LRUtil.Distance(owner.Location.X, owner.Location.Y,
                                                           item.Location.X, item.Location.Y);
                    if (distanceOwner > 20)
                    {
                        result.Add(item);
                    }
                }
            }
            return(result);
        }