@@ -2,60 +2,6 @@ const xpath = require('xpath');
2
2
const { getDecoder } = require ( 'geotiff/dist/compression' ) ;
3
3
const { parseXml } = require ( 'geotiff/dist/globals' ) ;
4
4
5
- /*
6
- async function getStats(image, options) {
7
- options = options || {};
8
- const maxBufferSize = options.maxBufferSize || 800; // this is 1 KB
9
- const debug = options.debug || false;
10
-
11
- if (debug) console.log("image:", image);
12
-
13
- const { fileDirectory } = image;
14
-
15
- const numBands = fileDirectory.SamplesPerPixel;
16
-
17
- const noDataValue = fileDirectory.GDAL_NODATA ? parseFloat(fileDirectory.GDAL_NODATA) : null;
18
- if (debug) console.log("noDataValue:", noDataValue);
19
-
20
- const bitsPerSample = Array.from(image.fileDirectory.BitsPerSample);
21
- console.log("bitsPerSample:", bitsPerSample);
22
- const chunkSizeInPixels = bitsPerSample.map(nbits => {
23
- return maxBufferSize / nbits;
24
- });
25
- console.log("chunkSizeInPixels:", chunkSizeInPixels);
26
- const sides = chunkSizeInPixels.map(size => Math.round(Math.sqrt(size)));
27
- if (debug) console.log("sides:", sides);
28
- const chunkHeights = sides.map(side => side);
29
- const chunkWidths = sides.map(side => side);
30
- console.log("width:", image.getWidth());
31
- const numRowsOfChunks = chunkHeights.map(chunkHeight => Math.ceil(image.getHeight() / chunkHeight));
32
- const numColumnsOfChunks = chunkWidths.map(chunkWidth => Math.ceil(image.getWidth() / chunkWidth));
33
-
34
- const maxes = [];
35
- const mins = [];
36
-
37
- for (let bandIndex = 0; bandIndex < numBands; bandIndex++) {
38
- const chunkHeight = chunkHeights[bandIndex];
39
- const chunkWidth = chunkWidths[bandIndex];
40
- for (let rowIndex = 0; rowIndex < numRowsOfChunks; rowIndex++) {
41
- for (let columnIndex = 0; columnIndex < numColumnsOfChunks; columnIndex++) {
42
- const top = rowIndex * chunkHeight;
43
- const left = columnIndex * chunkWidth;
44
- const right = left + chunkWidth;
45
- const bottom = top + chunkHeight;
46
- const params = {
47
- samples: [bandIndex],
48
- window: [left, top, right, bottom]
49
- };
50
- console.log("params:", params);
51
- const chunk = await image.readRasters(options);
52
- console.log("chunk:", chunk);
53
- }
54
- }
55
- }
56
- }
57
- */
58
-
59
5
function sum ( array , start , end ) {
60
6
let s = 0 ;
61
7
for ( let i = start ; i < end ; ++ i ) {
0 commit comments