File tree Expand file tree Collapse file tree 2 files changed +23
-11
lines changed Expand file tree Collapse file tree 2 files changed +23
-11
lines changed Original file line number Diff line number Diff line change @@ -361,14 +361,25 @@ function getFeatureScoord3dLength (feature, pyramid) {
361361 const scoord3dCoordinates = coordinates . map ( ( c ) =>
362362 geometryCoordinates2scoord3dCoordinates ( c , pyramid )
363363 )
364- const p1 = scoord3dCoordinates [ 0 ]
365- const p2 = scoord3dCoordinates [ 1 ]
366- let xLen = p2 [ 0 ] - p1 [ 0 ]
367- let yLen = p2 [ 1 ] - p1 [ 1 ]
368- xLen *= xLen
369- yLen *= yLen
370- return Math . sqrt ( xLen + yLen ) * 1000
364+ let length = 0
365+ for ( let i = 0 ; i < ( scoord3dCoordinates . length - 1 ) ; i ++ ) {
366+ const p1 = scoord3dCoordinates [ i ]
367+ const p2 = scoord3dCoordinates [ i + 1 ]
368+ let xLen = p2 [ 0 ] - p1 [ 0 ]
369+ let yLen = p2 [ 1 ] - p1 [ 1 ]
370+ xLen *= xLen
371+ yLen *= yLen
372+ length += Math . sqrt ( xLen + yLen ) * 1000
373+ }
374+ return length
375+ } else {
376+ throw new Error ( 'ROI does not have any coordinates.' )
371377 }
378+ } else {
379+ throw new Error (
380+ 'Calculation of length is only supported for ROIs with spatial ' +
381+ 'coordinates of graphic type POLYLINE.'
382+ )
372383 }
373384}
374385
Original file line number Diff line number Diff line change @@ -675,14 +675,15 @@ class VolumeImageViewer {
675675 */
676676 this [ _projection ] = new Projection ( {
677677 code : 'DICOM' ,
678- units : 'metric' ,
678+ units : 'm' ,
679+ global : true ,
679680 extent : this [ _referenceExtents ] ,
680681 getPointResolution : ( pixelRes , point ) => {
681682 /** DICOM Pixel Spacing has millimeter unit while the projection has
682- * has meter unit.
683+ * meter unit.
683684 */
684685 const spacing = getPixelSpacing (
685- image . pyramidMetadata [ image . pyramidMetadata . length - 1 ]
686+ this [ _pyramidMetadata ] [ this [ _pyramidMetadata ] . length - 1 ]
686687 ) [ 0 ]
687688 return pixelRes * spacing / 10 ** 3
688689 }
@@ -2219,7 +2220,7 @@ class _NonVolumeImageViewer {
22192220 extent : extent ,
22202221 getPointResolution : ( pixelRes , point ) => {
22212222 /** DICOM Pixel Spacing has millimeter unit while the projection has
2222- * has meter unit.
2223+ * meter unit.
22232224 */
22242225 const mmSpacing = getPixelSpacing ( this [ _metadata ] ) [ 0 ]
22252226 const spacing = mmSpacing / resizeFactor / 10 ** 3
You can’t perform that action at this time.
0 commit comments