Esempio n. 1
0
        /// <summary>
        /// Draw Line for merging cordinates
        /// </summary>
        /// <param name="ward"></param>
        /// <param name="p"></param>
        private bool DrawLineTowardsTop(Ward wardDetails, decimal latitude, decimal longitude)
        {
            decimal counter = 0.00001M;
            IList<Cordinate> cordinates = new List<Cordinate>();
            IList<Cordinate> cordinateList = new List<Cordinate>();

            cordinateList = context.Cordinates.Where(@w => @w.WardId == wardDetails.Id).ToList();

            //Get points with equal latitude
            var processedList = cordinateList.Where(@w => Convert.ToDecimal(@w.Longitude) == longitude &&
                Convert.ToDecimal(@w.Latitude) > latitude);

            if (processedList.Count() > 0)
            {
                return true;
            }

            for (int i = 0; i <= 5; i++)
            {
                decimal leftLongitude = Decimal.Add(longitude, counter);
                var processedLeftList = cordinateList.Where(@w => Convert.ToDecimal(@w.Longitude) == leftLongitude &&
                    Convert.ToDecimal(@w.Latitude) > latitude);

                decimal rightLatitude = Decimal.Subtract(longitude, counter);
                var processedRightList = cordinateList.Where(@w => Convert.ToDecimal(@w.Longitude) == rightLatitude &&
                    Convert.ToDecimal(@w.Latitude) > latitude);

                cordinates = cordinates.Union(processedList).Union(processedLeftList).Union(processedRightList).ToList();

                if (cordinates.Count() > 0)
                {
                    return true;
                }

                longitude = Decimal.Add(longitude, counter);
            }

            return false;
        }
Esempio n. 2
0
        /// <summary>
        /// Eliminate LHS of the Cordinates from the Ward
        /// </summary>
        /// <param name="longWards"></param>
        private IList<Cordinate> EliminateLHSCordinate(Ward ward)
        {
            IList<Cordinate> cordinates = new List<Cordinate>();

            var cordinateList = context.Cordinates.Where(@w => @w.WardId.Equals(ward.Id));

            string top = ward.TopCordinate.Split(',')[1];
            IList<Cordinate> topList = cordinateList.Where(@w => @w.Longitude == top).ToList();
            int topRank = topList.OrderByDescending(@orderby => @orderby.Rank).First().Rank;

            string bottom = ward.BottomCordinate.Split(',')[1];
            IList<Cordinate> bottomList = cordinateList.Where(@w => @w.Longitude == bottom).ToList();
            int bottomRank = bottomList.OrderBy(@orderby => @orderby.Rank).First().Rank;

            if (topRank > bottomRank)
            {
                var list = cordinateList.Where(@w => @w.Rank <= topRank && @w.Rank >= bottomRank).ToList();
                cordinates = list;
            }
            else
            {
                var list = cordinateList.Where(@w => @w.Rank >= topRank && @w.Rank <= bottomRank).ToList();
                cordinates = list;
            }

            return cordinates;
        }
Esempio n. 3
0
 partial void DeleteWard(Ward instance);
Esempio n. 4
0
        private Guid InsertWardMetadata(Guid zoneId, int wardNumber, string wardName, CordinatePoint top, CordinatePoint left, CordinatePoint bottom, CordinatePoint right, DataAccessDataContext context)
        {
            Guid wardId = Guid.NewGuid();

            Ward ward = new Ward
            {
                Id = wardId,
                Number = wardNumber,
                Name = wardName,
                ZoneId = zoneId,
                TopCordinate = top.Latitude + "," + top.Longitude,
                LeftCordinate = left.Latitude + "," + left.Longitude,
                BottomCordinate = bottom.Latitude + "," + bottom.Longitude,
                RightCordinate = right.Latitude + "," + right.Longitude
            };

            context.Wards.InsertOnSubmit(ward);
            SubmitData();

            return wardId;
        }
Esempio n. 5
0
 partial void UpdateWard(Ward instance);
Esempio n. 6
0
 partial void InsertWard(Ward instance);
Esempio n. 7
0
 partial void DeleteWard(Ward instance);
Esempio n. 8
0
 partial void UpdateWard(Ward instance);
Esempio n. 9
0
 partial void InsertWard(Ward instance);