예제 #1
0
        private PaletteBase ConvertColorPalettes(DisplayMode mode, ISiteModel siteModel, OverrideParameters overrides)
        {
            const double PERCENTAGE_RANGE_MIN        = 0.0;
            const double PERCENTAGE_RANGE_MAX        = 100.0;
            const ushort PASS_COUNT_TARGET_RANGE_MIN = 1;
            const ushort PASS_COUNT_TARGET_RANGE_MAX = ushort.MaxValue;
            const ushort TEMPERATURE_LEVELS_MIN      = 0;
            const ushort TEMPERATURE_LEVELS_MAX      = 100;

            PaletteBase convertedPalette;

            switch (mode)
            {
            case DisplayMode.CCA:
                convertedPalette = new CCAPalette();
                break;

            case DisplayMode.CCASummary:
                convertedPalette = new CCASummaryPalette();
                break;

            case DisplayMode.CCV:
                convertedPalette = new CMVPalette();

                var cmvPalette = ((CMVPalette)convertedPalette);

                cmvPalette.CMVPercentageRange.Min = overrides?.CMVRange.Min ?? PERCENTAGE_RANGE_MIN;
                cmvPalette.CMVPercentageRange.Max = overrides?.CMVRange.Max ?? PERCENTAGE_RANGE_MAX;

                cmvPalette.UseMachineTargetCMV = !overrides?.OverrideMachineCCV ?? true;
                cmvPalette.AbsoluteTargetCMV   = overrides?.OverridingMachineCCV ?? 0;

                cmvPalette.TargetCCVColour           = Color.Green;
                cmvPalette.DefaultDecoupledCMVColour = Color.Black;
                break;

            case DisplayMode.CCVPercent:
            case DisplayMode.CCVPercentSummary:
            case DisplayMode.CCVPercentChange:
                convertedPalette = new CCVPercentPalette();

                var cmvSummaryPalette = ((CCVPercentPalette)convertedPalette);

                cmvSummaryPalette.CMVPercentageRange.Min = overrides?.CMVRange.Min ?? PERCENTAGE_RANGE_MIN;
                cmvSummaryPalette.CMVPercentageRange.Max = overrides?.CMVRange.Max ?? PERCENTAGE_RANGE_MAX;

                cmvSummaryPalette.UseMachineTargetCMV = !overrides?.OverrideMachineCCV ?? true;
                cmvSummaryPalette.AbsoluteTargetCMV   = overrides?.OverridingMachineCCV ?? 0;
                break;

            case DisplayMode.CMVChange:
                convertedPalette = new CMVChangePalette();

                var cmvPercentChangePalette = ((CMVChangePalette)convertedPalette);

                cmvPercentChangePalette.CMVPercentageRange.Min = overrides?.CMVRange.Min ?? PERCENTAGE_RANGE_MIN;
                cmvPercentChangePalette.CMVPercentageRange.Max = overrides?.CMVRange.Max ?? PERCENTAGE_RANGE_MAX;

                cmvPercentChangePalette.UseAbsoluteValues = false;

                cmvPercentChangePalette.UseMachineTargetCMV = !overrides?.OverrideMachineCCV ?? true;
                cmvPercentChangePalette.AbsoluteTargetCMV   = overrides?.OverridingMachineCCV ?? 0;

                cmvPercentChangePalette.TargetCCVColour           = Color.Green;
                cmvPercentChangePalette.DefaultDecoupledCMVColour = Color.Black;
                break;

            case DisplayMode.CutFill:
                convertedPalette = new CutFillPalette();
                break;

            case DisplayMode.Height:
                var extent = siteModel.GetAdjustedDataModelSpatialExtents(new Guid[0]);

                convertedPalette = new HeightPalette(extent.MinZ, extent.MaxZ);
                break;

            case DisplayMode.MDP:
                convertedPalette = new MDPPalette();

                var mdpPalette = ((MDPPalette)convertedPalette);

                mdpPalette.MDPPercentageRange.Min = overrides?.MDPRange.Min ?? PERCENTAGE_RANGE_MIN;
                mdpPalette.MDPPercentageRange.Max = overrides?.MDPRange.Max ?? PERCENTAGE_RANGE_MAX;

                mdpPalette.UseMachineTargetMDP = !overrides?.OverrideMachineMDP ?? true;
                mdpPalette.AbsoluteTargetMDP   = overrides?.OverridingMachineMDP ?? 0;

                mdpPalette.TargetMDPColour = Color.Green;
                break;

            case DisplayMode.MDPPercentSummary:
                convertedPalette = new MDPSummaryPalette();

                var mdpSummaryPalette = ((MDPSummaryPalette)convertedPalette);

                mdpSummaryPalette.MDPPercentageRange.Min = overrides?.MDPRange.Min ?? PERCENTAGE_RANGE_MIN;
                mdpSummaryPalette.MDPPercentageRange.Max = overrides?.MDPRange.Max ?? PERCENTAGE_RANGE_MAX;

                mdpSummaryPalette.UseMachineTargetMDP = !overrides?.OverrideMachineMDP ?? true;
                mdpSummaryPalette.AbsoluteTargetMDP   = overrides?.OverridingMachineMDP ?? 0;
                break;

            case DisplayMode.PassCount:
                convertedPalette = new PassCountPalette();
                break;

            case DisplayMode.PassCountSummary:
                convertedPalette = new PassCountSummaryPalette();

                var passCountPalette = ((PassCountSummaryPalette)convertedPalette);

                passCountPalette.UseMachineTargetPass     = !overrides?.OverrideTargetPassCount ?? true;
                passCountPalette.TargetPassCountRange.Min = overrides?.OverridingTargetPassCountRange.Min ?? PASS_COUNT_TARGET_RANGE_MIN;
                passCountPalette.TargetPassCountRange.Max = overrides?.OverridingTargetPassCountRange.Max ?? PASS_COUNT_TARGET_RANGE_MAX;
                break;

            case DisplayMode.MachineSpeed:
                convertedPalette = new SpeedPalette();
                break;

            case DisplayMode.TargetSpeedSummary:
                convertedPalette = new SpeedSummaryPalette();

                var speedSummaryPalette = ((SpeedSummaryPalette)convertedPalette);

                speedSummaryPalette.MachineSpeedTarget.Min = overrides?.TargetMachineSpeed.Min ?? CellPassConsts.NullMachineSpeed;
                speedSummaryPalette.MachineSpeedTarget.Max = overrides?.TargetMachineSpeed.Max ?? CellPassConsts.NullMachineSpeed;
                break;

            case DisplayMode.TemperatureDetail:
                convertedPalette = new TemperaturePalette();
                break;

            case DisplayMode.TemperatureSummary:
                convertedPalette = new TemperatureSummaryPalette();

                var temperatureSummaryPalette = ((TemperatureSummaryPalette)convertedPalette);

                temperatureSummaryPalette.UseMachineTempWarningLevels = !overrides?.OverrideTemperatureWarningLevels ?? true;
                temperatureSummaryPalette.TemperatureLevels.Min       = overrides?.OverridingTemperatureWarningLevels.Min ?? TEMPERATURE_LEVELS_MIN;
                temperatureSummaryPalette.TemperatureLevels.Max       = overrides?.OverridingTemperatureWarningLevels.Max ?? TEMPERATURE_LEVELS_MAX;
                break;

            default:
                throw new TRexException($"No implemented color palette for this mode ({mode})");
            }

            return(convertedPalette);
        }
예제 #2
0
        public static IPlanViewPalette GetPalette(ISiteModel siteModel, DisplayMode mode, BoundingWorldExtent3D spatialExtents)
        {
            switch (mode)
            {
            case DisplayMode.Height:
                BoundingWorldExtent3D extent = siteModel.GetAdjustedDataModelSpatialExtents(new Guid[0]);
                return(new HeightPalette(extent.MinZ, extent.MaxZ));

            case DisplayMode.MachineSpeed: return(new SpeedPalette());

            case DisplayMode.TargetSpeedSummary: return(new SpeedSummaryPalette());

            case DisplayMode.CCV: return(new CMVPalette());

            case DisplayMode.CCVPercent:
            case DisplayMode.CCVPercentSummary:
            case DisplayMode.CCVPercentChange:
                return(new CCVPercentPalette());

            case DisplayMode.CMVChange: return(new CMVChangePalette());

            case DisplayMode.MDP: return(new MDPPalette());

            case DisplayMode.MDPPercentSummary: return(new MDPSummaryPalette());

            case DisplayMode.PassCount: return(new PassCountPalette());

            case DisplayMode.PassCountSummary: return(new PassCountSummaryPalette());

            case DisplayMode.TemperatureDetail: return(new TemperaturePalette());

            case DisplayMode.TemperatureSummary: return(new TemperatureSummaryPalette());

            case DisplayMode.CutFill: return(new CutFillPalette());

            case DisplayMode.CCA: return(new CCAPalette());

            case DisplayMode.CCASummary: return(new CCASummaryPalette());

            case DisplayMode.CompactionCoverage: return(new CompactionCoveragePalette());

            default:
                throw new TRexException($"Unknown display mode in {nameof(GetPalette)}");
            }

            // TODO The additional logic in the commented out code below should be implemented as per the corresponding User Story...

            /*
             * Complicated legacy implementation follows:
             * if Assigned(FDisplayPalettes) then
             *  case FMode of
             *    icdmHeight             : FPalette := FDisplayPalettes.HeightPalette;
             *    icdmCCV                : FPalette := FDisplayPalettes.CCVPalette;
             *    icdmCCVPercent         : FPalette := FDisplayPalettes.CCVPercentPalette;
             *    icdmLatency            : FPalette := FDisplayPalettes.RadioLatencyPalette;
             *    icdmPassCount,
             *    icdmPassCountSummary   : FPalette := FDisplayPalettes.PassCountPalette;
             *    icdmRMV                : FPalette := FDisplayPalettes.RMVPalette;
             *    icdmFrequency          : FPalette := FDisplayPalettes.FrequencyPalette;
             *    icdmAmplitude          : FPalette := FDisplayPalettes.AmplitudePalette;
             *    icdmCutFill            : FPalette := FDisplayPalettes.CutFillPalette;
             *    icdmMoisture           : FPalette := FDisplayPalettes.MoisturePalette;
             *    icdmTemperatureSummary :; // see below AJR 14974
             *    icdmGPSMode            :; // See GPSMode palette assignment below
             *    icdmCCVSummary         :; // See CCV summary palette assignment below
             *    icdmCCVPercentSummary  :; // See CCV Percent summary palette assignment below
             *    icdmCompactionCoverage : FPalette := Nil; // Single fixed colour
             *    icdmVolumeCoverage     : FPalette := FDisplayPalettes.VolumeOverlayPalette;
             *    icdmMDP                : FPalette := FDisplayPalettes.MDPPalette;
             *    icdmMDPSummary         :;
             *    icdmMDPPercent         : FPalette := FDisplayPalettes.MDPPercentPalette;
             *    icdmMDPPercentSummary  :;
             *    icdmMachineSpeed       : FPalette := FDisplayPalettes.MachineSpeedPalette;
             *    icdmTargetSpeedSummary :;// FPalette := FDisplayPalettes.SpeedSummaryPalette;
             * //    icdmCCA                : FPalette :=    does not seem to be need right now?
             * //      icdmCCASummary       : FPalette :=   does not seem to be needed right now?
             *
             *  end;
             *
             * if Assigned(FPalette) and (FPalette.TransitionColours.Count = 0) then
             *  FPalette.SetToDefaults;
             *
             * FDisplayer.Palette := FPalette; // CCA set up here
             *
             * // Assign specialty palettes that don't conform to the scaled palette base class
             * case FMode of
             *
             *  icdmTemperatureSummary:
             *    begin
             *      with (FDisplayer as TSVOICPVMDisplayer_TemperatureSummary) do
             *        BuildTemperaturePaletteFromPaletteTransitions(FPalette);
             *
             *    end;
             *  icdmCCVSummary,
             *  icdmCCVPercentSummary:
             *    begin
             *      with (FDisplayer as TSVOICPVMDisplayer_CCV) do
             *        BuildCCVSummaryPaletteFromPaletteTransitions(FPalette);
             *    end;
             *
             *  icdmGPSMode:
             *    begin
             *      with (FDisplayer as TSVOICPVMDisplayer_GPSMode) do
             *        BuildGPSModeSummaryPaletteFromPaletteTransitions(FPalette)
             *    end;
             *
             *  icdmMDPSummary,
             *  icdmMDPPercentSummary:
             *    begin
             *      with (FDisplayer as TSVOICPVMDisplayer_MDP) do
             *        BuildMDPSummaryPaletteFromPaletteTransitions(FPalette);
             *    end;
             *  icdmTargetSpeedSummary:
             *    begin
             *      with (FDisplayer as TSVOICPVMDisplayer_SpeedSummary) do
             *        BuildSpeedSummaryPaletteFromPaletteTransitions(FPalette);
             *    end;
             * end;
             */
        }
예제 #3
0
        /// <summary>
        /// Executor that implements requesting and rendering grid information to create the grid rows
        /// </summary>
        /// <returns></returns>
        public async Task <bool> ExecuteAsync()
        {
            // Get the lat lon boundary from xyz tile request
            TileBoundaryLL = MapGeo.TileXYZToRectLL(TileX, TileY, TileZ, out var yFlip);
            _log.LogInformation($"#Tile#.({TileX},{TileY}) Execute Start.  DMode:{DisplayMode}, HasLighting:{HasLighting}, Zoom:{TileZ} FlipY:{yFlip}. TileBoundary:{TileBoundaryLL.ToDisplay()}, DataModel:{DataModelUid}");

            if (TileZ == 0) // Send back default root tile
            {
                MakeRootTile();
                return(true);
            }

            SiteModel = DIContext.Obtain <ISiteModels>().GetSiteModel(DataModelUid);
            if (SiteModel == null)
            {
                ResultStatus = RequestErrorStatus.NoSuchDataModel;
                _log.LogError($"Tile.({TileX},{TileY}) Failed to obtain site model for {DataModelUid}");
                return(false);
            }

            var siteModelExtentWithSurveyedSurfaces = SiteModel.GetAdjustedDataModelSpatialExtents(null);

            _log.LogDebug($"Tile.({TileX},{TileY}) Site model extents are {siteModelExtentWithSurveyedSurfaces}. TileBoundary:{TileBoundaryLL.ToDisplay()}");
            if (!siteModelExtentWithSurveyedSurfaces.IsValidPlanExtent) // No data return empty tile
            {
                return(BuildEmptyTile());
            }

            // We will draw all missing data just below lowest elevation for site
            LowestElevation = (float)siteModelExtentWithSurveyedSurfaces.MinZ - 1F;

            Initialise();                                           // setup tile requirements

            if (TileGridSize == QMConstants.FlatResolutionGridSize) // Too far out to see detail so return empty tile
            {
                return(BuildEmptyTile());
            }

            if (DisplayMode == QMConstants.DisplayModeDemo) // development use only
            {
                return(BuildDemoTile());
            }

            try
            {
                var setupResult = await SetupPipelineTask(siteModelExtentWithSurveyedSurfaces, SiteModel.CellSize);

                if (!setupResult)
                {
                    if (ResultStatus != RequestErrorStatus.InvalidCoordinateRange)
                    {
                        _log.LogError($"Tile.({TileX},{TileY}) Unable to setup pipelinetask.");
                    }
                    return(BuildEmptyTile());
                }

                processor.Process();

                if (GriddedElevationsResponse.ResultStatus != RequestErrorStatus.OK)
                {
                    _log.LogError($"Tile.({TileX},{TileY}) Unable to obtain data for gridded data. GriddedElevationRequestResponse: {GriddedElevationsResponse.ResultStatus.ToString()}");
                    return(BuildEmptyTile());
                }

                ElevData.HasData = !float.IsPositiveInfinity(task.MinElevation); // check for data

                // Developer Debugging Only
                if (ElevData.HasData)
                {
                    OutputDebugTile("Raw");
                }

                if (!ElevData.HasData)
                {
                    return(BuildEmptyTile());
                }

                _log.LogInformation($"#Tile#.({TileX},{TileY}) Data successfully sampled. GridSize:{TileGridSize} Min:{task.MinElevation}, Max:{task.MaxElevation} FirstElev:{GriddedElevDataArray[0, 0].Elevation}, LastElev:{GriddedElevDataArray[TileGridSize - 1, TileGridSize - 1].Elevation}");

                ElevData.HasLighting = HasLighting;
                // Transform gridded data into a format the mesh builder can use
                ConvertGridToDEM(task.MinElevation, task.MaxElevation);

                // Build a quantized mesh from sampled elevations
                QMTileBuilder tileBuilder = new QMTileBuilder()
                {
                    TileData = ElevData, GridSize = TileGridSize
                };
                _log.LogInformation($"Tile.({TileX},{TileY}) BuildQuantizedMeshTile. GridSize:{TileGridSize} Min:{ElevData.MinimumHeight}, Max:{ElevData.MaximumHeight}");
                if (!tileBuilder.BuildQuantizedMeshTile())
                {
                    _log.LogError($"Tile.({TileX},{TileY}) BuildQuantizedMeshTile returned false with error code: {tileBuilder.BuildTileFaultCode}");
                    return(false);
                }

                QMTileResponse.data         = tileBuilder.QuantizedMeshTile; // Make tile from mesh
                ResultStatus                = RequestErrorStatus.OK;
                QMTileResponse.ResultStatus = ResultStatus;
                _log.LogDebug($"#Tile#.({TileX},{TileY}) Execute End. Returning production tile. CesiumY:{yFlip}, Zoom:{TileZ}, GridSize:{TileGridSize}");

                return(true);
            }
            catch (Exception ex)
            {
                _log.LogError(ex, $"#Tile#.({TileX},{TileY}). Exception building QuantizedMesh tile: ");
                return(false);
            }
        }