Example #1
0
        /// <summary>
        /// Checks if a place falls within on of the test areas
        /// </summary>
        /// <param name="testPlace"></param>
        /// <param name="areasToTest"></param>
        /// <returns></returns>
        public static bool PlaceIntersectsAnArea(this IPlaceWithGeo testPlace, IList <Area> areasToTest)
        {
            foreach (var a in areasToTest)
            {
                if (testPlace.Geo.STIntersects(a.Geo))
                {
                    return(true);
                }
            }

            return(false);
        }
Example #2
0
        /// <summary>
        /// Checks all areas in related areas to see if any do not intersect with the test place and returns them
        /// </summary>
        /// <param name="place"></param>
        /// <param name="relatedAreas"></param>
        /// <returns></returns>
        public static List <Area> GetNonIntersectingAreas(this IPlaceWithGeo testPlace, IList <Area> relatedAreas)
        {
            List <Area> notIntersectingAreas = new List <Area>();

            foreach (var a in relatedAreas)
            {
                if (testPlace.IDstring != a.ID.ToString() && !a.Geo.STIntersects(testPlace.Geo))
                {
                    notIntersectingAreas.Add(a);
                }
            }

            return(notIntersectingAreas);
        }
Example #3
0
        /// <summary>
        /// Used in the mapping service to stop parent areas hiding sub areas of the current focused area
        /// </summary>
        /// <param name="area"></param>
        /// <param name="areas"></param>
        /// <returns></returns>
        /// <remarks>Use for GetProvinceItems, GetCityItems, GetAreaItems</remarks>
        /// <example>(1) The Bay Area hiding all the sub areas of San Francisco. (2) Patagonia hiding EVERYTHING in Argentina/Chile hahah        /// </example>
        public static List <Area> RemoveIntersectingNonChildAreas(this IPlaceWithGeo testPlace, IList <Area> areas)
        {
            var nonParentAreas = new List <Area>();

            foreach (var a in areas)
            {
                if (testPlace.IDstring != a.ID.ToString())
                {
                    if (testPlace.Geo.STContains2(a.Geo))
                    {
                        nonParentAreas.Add(a);
                    }
                }
            }

            return(nonParentAreas);
        }
Example #4
0
        /// <summary>
        /// Checks all areas in related areas to see if any completely contains the child place and returns the ones that do
        /// </summary>
        /// <param name="childPlace"></param>
        /// <param name="relatedAreas"></param>
        /// <returns></returns>
        public static List <Area> GetParentAreas(this IPlaceWithGeo childPlace, IEnumerable <Area> relatedAreas)
        {
            var parentAreas = new List <Area>();
            var cGeom       = childPlace.Geo.AsGeom();

            foreach (var a in relatedAreas)
            {
                var ageom = a.Geo.AsGeom();

                //-- First check we're not comparing the area with itself, then if the current checking area completely contains the
                //-- child area we add it to the parent areas list
                if (childPlace.IDstring != a.ID.ToString() && ageom.STContains(cGeom))
                {
                    parentAreas.Add(a);
                }
            }

            return(parentAreas);
        }