Пример #1
0
        public async Task <ProjectExtentsResult> GetProjectExtentsV1(
            [FromQuery] long projectId,
            [FromServices] IBoundingBoxService boundingBoxService)
        {
            Log.LogInformation($"{nameof(GetProjectExtentsV1)}: {Request.QueryString}");

            var projectUid  = await((RaptorPrincipal)User).GetProjectUid(projectId);
            var excludedIds = await ProjectStatisticsHelper.GetExcludedSurveyedSurfaceIds(projectUid, GetUserId(), CustomHeaders);

            try
            {
                var result = await boundingBoxService.GetProductionDataExtents(projectUid, projectId, excludedIds?.Select(e => e.Item1), excludedIds?.Select(e => e.Item2), GetUserId(), CustomHeaders);

                return(await FormatProjectExtentsResult(projectUid, result));
            }
            catch (ServiceException se)
            {
                Log.LogError(se, $"{nameof(GetProjectExtentsV1)}: exception");
                throw;
            }
            finally
            {
                Log.LogInformation($"{nameof(GetProjectExtentsV1)} returned: {Response.StatusCode}");
            }
        }
Пример #2
0
        /// <summary>
        /// Tests if there is overlapping data in Raptor
        /// </summary>
        protected async Task <(bool isValidFilterForProjectExtents, FilterResult filterResult)> ValidateFilterAgainstProjectExtents(Guid projectUid, Guid?filterUid)
        {
            if (!filterUid.HasValue)
            {
                return(true, null);
            }

            try
            {
                var filterTask = GetCompactionFilter(projectUid, filterUid, filterMustExist: true);
                var projectId  = GetLegacyProjectId(projectUid);

                await Task.WhenAll(filterTask, projectId);

                var projectExtents = await ProjectStatisticsHelper.GetProjectStatisticsWithProjectSsExclusions(projectUid, projectId.Result, GetUserId(), CustomHeaders);

                //No data in Raptor - stop
                if (projectExtents == null)
                {
                    return(false, null);
                }

                var filter = await filterTask;

                //No filter dates defined - project extents requested. Proceed further
                if (filter.StartUtc == null && filter.EndUtc == null)
                {
                    return(true, filter);
                }

                //Do we have intersecting dates? True if yes
                if (filter.StartUtc != null && filter.EndUtc != null)
                {
                    return(true, filter);
                }

                //Handle 'as-at' dates where StartUTC is null but EndUTC is not null
                if (filter.StartUtc == null && filter.EndUtc != null)
                {
                    return(true, filter);
                }

                //All other cases - proceed further
                return(true, filter);
            }
            catch
            {
                //Some exception - do not proceed further
                return(false, null);
            }
        }
Пример #3
0
        /// <summary>
        /// Validates new edit is within production data date range for the project
        /// </summary>
        private async Task ValidateDates(Guid projectUid, ProductionDataEdit dataEdit)
        {
            var projectExtents = await ProjectStatisticsHelper.GetProjectStatisticsWithProjectSsExclusions(projectUid, VelociraptorConstants.NO_PROJECT_ID, GetUserId(), CustomHeaders);

            if (projectExtents == null)
            {
                throw new ServiceException(HttpStatusCode.BadRequest,
                                           new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError,
                                                                       "Cannot obtain ProjectStatistics."));
            }
            if (dataEdit.startUTC < projectExtents.startTime || dataEdit.endUTC > projectExtents.endTime)
            {
                throw new ServiceException(HttpStatusCode.BadRequest,
                                           new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError,
                                                                       $"Data edit outside production data date range: {projectExtents.startTime}-{projectExtents.endTime}"));
            }
        }
Пример #4
0
        /// <summary>
        /// Gets the date range for the export.
        /// </summary>
        private async Task <(DateTime startUtc, DateTime endUtc)> GetDateRange(long projectId, FilterResult filter)
        {
#if RAPTOR
            if (filter?.StartUtc == null || !filter.EndUtc.HasValue)
            {
                //Special case of project extents where start and end UTC not set in filter for Raptor performance.
                //But need to set here for export.
                var projectUid = await((RaptorPrincipal)User).GetProjectUid(projectId);
                var result     = await ProjectStatisticsHelper.GetProjectStatisticsWithFilterSsExclusions(projectUid, projectId,
                                                                                                          filter?.SurveyedSurfaceExclusionList, filter?.ExcludedSurveyedSurfaceUids);

                var startUtc = filter?.StartUtc ?? result.startTime;
                var endUtc   = filter?.EndUtc ?? result.endTime;
                return(startUtc, endUtc);
            }

            return(filter.StartUtc.Value, filter.EndUtc.Value);
#else
// TRex determines this date range within the export API call
            return(DateTime.MinValue, DateTime.MinValue);
#endif
        }
Пример #5
0
        public async Task <ProjectStatisticsResult> PostProjectStatisticsTbc([FromBody] ProjectStatisticsRequest request)
        {
            _log.LogDebug($"{nameof(PostProjectStatisticsTbc)}: {JsonConvert.SerializeObject(request)}");

            if (!request.ProjectUid.HasValue)
            {
                request.ProjectUid = await((RaptorPrincipal)User).GetProjectUid(request.ProjectId ?? -1);
            }

            request.Validate();

            var projectStatisticsHelper = new ProjectStatisticsHelper(_logger, configStore, FileImportProxy, tRexCompactionDataProxy, _log
#if RAPTOR
                                                                      , raptorClient
#endif
                                                                      );

            return(await projectStatisticsHelper.GetProjectStatisticsWithRequestSsExclusions(
                       request.ProjectUid ?? Guid.Empty,
                       request.ProjectId ?? -1,
                       GetUserId(),
                       request.ExcludedSurveyedSurfaceIds,
                       CustomHeaders));
        }
Пример #6
0
        public async Task <ProjectStatisticsResult> GetProjectStatistics(
            [FromQuery] Guid projectUid)
        {
            Log.LogInformation($"{nameof(GetProjectStatistics)}:  {Request.QueryString}");

            try
            {
                var projectId = await GetLegacyProjectId(projectUid);

                var result = await ProjectStatisticsHelper.GetProjectStatisticsWithProjectSsExclusions(projectUid, projectId, GetUserId(), CustomHeaders);

                Log.LogInformation($"{nameof(GetProjectStatistics)}: result: {JsonConvert.SerializeObject(result)}");
                return(result);
            }
            catch (ServiceException se)
            {
                Log.LogError(se, $"{nameof(GetProjectStatistics)}: exception");
                throw;
            }
            finally
            {
                Log.LogInformation($"{nameof(GetProjectStatistics)}: returned: {Response.StatusCode}");
            }
        }