Skip to content

Commit 5a77b9c

Browse files
hackermdhackermd
authored andcommitted
Use constant to avoid repeated access of pyramid
1 parent b4fe781 commit 5a77b9c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/api.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,14 @@ import DICOMwebClient from 'dicomweb-client/build/dicomweb-client.js'
4343

4444

4545
function _geometry2Scoord3d(geometry, pyramid) {
46+
const referencedFrameOfReferenceUID = pyramid[pyramid.length-1].frameOfReferenceUID;
4647
const type = geometry.getType();
4748
if (type === 'Point') {
4849
let coordinates = geometry.getCoordinates();
4950
coordinates = _geometryCoordinates2scoord3dCoordinates(coordinates, pyramid);
5051
return new Point({
5152
coordinates,
52-
referencedFrameOfReferenceUID: pyramid[pyramid.length-1].frameOfReferenceUID
53+
referencedFrameOfReferenceUID: referencedFrameOfReferenceUID
5354
});
5455
} else if (type === 'Polygon') {
5556
/*
@@ -61,15 +62,15 @@ function _geometry2Scoord3d(geometry, pyramid) {
6162
});
6263
return new Polygon({
6364
coordinates,
64-
referencedFrameOfReferenceUID: pyramid[pyramid.length-1].frameOfReferenceUID
65+
referencedFrameOfReferenceUID: referencedFrameOfReferenceUID
6566
});
6667
} else if (type === 'LineString') {
6768
let coordinates = geometry.getCoordinates().map(c => {
6869
return _geometryCoordinates2scoord3dCoordinates(c, pyramid);
6970
});
7071
return new Polyline({
7172
coordinates,
72-
referencedFrameOfReferenceUID: pyramid[pyramid.length-1].frameOfReferenceUID
73+
referencedFrameOfReferenceUID: referencedFrameOfReferenceUID
7374
});
7475
} else if (type === 'Circle') {
7576
// chunking the Flat Coordinates into two arrays within 3 elements each
@@ -84,7 +85,7 @@ function _geometry2Scoord3d(geometry, pyramid) {
8485
})
8586
return new Circle({
8687
coordinates,
87-
referencedFrameOfReferenceUID: pyramid[pyramid.length-1].frameOfReferenceUID
88+
referencedFrameOfReferenceUID: referencedFrameOfReferenceUID
8889
});
8990
} else {
9091
// TODO: Combine multiple points into MULTIPOINT.

0 commit comments

Comments
 (0)