mapshaper 0.7.52 → 0.7.53

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mapshaper",
3
- "version": "0.7.52",
3
+ "version": "0.7.53",
4
4
  "description": "A tool for editing geospatial data for mapping and GIS.",
5
5
  "keywords": [
6
6
  "shapefile",
@@ -32,7 +32,6 @@
32
32
  "postpublish": "./release_web_ui; ./release_github_version",
33
33
  "dev": "rollup --config --watch",
34
34
  "test:browser": "playwright test --fully-parallel --workers=6",
35
- "install:browsers": "./install-playwright-browsers",
36
35
  "benchmark:raster": "MAPSHAPER_RUN_BENCHMARKS=1 playwright test browser-tests/raster-resampling-benchmark.spec.mjs --project=chromium --workers=1"
37
36
  },
38
37
  "main": "./mapshaper.js",
@@ -12786,8 +12786,10 @@
12786
12786
  });
12787
12787
 
12788
12788
  gui.on('snip', function(e) {
12789
- var target = e.target;
12790
- var result = e.result;
12789
+ // read from e.data: the event dispatcher sets e.target to itself, so a
12790
+ // 'target' property in the payload never reaches the handler
12791
+ var target = e.data.target;
12792
+ var result = e.data.result;
12791
12793
  var undo = function() {
12792
12794
  undoSnip(target, result);
12793
12795
  gui.model.updated({arc_count: true});
@@ -13306,9 +13308,9 @@
13306
13308
  polygon_style: 'style polygons',
13307
13309
  labels: 'position labels',
13308
13310
  edit_points: 'add/drag points',
13309
- edit_lines: 'draw/edit polylines',
13311
+ edit_lines: 'draw/edit lines',
13310
13312
  edit_polygons: 'draw/edit polygons',
13311
- snip_lines: 'snip polylines',
13313
+ snip_lines: 'snip lines',
13312
13314
  vertices: 'edit vertices',
13313
13315
  selection: 'selection tool',
13314
13316
  ruler: 'measure distance',
@@ -23221,9 +23223,11 @@ GUI and setting the size and crop of SVG output.</p><div><input type="text" clas
23221
23223
  }
23222
23224
  }
23223
23225
 
23224
- function getDistanceDisplay(distanceMeters, unitHint) {
23225
- var unit = unitHint || (distanceMeters >= 1000 ? 'km' : 'm');
23226
- var value = unit == 'km' ? distanceMeters / 1000 : distanceMeters;
23226
+ function getDistanceDisplay(distanceMeters) {
23227
+ var unit = getDistanceUnit(distanceMeters);
23228
+ var value = unit == 'km' && distanceMeters / 1000 ||
23229
+ unit == 'm' && distanceMeters || unit == 'cm' && distanceMeters * 100 ||
23230
+ unit == 'mm' && distanceMeters * 1000 || 0;
23227
23231
  return {
23228
23232
  value,
23229
23233
  unit,
@@ -23237,7 +23241,9 @@ GUI and setting the size and crop of SVG output.</p><div><input type="text" clas
23237
23241
  }
23238
23242
 
23239
23243
  function getDistanceUnit(distanceMeters) {
23240
- return distanceMeters >= 1000 ? 'km' : 'm';
23244
+ return distanceMeters >= 1000 && 'km' ||
23245
+ distanceMeters >= 0.1 && 'm' || distanceMeters >= 0.01 && 'cm' ||
23246
+ distanceMeters > 0 && 'mm' || 'm';
23241
23247
  }
23242
23248
 
23243
23249
  function pointIsInLngLatRange(p) {
@@ -23281,7 +23287,8 @@ GUI and setting the size and crop of SVG output.</p><div><input type="text" clas
23281
23287
  if (value >= 100) return 0;
23282
23288
  if (value >= 10) return 1;
23283
23289
  if (value >= 1) return 2;
23284
- return 3;
23290
+ if (value > 0) return 3;
23291
+ return 1;
23285
23292
  }
23286
23293
 
23287
23294
  function lngLatToUnitVector(lng, lat) {
@@ -23759,11 +23766,10 @@ GUI and setting the size and crop of SVG output.</p><div><input type="text" clas
23759
23766
  var projectedMeters = isLatLng ? null : getProjectedPathDistanceMeters(path);
23760
23767
  var geographicMeters = getGeographicPathDistanceMeters(path);
23761
23768
  var displayedMeters = geographicMeters !== null ? geographicMeters : projectedMeters;
23762
- var unit = getDistanceUnit(displayedMeters || 0);
23763
23769
  return {
23764
23770
  projectedMeters,
23765
23771
  geographicMeters,
23766
- distanceLabel: displayedMeters === null ? null : getDistanceDisplay(displayedMeters, unit).label
23772
+ distanceLabel: displayedMeters === null ? null : getDistanceDisplay(displayedMeters).label
23767
23773
  };
23768
23774
  }
23769
23775
 
@@ -25693,6 +25699,23 @@ GUI and setting the size and crop of SVG output.</p><div><input type="text" clas
25693
25699
  appendNewPointForTest(target.layer, p);
25694
25700
  gui.dispatchEvent('point_add', {target: target.layer, p: p});
25695
25701
  gui.dispatchEvent('map-needs-refresh');
25702
+ },
25703
+ // Perform the same edit as the snip tool, without simulating the pointer
25704
+ // events that choose the cut locations.
25705
+ snipActiveLayerPath: function(fid, partId, cuts) {
25706
+ var target = gui.model.getActiveLayer();
25707
+ var lyr = target && target.layer;
25708
+ var result;
25709
+ if (!lyr || lyr.geometry_type != 'polyline') {
25710
+ throw new Error('Active layer is not a polyline layer');
25711
+ }
25712
+ result = snipPath(lyr, fid, partId, cuts);
25713
+ if (!result) {
25714
+ throw new Error('Snip was rejected');
25715
+ }
25716
+ gui.dispatchEvent('snip', {target: lyr, result: result});
25717
+ gui.model.updated({arc_count: true});
25718
+ return result;
25696
25719
  }
25697
25720
  };
25698
25721
  }