/usr/bin/mapnik-inspect is in node-mapnik 1.2.0-1build1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | #!/usr/bin/nodejs
var exists = require('fs').existsSync || require('path').existsSync;
var fs = require('fs');
var usage = 'usage:';
usage += '\n mapnik-inspect.js <datasource> (.shp|.json|.geojson|.osm|.kml|.sqlite|.gml|.vrt|.csv)';
usage += '\n mapnik-inspect.js <stylesheet> (.xml)';
usage += '\n mapnik-inspect.js <projection> (.prj)';
usage += '\n mapnik-inspect.js <zipfile> (.zip)';
var obj = process.argv[2];
if (!obj) {
console.log(usage);
process.exit(1);
}
if (!exists(obj)) {
console.log(obj + ' does not exist');
process.exit(1);
}
var mapnik = require('mapnik');
console.log(obj);
var meta = function(ds) {
console.log('Description -->');
console.log(ds.describe());
console.log('extent: ' + ds.extent().toString());
console.log('First feature --> ');
console.log(ds.features().slice(0, 1));
}
if (/.shp$/.test(obj)) {
var opened = new mapnik.Datasource({type: 'shape', file: obj});
meta(opened);
}
else if ((/.csv$/.test(obj)) ||
(/.tsv$/.test(obj)) || // google refine output .tsv for tab-separated files
(/.txt$/.test(obj))) {
var opened = new mapnik.Datasource({type: 'csv', file: obj});
meta(opened);
}
else if (/.osm$/.test(obj)) {
var opened = new mapnik.Datasource({type: 'osm', file: obj});
meta(opened);
}
else if ((/.sqlite$/.test(obj)) ||
(/.sqlite3$/.test(obj)) ||
(/.db$/.test(obj))
) {
var opened = new mapnik.Datasource({type: 'sqlite', file: obj, 'table_by_index': 0});
meta(opened);
}
else if ((/.json$/.test(obj)) ||
(/.geojson$/.test(obj))) {
var opened = new mapnik.Datasource({type: 'geojson', file: obj});
meta(opened);
}
else if ((/.kml$/.test(obj)) ||
(/.gml$/.test(obj)) ||
(/.dbf$/.test(obj))
) {
var opened = new mapnik.Datasource({type: 'ogr', file: obj, 'layer_by_index': 0});
meta(opened);
}
else if ((/.tif$/.test(obj)) ||
(/.tiff$/.test(obj)) ||
(/.vrt$/.test(obj)) ||
(/.geotif$/.test(obj)) ||
(/.geotiff$/.test(obj))
) {
var opened = new mapnik.Datasource({type: 'gdal', file: obj});
meta(opened);
}
else if (/.xml$/.test(obj)) {
var map = new mapnik.Map(1, 1);
map.loadSync(obj);
console.log(map.layers());
}
else if (/.prj$/.test(obj)) {
var srs = require('srs');
var string = fs.readFileSync(obj).toString();
var srs_obj = srs.parse(string);
if (!srs_obj.proj4)
srs_obj = srs.parse('ESRI::' + string);
console.log(srs_obj);
}
else if (/.zip$/.test(obj)) {
var zip = require('zipfile');
var zf = new zip.ZipFile(obj);
console.log(zf);
}
else {
console.log('Error: unsupported file, unable to inspect');
process.exit(1);
}
|