mapshaper 0.6.88 → 0.6.89

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
@@ -45584,7 +45584,7 @@ ${svg}
45584
45584
  });
45585
45585
  }
45586
45586
 
45587
- var version = "0.6.88";
45587
+ var version = "0.6.89";
45588
45588
 
45589
45589
  // Parse command line args into commands and run them
45590
45590
  // Function takes an optional Node-style callback. A Promise is returned if no callback is given.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mapshaper",
3
- "version": "0.6.88",
3
+ "version": "0.6.89",
4
4
  "description": "A tool for editing vector datasets for mapping and GIS.",
5
5
  "keywords": [
6
6
  "shapefile",
@@ -56,7 +56,7 @@
56
56
  "iconv-lite": "^0.6.3",
57
57
  "idb-keyval": "^6.2.0",
58
58
  "kdbush": "^3.0.0",
59
- "mproj": "0.0.38",
59
+ "mproj": "0.0.39",
60
60
  "msgpackr": "^1.10.1",
61
61
  "opn": "^5.3.0",
62
62
  "rw": "~1.3.3",
package/www/index.html CHANGED
@@ -123,7 +123,7 @@
123
123
  <div class="erase-btn btn sidebar-btn">Erase</div>
124
124
  <div class="rect-btn btn sidebar-btn">Rectangle</div>
125
125
  <div class="frame-btn btn sidebar-btn">Frame</div>
126
- <div class="info-btn btn sidebar-btn">Coords</div>
126
+ <div class="info-btn btn sidebar-btn">Bounds</div>
127
127
  <div class="box-coords selectable"></div>
128
128
  <div class="cancel-btn btn sidebar-btn">Cancel</div>
129
129
  </div>
@@ -135,7 +135,7 @@
135
135
  <div class="filter-btn btn sidebar-btn">Keep</div>
136
136
  <div class="duplicate-btn btn sidebar-btn">Duplicate</div>
137
137
  <div class="split-btn btn sidebar-btn">Split</div>
138
- <div class="coords-btn btn sidebar-btn toggle-btn">Coords</div>
138
+ <div class="coords-btn btn sidebar-btn toggle-btn">Bounds</div>
139
139
  <div class="box-coords selectable"></div>
140
140
  <div class="data-btn btn sidebar-btn toggle-btn">Edit data</div>
141
141
  <div class="cancel-btn btn sidebar-btn">Clear</div>
@@ -3500,15 +3500,6 @@
3500
3500
  }
3501
3501
  }
3502
3502
 
3503
- function deleteFeature(lyr, fid) {
3504
- var records = lyr.data?.getRecords();
3505
- if (records) records.splice(fid, 1);
3506
- lyr.shapes.splice(fid, 1);
3507
- if (isProjectedLayer(lyr) && lyr.shapes != lyr.gui.displayLayer.shapes) {
3508
- lyr.gui.displayLayer.shapes.splice(fid, 1);
3509
- }
3510
- }
3511
-
3512
3503
  // p: one point in source data coords
3513
3504
  function appendNewPoint(lyr, p) {
3514
3505
  lyr.shapes.push([p]);
@@ -3521,15 +3512,20 @@
3521
3512
  }
3522
3513
  }
3523
3514
 
3524
- function deletePoint(lyr, fid) {
3525
- deleteFeature(lyr, fid);
3515
+ function deleteFeature(lyr, fid) {
3516
+ var records = lyr.data?.getRecords();
3517
+ if (records) records.splice(fid, 1);
3518
+ lyr.shapes.splice(fid, 1);
3519
+ if (isProjectedLayer(lyr) && lyr.geometry_type == 'point') {
3520
+ lyr.gui.displayLayer.shapes.splice(fid, 1); // point layer
3521
+ }
3526
3522
  }
3527
3523
 
3528
- function insertPoint(lyr, fid, shp, d) {
3524
+ function insertFeature(lyr, fid, shp, d) {
3529
3525
  var records = lyr.data?.getRecords();
3530
3526
  if (records) records.splice(fid, 0, d);
3531
3527
  lyr.shapes.splice(fid, 0, shp);
3532
- if (isProjectedLayer(lyr)) {
3528
+ if (isProjectedLayer(lyr) && lyr.geometry_type == 'point') {
3533
3529
  var shp2 = projectPointCoords(shp, lyr.gui.projectPoint);
3534
3530
  lyr.gui.displayLayer.shapes.splice(fid, 0, shp2);
3535
3531
  }
@@ -4255,6 +4251,10 @@
4255
4251
  setDisplayProjection(gui, cmd);
4256
4252
  } else {
4257
4253
  line.hide(); // hide cursor while command is being run
4254
+ // quit certain edit modes
4255
+ if (!gui.interaction.modeWorksWithConsole(gui.interaction.getMode())) {
4256
+ gui.interaction.turnOff();
4257
+ }
4258
4258
  runMapshaperCommands(cmd, function(err, flags) {
4259
4259
  if (flags) {
4260
4260
  gui.clearMode();
@@ -5606,12 +5606,12 @@
5606
5606
  addHistoryState(undo, redo);
5607
5607
  });
5608
5608
 
5609
- gui.on('point_delete', function(e) {
5609
+ gui.on('feature_delete', function(e) {
5610
5610
  var redo = function() {
5611
- deletePoint(e.data.target, e.fid);
5611
+ deleteFeature(e.data.target, e.fid);
5612
5612
  };
5613
5613
  var undo = function() {
5614
- insertPoint(e.data.target, e.fid, e.coords, e.d);
5614
+ insertFeature(e.data.target, e.fid, e.coords, e.d);
5615
5615
  };
5616
5616
  addHistoryState(undo, redo);
5617
5617
  });
@@ -5966,6 +5966,10 @@
5966
5966
  setMode('off');
5967
5967
  };
5968
5968
 
5969
+ this.modeWorksWithConsole = function(mode) {
5970
+ return ['off', 'info'];
5971
+ };
5972
+
5969
5973
  this.modeUsesHitDetection = function(mode) {
5970
5974
  return ['info', 'selection', 'data', 'labels', 'edit_points', 'vertices', 'rectangles', 'edit_lines', 'edit_polygons'].includes(mode);
5971
5975
  };
@@ -10243,8 +10247,8 @@
10243
10247
  function removePoint(target, id) {
10244
10248
  var d = target.data ? target.data.getRecords()[id] : null;
10245
10249
  var coords = target.shapes[id];
10246
- deletePoint(target, id);
10247
- gui.dispatchEvent('point_delete', {coords, d, target, fid: id});
10250
+ deleteFeature(target, id);
10251
+ gui.dispatchEvent('feature_delete', {coords, d, target, fid: id});
10248
10252
  gui.dispatchEvent('map-needs-refresh');
10249
10253
  hit.setHitId(-1);
10250
10254
  }
@@ -10492,7 +10496,7 @@
10492
10496
  }
10493
10497
 
10494
10498
  gui.keyboard.on('keydown', function(e) {
10495
- if (active() && e.keyName == 'space') {
10499
+ if (pathDrawing() && e.keyName == 'space') {
10496
10500
  e.stopPropagation(); // prevent console from opening if shift-panning
10497
10501
  }
10498
10502
  }, null, 1);
@@ -10506,6 +10510,7 @@
10506
10510
  deleteActiveVertex(e, vInfo);
10507
10511
  };
10508
10512
  }
10513
+
10509
10514
  // don't allow copying of open paths as geojson in polygon mode
10510
10515
  gui.contextMenu.open(e, target);
10511
10516
  });
@@ -10669,7 +10674,7 @@
10669
10674
 
10670
10675
  // esc or enter key finishes a path
10671
10676
  gui.keyboard.on('keydown', function(e) {
10672
- if (active() && (e.keyName == 'esc' || e.keyName == 'enter')) {
10677
+ if (pathDrawing() && (e.keyName == 'esc' || e.keyName == 'enter')) {
10673
10678
  e.stopPropagation();
10674
10679
  finishCurrentPath();
10675
10680
  e.originalEvent.preventDefault(); // block console "enter"
@@ -12402,6 +12407,7 @@ GUI and setting the size and crop of SVG output.</p><div><input type="text" clas
12402
12407
 
12403
12408
  this.pixelCoordsToLngLatCoords = function(x, y) {
12404
12409
  var crsFrom = this.getDisplayCRS();
12410
+ if (!crsFrom) return null; // e.g. table view
12405
12411
  var p1 = internal.toLngLat(_ext.translatePixelCoords(x, y), crsFrom);
12406
12412
  var p2 = internal.toLngLat(_ext.translatePixelCoords(x+1, y+1), crsFrom);
12407
12413
  return p1 && p2 && p1[1] <= 90 && p1[1] >= -90 ?
@@ -12893,10 +12899,12 @@ GUI and setting the size and crop of SVG output.</p><div><input type="text" clas
12893
12899
  }
12894
12900
 
12895
12901
  function addMenuItem(label, func) {
12902
+ var prefix = '• &nbsp;';
12903
+
12896
12904
  El('div')
12897
12905
  .appendTo(menu)
12898
12906
  .addClass('contextmenu-item')
12899
- .html(label)
12907
+ .html(prefix + label)
12900
12908
  .on('click', func)
12901
12909
  .show();
12902
12910
  }
@@ -12909,28 +12917,36 @@ GUI and setting the size and crop of SVG output.</p><div><input type="text" clas
12909
12917
  }
12910
12918
 
12911
12919
  this.open = function(e, lyr) {
12920
+ var copyable = e.ids?.length;
12912
12921
  if (lyr && !lyr.gui.geographic) return; // no popup for tabular data
12913
12922
  menu.empty();
12914
12923
 
12915
12924
  // menu contents
12916
12925
  //
12917
- if (e.deleteVertex) {
12918
- addMenuItem('Delete vertex', e.deleteVertex);
12919
- }
12920
- if (e.deletePoint) {
12921
- addMenuItem('Delete point', e.deletePoint);
12922
- }
12923
- if (e.ids?.length) {
12924
- addMenuItem('Copy as GeoJSON', copyGeoJSON);
12925
- }
12926
- if (e.deleteFeature) {
12927
- addMenuItem(getDeleteLabel(), e.deleteFeature);
12926
+ if (e.deleteVertex || e.deletePoint || copyable || e.deleteFeature) {
12927
+
12928
+ addMenuLabel('selection');
12929
+ if (e.deleteVertex) {
12930
+ addMenuItem('delete vertex', e.deleteVertex);
12931
+ }
12932
+ if (e.deletePoint) {
12933
+ addMenuItem('delete point', e.deletePoint);
12934
+ }
12935
+ if (e.ids?.length) {
12936
+ addMenuItem('copy as GeoJSON', copyGeoJSON);
12937
+ }
12938
+ if (e.deleteFeature) {
12939
+ addMenuItem(getDeleteLabel(), e.deleteFeature);
12940
+ }
12928
12941
  }
12942
+
12929
12943
  if (e.lonlat_coordinates) {
12930
- addCoords(e.lonlat_coordinates, 'longitude, latitude');
12944
+ addMenuLabel('longitude, latitude');
12945
+ addCoords(e.lonlat_coordinates);
12931
12946
  }
12932
12947
  if (e.projected_coordinates) {
12933
- addCoords(e.projected_coordinates, 'easting, northing');
12948
+ addMenuLabel('easting, northing');
12949
+ addCoords(e.projected_coordinates);
12934
12950
  }
12935
12951
 
12936
12952
  if (menu.node().childNodes.length === 0) {
@@ -12952,16 +12968,13 @@ GUI and setting the size and crop of SVG output.</p><div><input type="text" clas
12952
12968
  menu.show();
12953
12969
 
12954
12970
  function getDeleteLabel() {
12955
- return 'Delete ' + (lyr.geometry_type == 'point' ? 'point' : 'shape');
12971
+ return 'delete ' + (lyr.geometry_type == 'point' ? 'point' : 'shape');
12956
12972
  }
12957
12973
 
12958
- function addCoords(p, label) {
12974
+ function addCoords(p) {
12959
12975
  var coordStr = p[0] + ',' + p[1];
12960
12976
  // var displayStr = '• &nbsp;' + coordStr.replace(/-/g, '–').replace(',', ', ');
12961
12977
  var displayStr = coordStr.replace(/-/g, '–').replace(',', ', ');
12962
- if (label) {
12963
- addMenuLabel(label);
12964
- }
12965
12978
  addMenuItem(displayStr, function() {
12966
12979
  saveFileContentToClipboard(coordStr);
12967
12980
  });
package/www/mapshaper.js CHANGED
@@ -45584,7 +45584,7 @@ ${svg}
45584
45584
  });
45585
45585
  }
45586
45586
 
45587
- var version = "0.6.88";
45587
+ var version = "0.6.89";
45588
45588
 
45589
45589
  // Parse command line args into commands and run them
45590
45590
  // Function takes an optional Node-style callback. A Promise is returned if no callback is given.
package/www/page.css CHANGED
@@ -1380,17 +1380,18 @@ body.pan.panning .map-layers:not(.drawing) {
1380
1380
  .contextmenu-item {
1381
1381
  background-color: #fff;
1382
1382
  white-space: nowrap;
1383
- padding: 5px 10px 6px 10px;
1384
- line-height: 11px;
1383
+ padding: 3px 10px 4px 10px;
1385
1384
  cursor: pointer;
1385
+ font-size: 13px;
1386
+ line-height: 13px;
1386
1387
  }
1387
1388
 
1388
1389
  .contextmenu-label {
1389
1390
  color: #999;
1390
- font-size: 82%;
1391
1391
  white-space: nowrap;
1392
- padding: 6px 10px 1px 10px;
1393
- line-height: 9px;
1392
+ padding: 4px 10px 1px 10px;
1393
+ font-size: 12px;
1394
+ line-height: 12px;
1394
1395
  margin-top: -2px;
1395
1396
  }
1396
1397