File tree Expand file tree Collapse file tree 3 files changed +12
-27
lines changed Expand file tree Collapse file tree 3 files changed +12
-27
lines changed Original file line number Diff line number Diff line change @@ -513,9 +513,12 @@ export function formatBytes(nbytes: number) {
513
513
}
514
514
515
515
export function formatVoxels ( voxelCount : number ) {
516
- if ( voxelCount == null || ! Number . isFinite ( voxelCount ) ) {
516
+ if ( voxelCount == null ) {
517
517
return "" ;
518
518
}
519
+ if ( ! Number . isFinite ( voxelCount ) ) {
520
+ return "Infinity" ;
521
+ }
519
522
if ( voxelCount > 2 ** 50 ) {
520
523
return `${ ( voxelCount / 2 ** 50 ) . toPrecision ( 4 ) } PVx` ;
521
524
}
Original file line number Diff line number Diff line change @@ -351,28 +351,13 @@ function getDatasetExtentAsProduct(extent: {
351
351
height : number ;
352
352
depth : number ;
353
353
} ) {
354
- const safeMultiply = ( a : number , b : number ) => {
355
- const result = a * b ;
356
- if ( ! Number . isFinite ( result ) ) {
357
- throw new Error ( "Dataset extent product exceeds maximum safe number" ) ;
358
- }
359
- return result ;
360
- } ;
361
- return safeMultiply ( safeMultiply ( extent . width , extent . height ) , extent . depth ) ;
354
+ return extent . width * extent . height * extent . depth ;
362
355
}
363
356
export function getDatasetExtentInVoxelAsProduct ( dataset : APIDataset ) {
364
- try {
365
- return getDatasetExtentAsProduct ( getDatasetExtentInVoxel ( dataset ) ) ;
366
- } catch ( e ) {
367
- console . error ( e ) ;
368
- }
357
+ return getDatasetExtentAsProduct ( getDatasetExtentInVoxel ( dataset ) ) ;
369
358
}
370
359
export function getDatasetExtentInUnitAsProduct ( dataset : APIDataset ) {
371
- try {
372
- return getDatasetExtentAsProduct ( getDatasetExtentInUnit ( dataset ) ) ;
373
- } catch ( e ) {
374
- console . error ( e ) ;
375
- }
360
+ return getDatasetExtentAsProduct ( getDatasetExtentInUnit ( dataset ) ) ;
376
361
}
377
362
export function determineAllowedModes ( settings ?: Settings ) : {
378
363
preferredMode : APIAllowedMode | null | undefined ;
Original file line number Diff line number Diff line change @@ -131,20 +131,17 @@ export function DatasetExtentRow({ dataset }: { dataset: APIDataset }) {
131
131
const extentInLength = getDatasetExtentAsString ( dataset , false ) ;
132
132
const extentProductInVx = getDatasetExtentInVoxelAsProduct ( dataset ) ;
133
133
const extentProductInUnit = getDatasetExtentInUnitAsProduct ( dataset ) ;
134
- const formattedExtentinUnit =
135
- extentProductInUnit != null
136
- ? formatNumberToVolume (
137
- extentProductInUnit ,
138
- LongUnitToShortUnitMap [ dataset . dataSource . scale . unit ] ,
139
- )
140
- : "Unable to calculate" ;
134
+ const formattedExtentinUnit = formatNumberToVolume (
135
+ extentProductInUnit ,
136
+ LongUnitToShortUnitMap [ dataset . dataSource . scale . unit ] ,
137
+ ) ;
141
138
142
139
const renderDSExtentTooltip = ( ) => {
143
140
return (
144
141
< div >
145
142
Dataset extent:
146
143
< br />
147
- { extentProductInVx != null ? formatVoxels ( extentProductInVx ) : "Unable to calculate" }
144
+ { formatVoxels ( extentProductInVx ) }
148
145
< br />
149
146
{ formattedExtentinUnit }
150
147
</ div >
You can’t perform that action at this time.
0 commit comments