/// <summary> /// Processes an elevation sub grid into a cut fill isopach and calculate the counts of cells where the cut fill /// height fits into the requested bands /// </summary> public override void ProcessSubGridResult(IClientLeafSubGrid[][] subGrids) { _lock.Wait(); try { base.ProcessSubGridResult(subGrids); // Works out the percentage each colour on the map represents foreach (var subGrid in subGrids) { if ((subGrid?.Length ?? 0) > 0 && subGrid[0] is ClientHeightLeafSubGrid SubGrid) { SubGridUtilities.SubGridDimensionalIterator((I, J) => { var Value = SubGrid.Cells[I, J]; if (Value != Consts.NullHeight) // is there a value to test { SummaryCellsScanned++; IncrementCountOfCutFillTransition(Value); } }); } } } finally { _lock.Release(); } }
public async Task CSVExportRequest_Execute_ExceedsLimit() { DILoggingFixture.SetMaxExportRowsConfig(1); AddApplicationGridRouting(); AddClusterComputeGridRouting(); var tempFileName = MockS3FileTransfer_UploadToBucket(); var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel(); var request = new CSVExportRequest(); var baseDate = DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 0, 0, 0), DateTimeKind.Utc); var cellPasses = new CellPass[SubGridTreeConsts.SubGridTreeDimension, SubGridTreeConsts.SubGridTreeDimension][]; SubGridUtilities.SubGridDimensionalIterator((x, y) => { cellPasses[x, y] = new[] { new CellPass { Time = baseDate, Height = 1.0f } }; }); DITAGFileAndSubGridRequestsFixture.AddSingleSubGridWithPasses(siteModel, SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset, cellPasses); var response = await request.ExecuteAsync(SimpleCSVExportRequestArgument(siteModel.ID)); response.Should().NotBeNull(); response.ResultStatus.Should().Be(RequestErrorStatus.ExportExceededRowLimit); CleanupMockedFile(tempFileName, siteModel.ID); }
private ISiteModel BuildModelForSubGridRequest() { var baseTime = DateTime.UtcNow; var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel(); var bulldozerMachineIndex = siteModel.Machines.Locate("Bulldozer", false).InternalSiteModelMachineIndex; CellPass[, ][] cellPasses = new CellPass[SubGridTreeConsts.SubGridTreeDimension, SubGridTreeConsts.SubGridTreeDimension][]; SubGridUtilities.SubGridDimensionalIterator((x, y) => { cellPasses[x, y] = Enumerable.Range(0, 1).Select(p => new CellPass { Height = 1 + x + y, InternalSiteModelMachineIndex = bulldozerMachineIndex, Time = baseTime.AddMinutes(p), PassType = PassType.Front }).ToArray(); }); DITAGFileAndSubGridRequestsFixture.AddSingleSubGridWithPasses(siteModel, SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset, cellPasses); return(siteModel); }
public void Test_NullCells() { var clientGrid = ClientLeafSubGridFactoryFactory.CreateClientSubGridFactory().GetSubGrid(GridDataType.HeightAndTime) as ClientHeightAndTimeLeafSubGrid; SubGridUtilities.SubGridDimensionalIterator((x, y) => Assert.True(clientGrid.Cells[x, y] == Consts.NullHeight, "Cell not set to correct null value")); SubGridUtilities.SubGridDimensionalIterator((x, y) => Assert.True(clientGrid.Times[x, y] == 0, "Cell time not set to correct null value")); }
public void SingleSubGrid_AtOrigin(ConvolutionMaskSize contextSize) { const float ELEVATION = 10.0f; var tree = DataSmoothingTestUtilities.ConstructSingleSubGridElevationSubGridTreeAtOrigin(ELEVATION); var subGrid = tree.LocateSubGridContaining(SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.SubGridTreeLevels) as GenericLeafSubGrid <float>; subGrid.Should().NotBeNull(); var result = DataSmoothingTestUtilities.ConstructElevationSubGrid(CellPassConsts.NullHeight); result.Should().NotBeNull(); var accumulator = new ConvolutionAccumulator_Float(CellPassConsts.NullHeight, contextSize); var filter = new MeanFilter <float>(accumulator, contextSize, NullInfillMode.NoInfill); var smoother = new ConvolutionTools <float>(); smoother.Convolve(subGrid, result, filter); // All cell values should remain mostly unchanged due to non-null values around perimeter of subgrid in smoothing context // Check all acquired values in the single subgrid are the same elevation, except for the perimeter values which // will be 2/3 * Elevation due to null values. Some corner vales will have 0.44444 * ElEVATION for same reason SubGridUtilities.SubGridDimensionalIterator((x, y) => { var ok = Math.Abs(result.Items[x, y] = ELEVATION) < 0.0001 || Math.Abs(result.Items[x, y] = (2 / 3) * ELEVATION) < 0.0001 || Math.Abs(result.Items[x, y] = 0.44444f * ELEVATION) < 0.0001; ok.Should().BeTrue(); }); }
/// <summary> /// Computes a tight bounding extent around the elevation values stored in the sub grid tree /// </summary> private static BoundingWorldExtent3D DataStoreExtents(ISubGridTree dataStore) { var computedGridExtent = BoundingWorldExtent3D.Inverted(); dataStore.ScanAllSubGrids(subGrid => { var items = ((GenericLeafSubGrid <float>)subGrid).Items; SubGridUtilities.SubGridDimensionalIterator((x, y) => { var elev = items[x, y]; if (elev != Common.Consts.NullHeight) { computedGridExtent.Include(subGrid.OriginX + x, subGrid.OriginY + y, elev); } }); return(true); }); if (computedGridExtent.IsValidPlanExtent) { computedGridExtent.Offset(-SubGridTreeConsts.DefaultIndexOriginOffset, -SubGridTreeConsts.DefaultIndexOriginOffset); } // Convert the grid rectangle to a world rectangle, padding out the 3D bound by a small margin to avoid edge effects in calculations var computedWorldExtent = new BoundingWorldExtent3D ((computedGridExtent.MinX - 1.01) * dataStore.CellSize, (computedGridExtent.MinY - 1.01) * dataStore.CellSize, (computedGridExtent.MaxX + 1.01) * dataStore.CellSize, (computedGridExtent.MaxY + 1.01) * dataStore.CellSize, computedGridExtent.MinZ - 0.01, computedGridExtent.MaxZ + 0.01); return(computedWorldExtent); }
public void SubGridCellSegmentPassesDataWrapper_NonStatic_SetState_Test() { // Create the main 2D array of cell pass arrays var cellPasses = new Cell_NonStatic[SubGridTreeConsts.SubGridTreeDimension, SubGridTreeConsts.SubGridTreeDimension]; // Create each sub array and add a test cell pass to it SubGridUtilities.SubGridDimensionalIterator((x, y) => { cellPasses[x, y].Passes = new TRexSpan <CellPass>(new CellPass[1], TRexSpan <CellPass> .NO_SLAB_INDEX, 0, 1, false); cellPasses[x, y].Passes.Add(TestCellPass()); }); using (var item = new SubGridCellSegmentPassesDataWrapper_NonStatic()) { // Feed the cell passes to the segment item.SetState(cellPasses); // Check the passes all match SubGridUtilities.SubGridDimensionalIterator((x, y) => { Assert.True(cellPasses[x, y].Passes.First().Equals(item.Pass(x, y, 0)), $"Pass in cell {x}:{y} does not match"); }); } }
private ISiteModel BuildModelForCellsCMV(short cmvIncrement, short targetCMV = CellPassConsts.NullCCV) { var baseTime = DateTime.UtcNow; short baseCMV = 10; var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel(); var bulldozerMachineIndex = siteModel.Machines.Locate("Bulldozer", false).InternalSiteModelMachineIndex; if (targetCMV != CellPassConsts.NullCCV) { siteModel.MachinesTargetValues[bulldozerMachineIndex].TargetCCVStateEvents.PutValueAtDate(TRex.Common.Consts.MIN_DATETIME_AS_UTC, targetCMV); } CellPass[, ][] cellPasses = new CellPass[SubGridTreeConsts.SubGridTreeDimension, SubGridTreeConsts.SubGridTreeDimension][]; SubGridUtilities.SubGridDimensionalIterator((x, y) => { cellPasses[x, y] = Enumerable.Range(0, 1).Select(p => new CellPass { InternalSiteModelMachineIndex = bulldozerMachineIndex, Time = baseTime.AddMinutes(p), CCV = (short)(baseCMV + x * cmvIncrement), // incrementally increase CCV across the sub grid PassType = PassType.Front }).ToArray(); }); DITAGFileAndSubGridRequestsFixture.AddSingleSubGridWithPasses(siteModel, SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset, cellPasses); return(siteModel); }
public void Test_GenericLeafSubGridTests_CellHasValue() { // Note: By definition, base generic cell has value behaviour is to assume the value exists var generic = new GenericLeafSubGrid <bool>(); SubGridUtilities.SubGridDimensionalIterator((x, y) => generic.CellHasValue((byte)x, (byte)y).Should().Be(true)); }
public override void ProcessSubGridResult(IClientLeafSubGrid[][] subGrids) { lock (this) { foreach (IClientLeafSubGrid[] subGrid in subGrids) { if ((subGrid?.Length ?? 0) > 0 && subGrid[0] is ClientHeightLeafSubGrid SubGrid) { CellsScanned += SubGridTreeConsts.SubGridTreeCellsPerSubGrid; BoundingExtents.Include(SubGrid.WorldExtents()); SubGridUtilities.SubGridDimensionalIterator((I, J) => { var heightValue = SubGrid.Cells[I, J]; if (Math.Abs(heightValue - CellPassConsts.NullHeight) > Consts.TOLERANCE_HEIGHT) { CellsUsed++; if (MinElevation > heightValue) { MinElevation = heightValue; } if (MaxElevation < heightValue) { MaxElevation = heightValue; } } }); } } } }
private ISiteModel BuildModelForCellsElevation(float elevationIncrement) { var baseTime = DateTime.UtcNow; var baseElevation = 1.0F; var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel(); var bulldozerMachineIndex = siteModel.Machines.Locate("Bulldozer", false).InternalSiteModelMachineIndex; CellPass[, ][] cellPasses = new CellPass[32, 32][]; SubGridUtilities.SubGridDimensionalIterator((x, y) => { cellPasses[x, y] = Enumerable.Range(0, 1).Select(p => new CellPass { InternalSiteModelMachineIndex = bulldozerMachineIndex, Time = baseTime.AddMinutes(p), Height = baseElevation + (x + y) * elevationIncrement, // incrementally increase height across the sub grid PassType = PassType.Front }).ToArray(); }); DITAGFileAndSubGridRequestsFixture.AddSingleSubGridWithPasses(siteModel, SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset, cellPasses); return(siteModel); }
private List <StationOffsetPoint> GetMockPointsFromSiteModel(Guid projectUid, int countPointsRequired) { var points = new List <StationOffsetPoint>(); double station = 0; var siteModel = DIContext.Obtain <ISiteModels>().GetSiteModel(projectUid); /* this piece of code reads data into memory, using the existence map */ siteModel.ExistenceMap.ScanAllSetBitsAsSubGridAddresses(address => { if (points.Count > countPointsRequired) { return; } var subGrid = SubGridUtilities.LocateSubGridContaining (siteModel.PrimaryStorageProxy, siteModel.Grid, address.X, address.Y, siteModel.Grid.NumLevels, false, false); if (subGrid != null) { subGrid.CalculateWorldOrigin(out var originX, out var originY); ((IServerLeafSubGrid)subGrid).Directory.GlobalLatestCells.PassDataExistenceMap.ForEachSetBit( (x, y) => { points.Add(new StationOffsetPoint(station += 1, 0, originY + y * siteModel.CellSize + siteModel.CellSize / 2, originX + x * siteModel.CellSize + siteModel.CellSize / 2)); return(points.Count < countPointsRequired); }); } }); return(points); }
public void SubGridCellSegmentPassesDataWrapper_NonStatic_NoMachineIDSet_Test() { var cellPasses = new Cell_NonStatic[SubGridTreeConsts.SubGridTreeDimension, SubGridTreeConsts.SubGridTreeDimension]; // Create each sub array and add a test cell pass to it SubGridUtilities.SubGridDimensionalIterator((x, y) => { cellPasses[x, y].Passes = new TRexSpan <CellPass>(new CellPass[1], TRexSpan <CellPass> .NO_SLAB_INDEX, 0, 1, false); cellPasses[x, y].Passes.Add(TestCellPass()); }); ISubGridCellSegmentPassesDataWrapper item = new SubGridCellSegmentPassesDataWrapper_StaticCompressed(); // Feed the cell passes to the segment and ask it to serialise itself which will create the machine ID set item.SetState(cellPasses); using (BinaryWriter writer = new BinaryWriter(new MemoryStream(Consts.TREX_DEFAULT_MEMORY_STREAM_CAPACITY_ON_CREATION))) { item.Write(writer); } BitArray MachineIDSet = item.GetMachineIDSet(); // Check there is a machine ID set, and it contains only a single machine, being the number of the internal machine ID used to construct TestPass Assert.True(MachineIDSet != null, "Static compressed pass wrapper returned null machine ID set"); Assert.Equal(_InternalMachineID + 1, MachineIDSet.Length); Assert.True(MachineIDSet[_InternalMachineID]); for (int i = 0; i < MachineIDSet.Length - 1; i++) { Assert.False(MachineIDSet[i]); } }
public void GridToTINDecimatorTests_BuildMesh_GetTIN() { var dataStore = new DecimationElevationSubGridTree(); SubGridUtilities.SubGridDimensionalIterator((x, y) => { dataStore[SubGridTreeConsts.DefaultIndexOriginOffset + x, SubGridTreeConsts.DefaultIndexOriginOffset + y] = 100f; }); var decimator = new GridToTINDecimator(dataStore); decimator.SetDecimationExtents(DataStoreExtents(dataStore)); bool result = decimator.BuildMesh(); result.Should().BeTrue($"Failed to build mesh from data store with a sub grid of points fault code {decimator.BuildMeshFaultCode}"); decimator.GetTIN().Should().NotBeNull(); //string fileName = $@"C:\temp\UnitTestExportTTM({DateTime.Now.Ticks}).ttm"; //decimator.GetTIN().SaveToFile(fileName, true); //TrimbleTINModel tin = new TrimbleTINModel(); //tin.LoadFromFile(fileName); decimator.GetTIN().Triangles.Count.Should().Be(3); decimator.GetTIN().Triangles[0].Vertices.ForEach(x => x.Z.Should().Be(100f)); decimator.GetTIN().Vertices.Count.Should().Be(5); decimator.GetTIN().Vertices.ForEach(x => x.Z.Should().Be(100.0f)); }
private static float[,] InitialiseNullHeights() { var result = new float[SubGridTreeConsts.SubGridTreeDimension, SubGridTreeConsts.SubGridTreeDimension]; SubGridUtilities.SubGridDimensionalIterator((x, y) => result[x, y] = Consts.NullHeight); return(result); }
public void MasksOutValues_WithoutSurveyedSurfaces() { SetupTestIgniteRouting(); var(siteModel, filter) = CreateSiteModelWithSimpleDesign(); // Create a sub grid at the Northwest origin so that it covers the small TIN design surrounding the // [CellSize / 2, CellSize / 2] point var baseTime = DateTime.UtcNow; var cellPasses = new CellPass[32, 32][]; SubGridUtilities.SubGridDimensionalIterator((x, y) => { cellPasses[x, y] = Enumerable.Range(0, 1).Select(p => new CellPass { Height = 1.0f, InternalSiteModelMachineIndex = siteModel.Machines[0].InternalSiteModelMachineIndex, Time = baseTime.AddMinutes(p), PassType = PassType.Front }).ToArray(); }); DITAGFileAndSubGridRequestsFixture.AddSingleSubGridWithPasses(siteModel, SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset, cellPasses); // Construct a requestor and ask it to retrieve the sub grid from the site model, using the filter // with the surface design mask var utilities = DIContext.Obtain <IRequestorUtilities>(); var requestors = utilities.ConstructRequestors(null, siteModel, new OverrideParameters(), new LiftParameters(), utilities.ConstructRequestorIntermediaries(siteModel, new FilterSet(filter), false, GridDataType.Height), AreaControlSet.CreateAreaControlSet(), siteModel.ExistenceMap); requestors.Length.Should().Be(1); var response = requestors[0].RequestSubGridInternal (new SubGridCellAddress(SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset), true, false); response.requestResult.Should().Be(ServerRequestResult.NoError); response.clientGrid.Should().NotBeNull(); // Ensure the filtered cell has data response.clientGrid.FilterMap[0, 0].Should().BeTrue(); (response.clientGrid as IClientHeightLeafSubGrid).Cells[0, 0].Should().Be(1.0f); // Ensure no other cells have data response.clientGrid.FilterMap.CountBits().Should().Be(1); var subGrid = response.clientGrid as IClientHeightLeafSubGrid; var count = 0; subGrid.ForEach((x, y) => count += subGrid.Cells[x, y] == 1.0f ? 1 : 0); count.Should().Be(1); }
/// <summary> /// Write the contents of the Items array using the supplied writer /// </summary> /// <param name="writer"></param> public override void Write(BinaryWriter writer) { SubGridUtilities.SubGridDimensionalIterator((x, y) => { writer.Write(Items[x, y].Count); writer.Write(Items[x, y].TriangleArrayIndex); }); }
private SubGridTreeSubGridExistenceBitMask MakeSprinkledBitMask(int sprinkleFactor) { var result = new SubGridTreeSubGridExistenceBitMask(); SubGridUtilities.SubGridDimensionalIterator((x, y) => { result[x * sprinkleFactor, y * sprinkleFactor] = true; }); return(result); }
public void Test_SubGridDimensionalIterator_ActionFunctor() { // Ensure the iterator covers all the cells in a sub grid int counter = 0; SubGridUtilities.SubGridDimensionalIterator((x, y) => counter++); Assert.Equal(SubGridTreeConsts.SubGridTreeCellsPerSubGrid, counter); }
public void Test_NullCells() { var cell = new ClientCellProfileAllPassesLeafSubgridRecord(); cell.Clear(); var clientGrid = ClientLeafSubGridFactoryFactory.CreateClientSubGridFactory().GetSubGrid(GridDataType.CellPasses) as ClientCellProfileAllPassesLeafSubgrid; SubGridUtilities.SubGridDimensionalIterator((x, y) => Assert.True(clientGrid.Cells[x, y].GetHashCode() == cell.GetHashCode())); }
public void Test_NullCells() { var cell = new MachineSpeedExtendedRecord(); cell.Clear(); var clientGrid = ClientLeafSubGridFactoryFactory.CreateClientSubGridFactory().GetSubGrid(GridDataType.MachineSpeedTarget) as ClientMachineTargetSpeedLeafSubGrid; SubGridUtilities.SubGridDimensionalIterator((x, y) => Assert.True(clientGrid.Cells[x, y].Equals(cell))); }
public void Test_NullCells() { var cell = new SubGridCellPassDataPassCountEntryRecord(); cell.Clear(); var clientGrid = ClientLeafSubGridFactoryFactory.CreateClientSubGridFactory().GetSubGrid(GridDataType.PassCount) as ClientPassCountLeafSubGrid; SubGridUtilities.SubGridDimensionalIterator((x, y) => Assert.True(clientGrid.Cells[x, y].Equals(cell))); }
public void AllCellsInOriginSubGridGivePartitionZero() { var func = new SubGridBasedSpatialAffinityFunction(); SubGridUtilities.SubGridDimensionalIterator((x, y) => { var partition = func.GetPartition(new SubGridSpatialAffinityKey(0, Guid.NewGuid(), new SubGridCellAddress(x, y))); partition.Should().Be(0); }); }
public void Test_NullCells() { var cell = new SubGridCellCompositeHeightsRecord(); cell.Clear(); var clientGrid = ClientLeafSubGridFactoryFactory.CreateClientSubGridFactory().GetSubGrid(GridDataType.CompositeHeights) as ClientCompositeHeightsLeafSubgrid; SubGridUtilities.SubGridDimensionalIterator((x, y) => Assert.True(clientGrid.Cells[x, y].Equals(cell))); }
/// <summary> /// Fill the items array by reading the binary representation using the provided reader. /// This is an unimplemented override; a generic BinaryReader based implementation is not provided. /// Override to implement if needed. /// </summary> /// <param name="reader"></param> public override void Read(BinaryReader reader) { TriangleArrayReference arrayReference = new TriangleArrayReference(); SubGridUtilities.SubGridDimensionalIterator((x, y) => { arrayReference.Count = reader.ReadInt16(); arrayReference.TriangleArrayIndex = reader.ReadInt32(); Items[x, y] = arrayReference; }); }
public void Test_MutabilityConverterTests_ConvertSubgridDirectoryTest() { // Create a sub grid directory with a single segment and some cells. Create a stream from it then use the // mutability converter to convert it to the immutable form. Read this back into an immutable representation // and compare the mutable and immutable versions for consistency. // Create a leaf to contain the mutable directory IServerLeafSubGrid mutableLeaf = new ServerSubGridTreeLeaf(null, null, SubGridTreeConsts.SubGridTreeLevels, StorageMutability.Mutable); mutableLeaf.Directory.GlobalLatestCells = DIContext.Obtain <ISubGridCellLatestPassesDataWrapperFactory>().NewMutableWrapper_Global(); // Load the mutable stream of information mutableLeaf.Directory.CreateDefaultSegment(); SubGridUtilities.SubGridDimensionalIterator((x, y) => { var cellPass = (mutableLeaf.Directory.GlobalLatestCells as SubGridCellLatestPassDataWrapper_NonStatic)[x, y]; cellPass.Height = 1234.5678F; (mutableLeaf.Directory.GlobalLatestCells as SubGridCellLatestPassDataWrapper_NonStatic)[x, y] = cellPass; }); // Take a copy of the mutable cells for later reference SubGridCellLatestPassDataWrapper_NonStatic mutableCells = (mutableLeaf.Directory.GlobalLatestCells as SubGridCellLatestPassDataWrapper_NonStatic); MemoryStream mutableStream = new MemoryStream(Consts.TREX_DEFAULT_MEMORY_STREAM_CAPACITY_ON_CREATION); mutableLeaf.SaveDirectoryToStream(mutableStream); var mutabilityConverter = new MutabilityConverter(); /* todo also test using the mutableStream */ mutabilityConverter.ConvertToImmutable(FileSystemStreamType.SubGridDirectory, null, mutableLeaf, out MemoryStream immutableStream); IServerLeafSubGrid immutableLeaf = new ServerSubGridTreeLeaf(null, null, SubGridTreeConsts.SubGridTreeLevels, StorageMutability.Immutable); immutableLeaf.Directory.GlobalLatestCells = DIContext.Obtain <ISubGridCellLatestPassesDataWrapperFactory>().NewImmutableWrapper_Global(); immutableStream.Position = 0; immutableLeaf.LoadDirectoryFromStream(immutableStream); SubGridCellLatestPassDataWrapper_StaticCompressed immutableCells = (immutableLeaf.Directory.GlobalLatestCells as SubGridCellLatestPassDataWrapper_StaticCompressed); // Check height of the cells match to tolerance given the compressed lossiness. SubGridUtilities.SubGridDimensionalIterator((x, y) => { double mutableValue = mutableCells[x, y].Height; double immutableValue = immutableCells.ReadHeight(x, y); double diff = immutableValue - mutableValue; Assert.True(Math.Abs(diff) <= 0.001, $"Cell height at ({x}, {y}) has unexpected value: {immutableValue} vs {mutableValue}, diff = {diff}"); }); }
public List <string> ProcessSubGrid(ClientCellProfileAllPassesLeafSubgrid allPassesSubGrid) { var rows = new List <string>(); if (RecordCountLimitReached()) { return(rows); } var runningIndexLLHCoords = 0; var halfPassCount = 0; if (_requestArgument.CoordType == CoordType.LatLon) { _llhCoords = SetupLLPositions(_siteModel.CSIB(), allPassesSubGrid); } allPassesSubGrid.CalculateWorldOrigin(out var subGridWorldOriginX, out var subGridWorldOriginY); SubGridUtilities.SubGridDimensionalIterator((x, y) => { if (RecordCountLimitReached()) { return; } var cell = allPassesSubGrid.Cells[x, y]; foreach (var cellPass in cell.CellPasses) { if (RecordCountLimitReached()) { break; } // we only include the 2nd part of a half pass if (cellPass.HalfPass) { halfPassCount++; if (halfPassCount < 2) { continue; } } halfPassCount = 0; var easting = subGridWorldOriginX + (x + 0.5) * allPassesSubGrid.CellSize; var northing = subGridWorldOriginY + (y + 0.5) * allPassesSubGrid.CellSize; rows.Add(FormatADataRow(cellPass, easting, northing, runningIndexLLHCoords)); _totalRowCountSoFar++; } runningIndexLLHCoords++; }); return(rows); }
public void AllCellsAssignment_AtOrigin() { var accum = new PVMTaskAccumulator <float, ClientHeightLeafSubGrid>( SubGridTreeConsts.DefaultCellSize, SubGridTreeConsts.DefaultCellSize, SubGridTreeConsts.SubGridTreeDimension, SubGridTreeConsts.SubGridTreeDimension, 0, 0, SubGridTreeConsts.SubGridTreeDimension * SubGridTreeConsts.DefaultCellSize, SubGridTreeConsts.SubGridTreeDimension * SubGridTreeConsts.DefaultCellSize, SubGridTreeConsts.DefaultCellSize); var subGrid = NewClientSubGrid(); accum.Transcribe(new IClientLeafSubGrid[] { subGrid }).Should().Be(true); SubGridUtilities.SubGridDimensionalIterator((x, y) => Math.Abs(accum.ValueStore[x, y] - (x + y)).Should().BeLessThan(0.01f)); }
private ClientCompositeHeightsLeafSubgrid TestSubGrid() { var clientGrid = ClientLeafSubGridFactoryFactory.CreateClientSubGridFactory().GetSubGrid(GridDataType.CompositeHeights) as ClientCompositeHeightsLeafSubgrid; SubGridUtilities.SubGridDimensionalIterator((x, y) => { clientGrid.Cells[x, y].FirstHeight = 1.1f; clientGrid.Cells[x, y].HighestHeight = 1.1f; clientGrid.Cells[x, y].LastHeight = 1.1f; clientGrid.Cells[x, y].LowestHeight = 1.1f; }); return(clientGrid); }
public void Test_CellPassAttributeFilter_ClearElevationRangeFilterInitialization() { var filterAnnex = new CellPassAttributeFilterProcessingAnnex { ElevationRangeIsInitialized = true, ElevationRangeDesignElevations = new float[SubGridTreeConsts.SubGridTreeDimension, SubGridTreeConsts.SubGridTreeDimension] }; SubGridUtilities.SubGridDimensionalIterator((x, y) => filterAnnex.ElevationRangeDesignElevations[x, y] = Consts.NullHeight); filterAnnex.ClearElevationRangeFilterInitialization(); Assert.True(filterAnnex.ElevationRangeIsInitialized == false && filterAnnex.ElevationRangeDesignElevations == null); }