Пример #1
0
            public void Should_set_Machines_From_AssetIDs_list_When_ContributingMachines_is_null_or_empty(bool setContributingMachines)
            {
                var assetIds = new List <long> {
                    1, 2, 3, 5, 8, 13
                };
                var contributingMachines = setContributingMachines
          ? new List <MachineDetails>()
          : null;

                var filterResult = FilterResult.CreateFilterForCCATileRequest(assetIDs: assetIds, contributingMachines: contributingMachines);
                var result       = RaptorConverters.ConvertFilter(filterResult);

                Assert.IsTrue(result.Machines.Length == assetIds.Count);
            }
Пример #2
0
        /// <summary>
        ///  CCA data colour palettes executor.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="item">A Domain object.</param>
        /// <returns>An instance of the ContractExecutionResult class with CCA data colour palettes.</returns>}
        ///
        protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item)
        {
            if (item != null)
            {
                try
                {
                    var request = CastRequestObjectTo <CCAColorPaletteRequest>(item);
#if RAPTOR
                    if (configStore.GetValueBool("ENABLE_TREX_GATEWAY_CCA_PALETTE") ?? false)
                    {
#endif
                    var filter = FilterResult.CreateFilterForCCATileRequest
                                 (
                        request.startUtc,
                        request.endUtc,
                        new List <long> {
                        request.assetId
                    },
                        null,
                        request.liftId.HasValue ? FilterLayerMethod.TagfileLayerNumber : FilterLayerMethod.None,
                        request.liftId,
                        new List <MachineDetails> {
                        new MachineDetails(request.assetId, null, false, request.assetUid)
                    }
                                 );
                    var trexRequest = new CCAColorPaletteTrexRequest(request.ProjectUid.Value, filter);
                    return(await trexCompactionDataProxy.SendDataPostRequest <CCAColorPaletteResult, CCAColorPaletteTrexRequest>(trexRequest, "/ccacolors", customHeaders));

#if RAPTOR
                }

                return(ProcessWithRaptor(request));
#endif
                }
                finally
                {
                    ContractExecutionStates.ClearDynamic();
                }
            }

            throw new ServiceException(HttpStatusCode.BadRequest,
                                       new ContractExecutionResult(ContractExecutionStatesEnum.InternalProcessingError,
                                                                   "No CCA data colour palettes request sent."));
        }
Пример #3
0
            public void Should_set_Machines_From_AssetIDs_list_When_ContributingMachines_is_not_empty(bool setAssetIds)
            {
                var assetIds = setAssetIds
          ? new List <long> {
                    1, 2, 3, 5, 8, 13
                }
          : null;

                var contributingMachines = new List <MachineDetails>
                {
                    new MachineDetails(21, "twentyone", false),
                    new MachineDetails(43, "thirtyfour", false)
                };

                var filterResult = FilterResult.CreateFilterForCCATileRequest(assetIDs: assetIds, contributingMachines: contributingMachines);
                var result       = RaptorConverters.ConvertFilter(filterResult);

                var expectedArrayLength = (assetIds?.Count ?? 0) + contributingMachines.Count;

                Assert.IsTrue(result.Machines.Length == expectedArrayLength);
                Assert.IsTrue(result.Machines[expectedArrayLength - 2].Name == "twentyone");
                Assert.IsTrue(result.Machines[expectedArrayLength - 1].Name == "thirtyfour");
            }
Пример #4
0
        private async Task <TileRequest> CreateAndValidateRequest(
            long projectId,
            Guid?projectUid,
            long assetId,
            string machineName,
            bool isJohnDoe,
            DateTime startUtc,
            DateTime endUtc,
            string bbox,
            ushort width,
            ushort height,
            int?liftId,
            Guid?assetUid)
        {
            if (liftId == 0)
            {
                liftId = null;
            }

            var points = bbox.Split(',');

            if (points.Length != 4)
            {
                throw new ServiceException(HttpStatusCode.BadRequest,
                                           new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError,
                                                                       "BBOX parameter must contain 4 coordinates!"));
            }

            /*** no longer supported in WorksOS as no geofenceService
             * List<WGSPoint> geometry = null;
             * if (geofenceUid.HasValue)
             * {
             * var geometryWKT = await geofenceProxy.GetGeofenceBoundary(((RaptorPrincipal) User).CustomerUid, geofenceUid.ToString(), Request.Headers.GetCustomHeaders());
             *
             * if (string.IsNullOrEmpty(geometryWKT))
             *  throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(ContractExecutionStatesEnum.InternalProcessingError,
             *      "No Geofence geometry found."));
             *
             * geometry = CommonConverters.GeometryToPoints(geometryWKT).ToList();
             * }
             ***/

            var filter = FilterResult.CreateFilterForCCATileRequest
                         (
                startUtc,
                endUtc,
                new List <long> {
                assetId
            },
                null,
                liftId.HasValue ? FilterLayerMethod.TagfileLayerNumber : FilterLayerMethod.None,
                liftId,
                new List <MachineDetails> {
                new MachineDetails(assetId, machineName, isJohnDoe, assetUid)
            }
                         );

            var request = new TileRequest
                          (
                projectId,
                projectUid,
                null,
                DisplayMode.CCA,
                null,
                null,
                VolumesType.None,
                0,
                null,
                filter,
                0,
                null,
                0,
                FilterLayerMethod.TagfileLayerNumber,
                new BoundingBox2DLatLon
                (
                    double.Parse(points[1]) * Coordinates.DEGREES_TO_RADIANS, // The Bottom Left corner, longitude...
                    double.Parse(points[0]) * Coordinates.DEGREES_TO_RADIANS, // The Bottom Left corner, latitude...
                    double.Parse(points[3]) * Coordinates.DEGREES_TO_RADIANS, // The Top Right corner, longitude..
                    double.Parse(points[2]) * Coordinates.DEGREES_TO_RADIANS  // The Top Right corner, latitude...
                ),
                null,
                width,
                height
                          );

            request.Validate();

            return(request);
        }