-
Notifications
You must be signed in to change notification settings - Fork 49
/
index.js
62 lines (54 loc) · 2.22 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const initGdalJs = require('gdal3.js/node');
async function main() {
const Gdal = await initGdalJs();
const count = Object.keys(Gdal.drivers.raster).length + Object.keys(Gdal.drivers.vector).length;
console.log("Number of drivers: " + count);
const drivers = {
raster: {
readWrite: [],
readOnly: [],
writeOnly: [],
},
vector: {
readWrite: [],
readOnly: [],
writeOnly: [],
},
}
Object.values(Gdal.drivers.raster).forEach(driver => {
if (driver.isReadable && driver.isWritable) {
drivers.raster.readWrite.push(driver.shortName);
} else if(driver.isReadable) {
drivers.raster.readOnly.push(driver.shortName);
} else if(driver.isWritable) {
drivers.raster.writeOnly.push(driver.shortName);
}
});
Object.values(Gdal.drivers.vector).forEach(driver => {
if (driver.isReadable && driver.isWritable) {
drivers.vector.readWrite.push(driver.shortName);
} else if(driver.isReadable) {
drivers.vector.readOnly.push(driver.shortName);
} else if(driver.isWritable) {
drivers.vector.writeOnly.push(driver.shortName);
}
});
console.log(`\nraster read & write drivers: ${drivers.raster.readWrite.sort().join(', ')}`);
console.log(`\nraster read only drivers: ${drivers.raster.readOnly.sort().join(', ')}`);
console.log(`\nraster write only drivers: ${drivers.raster.writeOnly.sort().join(', ')}`);
console.log(`\nvector read & write drivers: ${drivers.vector.readWrite.sort().join(', ')}`);
console.log(`\nvector read only drivers: ${drivers.vector.readOnly.sort().join(', ')}`);
console.log(`\nvector write only drivers: ${drivers.vector.writeOnly.sort().join(', ')}`);
const coords = [
[27.143757, 38.4247972],
];
const options = [
'-s_srs', 'EPSG:4326',
'-t_srs', 'EPSG:3857',
'-output_xy',
];
const newCoords = await Gdal.gdaltransform(coords, options);
console.log('coordinates (EPSG:4326): ', coords);
console.log('coordinates (EPSG:3857): ', newCoords); // [ [ 3021629.2074563554, 4639610.441991095, 0 ] ]
}
main();