forked from yocontra/node-gdal-next
-
-
Notifications
You must be signed in to change notification settings - Fork 27
/
ogrinfo.js
45 lines (36 loc) · 1.11 KB
/
ogrinfo.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
const gdal = require('../lib/gdal.js')
const filename = process.argv[2]
if (!filename) {
console.error('Filename must be provided')
process.exit(1)
}
const ds = gdal.open(filename)
const driver = ds.driver
const driver_metadata = driver.getMetadata()
if (driver_metadata.DCAP_VECTOR !== 'YES') {
console.error('Source file is not a vector')
process.exit(1)
}
console.log(`Driver = ${driver.description}`)
console.log('')
// layers
let i = 0
console.log('Layers: ')
ds.layers.forEach((layer) => {
console.log(`${i++}: ${layer.name}`)
console.log(` Geometry Type = ${gdal.Geometry.getName(layer.geomType)}`)
console.log(
` Spatial Reference = ${layer.srs ? layer.srs.toWKT() : 'null'}`
)
const extent = layer.getExtent()
console.log(' Extent: ')
console.log(` minX = ${extent.minX}`)
console.log(` minY = ${extent.minY}`)
console.log(` maxX = ${extent.maxX}`)
console.log(` maxY = ${extent.maxY}`)
console.log(' Fields: ')
layer.fields.forEach((field) => {
console.log(` -${field.name} (${field.type})`)
})
console.log(` Feature Count = ${layer.features.count()}`)
})