Skip to content

Commit a178ed6

Browse files
author
Anand Thakker
committed
Guard against properties absent in the info
1 parent dce998a commit a178ed6

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Diff for: index.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,19 @@ module.exports.local = function(filename, callback) {
3939

4040
var geotransform = ds.geoTransform;
4141
var size = ds.rasterSize;
42+
var description = (ds.driver || {}).description;
43+
var numBands = (ds.bands && typeof ds.bands.count === 'function') ?
44+
ds.bands.count() : null;
45+
var srs = (ds.srs && typeof ds.srs.toWKT === 'function') ?
46+
ds.srs.toWKT() : null;
4247

4348
var metadata = {
4449
filename: filename,
45-
driver: ds.driver.description,
50+
driver: description,
4651
width: size.x,
4752
height: size.y,
48-
numBands: ds.bands.count(),
49-
srs: ds.srs.toWKT(),
53+
numBands: numBands,
54+
srs: srs,
5055
geotransform: ds.geoTransform,
5156
origin: [geotransform[0], geotransform[3]],
5257
pixel_size: [geotransform[1], geotransform[5]],

0 commit comments

Comments
 (0)