public ISOGrid Export(RasterGridPrescription adaptRx, ISOTreatmentZone type2DefaultTreatmentZone = null, List <byte> type1TreatmentZoneCodes = null) { ISOGrid grid = new ISOGrid(); if (type1TreatmentZoneCodes != null) { grid.Filename = WriteType1GridFile(type1TreatmentZoneCodes); grid.GridType = 1; } else if (type2DefaultTreatmentZone != null) { grid.Filename = WriteType2GridFile(adaptRx, type2DefaultTreatmentZone); grid.GridType = 2; grid.TreatmentZoneCode = type2DefaultTreatmentZone.TreatmentZoneCode; } FileInfo info = new FileInfo(Path.Combine(this.TaskDataPath, Path.ChangeExtension(grid.Filename, "bin"))); grid.Filelength = (uint)info.Length; grid.GridMinimumNorthPosition = Convert.ToDecimal(GetOriginY(adaptRx)); grid.GridMinimumEastPosition = Convert.ToDecimal(GetOriginX(adaptRx)); grid.GridCellNorthSize = GetCellHeight(adaptRx); grid.GridCellEastSize = GetCellWidth(adaptRx); grid.GridMaximumColumn = (uint)adaptRx.ColumnCount; grid.GridMaximumRow = (uint)adaptRx.RowCount; return(grid); }
internal bool LoadGridDefinition(ISOGrid grid) { if (!LoadOriginPosition(grid)) { return(false); } if (!LoadCellDimensions(grid)) { return(false); } return(true); }
private bool LoadOriginPosition(ISOGrid grid) { decimal minLatitude = grid.GridMinimumNorthPosition; if (minLatitude < -90 || minLatitude > 90) { return(false); } decimal minLongitude = grid.GridMinimumEastPosition; if (minLongitude < -180 || minLongitude > 180) { return(false); } Origin = new Point(); Origin.Y = (double)minLatitude; Origin.X = (double)minLongitude; return(true); }
internal bool LoadRates(string dataPath, ISOGrid grid, ISOTreatmentZone treatmentZone = null) { if (string.IsNullOrEmpty(grid.Filename)) { return(false); } if (grid.GridType == 1) { TreatmentZoneCodes = grid.GetRatesForGridType1(dataPath); return(TreatmentZoneCodes?.Count == RowCount * ColumnCount); } else if (grid.GridType == 2) { ProductRates = grid.GetRatesForGridType2(dataPath, treatmentZone); return(ProductRates?.Count == RowCount * ColumnCount); } else { return(false); } }
private bool LoadCellDimensions(ISOGrid grid) { double gridCellSizeLatitude = grid.GridCellNorthSize; if (gridCellSizeLatitude < 0 || gridCellSizeLatitude > 1) { return(false); } double gridCellSizeLongitude = grid.GridCellEastSize; if (gridCellSizeLongitude < 0 || gridCellSizeLongitude > 1) { return(false); } uint columnCount = grid.GridMaximumColumn; if (columnCount < 0) { return(false); } uint rowCount = grid.GridMaximumRow; if (rowCount < 0) { return(false); } ColumnCount = (int)columnCount; RowCount = (int)rowCount; CellHeight = new NumericRepresentationValue(null, new NumericValue(null, gridCellSizeLatitude)); CellWidth = new NumericRepresentationValue(null, new NumericValue(null, gridCellSizeLongitude)); return(true); }