nodenetcdf 4.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.clang-format +13 -0
- package/.github/workflows/nodejs.yml +97 -0
- package/LICENSE +13 -0
- package/README.md +330 -0
- package/binding.gyp +95 -0
- package/package.json +35 -0
- package/scripts/copy-deps.js +57 -0
- package/scripts/setup-vcpkg.js +93 -0
- package/scripts/verify-build-deps.js +61 -0
- package/src/Attribute.cpp +334 -0
- package/src/Attribute.h +46 -0
- package/src/Dimension.cpp +105 -0
- package/src/Dimension.h +40 -0
- package/src/File.cpp +170 -0
- package/src/File.h +42 -0
- package/src/Group.cpp +483 -0
- package/src/Group.h +49 -0
- package/src/Variable.cpp +1352 -0
- package/src/Variable.h +88 -0
- package/src/nodenetcdfjs.cpp +24 -0
- package/src/nodenetcdfjs.h +37 -0
- package/test/attribute.js +36 -0
- package/test/dimension.js +18 -0
- package/test/file.js +19 -0
- package/test/group.js +57 -0
- package/test/test_hgroups.nc +0 -0
- package/test/testrh.nc +0 -0
- package/test/variable.js +16 -0
package/.clang-format
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
Language: Cpp
|
|
3
|
+
BasedOnStyle: Microsoft
|
|
4
|
+
SpaceAfterTemplateKeyword: false
|
|
5
|
+
AlignEscapedNewlines: Left
|
|
6
|
+
AlignTrailingComments: true
|
|
7
|
+
BreakBeforeInheritanceComma: true
|
|
8
|
+
BreakConstructorInitializers: BeforeComma
|
|
9
|
+
IndentPPDirectives: AfterHash
|
|
10
|
+
BreakBeforeBraces: Custom
|
|
11
|
+
BraceWrapping:
|
|
12
|
+
AfterControlStatement: Always
|
|
13
|
+
NamespaceIndentation: None
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
name: Node.js CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ master, main ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ master, main ]
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
inputs:
|
|
10
|
+
node-version:
|
|
11
|
+
description: 'Node.js version to test (optional, defaults to matrix)'
|
|
12
|
+
required: false
|
|
13
|
+
type: choice
|
|
14
|
+
options:
|
|
15
|
+
- 'all'
|
|
16
|
+
- '22.x'
|
|
17
|
+
default: 'all'
|
|
18
|
+
os:
|
|
19
|
+
description: 'Operating system to test (optional, defaults to matrix)'
|
|
20
|
+
required: false
|
|
21
|
+
type: choice
|
|
22
|
+
options:
|
|
23
|
+
- 'all'
|
|
24
|
+
- 'ubuntu-latest'
|
|
25
|
+
- 'windows-latest'
|
|
26
|
+
- 'macos-latest'
|
|
27
|
+
default: 'all'
|
|
28
|
+
|
|
29
|
+
jobs:
|
|
30
|
+
build-and-test:
|
|
31
|
+
name: Build and Test on ${{ matrix.os }}
|
|
32
|
+
runs-on: ${{ matrix.os }}
|
|
33
|
+
timeout-minutes: 20 # ⬅️ Added timeout here
|
|
34
|
+
|
|
35
|
+
strategy:
|
|
36
|
+
fail-fast: false
|
|
37
|
+
matrix:
|
|
38
|
+
os: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.os != 'all' && fromJSON(format('["{0}"]', github.event.inputs.os)) || fromJSON('["ubuntu-latest", "windows-latest", "macos-latest"]') }}
|
|
39
|
+
node-version: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.node-version != 'all' && fromJSON(format('["{0}"]', github.event.inputs.node-version)) || fromJSON('["22.x"]') }}
|
|
40
|
+
|
|
41
|
+
steps:
|
|
42
|
+
- name: Checkout code
|
|
43
|
+
uses: actions/checkout@v4
|
|
44
|
+
with:
|
|
45
|
+
submodules: false
|
|
46
|
+
|
|
47
|
+
- name: Setup Node.js ${{ matrix.node-version }}
|
|
48
|
+
uses: actions/setup-node@v4
|
|
49
|
+
with:
|
|
50
|
+
node-version: ${{ matrix.node-version }}
|
|
51
|
+
|
|
52
|
+
- name: Install build tools (Ubuntu)
|
|
53
|
+
if: runner.os == 'Linux'
|
|
54
|
+
run: |
|
|
55
|
+
sudo apt-get update
|
|
56
|
+
sudo apt-get install -y build-essential cmake git curl zip unzip tar pkg-config linux-libc-dev
|
|
57
|
+
|
|
58
|
+
- name: Install build tools (macOS)
|
|
59
|
+
if: runner.os == 'macOS'
|
|
60
|
+
run: |
|
|
61
|
+
# Xcode command line tools are usually pre-installed
|
|
62
|
+
# Install additional tools if needed
|
|
63
|
+
brew install cmake pkg-config
|
|
64
|
+
|
|
65
|
+
- name: Install build tools (Windows)
|
|
66
|
+
if: runner.os == 'Windows'
|
|
67
|
+
uses: microsoft/setup-msbuild@v2
|
|
68
|
+
|
|
69
|
+
- name: Setup vcpkg cache
|
|
70
|
+
uses: actions/cache@v4
|
|
71
|
+
with:
|
|
72
|
+
path: |
|
|
73
|
+
vcpkg
|
|
74
|
+
vcpkg_installed
|
|
75
|
+
key: ${{ runner.os }}-vcpkg-${{ hashFiles('**/package.json') }}
|
|
76
|
+
restore-keys: |
|
|
77
|
+
${{ runner.os }}-vcpkg-
|
|
78
|
+
|
|
79
|
+
- name: Install dependencies and build
|
|
80
|
+
run: npm install
|
|
81
|
+
env:
|
|
82
|
+
CI: true
|
|
83
|
+
|
|
84
|
+
- name: Run tests
|
|
85
|
+
run: npm test
|
|
86
|
+
env:
|
|
87
|
+
CI: true
|
|
88
|
+
|
|
89
|
+
- name: Upload build artifacts on failure
|
|
90
|
+
if: failure()
|
|
91
|
+
uses: actions/upload-artifact@v4
|
|
92
|
+
with:
|
|
93
|
+
name: build-logs-${{ matrix.os }}-node-${{ matrix.node-version }}
|
|
94
|
+
path: |
|
|
95
|
+
build/
|
|
96
|
+
*.log
|
|
97
|
+
retention-days: 7
|
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright (c) 2015, Sven Willner <sven.willner@gmail.com>
|
|
2
|
+
|
|
3
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
4
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
5
|
+
copyright notice and this permission notice appear in all copies.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
8
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
9
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
10
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
11
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
12
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
13
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
# nodenetcdf
|
|
2
|
+
|
|
3
|
+
A Node.js native addon for reading and writing NodeNetCDF files, providing a comprehensive interface to the NetCDF-4 C library.
|
|
4
|
+
|
|
5
|
+
IMPORTANT NOTE: this project dose not follow conventional open source standards we will accept PR's but we will not be actively changeing code unless something breaks
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
This package provides Node.js bindings to the NetCDF-4 library, allowing you to read and write NodeNetCDF files directly from JavaScript. NetCDF (Network Common Data Form) is a set of software libraries and machine-independent data formats that support the creation, access, and sharing of array-oriented scientific data.
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
- Read and write NetCDF-4 files
|
|
14
|
+
- Full support for groups, variables, dimensions, and attributes
|
|
15
|
+
- Support for all NetCDF-4 data types
|
|
16
|
+
- Chunk mode and compression options
|
|
17
|
+
- Fill values and endianness control
|
|
18
|
+
- Strided slice operations for efficient data access
|
|
19
|
+
- Cross-platform support (Windows, Linux, macOS)
|
|
20
|
+
|
|
21
|
+
## Requirements
|
|
22
|
+
|
|
23
|
+
- Node.js >= 22.0.0
|
|
24
|
+
- C++ compiler with C++20 support
|
|
25
|
+
- CMake (for building dependencies)
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install nodenetcdf
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The installation process will:
|
|
34
|
+
1. Set up vcpkg package manager
|
|
35
|
+
2. Verify build dependencies
|
|
36
|
+
3. Build the native addon using node-gyp
|
|
37
|
+
4. Copy required shared libraries
|
|
38
|
+
|
|
39
|
+
### Platform-Specific Notes
|
|
40
|
+
|
|
41
|
+
**Windows:**
|
|
42
|
+
- Requires Visual Studio 2022 (v143 toolset)
|
|
43
|
+
- Build uses vcpkg to manage NetCDF and HDF5 dependencies
|
|
44
|
+
|
|
45
|
+
**Linux:**
|
|
46
|
+
- Requires gcc with C++20 support
|
|
47
|
+
- Dependencies are statically linked via vcpkg
|
|
48
|
+
|
|
49
|
+
**macOS:**
|
|
50
|
+
- Requires Xcode command line tools
|
|
51
|
+
- Minimum deployment target: macOS 10.15
|
|
52
|
+
|
|
53
|
+
## Usage
|
|
54
|
+
|
|
55
|
+
### Opening a NetCDF File
|
|
56
|
+
|
|
57
|
+
```javascript
|
|
58
|
+
const nodenetcdf = require('nodenetcdf');
|
|
59
|
+
|
|
60
|
+
// Open an existing file for reading
|
|
61
|
+
const file = new nodenetcdf.File('path/to/file.nc', 'r');
|
|
62
|
+
|
|
63
|
+
// Create a new file
|
|
64
|
+
const newFile = new nodenetcdf.File('path/to/new-file.nc', 'w', 'nodenetcdf');
|
|
65
|
+
|
|
66
|
+
// Available modes:
|
|
67
|
+
// 'r' - read-only
|
|
68
|
+
// 'w' - write (create new file)
|
|
69
|
+
// 'c' - create (fail if exists)
|
|
70
|
+
// 'a' - append (read/write existing file)
|
|
71
|
+
|
|
72
|
+
// Available formats:
|
|
73
|
+
// 'nodenetcdf' - NetCDF-4 format
|
|
74
|
+
// 'classic' - NetCDF classic format
|
|
75
|
+
// '64bit' - 64-bit offset format
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Working with Groups
|
|
79
|
+
|
|
80
|
+
```javascript
|
|
81
|
+
// Access the root group
|
|
82
|
+
const root = file.root;
|
|
83
|
+
|
|
84
|
+
// Get group properties
|
|
85
|
+
console.log(root.name); // Group name
|
|
86
|
+
console.log(root.fullname); // Full path
|
|
87
|
+
console.log(root.id); // NetCDF ID
|
|
88
|
+
|
|
89
|
+
// Create a subgroup
|
|
90
|
+
const dataGroup = root.addSubgroup('data');
|
|
91
|
+
|
|
92
|
+
// Access subgroups
|
|
93
|
+
const subgroups = root.subgroups;
|
|
94
|
+
console.log(subgroups); // Object with subgroup names as keys
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Working with Dimensions
|
|
98
|
+
|
|
99
|
+
```javascript
|
|
100
|
+
// Add dimensions
|
|
101
|
+
const timeDim = root.addDimension('time', 0); // Unlimited dimension
|
|
102
|
+
const latDim = root.addDimension('lat', 180); // Fixed dimension
|
|
103
|
+
const lonDim = root.addDimension('lon', 360);
|
|
104
|
+
|
|
105
|
+
// Access dimension properties
|
|
106
|
+
console.log(timeDim.name); // 'time'
|
|
107
|
+
console.log(timeDim.length); // Current length
|
|
108
|
+
console.log(timeDim.id); // NetCDF ID
|
|
109
|
+
|
|
110
|
+
// Get all dimensions
|
|
111
|
+
const dimensions = root.dimensions;
|
|
112
|
+
const unlimitedDims = root.unlimited; // Array of unlimited dimensions
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Working with Variables
|
|
116
|
+
|
|
117
|
+
```javascript
|
|
118
|
+
// Create a variable
|
|
119
|
+
const tempVar = root.addVariable('temperature', 'float', ['time', 'lat', 'lon']);
|
|
120
|
+
|
|
121
|
+
// Supported data types:
|
|
122
|
+
// 'byte', 'char', 'short', 'int', 'float', 'double',
|
|
123
|
+
// 'ubyte', 'ushort', 'uint', 'int64', 'uint64'
|
|
124
|
+
|
|
125
|
+
// Write data
|
|
126
|
+
tempVar.write([1.5, 2.3, 3.7, ...]);
|
|
127
|
+
|
|
128
|
+
// Write a slice
|
|
129
|
+
tempVar.writeSlice([0, 0, 0], [1, 180, 360], data);
|
|
130
|
+
|
|
131
|
+
// Write with stride
|
|
132
|
+
tempVar.writeStridedSlice([0, 0, 0], [1, 1, 1], [10, 180, 360], data);
|
|
133
|
+
|
|
134
|
+
// Read data
|
|
135
|
+
const data = tempVar.read();
|
|
136
|
+
|
|
137
|
+
// Read a slice
|
|
138
|
+
const slice = tempVar.readSlice([0, 0, 0], [1, 180, 360]);
|
|
139
|
+
|
|
140
|
+
// Read with stride
|
|
141
|
+
const stridedData = tempVar.readStridedSlice([0, 0, 0], [2, 2, 2], [10, 180, 360]);
|
|
142
|
+
|
|
143
|
+
// Variable properties
|
|
144
|
+
console.log(tempVar.name); // Variable name
|
|
145
|
+
console.log(tempVar.type); // Data type
|
|
146
|
+
console.log(tempVar.dimensions); // Array of dimension names
|
|
147
|
+
console.log(tempVar.id); // NetCDF ID
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Variable Settings
|
|
151
|
+
|
|
152
|
+
```javascript
|
|
153
|
+
// Set endianness
|
|
154
|
+
tempVar.endianness = 'little'; // or 'big', 'native'
|
|
155
|
+
|
|
156
|
+
// Set checksum mode
|
|
157
|
+
tempVar.checksummode = 'fletcher32'; // or 'none'
|
|
158
|
+
|
|
159
|
+
// Set chunking
|
|
160
|
+
tempVar.chunkmode = 'chunked'; // or 'contiguous'
|
|
161
|
+
tempVar.chunksizes = [1, 180, 360];
|
|
162
|
+
|
|
163
|
+
// Set fill mode and value
|
|
164
|
+
tempVar.fillmode = true;
|
|
165
|
+
tempVar.fillvalue = -999.9;
|
|
166
|
+
|
|
167
|
+
// Set compression
|
|
168
|
+
tempVar.compression_shuffle = true;
|
|
169
|
+
tempVar.compression_deflate = true;
|
|
170
|
+
tempVar.compression_level = 6; // 0-9
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Working with Attributes
|
|
174
|
+
|
|
175
|
+
```javascript
|
|
176
|
+
// Add attributes to variables
|
|
177
|
+
tempVar.addAttribute('units', 'Kelvin');
|
|
178
|
+
tempVar.addAttribute('long_name', 'Air Temperature');
|
|
179
|
+
tempVar.addAttribute('valid_range', [200.0, 350.0]);
|
|
180
|
+
|
|
181
|
+
// Add global attributes (to groups)
|
|
182
|
+
root.addAttribute('title', 'Climate Data');
|
|
183
|
+
root.addAttribute('institution', 'Research Center');
|
|
184
|
+
root.addAttribute('created', new Date().toISOString());
|
|
185
|
+
|
|
186
|
+
// Read attributes
|
|
187
|
+
const attrs = tempVar.attributes;
|
|
188
|
+
console.log(attrs.units.value); // 'Kelvin'
|
|
189
|
+
|
|
190
|
+
// Modify attribute value
|
|
191
|
+
attrs.units.value = 'Celsius';
|
|
192
|
+
|
|
193
|
+
// Delete an attribute
|
|
194
|
+
attrs.units.delete();
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### Closing Files
|
|
198
|
+
|
|
199
|
+
```javascript
|
|
200
|
+
// Sync changes to disk
|
|
201
|
+
file.sync();
|
|
202
|
+
|
|
203
|
+
// Close the file
|
|
204
|
+
file.close();
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## API Reference
|
|
208
|
+
|
|
209
|
+
### File
|
|
210
|
+
|
|
211
|
+
- `new File(path, mode, format)` - Open or create a NetCDF file
|
|
212
|
+
- `file.root` - Access the root group
|
|
213
|
+
- `file.close()` - Close the file
|
|
214
|
+
- `file.sync()` - Sync changes to disk
|
|
215
|
+
|
|
216
|
+
### Group
|
|
217
|
+
|
|
218
|
+
Properties:
|
|
219
|
+
- `group.id` - NetCDF group ID
|
|
220
|
+
- `group.name` - Group name
|
|
221
|
+
- `group.fullname` - Full path of the group
|
|
222
|
+
- `group.dimensions` - Object containing dimensions
|
|
223
|
+
- `group.unlimited` - Array of unlimited dimensions
|
|
224
|
+
- `group.variables` - Object containing variables
|
|
225
|
+
- `group.attributes` - Object containing attributes
|
|
226
|
+
- `group.subgroups` - Object containing subgroups
|
|
227
|
+
|
|
228
|
+
Methods:
|
|
229
|
+
- `group.addDimension(name, length)` - Add a dimension
|
|
230
|
+
- `group.addVariable(name, type, dimensions)` - Add a variable
|
|
231
|
+
- `group.addAttribute(name, value)` - Add an attribute
|
|
232
|
+
- `group.addSubgroup(name)` - Add a subgroup
|
|
233
|
+
|
|
234
|
+
### Dimension
|
|
235
|
+
|
|
236
|
+
Properties:
|
|
237
|
+
- `dimension.id` - NetCDF dimension ID
|
|
238
|
+
- `dimension.name` - Dimension name
|
|
239
|
+
- `dimension.length` - Current length of the dimension
|
|
240
|
+
|
|
241
|
+
### Variable
|
|
242
|
+
|
|
243
|
+
Properties:
|
|
244
|
+
- `variable.id` - NetCDF variable ID
|
|
245
|
+
- `variable.name` - Variable name
|
|
246
|
+
- `variable.type` - Data type
|
|
247
|
+
- `variable.dimensions` - Array of dimension names
|
|
248
|
+
- `variable.attributes` - Object containing attributes
|
|
249
|
+
- `variable.endianness` - Byte order ('little', 'big', 'native')
|
|
250
|
+
- `variable.checksummode` - Checksum mode ('none', 'fletcher32')
|
|
251
|
+
- `variable.chunkmode` - Chunking mode ('contiguous', 'chunked')
|
|
252
|
+
- `variable.chunksizes` - Array of chunk sizes
|
|
253
|
+
- `variable.fillmode` - Whether fill values are enabled
|
|
254
|
+
- `variable.fillvalue` - Fill value
|
|
255
|
+
- `variable.compression_shuffle` - Shuffle filter enabled
|
|
256
|
+
- `variable.compression_deflate` - Deflate compression enabled
|
|
257
|
+
- `variable.compression_level` - Compression level (0-9)
|
|
258
|
+
|
|
259
|
+
Methods:
|
|
260
|
+
- `variable.read()` - Read all data
|
|
261
|
+
- `variable.readSlice(start, count)` - Read a slice
|
|
262
|
+
- `variable.readStridedSlice(start, stride, count)` - Read with stride
|
|
263
|
+
- `variable.write(data)` - Write data
|
|
264
|
+
- `variable.writeSlice(start, count, data)` - Write a slice
|
|
265
|
+
- `variable.writeStridedSlice(start, stride, count, data)` - Write with stride
|
|
266
|
+
- `variable.addAttribute(name, value)` - Add an attribute
|
|
267
|
+
|
|
268
|
+
### Attribute
|
|
269
|
+
|
|
270
|
+
Properties:
|
|
271
|
+
- `attribute.name` - Attribute name
|
|
272
|
+
- `attribute.value` - Attribute value
|
|
273
|
+
|
|
274
|
+
Methods:
|
|
275
|
+
- `attribute.delete()` - Delete the attribute
|
|
276
|
+
|
|
277
|
+
## Development
|
|
278
|
+
|
|
279
|
+
### Running Tests
|
|
280
|
+
|
|
281
|
+
```bash
|
|
282
|
+
npm test
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### Building from Source
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
npm install
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
The build process uses:
|
|
292
|
+
- `node-gyp` for compiling the native addon
|
|
293
|
+
- `vcpkg` for managing C++ dependencies (NetCDF, HDF5, zlib, curl)
|
|
294
|
+
|
|
295
|
+
## Original Project and License
|
|
296
|
+
|
|
297
|
+
This is a fork and modernization of the original [nodenetcdf](https://github.com/parro-it/nodenetcdf) project.
|
|
298
|
+
|
|
299
|
+
### Original Contributors
|
|
300
|
+
|
|
301
|
+
- Andrea Parodi <andrea@parro.it> (http://www.parro.it/)
|
|
302
|
+
- Sven Willner <sven.willner@gmail.com> (http://svenwillner.net)
|
|
303
|
+
|
|
304
|
+
### Current Maintainer
|
|
305
|
+
|
|
306
|
+
- Luke Shore <luke.a.shore@oliva.energy> (https://oliva.energy)
|
|
307
|
+
|
|
308
|
+
### License
|
|
309
|
+
|
|
310
|
+
ISC License
|
|
311
|
+
|
|
312
|
+
Copyright (c) 2015, Sven Willner <sven.willner@gmail.com>
|
|
313
|
+
|
|
314
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
315
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
316
|
+
copyright notice and this permission notice appear in all copies.
|
|
317
|
+
|
|
318
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
319
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
320
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
321
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
322
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
323
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
324
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
325
|
+
|
|
326
|
+
## Links
|
|
327
|
+
|
|
328
|
+
- [Original Project](https://github.com/parro-it/nodenetcdf)
|
|
329
|
+
- [NetCDF Documentation](https://www.unidata.ucar.edu/software/netcdf/docs/)
|
|
330
|
+
- [GitHub Repository](https://github.com/pheonixfirewingz/nodenetcdf)
|
package/binding.gyp
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
{
|
|
2
|
+
"targets": [
|
|
3
|
+
{
|
|
4
|
+
"sources": [
|
|
5
|
+
"src/Group.cpp",
|
|
6
|
+
"src/File.cpp",
|
|
7
|
+
"src/Variable.cpp",
|
|
8
|
+
"src/Dimension.cpp",
|
|
9
|
+
"src/Attribute.cpp",
|
|
10
|
+
"src/nodenetcdfjs.cpp"
|
|
11
|
+
],
|
|
12
|
+
"target_name": "nodenetcdf",
|
|
13
|
+
"cflags!": [ "-fno-exceptions" ],
|
|
14
|
+
"cflags_cc!": [ "-fno-exceptions" ],
|
|
15
|
+
"cflags": [ "-std=c++20" ],
|
|
16
|
+
"cflags_cc": [ "-std=c++20" ],
|
|
17
|
+
"conditions": [
|
|
18
|
+
['OS=="win"', {
|
|
19
|
+
"variables": {
|
|
20
|
+
"vcpkg_installed%": "<(module_root_dir)/vcpkg/installed/x64-windows",
|
|
21
|
+
"netcdf_include%": "<!(node -p \"require('path').resolve(process.cwd(), 'vcpkg', 'installed', 'x64-windows', 'include')\")",
|
|
22
|
+
"netcdf_lib%": "<!(node -p \"require('path').resolve(process.cwd(), 'vcpkg', 'installed', 'x64-windows', 'lib')\")"
|
|
23
|
+
},
|
|
24
|
+
"include_dirs": [
|
|
25
|
+
"<(vcpkg_installed)/include",
|
|
26
|
+
"<(netcdf_include)"
|
|
27
|
+
],
|
|
28
|
+
"libraries": [
|
|
29
|
+
"<(vcpkg_installed)/lib/netcdf.lib"
|
|
30
|
+
],
|
|
31
|
+
"msvs_settings": {
|
|
32
|
+
"VCLinkerTool": {
|
|
33
|
+
"AdditionalLibraryDirectories": [
|
|
34
|
+
"<(vcpkg_installed)/lib",
|
|
35
|
+
"<(netcdf_lib)"
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
"VCCLCompilerTool": {
|
|
39
|
+
"AdditionalOptions": [ "/std:c++20" ],
|
|
40
|
+
"ExceptionHandling": 1,
|
|
41
|
+
"AdditionalIncludeDirectories": [
|
|
42
|
+
"<(vcpkg_installed)/include",
|
|
43
|
+
"<(netcdf_include)"
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"defines": [
|
|
48
|
+
"_HAS_EXCEPTIONS=1"
|
|
49
|
+
],
|
|
50
|
+
"msbuild_toolset": "v143"
|
|
51
|
+
}],
|
|
52
|
+
['OS=="linux"', {
|
|
53
|
+
"variables": {
|
|
54
|
+
"vcpkg_installed%": "<(module_root_dir)/vcpkg/installed/x64-linux"
|
|
55
|
+
},
|
|
56
|
+
"include_dirs": [
|
|
57
|
+
"<(vcpkg_installed)/include"
|
|
58
|
+
],
|
|
59
|
+
"libraries": [
|
|
60
|
+
"<(vcpkg_installed)/lib/libnetcdf.a",
|
|
61
|
+
"<(vcpkg_installed)/lib/libhdf5_hl.a",
|
|
62
|
+
"<(vcpkg_installed)/lib/libhdf5.a",
|
|
63
|
+
"<(vcpkg_installed)/lib/libsz.a",
|
|
64
|
+
"<(vcpkg_installed)/lib/libz.a",
|
|
65
|
+
"<(vcpkg_installed)/lib/libcurl.a",
|
|
66
|
+
"-ldl",
|
|
67
|
+
"-lpthread"
|
|
68
|
+
]
|
|
69
|
+
}],
|
|
70
|
+
['OS=="mac"', {
|
|
71
|
+
"variables": {
|
|
72
|
+
"vcpkg_installed%": "<(module_root_dir)/vcpkg/installed/arm64-osx"
|
|
73
|
+
},
|
|
74
|
+
"include_dirs": [
|
|
75
|
+
"<(vcpkg_installed)/include"
|
|
76
|
+
],
|
|
77
|
+
"libraries": [
|
|
78
|
+
"<(vcpkg_installed)/lib/libnetcdf.a",
|
|
79
|
+
"<(vcpkg_installed)/lib/libhdf5_hl.a",
|
|
80
|
+
"<(vcpkg_installed)/lib/libhdf5.a",
|
|
81
|
+
"<(vcpkg_installed)/lib/libsz.a",
|
|
82
|
+
"<(vcpkg_installed)/lib/libz.a",
|
|
83
|
+
"<(vcpkg_installed)/lib/libcurl.a"
|
|
84
|
+
],
|
|
85
|
+
"xcode_settings": {
|
|
86
|
+
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
|
|
87
|
+
"CLANG_CXX_LIBRARY": "libc++",
|
|
88
|
+
"MACOSX_DEPLOYMENT_TARGET": "10.15",
|
|
89
|
+
"CLANG_CXX_LANGUAGE_STANDARD": "c++20"
|
|
90
|
+
}
|
|
91
|
+
}]
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nodenetcdf",
|
|
3
|
+
"version": "4.9.3",
|
|
4
|
+
"description": "Read and write NodeNetCDF files",
|
|
5
|
+
"main": "./build/Release/nodenetcdf.node",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"preinstall": "node scripts/setup-vcpkg.js",
|
|
8
|
+
"install": "node scripts/verify-build-deps.js && node-gyp configure build",
|
|
9
|
+
"postinstall": "node scripts/copy-deps.js",
|
|
10
|
+
"test": "mocha",
|
|
11
|
+
"verify-deps": "node scripts/verify-build-deps.js"
|
|
12
|
+
},
|
|
13
|
+
"author": {
|
|
14
|
+
"name": "Luke Shore",
|
|
15
|
+
"email": "luke.a.shore@oliva.energy",
|
|
16
|
+
"url": "https://oliva.energy"
|
|
17
|
+
},
|
|
18
|
+
"contributors": [
|
|
19
|
+
"Andrea Parodi <andrea@parro.it> (http://www.parro.it/)",
|
|
20
|
+
"Sven Willner <sven.willner@gmail.com> (http://svenwillner.net)"
|
|
21
|
+
],
|
|
22
|
+
"repository": "pheonixfirewingz/nodenetcdf",
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=22.0.0"
|
|
25
|
+
},
|
|
26
|
+
"license": "ISC",
|
|
27
|
+
"gypfile": true,
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"node-gyp": "^11.5.0"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"chai": "^6.2.0",
|
|
33
|
+
"mocha": "^11.7.4"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const os = require('os');
|
|
4
|
+
|
|
5
|
+
// Determine the platform-specific vcpkg directory
|
|
6
|
+
const platform = os.platform();
|
|
7
|
+
let vcpkgDir;
|
|
8
|
+
|
|
9
|
+
if (platform === 'win32') {
|
|
10
|
+
vcpkgDir = 'vcpkg/installed/x64-windows/bin';
|
|
11
|
+
} else if (platform === 'linux') {
|
|
12
|
+
vcpkgDir = 'vcpkg/installed/x64-linux/lib';
|
|
13
|
+
} else if (platform === 'darwin') {
|
|
14
|
+
vcpkgDir = 'vcpkg/installed/arm64-osx/lib';
|
|
15
|
+
} else {
|
|
16
|
+
console.log('Unknown platform, skipping dependency copy');
|
|
17
|
+
process.exit(0);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const buildDir = 'build/Release';
|
|
21
|
+
|
|
22
|
+
// Check if vcpkg directory exists
|
|
23
|
+
if (!fs.existsSync(vcpkgDir)) {
|
|
24
|
+
console.log(`vcpkg directory not found: ${vcpkgDir}`);
|
|
25
|
+
console.log('Skipping dependency copy - assuming system libraries are available');
|
|
26
|
+
process.exit(0);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Check if build directory exists
|
|
30
|
+
if (!fs.existsSync(buildDir)) {
|
|
31
|
+
console.log(`Build directory not found: ${buildDir}`);
|
|
32
|
+
console.log('Skipping dependency copy - build directory does not exist yet');
|
|
33
|
+
process.exit(0);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Copy shared libraries based on platform
|
|
37
|
+
try {
|
|
38
|
+
const files = fs.readdirSync(vcpkgDir);
|
|
39
|
+
let copied = 0;
|
|
40
|
+
|
|
41
|
+
files.forEach(file => {
|
|
42
|
+
const ext = path.extname(file);
|
|
43
|
+
// Copy .dll on Windows, .so on Linux, .dylib on macOS
|
|
44
|
+
if (ext === '.dll' || ext === '.so' || ext === '.dylib') {
|
|
45
|
+
const src = path.join(vcpkgDir, file);
|
|
46
|
+
const dest = path.join(buildDir, file);
|
|
47
|
+
fs.copyFileSync(src, dest);
|
|
48
|
+
copied++;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
console.log(`Copied ${copied} dependency files to ${buildDir}`);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
console.error('Error copying dependencies:', error.message);
|
|
55
|
+
console.log('Continuing anyway - system libraries may be sufficient');
|
|
56
|
+
process.exit(0);
|
|
57
|
+
}
|