dem2terrain
dem2terrain copied to clipboard
Array length must be greater than or equal to -281759359
大佬你好,出现这个问题难道是我没有C++环境造成的么?
D:\>cd dem2terrain
D:\dem2terrain>cnpm install && cnpm link
√ Installed 6 packages on D:\dem2terrain
√ Linked 136 latest versions fallback to D:\dem2terrain\node_modules\.store\node_modules
[1/3] scripts.postinstall [email protected] › es5-ext@^0.10.61 run " node -e \"try{require('./_postinstall')}catch(e){}\" || exit 0", root: "D:\\dem2terrain\\node_modules\\.store\\[email protected]\\node_modules\\es5-ext"
[1/3] scripts.postinstall [email protected] › es5-ext@^0.10.61 finished in 317ms
[2/3] scripts.install @mapbox/[email protected] › sqlite3@^5.0.0 run "node-pre-gyp install --fallback-to-build", root: "D:\\dem2terrain\\node_modules\\.store\\[email protected]\\node_modules\\sqlite3"
node-pre-gyp http GET https://cdn.npmmirror.com/binaries/sqlite3/v5.1.4/napi-v6-win32-unknown-x64.tar.gz
[sqlite3] Success: "D:\dem2terrain\node_modules\.store\[email protected]\node_modules\sqlite3\lib\binding\napi-v6-win32-unknown-x64\node_sqlite3.node" is installed via remote
[2/3] scripts.install @mapbox/[email protected] › sqlite3@^5.0.0 finished in 722ms
[3/3] scripts.install gdal-async@^3.5.1 run "node-pre-gyp install --fallback-to-build -j max && echo 'I am currently unemployed and looking for work. Please, consider hiring me if you like and use gdal-async. Check https://github.com/mmomtchev to what I do and what is my current situation.'", root: "D:\\dem2terrain\\node_modules\\.store\\[email protected]\\node_modules\\gdal-async"
node-pre-gyp http GET https://cdn.npmmirror.com/binaries/node-gdal-async/v3.6.2/node-v93-win32-x64.tar.gz
[gdal-async] Success: "D:\dem2terrain\node_modules\.store\[email protected]\node_modules\gdal-async\lib\binding\node-v93-win32-x64\gdal.node" is installed via remote
'I am currently unemployed and looking for work. Please, consider hiring me if you like and use gdal-async. Check https://github.com/mmomtchev to what I do and what is my current situation.'
[3/3] scripts.install gdal-async@^3.5.1 finished in 2s
√ Run 3 scripts
deprecate @mapbox/[email protected] › [email protected] › [email protected] › [email protected] › [email protected] › @npmcli/move-file@^1.0.1 This functionality has been moved to @npmcli/fs
Recently updated (since 2023-01-29): 3 packages (detail see file D:\dem2terrain\node_modules\.recently_updates.txt)
Today:
→ [email protected] › [email protected] › @types/node@*(18.11.19) (07:02:40)
√ All packages installed (147 packages installed from npm registry, used 21s(network 19s), speed 2.22MB/s, json 87(821.23KB), tarball 40.74MB, manifests cache hit 49, etag hit 49 / miss 4)
added 1 package in 905ms
D:\dem2terrain>dem2terrain -f d://dem2terrain/config.json
>> 开始转换...
- 输入文件: D:\dem2terrain\广东省.tif
- 输出路径: D:\dem2terrain\data\tile
- Tile适用坐标系: EPSG:3857
- 瓦片编码: mapbox(raster-dem)
- 瓦片尺寸: 256 px
- 瓦片等级: 5 至 13 级
>> 步骤1: 清空输出文件夹 - 完成
D:\dem2terrain\node_modules\.store\[email protected]\node_modules\gdal-async\lib\gdal.js:712
return read.apply(this, mangleRead(arguments))
^
Error: Array length must be greater than or equal to -281759359
at RasterBandPixels.read (D:\dem2terrain\node_modules\.store\[email protected]\node_modules\gdal-async\lib\gdal.js:712:17)
at encodeDataset (D:\dem2terrain\src\index.js:111:24)
at main (D:\dem2terrain\src\index.js:275:19)
at Object.<anonymous> (D:\dem2terrain\bin\dem2terrain.js:70:1)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47
config.json文件:
{
"zoom":"5-13",
"epsg": 3857,
"size": 256,
"encoding": "mapbox",
"input": "./广东省.tif",
"output": "./data/tile",
"clean": true
}
报错代码定位:` const sourceWidth = sourceDataset.rasterSize.x; const sourceHeight = sourceDataset.rasterSize.y;
const bandOneHeight = sourceDataset.bands.get(1); const heightBuffer = new Int16Array(sourceWidth * sourceHeight); // 地形是GDT_Int16 读取所有像素 const dataType = gdal.GDT_Int16; bandOneHeight.pixels.read(0, 0, sourceWidth, sourceHeight, heightBuffer, { buffer_width: sourceWidth, buffer_height: sourceHeight, data_type: dataType });` 请给出调试信息,例如sourceWidth, sourceHeight数值,出现这种错误,通常nodejs有数组最大长度限制等原因,需要提供数据或调试信息进一步判断。
请试用2.2.0版本以上,目前新版本已经不含你报错代码,试试看是否正常出图。