/// <summary>
        /// Get time step specific species observation counts for a specific set of species observation search criteria.
        /// Only counts greater than zero is included in the resulting list.
        /// </summary>
        /// <param name="clientInformation">Information about the client that makes this web service call.</param>
        /// <param name="searchCriteria">Species observation search criteria - defined in class WebSpeciesObservationSearchCriteria.</param>
        /// <param name="periodicity">Specification on time step length and interval.</param>
        /// <param name="coordinateSystem">Coordinate system used in returned species observations.</param>
        /// <returns>A list of time step specific species observation counts.</returns>
        public List <WebTimeStepSpeciesObservationCount> GetTimeSpeciesObservationCountsBySpeciesObservationSearchCriteria(WebClientInformation clientInformation,
                                                                                                                           WebSpeciesObservationSearchCriteria searchCriteria,
                                                                                                                           Periodicity periodicity,
                                                                                                                           WebCoordinateSystem coordinateSystem)
        {
            List <WebTimeStepSpeciesObservationCount> timeStepSpeciesObservationCount;

            using (WebServiceContext context = GetWebServiceContext(clientInformation))
            {
                try
                {
                    if (SpeciesObservationConfiguration.IsElasticsearchUsed)
                    {
                        timeStepSpeciesObservationCount = AnalysisManager.GetTimeSpeciesObservationCountsBySearchCriteriaElasticsearch(context, searchCriteria, periodicity, coordinateSystem);
                    }
                    else
                    {
                        timeStepSpeciesObservationCount = AnalysisManager.GetTimeSpeciesObservationCountsBySearchCriteria(context, searchCriteria, periodicity, coordinateSystem);
                    }

                    LogSpeciesObservationCount(timeStepSpeciesObservationCount);
                    return(timeStepSpeciesObservationCount);
                }
                catch (Exception exception)
                {
                    WebServiceData.LogManager.LogError(context, exception);
                    throw;
                }
            }
        }
        /// <summary>
        /// Get number of species observations
        /// that matches the search criteria.
        /// </summary>
        /// <param name="clientInformation">Information about the client that makes this web service call.</param>
        /// <param name="searchCriteria">Species observation search criteria - defined in class WebSpeciesObservationSearchCriteria.</param>
        /// <param name="coordinateSystem">Coordinate system used in search criteria.</param>
        /// <returns>Number of species observations that matches the search criteria.</returns>
        public Int64 GetSpeciesObservationCountBySpeciesObservationSearchCriteria(WebClientInformation clientInformation,
                                                                                  WebSpeciesObservationSearchCriteria searchCriteria,
                                                                                  WebCoordinateSystem coordinateSystem)
        {
            Int64 speciesObservationCount;

            using (WebServiceContext context = GetWebServiceContext(clientInformation))
            {
                try
                {
                    if (SpeciesObservationConfiguration.IsElasticsearchUsed)
                    {
                        speciesObservationCount =
                            AnalysisManager.GetSpeciesObservationCountBySearchCriteriaElasticsearch(context, searchCriteria, coordinateSystem);
                    }
                    else
                    {
                        speciesObservationCount =
                            AnalysisManager.GetSpeciesObservationCountBySearchCriteria(context, searchCriteria, coordinateSystem);
                    }

                    LogSpeciesObservationCount(speciesObservationCount);
                    return(speciesObservationCount);
                }
                catch (Exception exception)
                {
                    WebServiceData.LogManager.LogError(context, exception);
                    throw;
                }
            }
        }
 /// <summary>
 /// Get species observation provenances
 /// that matches the search criteria.
 /// </summary>
 /// <param name="clientInformation">Information about the client that makes this web service call.</param>
 /// <param name="searchCriteria">Species observation search criteria - defined in class WebSpeciesObservationSearchCriteria.</param>
 /// <param name="coordinateSystem">Coordinate system used in search criteria.</param>
 /// <returns>Number of species that matches the search criteria.</returns>
 public List <WebSpeciesObservationProvenance> GetSpeciesObservationProvenancesBySearchCriteria(WebClientInformation clientInformation,
                                                                                                WebSpeciesObservationSearchCriteria searchCriteria,
                                                                                                WebCoordinateSystem coordinateSystem)
 {
     using (WebServiceContext context = GetWebServiceContext(clientInformation))
     {
         try
         {
             if (SpeciesObservationConfiguration.IsElasticsearchUsed)
             {
                 return(AnalysisManager.GetProvenancesBySearchCriteriaElasticsearch(context,
                                                                                    searchCriteria,
                                                                                    coordinateSystem));
             }
             else
             {
                 return(AnalysisManager.GetProvenancesBySearchCriteria(context,
                                                                       searchCriteria,
                                                                       coordinateSystem));
             }
         }
         catch (Exception exception)
         {
             WebServiceData.LogManager.LogError(context, exception);
             throw;
         }
     }
 }
        public List <WebGridCellSpeciesObservationCount> GetGridSpeciesObservationCountsBySpeciesObservationSearchCriteria(WebClientInformation clientInformation,
                                                                                                                           WebSpeciesObservationSearchCriteria searchCriteria,
                                                                                                                           WebGridSpecification gridSpecification,
                                                                                                                           WebCoordinateSystem coordinateSystem)
        {
            List <WebGridCellSpeciesObservationCount> grid;

            using (WebServiceContext context = GetWebServiceContext(clientInformation))
            {
                try
                {
                    if (SpeciesObservationConfiguration.IsElasticsearchUsed)
                    {
                        grid = AnalysisManager.GetGridSpeciesObservationCountsElasticsearch(context, searchCriteria, gridSpecification, coordinateSystem);
                    }
                    else
                    {
                        grid = AnalysisManager.GetGridSpeciesObservationCounts(context, searchCriteria, gridSpecification, coordinateSystem);
                    }

                    LogSpeciesObservationCount(grid);
                    return(grid);
                }
                catch (Exception exception)
                {
                    WebServiceData.LogManager.LogError(context, exception);
                    throw;
                }
            }
        }
 public List <WebGridCellFeatureStatistics> GetGridFeatureStatistics(WebClientInformation clientInformation,
                                                                     WebFeatureStatisticsSpecification featureStatisticsSpecification,
                                                                     String featuresUrl,
                                                                     String featureCollectionJson,
                                                                     WebGridSpecification gridSpecification,
                                                                     WebCoordinateSystem coordinateSystem)
 {
     using (WebServiceContext context = GetWebServiceContext(clientInformation))
     {
         try
         {
             var featuresUri = string.IsNullOrEmpty(featuresUrl) ? null : new Uri(featuresUrl);
             return(AnalysisManager.GetGridCellFeatureStatistics(context,
                                                                 featuresUri,
                                                                 featureCollectionJson,
                                                                 gridSpecification,
                                                                 coordinateSystem));
         }
         catch (Exception exception)
         {
             WebServiceData.LogManager.LogError(context, exception);
             throw;
         }
     }
 }
 /// <summary>
 /// Get EOO as geojson, EOO and AOO area as attributes
 /// </summary>
 /// <param name="clientInformation">Information about the client that makes this web service call.</param>
 /// <param name="gridCells">Grid cells used to calculate result</param>
 /// <param name="alphaValue">If greater than 0 a concave hull will be calculated with this alpha value</param>
 /// <param name="useCenterPoint">Used when concave hull is calculated. Grid corner coordinates used when false</param>
 /// <returns>A JSON FeatureCollection with one feature showing EOO. EOO AND AOO Areas stored in feature attributes</returns>
 public string GetSpeciesObservationAOOEOOAsGeoJson(WebClientInformation clientInformation, List <WebGridCellSpeciesObservationCount> gridCells, int alphaValue, bool useCenterPoint)
 {
     using (WebServiceContext context = GetWebServiceContext(clientInformation))
     {
         try
         {
             return(AnalysisManager.GetSpeciesObservationAOOEOOAsGeoJson(gridCells, alphaValue, useCenterPoint));
         }
         catch (Exception exception)
         {
             WebServiceData.LogManager.LogError(context, exception);
             throw;
         }
     }
 }
 /// <summary>
 /// Get unique taxa for all species facts
 /// that matches search criteria.
 /// </summary>
 /// <param name="clientInformation">Information about the client that makes this web service call.</param>
 /// <param name="searchCriteria">Species fact search criteria.</param>
 /// <returns>Taxa for all species facts that matches search criteria.</returns>
 public List <WebTaxon> GetTaxaBySpeciesFactSearchCriteria(WebClientInformation clientInformation,
                                                           WebSpeciesFactSearchCriteria searchCriteria)
 {
     using (WebServiceContext context = GetWebServiceContext(clientInformation))
     {
         try
         {
             return(AnalysisManager.GetTaxaBySpeciesFactSearchCriteria(context, searchCriteria));
         }
         catch (Exception exception)
         {
             WebServiceData.LogManager.LogError(context, exception);
             throw;
         }
     }
 }
 /// <summary>
 /// Gets the grid cell feature statistics combined with species observation counts.
 /// </summary>
 /// <param name="clientInformation">Client information.</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="featureStatisticsSpecification">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 collecation as json.</param>
 /// <param name="coordinateSystem">Coordinate system used in returned grid.</param>
 /// <returns>A list with combined result from GetGridSpeciesCounts() and GetGridCellFeatureStatistics().</returns>
 public List <WebGridCellCombinedStatistics> GetGridCellFeatureStatisticsCombinedWithSpeciesObservationCounts(
     WebClientInformation clientInformation,
     WebGridSpecification gridSpecification,
     WebSpeciesObservationSearchCriteria searchCriteria,
     WebFeatureStatisticsSpecification featureStatisticsSpecification,
     String featuresUrl,
     String featureCollectionJson,
     WebCoordinateSystem coordinateSystem)
 {
     using (WebServiceContext context = GetWebServiceContext(clientInformation))
     {
         try
         {
             if (SpeciesObservationConfiguration.IsElasticsearchUsed)
             {
                 return(AnalysisManager.GetGridCellFeatureStatisticsCombinedWithSpeciesObservationCountsElasticsearch(context,
                                                                                                                      searchCriteria,
                                                                                                                      gridSpecification,
                                                                                                                      coordinateSystem,
                                                                                                                      featuresUrl,
                                                                                                                      featureCollectionJson));
             }
             else
             {
                 return(AnalysisManager.GetGridCellFeatureStatisticsCombinedWithSpeciesObservationCounts(context,
                                                                                                         searchCriteria,
                                                                                                         gridSpecification,
                                                                                                         coordinateSystem,
                                                                                                         featuresUrl,
                                                                                                         featureCollectionJson));
             }
         }
         catch (Exception exception)
         {
             WebServiceData.LogManager.LogError(context, exception);
             throw;
         }
     }
 }