Skip to content

Commit 1607859

Browse files
Handle area and length calc exceptions (#61)
1 parent 20ca619 commit 1607859

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

src/annotations/markups/measurement.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import {
1313
* @return {string} The formatted measure of this feature
1414
*/
1515
export const format = (feature, units, pyramid) => {
16-
const length = getFeatureScoord3dLength(feature, pyramid)
1716
const area = getFeatureScoord3dArea(feature, pyramid)
18-
const value = length || area
17+
const length = getFeatureScoord3dLength(feature, pyramid)
18+
const value = length || area || 0
1919
return length
2020
? `${value.toFixed(2)} ${units}`
2121
: `${value.toFixed(2)} ${units}²`

src/scoord3dUtils.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -375,11 +375,6 @@ function getFeatureScoord3dLength (feature, pyramid) {
375375
} else {
376376
throw new Error('ROI does not have any coordinates.')
377377
}
378-
} else {
379-
throw new Error(
380-
'Calculation of length is only supported for ROIs with spatial ' +
381-
'coordinates of graphic type POLYLINE.'
382-
)
383378
}
384379
}
385380

src/viewer.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,9 @@ function _updateFeatureMeasurements (map, feature, pyramid) {
337337
const area = getFeatureScoord3dArea(feature, pyramid)
338338
const length = getFeatureScoord3dLength(feature, pyramid)
339339

340-
if (!area && !length) return
340+
if (area == null && length == null) {
341+
return
342+
}
341343

342344
const unitSuffixToMeaningMap = {
343345
μm: 'micrometer',

0 commit comments

Comments
 (0)