fix lint
This commit is contained in:
+78
-77
@@ -685,97 +685,98 @@ class GeoTIFFSource extends DataTile {
|
|||||||
const normalize = this.normalize_;
|
const normalize = this.normalize_;
|
||||||
const metadata = this.metadata_;
|
const metadata = this.metadata_;
|
||||||
|
|
||||||
return Promise.all(requests).then(function (sourceSamples) {
|
return Promise.all(requests)
|
||||||
/** @type {Uint8Array|Float32Array} */
|
.then(function (sourceSamples) {
|
||||||
let data;
|
/** @type {Uint8Array|Float32Array} */
|
||||||
if (normalize) {
|
let data;
|
||||||
data = new Uint8Array(dataLength);
|
if (normalize) {
|
||||||
} else {
|
data = new Uint8Array(dataLength);
|
||||||
data = new Float32Array(dataLength);
|
} else {
|
||||||
}
|
data = new Float32Array(dataLength);
|
||||||
|
}
|
||||||
|
|
||||||
let dataIndex = 0;
|
let dataIndex = 0;
|
||||||
for (let pixelIndex = 0; pixelIndex < pixelCount; ++pixelIndex) {
|
for (let pixelIndex = 0; pixelIndex < pixelCount; ++pixelIndex) {
|
||||||
let transparent = addAlpha;
|
let transparent = addAlpha;
|
||||||
for (let sourceIndex = 0; sourceIndex < sourceCount; ++sourceIndex) {
|
for (let sourceIndex = 0; sourceIndex < sourceCount; ++sourceIndex) {
|
||||||
const source = sourceInfo[sourceIndex];
|
const source = sourceInfo[sourceIndex];
|
||||||
|
|
||||||
let min = source.min;
|
let min = source.min;
|
||||||
let max = source.max;
|
let max = source.max;
|
||||||
let gain, bias;
|
let gain, bias;
|
||||||
if (normalize) {
|
|
||||||
const stats = metadata[sourceIndex][0];
|
|
||||||
if (min === undefined) {
|
|
||||||
if (stats && STATISTICS_MINIMUM in stats) {
|
|
||||||
min = parseFloat(stats[STATISTICS_MINIMUM]);
|
|
||||||
} else {
|
|
||||||
min = getMinForDataType(sourceSamples[sourceIndex][0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (max === undefined) {
|
|
||||||
if (stats && STATISTICS_MAXIMUM in stats) {
|
|
||||||
max = parseFloat(stats[STATISTICS_MAXIMUM]);
|
|
||||||
} else {
|
|
||||||
max = getMaxForDataType(sourceSamples[sourceIndex][0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gain = 255 / (max - min);
|
|
||||||
bias = -min * gain;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (
|
|
||||||
let sampleIndex = 0;
|
|
||||||
sampleIndex < samplesPerPixel[sourceIndex];
|
|
||||||
++sampleIndex
|
|
||||||
) {
|
|
||||||
const sourceValue =
|
|
||||||
sourceSamples[sourceIndex][sampleIndex][pixelIndex];
|
|
||||||
|
|
||||||
let value;
|
|
||||||
if (normalize) {
|
if (normalize) {
|
||||||
value = clamp(gain * sourceValue + bias, 0, 255);
|
const stats = metadata[sourceIndex][0];
|
||||||
} else {
|
if (min === undefined) {
|
||||||
value = sourceValue;
|
if (stats && STATISTICS_MINIMUM in stats) {
|
||||||
|
min = parseFloat(stats[STATISTICS_MINIMUM]);
|
||||||
|
} else {
|
||||||
|
min = getMinForDataType(sourceSamples[sourceIndex][0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (max === undefined) {
|
||||||
|
if (stats && STATISTICS_MAXIMUM in stats) {
|
||||||
|
max = parseFloat(stats[STATISTICS_MAXIMUM]);
|
||||||
|
} else {
|
||||||
|
max = getMaxForDataType(sourceSamples[sourceIndex][0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gain = 255 / (max - min);
|
||||||
|
bias = -min * gain;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!addAlpha) {
|
for (
|
||||||
data[dataIndex] = value;
|
let sampleIndex = 0;
|
||||||
} else {
|
sampleIndex < samplesPerPixel[sourceIndex];
|
||||||
let nodata = source.nodata;
|
++sampleIndex
|
||||||
if (nodata === undefined) {
|
) {
|
||||||
let bandIndex;
|
const sourceValue =
|
||||||
if (source.bands) {
|
sourceSamples[sourceIndex][sampleIndex][pixelIndex];
|
||||||
bandIndex = source.bands[sampleIndex] - 1;
|
|
||||||
} else {
|
let value;
|
||||||
bandIndex = sampleIndex;
|
if (normalize) {
|
||||||
}
|
value = clamp(gain * sourceValue + bias, 0, 255);
|
||||||
nodata = nodataValues[sourceIndex][bandIndex];
|
} else {
|
||||||
|
value = sourceValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sourceValue !== nodata) {
|
if (!addAlpha) {
|
||||||
transparent = false;
|
|
||||||
data[dataIndex] = value;
|
data[dataIndex] = value;
|
||||||
|
} else {
|
||||||
|
let nodata = source.nodata;
|
||||||
|
if (nodata === undefined) {
|
||||||
|
let bandIndex;
|
||||||
|
if (source.bands) {
|
||||||
|
bandIndex = source.bands[sampleIndex] - 1;
|
||||||
|
} else {
|
||||||
|
bandIndex = sampleIndex;
|
||||||
|
}
|
||||||
|
nodata = nodataValues[sourceIndex][bandIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sourceValue !== nodata) {
|
||||||
|
transparent = false;
|
||||||
|
data[dataIndex] = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
dataIndex++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (addAlpha) {
|
||||||
|
if (!transparent) {
|
||||||
|
data[dataIndex] = 255;
|
||||||
}
|
}
|
||||||
dataIndex++;
|
dataIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (addAlpha) {
|
|
||||||
if (!transparent) {
|
|
||||||
data[dataIndex] = 255;
|
|
||||||
}
|
|
||||||
dataIndex++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
// output then rethrow
|
// output then rethrow
|
||||||
console.error(error); // eslint-disable-line no-console
|
console.error(error); // eslint-disable-line no-console
|
||||||
throw error;
|
throw error;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user