@@ -50226,12 +50226,50 @@
5022650226 }
5022750227
5022850228
50229+ function _scoord2Geometry(scoord) {
50230+ const type = scoord.graphicType;
50231+ const data = scoord.graphicData;
50232+ if (type === 'POINT') {
50233+ let coordinates = _scoordCoordinates2geometryCoordinates(data);
50234+ return new Point(coordinates);
50235+ } else if (type === 'MULTIPOINT') {
50236+ const points = [];
50237+ for (d in data) {
50238+ let coordinates = _scoordCoordinates2geometryCoordinates(d);
50239+ let p = new Point(coordinates);
50240+ points.push(p);
50241+ }
50242+ return points;
50243+ } else if (type === 'POLYLINE') {
50244+ if (data[0] === data[data.length-1]) {
50245+ let coordinates = [_scoordCoordinates2geometryCoordinates(data)];
50246+ return new Polygon(coordinates);
50247+ } else {
50248+ let coordinates = _scoordCoordinates2geometryCoordinates(data);
50249+ return new LineStringGeometry(coordinates);
50250+ }
50251+ } else if (type === 'CIRCLE') {
50252+ let coordinates = _scoordCoordinates2geometryCoordinates(data);
50253+ let center = coordinates[0];
50254+ let radius = Math.abs(coordinates[1][0] - coordinates[0][0]);
50255+ return new Circle(center, radius);
50256+ } else if (type === 'ELLIPSE') ; else {
50257+ console.error(`unknown graphic type "${type}"`);
50258+ }
50259+ }
50260+
50261+
5022950262 function _geometryCoordinates2scoordCoordinates(coordinates) {
5023050263 // TODO: Transform to coordinates on pyramid base layer???
5023150264 return [coordinates[0] + 1, -coordinates[1]]
5023250265 }
5023350266
5023450267
50268+ function _scoordCoordinates2geometryCoordinates(coordinates) {
50269+ return [coordinates[0] - 1, -coordinates[1]]
50270+ }
50271+
50272+
5023550273 const _map = Symbol('map');
5023650274 const _features = Symbol('features');
5023750275 const _drawingSource = Symbol('drawingSource');
@@ -50338,11 +50376,13 @@
5033850376 const totalSizes = [];
5033950377 const resolutions = [];
5034050378 const origins = [[0, -1]];
50341- for (let j = 0; j < this[_pyramid].length; j++) {
50379+ const nLevels = this[_pyramid].length;
50380+ for (let j = 0; j < nLevels; j++) {
5034250381 let columns = this[_pyramid][j].columns;
5034350382 let rows = this[_pyramid][j].rows;
5034450383 let totalPixelMatrixColumns = this[_pyramid][j].totalPixelMatrixColumns;
5034550384 let totalPixelMatrixRows = this[_pyramid][j].totalPixelMatrixRows;
50385+ let pixelSpacing = this[_pyramid][j].pixelSpacing;
5034650386 let colFactor = Math.ceil(totalPixelMatrixColumns / columns);
5034750387 let rowFactor = Math.ceil(totalPixelMatrixRows / rows);
5034850388 tileSizes.push([columns, rows]);
5035250392 * Compute the resolution at each pyramid level, since the zoom
5035350393 * factor may not be the same between adjacent pyramid levels.
5035450394 */
50355- let zoomFactorColumns = this[_pyramid][0].totalPixelMatrixColumns / totalPixelMatrixColumns;
50356- let zoomFactorRows = this[_pyramid][0].totalPixelMatrixRows / totalPixelMatrixRows;
50357- let zoomFactor = (zoomFactorColumns + zoomFactorRows) / 2;
50395+ let zoomFactor = this[_pyramid][nLevels-1].totalPixelMatrixRows / totalPixelMatrixRows;
5035850396 resolutions.push(zoomFactor);
5035950397
5036050398 /*
5047050508 */
5047150509 const extent = [
5047250510 0, // min X
50473- -pyramid[0 ].totalPixelMatrixRows, // min Y
50474- pyramid[0 ].totalPixelMatrixColumns, // max X
50511+ -pyramid[nLevels-1 ].totalPixelMatrixRows, // min Y
50512+ pyramid[nLevels-1 ].totalPixelMatrixColumns, // max X
5047550513 -1 // max Y
5047650514 ];
5047750515
5052150559 * DICOM pixel spacing has millimeter unit while the projection has
5052250560 * has meter unit.
5052350561 */
50524- let spacing = pyramid[0 ].pixelSpacing[1 ] / 10**3;
50525- let metricRes = pixelRes * spacing;
50526- return(metricRes );
50562+ let spacing = pyramid[nLevels-1 ].pixelSpacing[0 ] / 10**3;
50563+ let res = pixelRes * spacing;
50564+ return(res );
5052750565 }
5052850566 });
5052950567 /*
@@ -50875,14 +50913,13 @@
5087550913 }
5087650914
5087750915 addScoord(item) {
50878- let geometry = _graphic2Geometry (item);
50916+ let geometry = _scoord2Geometry (item);
5087950917 let feature = new Feature({geometry});
50880- this[_features].push(feature);
5088150918 this[_drawingSource].addFeature(feature);
5088250919 }
5088350920
5088450921 updateScoord(index, item) {
50885- let geometry = _graphic2Geometry (item);
50922+ let geometry = _scoord2Geometry (item);
5088650923 let feature = new Feature({geometry});
5088750924 this[_features].setAt(index, feature);
5088850925 }
0 commit comments