Rock.Model.GroupLocationService.GetMappedLocationsByGeofences C# (CSharp) Method

GetMappedLocationsByGeofences() public method

Gets the 'IsMappedLocation' locations that are within and of the selected geofences
public GetMappedLocationsByGeofences ( List geofences ) : IQueryable
geofences List The geofences.
return IQueryable
        public IQueryable<GroupLocation> GetMappedLocationsByGeofences( List<DbGeography> geofences )
        {
            return Queryable()
                .Where( l =>
                    l.IsMappedLocation &&
                    l.Location != null &&
                    l.Location.GeoPoint != null &&
                    geofences.Any( f => l.Location.GeoPoint.Intersects( f ) )
                );
        }

Usage Example

Example #1
0
        /// <summary>
        /// Gets the family groups that are geofenced by any of the selected geofences
        /// </summary>
        /// <param name="geofences">The geofences.</param>
        /// <returns></returns>
        public IQueryable <Group> GetGeofencedFamilies(List <DbGeography> geofences)
        {
            var rockContext          = (RockContext)this.Context;
            var groupLocationService = new GroupLocationService(rockContext);

            Guid familyTypeGuid = Rock.SystemGuid.GroupType.GROUPTYPE_FAMILY.AsGuid();

            return(groupLocationService.GetMappedLocationsByGeofences(geofences)
                   .Where(l =>
                          l.Group != null &&
                          l.Group.GroupType != null &&
                          l.Group.GroupType.Guid.Equals(familyTypeGuid))
                   .Select(l => l.Group));
        }
All Usage Examples Of Rock.Model.GroupLocationService::GetMappedLocationsByGeofences