/// <summary> /// Gets no of species /// that matches the search criteria and grid specifications. /// </summary> /// <param name="userContext">User context.</param> /// <param name="searchCriteria">The species observation search criteria.</param> /// <param name="gridSpecification">The species observation search criteria, GridCellSize and GridCoordinateSystem are the /// only properties that is used in this method.</param> /// <param name="coordinateSystem">Coordinate system used in geometry search criteria.</param> /// <returns>Information about species.</returns> public IList <IGridCellSpeciesCount> GetGridSpeciesCounts(IUserContext userContext, ISpeciesObservationSearchCriteria searchCriteria, IGridSpecification gridSpecification, ICoordinateSystem coordinateSystem) { return(DataSource.GetGridSpeciesCounts(userContext, searchCriteria, gridSpecification, coordinateSystem)); }
public async ValueTask <long> CountAsync(IGridSpecification <TEntity> spec) { spec.IsPagingEnabled = false; var specificationResult = GetQuery(_dbContext.Set <TEntity>(), spec); return(await ValueTask.FromResult(specificationResult.LongCount())); }
public async Task <List <TEntity> > FindAsync(IGridSpecification <TEntity> spec) { await using var dbContext = _dbContextFactory.CreateDbContext(); var specificationResult = GetQuery(dbContext.Set <TEntity>(), spec); return(await specificationResult.ToListAsync()); }
public async ValueTask <long> CountAsync(IGridSpecification <TEntity> spec) { await using var dbContext = _dbContextFactory.CreateDbContext(); spec.IsPagingEnabled = false; var specificationResult = GetQuery(dbContext.Set <TEntity>(), spec); return(specificationResult.LongCount()); }
/// <summary> /// Gets the grid cell feature statistics combined with species observation counts. /// </summary> /// <param name="userContext">User context.</param> /// <param name="gridSpecification">The grid specification: bounding box, grid cell size, etc.</param> /// <param name="searchCriteria">The species observation search criteria.</param> /// <param name="featureStatistics">Information about requested information from a web feature service.</param> /// <param name="featuresUrl">Address to data in a web feature service.</param> /// <param name="featureCollectionJson">Feature collection json.</param> /// <param name="coordinateSystem">Coordinate system used in returned grid.</param> /// <returns>A list with combined result from GetGridSpeciesCounts() and GetGridCellFeatureStatistics().</returns> public IList <IGridCellCombinedStatistics> GetGridCellFeatureStatisticsCombinedWithSpeciesObservationCounts( IUserContext userContext, IGridSpecification gridSpecification, ISpeciesObservationSearchCriteria searchCriteria, FeatureStatisticsSummary featureStatistics, String featuresUrl, String featureCollectionJson, ICoordinateSystem coordinateSystem) { return(DataSource.GetGridCellFeatureStatisticsCombinedWithSpeciesObservationCounts(userContext, gridSpecification, searchCriteria, featureStatistics, featuresUrl, featureCollectionJson, coordinateSystem)); }
private static IQueryable <TEntity> GetQuery(IQueryable <TEntity> inputQuery, IGridSpecification <TEntity> specification) { var query = inputQuery; if (specification.Criterias is not null && specification.Criterias.Count > 0) { var expr = specification.Criterias.First(); for (var i = 1; i < specification.Criterias.Count; i++) { expr = expr.And(specification.Criterias[i]); } query = query.Where(expr); } query = specification.Includes.Aggregate(query, (current, include) => current.Include(include)); query = specification.IncludeStrings.Aggregate(query, (current, include) => current.Include(include)); if (specification.OrderBy is not null) { query = query.OrderBy(specification.OrderBy); } else if (specification.OrderByDescending is not null) { query = query.OrderByDescending(specification.OrderByDescending); } if (specification.GroupBy is not null) { query = query.GroupBy(specification.GroupBy).SelectMany(x => x); } if (specification.IsPagingEnabled) { query = query.Skip(specification.Skip - 1) .Take(specification.Take); } return(query); }
/// <summary> /// Get information about spatial features in a grid representation inside a user supplied bounding box. /// </summary> /// /// <param name="userContext">User context.</param> /// <param name="featureStatistics">Information about what statistics are requested from a web feature /// service and wich spatial feature type that is to be measured</param> /// <param name="featuresUrl">String with the requested url.</param> /// <param name="featureCollectionJson">Feature collection as json string.</param> /// <param name="gridSpecification">Specifications of requested grid cell size, requested coordinate system /// and user supplied bounding box.</param> /// <param name="coordinateSystem">Coordinate system used in geometry search criteria.</param> /// <returns>Statistical measurements on spatial features in grid format.</returns> public List <IGridCellFeatureStatistics> GetGridFeatureStatistics(IUserContext userContext, FeatureStatisticsSummary featureStatistics, String featuresUrl, String featureCollectionJson, IGridSpecification gridSpecification, ICoordinateSystem coordinateSystem) { //Todo: Check data for weird combinations like area of point features and such. Use existing check-methods. return(DataSource.GetGridCellFeatureStatistics(userContext, featureStatistics, featuresUrl, featureCollectionJson, gridSpecification, coordinateSystem)); }
public async Task <List <TEntity> > FindAsync(IGridSpecification <TEntity> spec) { var specificationResult = GetQuery(_dbContext.Set <TEntity>(), spec); return(await specificationResult.ToListAsync()); }