mapshaper 0.6.40 → 0.6.41

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/bin/mapshaper-gui CHANGED
@@ -9,7 +9,7 @@ var defaultPort = 5555,
9
9
  .option('-q, --quick-view', 'load files with default options, bypassing import dialog')
10
10
  .option('-s, --direct-save', 'save files outside the browser\'s download folder')
11
11
  .option('-f, --force-save', 'allow overwriting input files with output files')
12
- .option('-a, --display-all', 'turn on visibility of all layers')
12
+ .option('-a, --display-all', 'turn on initial visibility of all layers')
13
13
  .option('-n, --name <name(s)>', 'rename input layer or layers')
14
14
  .option('-c, --commands <string>', 'console commands to run initially')
15
15
  .option('-t, --target <name>', 'name of layer to select initially')
package/mapshaper.js CHANGED
@@ -1,6 +1,6 @@
1
1
  (function () {
2
2
 
3
- var VERSION = "0.6.40";
3
+ var VERSION = "0.6.41";
4
4
 
5
5
 
6
6
  var utils = /*#__PURE__*/Object.freeze({
@@ -10877,7 +10877,8 @@
10877
10877
  pack: pack,
10878
10878
  exportDatasetsToPack: exportDatasetsToPack,
10879
10879
  applyCompression: applyCompression,
10880
- exportDataset: exportDataset
10880
+ exportDataset: exportDataset,
10881
+ exportInfo: exportInfo
10881
10882
  });
10882
10883
 
10883
10884
  // Guess the type of a data file from file extension, or return null if not sure
@@ -23386,6 +23387,10 @@ ${svg}
23386
23387
  describe: '[TopoJSON] export coordinates without quantization',
23387
23388
  type: 'flag'
23388
23389
  })
23390
+ .option('metadata', {
23391
+ // describe: '[TopoJSON] Add a metadata object containing CRS information',
23392
+ type: 'flag'
23393
+ })
23389
23394
  .option('no-point-quantization', {
23390
23395
  // describe: '[TopoJSON] export point coordinates without quantization',
23391
23396
  type: 'flag'
@@ -27562,6 +27567,7 @@ ${svg}
27562
27567
  var separator = path.indexOf('/') > 0 ? '/' : '.';
27563
27568
  var parts = path.split(separator);
27564
27569
  var subpath, array, match;
27570
+
27565
27571
  while (parts.length > 0) {
27566
27572
  subpath = parts.shift();
27567
27573
  match = arrayRxp.exec(subpath);
@@ -36244,31 +36250,6 @@ ${svg}
36244
36250
 
36245
36251
  var externalCommands = {};
36246
36252
 
36247
- cmd.external = function(opts) {
36248
- // TODO: remove duplication with -require command
36249
- var _module, moduleFile, moduleName;
36250
- if (!opts.module) {
36251
- stop('Missing required "module" parameter');
36252
- }
36253
- if (cli.isFile(opts.module)) {
36254
- moduleFile = opts.module;
36255
- } else if (cli.isFile(opts.module + '.js')) {
36256
- moduleFile = opts.module + '.js';
36257
- } else {
36258
- moduleName = opts.module;
36259
- }
36260
- if (moduleFile) {
36261
- moduleFile = require$1('path').join(process.cwd(), moduleFile);
36262
- }
36263
- try {
36264
- _module = require$1(moduleFile || moduleName);
36265
- _module(coreAPI);
36266
- } catch(e) {
36267
- // stop(e);
36268
- stop('Unable to load external module:', e.message);
36269
- }
36270
- };
36271
-
36272
36253
  cmd.registerCommand = function(name, params) {
36273
36254
  var defn = {name: name, options: params.options || []};
36274
36255
  // Add definitions of options common to all commands (TODO: remove duplication)
@@ -36278,13 +36259,25 @@ ${svg}
36278
36259
  externalCommands[name] = defn;
36279
36260
  };
36280
36261
 
36262
+ function isValidExternalCommand(defn) {
36263
+ try {
36264
+ validateExternalCommand(defn);
36265
+ return true;
36266
+ } catch(e) {}
36267
+ return false;
36268
+ }
36269
+
36281
36270
  function validateExternalCommand(defn) {
36271
+ var targetTypes = ['layer', 'layers'];
36282
36272
  if (typeof defn.command != 'function') {
36283
36273
  stop('Expected "command" parameter function');
36284
36274
  }
36285
36275
  if (!defn.target) {
36286
36276
  stop('Missing required "target" parameter');
36287
36277
  }
36278
+ if (!targetTypes.includes(defn.target)) {
36279
+ stop('Unrecognized command target type:', defn.target);
36280
+ }
36288
36281
  }
36289
36282
 
36290
36283
  cmd.runExternalCommand = function(cmdOpts, catalog) {
@@ -40624,6 +40617,7 @@ ${svg}
40624
40617
  return outputLayers;
40625
40618
  };
40626
40619
 
40620
+
40627
40621
  function getPolygonDataset(pointLyr, gridBBox, opts) {
40628
40622
  var points = getPointsInLayer(pointLyr);
40629
40623
  var cellSize = opts.interval;
@@ -40729,6 +40723,8 @@ ${svg}
40729
40723
  return getPointBufferCoordinates(center, radius, 20, getPlanarSegmentEndpoint);
40730
40724
  }
40731
40725
 
40726
+ // Returns a function that receives a cell index and returns indices of points
40727
+ // within a given distance of the cell.
40732
40728
  function getPointIndex(points, grid, radius) {
40733
40729
  var Flatbush = require$1('flatbush');
40734
40730
  var gridIndex = new IdTestIndex(grid.cells());
@@ -40860,12 +40856,26 @@ ${svg}
40860
40856
  xmin + (c + 1) * interval, ymin + (r + 1) * interval
40861
40857
  ];
40862
40858
  }
40859
+
40863
40860
  return {
40864
40861
  size, cells, pointToCol, pointToRow, colRowToIdx, pointToIdx,
40865
40862
  idxToCol, idxToRow, idxToBBox, idxToPoint
40866
40863
  };
40867
40864
  }
40868
40865
 
40866
+ var PointToGrid = /*#__PURE__*/Object.freeze({
40867
+ __proto__: null,
40868
+ getPointCircleRadius: getPointCircleRadius,
40869
+ calcCellProperties: calcCellProperties,
40870
+ calcWeights: calcWeights,
40871
+ twoCircleIntersection: twoCircleIntersection,
40872
+ makeCellPolygon: makeCellPolygon,
40873
+ getPointIndex: getPointIndex,
40874
+ getAlignedGridBounds: getAlignedGridBounds,
40875
+ getCenteredGridBounds: getCenteredGridBounds,
40876
+ getGridData: getGridData
40877
+ });
40878
+
40869
40879
  function closeUndershoots(lyr, dataset, opts) {
40870
40880
  var maxGapLen = opts.gap_tolerance ? convertIntervalParam(opts.gap_tolerance, getDatasetCRS(dataset)) : 0;
40871
40881
  var arcs = dataset.arcs;
@@ -41180,8 +41190,16 @@ ${svg}
41180
41190
  }
41181
41191
  try {
41182
41192
  mod = require$1(moduleFile || moduleName);
41193
+ if (typeof mod == 'function') {
41194
+ // -require now includes the functionality of the old -external command
41195
+ var retn = mod(api);
41196
+ if (retn && isValidExternalCommand(retn)) {
41197
+ cmd.registerCommand(retn.name, retn);
41198
+ }
41199
+ }
41183
41200
  } catch(e) {
41184
- stop(e);
41201
+ // stop(e);
41202
+ stop('Unable to load external module:', e.message);
41185
41203
  }
41186
41204
  if (moduleName || opts.alias) {
41187
41205
  defs[opts.alias || moduleName] = mod;
@@ -43347,7 +43365,7 @@ ${svg}
43347
43365
  }
43348
43366
 
43349
43367
  function commandAcceptsMultipleTargetDatasets(name) {
43350
- return name == 'rotate' || name == 'info' || name == 'proj' ||
43368
+ return name == 'rotate' || name == 'info' || name == 'proj' || name == 'require' ||
43351
43369
  name == 'drop' || name == 'target' || name == 'if' || name == 'elif' ||
43352
43370
  name == 'else' || name == 'endif' || name == 'run' || name == 'i';
43353
43371
  }
@@ -43505,7 +43523,8 @@ ${svg}
43505
43523
  outputLayers = applyCommandToEachLayer(cmd.explodeFeatures, targetLayers, arcs, opts);
43506
43524
 
43507
43525
  } else if (name == 'external') {
43508
- cmd.external(opts);
43526
+ // -require now incorporates -external
43527
+ cmd.require(targets, opts);
43509
43528
 
43510
43529
  } else if (name == 'filter') {
43511
43530
  outputLayers = applyCommandToEachLayer(cmd.filterFeatures, targetLayers, arcs, opts);
@@ -44130,14 +44149,6 @@ ${svg}
44130
44149
  runAndRemoveInfoCommands: runAndRemoveInfoCommands
44131
44150
  });
44132
44151
 
44133
- // the mapshaper public api only has 4 functions
44134
- var coreAPI = {
44135
- runCommands,
44136
- applyCommands,
44137
- runCommandsXL,
44138
- enableLogging
44139
- };
44140
-
44141
44152
  // Return an array containing points from a path iterator, clipped to a bounding box
44142
44153
  // Currently using this function for clipping styled polygons in the GUI to speed up layer rendering.
44143
44154
  // Artifacts along the edges make this unsuitable for clipping datasets
@@ -44534,6 +44545,7 @@ ${svg}
44534
44545
  PixelTransform,
44535
44546
  PointPolygonJoin,
44536
44547
  Points,
44548
+ PointToGrid,
44537
44549
  PointUtils,
44538
44550
  PolygonDissolve,
44539
44551
  PolygonDissolve2,
@@ -44581,16 +44593,26 @@ ${svg}
44581
44593
  Zip
44582
44594
  );
44583
44595
 
44584
- // The entry point for the core mapshaper module
44596
+ // the mapshaper public api only has 4 functions
44597
+ var api = {
44598
+ runCommands,
44599
+ applyCommands,
44600
+ runCommandsXL,
44601
+ enableLogging
44602
+ };
44585
44603
 
44586
- var moduleAPI = Object.assign({
44604
+ // Add some namespaces, for easier testability and
44605
+ // to expose internal functions to the web UI
44606
+ Object.assign(api, {
44587
44607
  cli, cmd, geom, utils, internal,
44588
- }, coreAPI);
44608
+ });
44609
+
44610
+ // The entry point for the core mapshaper module
44589
44611
 
44590
44612
  if (typeof module === "object" && module.exports) {
44591
- module.exports = moduleAPI;
44613
+ module.exports = api;
44592
44614
  } else if (typeof window === "object" && window) {
44593
- window.mapshaper = moduleAPI;
44615
+ window.mapshaper = api;
44594
44616
  }
44595
44617
 
44596
44618
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mapshaper",
3
- "version": "0.6.40",
3
+ "version": "0.6.41",
4
4
  "description": "A tool for editing vector datasets for mapping and GIS.",
5
5
  "keywords": [
6
6
  "shapefile",
@@ -1979,7 +1979,7 @@
1979
1979
  var names = getFileNames(files);
1980
1980
  var expanded = [];
1981
1981
  if (files.length === 0) return;
1982
- useQuickView = importCount === 0 && (opts.quick_view || overQuickView);
1982
+ useQuickView = importTotal === 0 && (opts.quick_view || overQuickView);
1983
1983
  try {
1984
1984
  expanded = await expandFiles(files);
1985
1985
  } catch(e) {
@@ -9171,6 +9171,10 @@
9171
9171
  return calcBounds(_cx, _cy, _scale / (k || 1));
9172
9172
  };
9173
9173
 
9174
+ this.getFullBounds = function() {
9175
+ return _fullBounds;
9176
+ };
9177
+
9174
9178
  // Update the extent of 'full' zoom without navigating the current view
9175
9179
  //
9176
9180
  this.setFullBounds = function(fullBounds, strictBounds) {
@@ -9506,6 +9510,7 @@
9506
9510
  canv.drawVertices(layer.shapes, arcs, style, filter);
9507
9511
  }
9508
9512
  }
9513
+ canv.clearStyles();
9509
9514
  }
9510
9515
 
9511
9516
 
@@ -9566,6 +9571,11 @@
9566
9571
  _pixelColor = getPixelColorFunction(),
9567
9572
  _ext;
9568
9573
 
9574
+ _self.clearStyles = function() {
9575
+ _ctx.fillStyle = null;
9576
+ _ctx.strokeStyle = null;
9577
+ };
9578
+
9569
9579
  _self.prep = function(extent) {
9570
9580
  var w = extent.width(),
9571
9581
  h = extent.height(),
@@ -10551,25 +10561,11 @@
10551
10561
 
10552
10562
 
10553
10563
  function getDisplayBounds(lyr, arcs) {
10554
- var arcBounds = arcs ? arcs.getBounds() : new Bounds(),
10555
- bounds = arcBounds, // default display extent: all arcs in the dataset
10556
- lyrBounds;
10557
-
10558
- if (lyr.geometry_type == 'point') {
10559
- lyrBounds = internal.getLayerBounds(lyr);
10560
- if (lyrBounds && lyrBounds.hasBounds()) {
10561
- if (lyrBounds.area() > 0 || !arcBounds.hasBounds()) {
10562
- bounds = lyrBounds;
10563
- } else {
10564
- // if a point layer has no extent (e.g. contains only a single point),
10565
- // then merge with arc bounds, to place the point in context.
10566
- bounds = arcBounds.mergeBounds(lyrBounds);
10567
- }
10568
- }
10569
- }
10570
-
10571
- if (!bounds || !bounds.hasBounds()) { // empty layer
10572
- bounds = new Bounds();
10564
+ var bounds = internal.getLayerBounds(lyr, arcs) || new Bounds();
10565
+ if (lyr.geometry_type == 'point' && arcs && bounds.hasBounds() && bounds.area() > 0 === false) {
10566
+ // if a point layer has no extent (e.g. contains only a single point),
10567
+ // then merge with arc bounds, to place the point in context.
10568
+ bounds = bounds.mergeBounds(arcs.getBounds());
10573
10569
  }
10574
10570
  return bounds;
10575
10571
  }
@@ -10843,7 +10839,6 @@
10843
10839
  _ext = new MapExtent(position),
10844
10840
  _nav = new MapNav(gui, _ext, _mouse),
10845
10841
  _visibleLayers = [], // cached visible map layers
10846
- _fullBounds = null,
10847
10842
  _hit,
10848
10843
  _basemap,
10849
10844
  _intersectionLyr, _activeLyr, _overlayLyr,
@@ -10951,8 +10946,8 @@
10951
10946
  updateLayerStyles(getDrawableContentLayers()); // kludge to make sure all layers have styles
10952
10947
 
10953
10948
  // Update map extent (also triggers redraw)
10954
- projectMapExtent(_ext, oldCRS, this.getDisplayCRS(), getFullBounds());
10955
- _fullBounds = getFullBounds(); // update this so map extent doesn't get reset after next update
10949
+ projectMapExtent(_ext, oldCRS, this.getDisplayCRS(), calcFullBounds());
10950
+ updateFullBounds();
10956
10951
  };
10957
10952
 
10958
10953
  // Refresh map display in response to data changes, layer selection, etc.
@@ -10995,28 +10990,27 @@
10995
10990
  gui.dispatchEvent('popup-needs-refresh');
10996
10991
  } else if (_hit) {
10997
10992
  _hit.clearSelection();
10998
- _hit.setLayer(_activeLyr);
10999
10993
  }
10994
+ _hit.setLayer(_activeLyr); // need this every time, to support dynamic reprojection
11000
10995
 
11001
10996
  updateVisibleMapLayers();
11002
- fullBounds = getFullBounds();
10997
+ fullBounds = calcFullBounds();
11003
10998
 
11004
- if (!prevLyr || !_fullBounds || prevLyr.tabular || _activeLyr.tabular || isFrameView()) {
10999
+ if (!prevLyr || prevLyr.tabular || _activeLyr.tabular || isFrameView()) {
11005
11000
  needReset = true;
11006
11001
  } else {
11007
- needReset = mapNeedsReset(fullBounds, _fullBounds, _ext.getBounds(), e.flags);
11002
+ needReset = mapNeedsReset(fullBounds, _ext.getFullBounds(), _ext.getBounds(), e.flags);
11008
11003
  }
11009
11004
 
11010
11005
  if (isFrameView()) {
11011
11006
  _nav.setZoomFactor(0.05); // slow zooming way down to allow fine-tuning frame placement // 0.03
11012
- _ext.setFrame(getFullBounds()); // TODO: remove redundancy with drawLayers()
11007
+ _ext.setFrame(calcFullBounds()); // TODO: remove redundancy with drawLayers()
11013
11008
  needReset = true; // snap to frame extent
11014
11009
  } else {
11015
11010
  _nav.setZoomFactor(1);
11016
11011
  }
11017
11012
  _ext.setFullBounds(fullBounds, getStrictBounds()); // update 'home' button extent
11018
11013
 
11019
- _fullBounds = fullBounds;
11020
11014
  if (needReset) {
11021
11015
  _ext.reset();
11022
11016
  }
@@ -11117,12 +11111,17 @@
11117
11111
  return null;
11118
11112
  }
11119
11113
 
11120
- function getFullBounds() {
11114
+ function updateFullBounds() {
11115
+ _ext.setFullBounds(calcFullBounds(), getStrictBounds());
11116
+ }
11117
+
11118
+ function calcFullBounds() {
11121
11119
  if (isPreviewView()) {
11122
11120
  return internal.getFrameLayerBounds(internal.findFrameLayer(model));
11123
11121
  }
11124
11122
  var b = new Bounds();
11125
- getDrawableContentLayers().forEach(function(lyr) {
11123
+ var layers = getDrawableContentLayers();
11124
+ layers.forEach(function(lyr) {
11126
11125
  b.mergeBounds(lyr.bounds);
11127
11126
  });
11128
11127
 
@@ -11267,6 +11266,7 @@
11267
11266
  // (default) anything could have changed
11268
11267
  function drawLayers2(action) {
11269
11268
  var layersMayHaveChanged = !action;
11269
+ var fullBounds;
11270
11270
  var contentLayers = getDrawableContentLayers();
11271
11271
  var furnitureLayers = getDrawableFurnitureLayers();
11272
11272
  if (!(_ext.width() > 0 && _ext.height() > 0)) {
@@ -11277,7 +11277,7 @@
11277
11277
  if (layersMayHaveChanged) {
11278
11278
  // kludge to handle layer visibility toggling
11279
11279
  _ext.setFrame(isPreviewView() ? getFrameData() : null);
11280
- _ext.setFullBounds(getFullBounds(), getStrictBounds());
11280
+ updateFullBounds();
11281
11281
  updateLayerStyles(contentLayers);
11282
11282
  updateLayerStackOrder(model.getLayers());// update menu_order property of all layers
11283
11283
  }
package/www/mapshaper.js CHANGED
@@ -1,6 +1,6 @@
1
1
  (function () {
2
2
 
3
- var VERSION = "0.6.40";
3
+ var VERSION = "0.6.41";
4
4
 
5
5
 
6
6
  var utils = /*#__PURE__*/Object.freeze({
@@ -10877,7 +10877,8 @@
10877
10877
  pack: pack,
10878
10878
  exportDatasetsToPack: exportDatasetsToPack,
10879
10879
  applyCompression: applyCompression,
10880
- exportDataset: exportDataset
10880
+ exportDataset: exportDataset,
10881
+ exportInfo: exportInfo
10881
10882
  });
10882
10883
 
10883
10884
  // Guess the type of a data file from file extension, or return null if not sure
@@ -23386,6 +23387,10 @@ ${svg}
23386
23387
  describe: '[TopoJSON] export coordinates without quantization',
23387
23388
  type: 'flag'
23388
23389
  })
23390
+ .option('metadata', {
23391
+ // describe: '[TopoJSON] Add a metadata object containing CRS information',
23392
+ type: 'flag'
23393
+ })
23389
23394
  .option('no-point-quantization', {
23390
23395
  // describe: '[TopoJSON] export point coordinates without quantization',
23391
23396
  type: 'flag'
@@ -27562,6 +27567,7 @@ ${svg}
27562
27567
  var separator = path.indexOf('/') > 0 ? '/' : '.';
27563
27568
  var parts = path.split(separator);
27564
27569
  var subpath, array, match;
27570
+
27565
27571
  while (parts.length > 0) {
27566
27572
  subpath = parts.shift();
27567
27573
  match = arrayRxp.exec(subpath);
@@ -36244,31 +36250,6 @@ ${svg}
36244
36250
 
36245
36251
  var externalCommands = {};
36246
36252
 
36247
- cmd.external = function(opts) {
36248
- // TODO: remove duplication with -require command
36249
- var _module, moduleFile, moduleName;
36250
- if (!opts.module) {
36251
- stop('Missing required "module" parameter');
36252
- }
36253
- if (cli.isFile(opts.module)) {
36254
- moduleFile = opts.module;
36255
- } else if (cli.isFile(opts.module + '.js')) {
36256
- moduleFile = opts.module + '.js';
36257
- } else {
36258
- moduleName = opts.module;
36259
- }
36260
- if (moduleFile) {
36261
- moduleFile = require$1('path').join(process.cwd(), moduleFile);
36262
- }
36263
- try {
36264
- _module = require$1(moduleFile || moduleName);
36265
- _module(coreAPI);
36266
- } catch(e) {
36267
- // stop(e);
36268
- stop('Unable to load external module:', e.message);
36269
- }
36270
- };
36271
-
36272
36253
  cmd.registerCommand = function(name, params) {
36273
36254
  var defn = {name: name, options: params.options || []};
36274
36255
  // Add definitions of options common to all commands (TODO: remove duplication)
@@ -36278,13 +36259,25 @@ ${svg}
36278
36259
  externalCommands[name] = defn;
36279
36260
  };
36280
36261
 
36262
+ function isValidExternalCommand(defn) {
36263
+ try {
36264
+ validateExternalCommand(defn);
36265
+ return true;
36266
+ } catch(e) {}
36267
+ return false;
36268
+ }
36269
+
36281
36270
  function validateExternalCommand(defn) {
36271
+ var targetTypes = ['layer', 'layers'];
36282
36272
  if (typeof defn.command != 'function') {
36283
36273
  stop('Expected "command" parameter function');
36284
36274
  }
36285
36275
  if (!defn.target) {
36286
36276
  stop('Missing required "target" parameter');
36287
36277
  }
36278
+ if (!targetTypes.includes(defn.target)) {
36279
+ stop('Unrecognized command target type:', defn.target);
36280
+ }
36288
36281
  }
36289
36282
 
36290
36283
  cmd.runExternalCommand = function(cmdOpts, catalog) {
@@ -40624,6 +40617,7 @@ ${svg}
40624
40617
  return outputLayers;
40625
40618
  };
40626
40619
 
40620
+
40627
40621
  function getPolygonDataset(pointLyr, gridBBox, opts) {
40628
40622
  var points = getPointsInLayer(pointLyr);
40629
40623
  var cellSize = opts.interval;
@@ -40729,6 +40723,8 @@ ${svg}
40729
40723
  return getPointBufferCoordinates(center, radius, 20, getPlanarSegmentEndpoint);
40730
40724
  }
40731
40725
 
40726
+ // Returns a function that receives a cell index and returns indices of points
40727
+ // within a given distance of the cell.
40732
40728
  function getPointIndex(points, grid, radius) {
40733
40729
  var Flatbush = require$1('flatbush');
40734
40730
  var gridIndex = new IdTestIndex(grid.cells());
@@ -40860,12 +40856,26 @@ ${svg}
40860
40856
  xmin + (c + 1) * interval, ymin + (r + 1) * interval
40861
40857
  ];
40862
40858
  }
40859
+
40863
40860
  return {
40864
40861
  size, cells, pointToCol, pointToRow, colRowToIdx, pointToIdx,
40865
40862
  idxToCol, idxToRow, idxToBBox, idxToPoint
40866
40863
  };
40867
40864
  }
40868
40865
 
40866
+ var PointToGrid = /*#__PURE__*/Object.freeze({
40867
+ __proto__: null,
40868
+ getPointCircleRadius: getPointCircleRadius,
40869
+ calcCellProperties: calcCellProperties,
40870
+ calcWeights: calcWeights,
40871
+ twoCircleIntersection: twoCircleIntersection,
40872
+ makeCellPolygon: makeCellPolygon,
40873
+ getPointIndex: getPointIndex,
40874
+ getAlignedGridBounds: getAlignedGridBounds,
40875
+ getCenteredGridBounds: getCenteredGridBounds,
40876
+ getGridData: getGridData
40877
+ });
40878
+
40869
40879
  function closeUndershoots(lyr, dataset, opts) {
40870
40880
  var maxGapLen = opts.gap_tolerance ? convertIntervalParam(opts.gap_tolerance, getDatasetCRS(dataset)) : 0;
40871
40881
  var arcs = dataset.arcs;
@@ -41180,8 +41190,16 @@ ${svg}
41180
41190
  }
41181
41191
  try {
41182
41192
  mod = require$1(moduleFile || moduleName);
41193
+ if (typeof mod == 'function') {
41194
+ // -require now includes the functionality of the old -external command
41195
+ var retn = mod(api);
41196
+ if (retn && isValidExternalCommand(retn)) {
41197
+ cmd.registerCommand(retn.name, retn);
41198
+ }
41199
+ }
41183
41200
  } catch(e) {
41184
- stop(e);
41201
+ // stop(e);
41202
+ stop('Unable to load external module:', e.message);
41185
41203
  }
41186
41204
  if (moduleName || opts.alias) {
41187
41205
  defs[opts.alias || moduleName] = mod;
@@ -43347,7 +43365,7 @@ ${svg}
43347
43365
  }
43348
43366
 
43349
43367
  function commandAcceptsMultipleTargetDatasets(name) {
43350
- return name == 'rotate' || name == 'info' || name == 'proj' ||
43368
+ return name == 'rotate' || name == 'info' || name == 'proj' || name == 'require' ||
43351
43369
  name == 'drop' || name == 'target' || name == 'if' || name == 'elif' ||
43352
43370
  name == 'else' || name == 'endif' || name == 'run' || name == 'i';
43353
43371
  }
@@ -43505,7 +43523,8 @@ ${svg}
43505
43523
  outputLayers = applyCommandToEachLayer(cmd.explodeFeatures, targetLayers, arcs, opts);
43506
43524
 
43507
43525
  } else if (name == 'external') {
43508
- cmd.external(opts);
43526
+ // -require now incorporates -external
43527
+ cmd.require(targets, opts);
43509
43528
 
43510
43529
  } else if (name == 'filter') {
43511
43530
  outputLayers = applyCommandToEachLayer(cmd.filterFeatures, targetLayers, arcs, opts);
@@ -44130,14 +44149,6 @@ ${svg}
44130
44149
  runAndRemoveInfoCommands: runAndRemoveInfoCommands
44131
44150
  });
44132
44151
 
44133
- // the mapshaper public api only has 4 functions
44134
- var coreAPI = {
44135
- runCommands,
44136
- applyCommands,
44137
- runCommandsXL,
44138
- enableLogging
44139
- };
44140
-
44141
44152
  // Return an array containing points from a path iterator, clipped to a bounding box
44142
44153
  // Currently using this function for clipping styled polygons in the GUI to speed up layer rendering.
44143
44154
  // Artifacts along the edges make this unsuitable for clipping datasets
@@ -44534,6 +44545,7 @@ ${svg}
44534
44545
  PixelTransform,
44535
44546
  PointPolygonJoin,
44536
44547
  Points,
44548
+ PointToGrid,
44537
44549
  PointUtils,
44538
44550
  PolygonDissolve,
44539
44551
  PolygonDissolve2,
@@ -44581,16 +44593,26 @@ ${svg}
44581
44593
  Zip
44582
44594
  );
44583
44595
 
44584
- // The entry point for the core mapshaper module
44596
+ // the mapshaper public api only has 4 functions
44597
+ var api = {
44598
+ runCommands,
44599
+ applyCommands,
44600
+ runCommandsXL,
44601
+ enableLogging
44602
+ };
44585
44603
 
44586
- var moduleAPI = Object.assign({
44604
+ // Add some namespaces, for easier testability and
44605
+ // to expose internal functions to the web UI
44606
+ Object.assign(api, {
44587
44607
  cli, cmd, geom, utils, internal,
44588
- }, coreAPI);
44608
+ });
44609
+
44610
+ // The entry point for the core mapshaper module
44589
44611
 
44590
44612
  if (typeof module === "object" && module.exports) {
44591
- module.exports = moduleAPI;
44613
+ module.exports = api;
44592
44614
  } else if (typeof window === "object" && window) {
44593
- window.mapshaper = moduleAPI;
44615
+ window.mapshaper = api;
44594
44616
  }
44595
44617
 
44596
44618
  })();