mapshaper 0.5.89 → 0.5.91

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/mapshaper.js CHANGED
@@ -1240,7 +1240,8 @@
1240
1240
  // print a message to stdout
1241
1241
  function print() {
1242
1242
  STDOUT = true; // tell logArgs() to print to stdout, not stderr
1243
- message.apply(null, arguments);
1243
+ // calling message() adds the "[command name]" prefix
1244
+ _message(utils.toArray(arguments));
1244
1245
  STDOUT = false;
1245
1246
  }
1246
1247
 
@@ -9356,6 +9357,18 @@
9356
9357
  };
9357
9358
  addGetters(obj, getters);
9358
9359
  addBBoxGetter(obj, lyr, arcs);
9360
+ obj.field_exists = function(name) {
9361
+ return lyr.data && lyr.data.fieldExists(name) ? true : false;
9362
+ };
9363
+ obj.field_type = function(name) {
9364
+ return lyr.data && getColumnType(name, lyr.data.getRecords()) || null;
9365
+ };
9366
+ obj.field_includes = function(name, val) {
9367
+ if (!lyr.data) return false;
9368
+ return lyr.data.getRecords().some(function(rec) {
9369
+ return rec && (rec[name] === val);
9370
+ });
9371
+ };
9359
9372
  return obj;
9360
9373
  }
9361
9374
 
@@ -20598,6 +20611,10 @@ ${svg}
20598
20611
  .option('target', targetOpt)
20599
20612
  .validate(validateExpressionOpt);
20600
20613
 
20614
+ parser.command('print')
20615
+ .describe('print a message to stdout')
20616
+ .flag('multi_arg');
20617
+
20601
20618
  parser.command('projections')
20602
20619
  .describe('print list of supported projections');
20603
20620
 
@@ -36633,6 +36650,10 @@ ${svg}
36633
36650
  };
36634
36651
  }
36635
36652
 
36653
+ cmd.print = function(msgArg) {
36654
+ print(msgArg || '');
36655
+ };
36656
+
36636
36657
  cmd.renameLayers = function(layers, names, catalog) {
36637
36658
  if (names && names.join('').indexOf('=') > -1) {
36638
36659
  renameByAssignment(names, catalog);
@@ -39140,7 +39161,7 @@ ${svg}
39140
39161
  }
39141
39162
  if (!(name == 'graticule' || name == 'i' || name == 'help' ||
39142
39163
  name == 'point-grid' || name == 'shape' || name == 'rectangle' ||
39143
- name == 'include')) {
39164
+ name == 'include' || name == 'print')) {
39144
39165
  throw new UserError("No data is available");
39145
39166
  }
39146
39167
  }
@@ -39325,6 +39346,9 @@ ${svg}
39325
39346
  } else if (name == 'polygons') {
39326
39347
  outputLayers = cmd.polygons(targetLayers, targetDataset, opts);
39327
39348
 
39349
+ } else if (name == 'print') {
39350
+ cmd.print(command._.join(' '));
39351
+
39328
39352
  } else if (name == 'proj') {
39329
39353
  initProjLibrary(opts, function() {
39330
39354
  var err = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mapshaper",
3
- "version": "0.5.89",
3
+ "version": "0.5.91",
4
4
  "description": "A tool for editing vector datasets for mapping and GIS.",
5
5
  "keywords": [
6
6
  "shapefile",
package/www/mapshaper.js CHANGED
@@ -1240,7 +1240,8 @@
1240
1240
  // print a message to stdout
1241
1241
  function print() {
1242
1242
  STDOUT = true; // tell logArgs() to print to stdout, not stderr
1243
- message.apply(null, arguments);
1243
+ // calling message() adds the "[command name]" prefix
1244
+ _message(utils.toArray(arguments));
1244
1245
  STDOUT = false;
1245
1246
  }
1246
1247
 
@@ -9356,6 +9357,18 @@
9356
9357
  };
9357
9358
  addGetters(obj, getters);
9358
9359
  addBBoxGetter(obj, lyr, arcs);
9360
+ obj.field_exists = function(name) {
9361
+ return lyr.data && lyr.data.fieldExists(name) ? true : false;
9362
+ };
9363
+ obj.field_type = function(name) {
9364
+ return lyr.data && getColumnType(name, lyr.data.getRecords()) || null;
9365
+ };
9366
+ obj.field_includes = function(name, val) {
9367
+ if (!lyr.data) return false;
9368
+ return lyr.data.getRecords().some(function(rec) {
9369
+ return rec && (rec[name] === val);
9370
+ });
9371
+ };
9359
9372
  return obj;
9360
9373
  }
9361
9374
 
@@ -20598,6 +20611,10 @@ ${svg}
20598
20611
  .option('target', targetOpt)
20599
20612
  .validate(validateExpressionOpt);
20600
20613
 
20614
+ parser.command('print')
20615
+ .describe('print a message to stdout')
20616
+ .flag('multi_arg');
20617
+
20601
20618
  parser.command('projections')
20602
20619
  .describe('print list of supported projections');
20603
20620
 
@@ -36633,6 +36650,10 @@ ${svg}
36633
36650
  };
36634
36651
  }
36635
36652
 
36653
+ cmd.print = function(msgArg) {
36654
+ print(msgArg || '');
36655
+ };
36656
+
36636
36657
  cmd.renameLayers = function(layers, names, catalog) {
36637
36658
  if (names && names.join('').indexOf('=') > -1) {
36638
36659
  renameByAssignment(names, catalog);
@@ -39140,7 +39161,7 @@ ${svg}
39140
39161
  }
39141
39162
  if (!(name == 'graticule' || name == 'i' || name == 'help' ||
39142
39163
  name == 'point-grid' || name == 'shape' || name == 'rectangle' ||
39143
- name == 'include')) {
39164
+ name == 'include' || name == 'print')) {
39144
39165
  throw new UserError("No data is available");
39145
39166
  }
39146
39167
  }
@@ -39325,6 +39346,9 @@ ${svg}
39325
39346
  } else if (name == 'polygons') {
39326
39347
  outputLayers = cmd.polygons(targetLayers, targetDataset, opts);
39327
39348
 
39349
+ } else if (name == 'print') {
39350
+ cmd.print(command._.join(' '));
39351
+
39328
39352
  } else if (name == 'proj') {
39329
39353
  initProjLibrary(opts, function() {
39330
39354
  var err = null;