mapshaper 0.6.104 → 0.6.105

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
@@ -46041,7 +46041,7 @@ ${svg}
46041
46041
  });
46042
46042
  }
46043
46043
 
46044
- var version = "0.6.104";
46044
+ var version = "0.6.105";
46045
46045
 
46046
46046
  // Parse command line args into commands and run them
46047
46047
  // 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.104",
3
+ "version": "0.6.105",
4
4
  "description": "A tool for editing vector datasets for mapping and GIS.",
5
5
  "keywords": [
6
6
  "shapefile",
package/www/basemap.js CHANGED
@@ -1,7 +1,8 @@
1
1
  window.mapboxParams = {
2
2
  js: 'https://api.mapbox.com/mapbox-gl-js/v2.11.1/mapbox-gl.js',
3
3
  css: 'https://api.mapbox.com/mapbox-gl-js/v2.11.1/mapbox-gl.css',
4
- key: 'pk.eyJ1IjoiZ3JhbW1hdGEiLCJhIjoiY2wxMzI4b3dqMDNhMjNpcDhzcmU0aGh5diJ9.m1lacx48pTYls-X3FVhG9g',
4
+ production_key: 'pk.eyJ1IjoiZ3JhbW1hdGEiLCJhIjoiY21jZ2RlbGk1MGhvNzJrcHV2dTYzZWE2byJ9.btkRnRrPW75c0AlQ5lH2cg',
5
+ localhost_key: 'pk.eyJ1IjoiZ3JhbW1hdGEiLCJhIjoiY21jZ2Rna2hrMGo2ZjJqcHFxMHAycDlyMSJ9.q8FchhB-NAN_FGBHN0AJeg',
5
6
  styles: [{
6
7
  name: 'Map',
7
8
  icon: 'images/thumb-map.jpg',
@@ -2946,7 +2946,6 @@
2946
2946
  style.styler = getOverlayPointStyler(getCanvasDisplayStyle(baseLyr).styler, styler);
2947
2947
  }
2948
2948
  style.type = 'styled';
2949
-
2950
2949
  }
2951
2950
  return ids.length > 0 ? style : null;
2952
2951
  }
@@ -8228,7 +8227,7 @@
8228
8227
  }
8229
8228
  });
8230
8229
  return {
8231
- ids: hits
8230
+ ids: utils$1.uniq(hits)
8232
8231
  };
8233
8232
  };
8234
8233
  }
@@ -8414,7 +8413,7 @@
8414
8413
  mouse.on('contextmenu', function(e) {
8415
8414
  e.originalEvent.preventDefault();
8416
8415
  if (El('body').hasClass('map-view')) {
8417
- triggerHitEvent('contextmenu', e);
8416
+ triggerPointerEvent('contextmenu', e);
8418
8417
  }
8419
8418
  });
8420
8419
 
@@ -8510,7 +8509,7 @@
8510
8509
  if (storedData.id == id) return;
8511
8510
  storedData.id = id;
8512
8511
  storedData.ids = id == -1 ? [] : [id];
8513
- triggerHitEvent('change');
8512
+ triggerChangeEvent();
8514
8513
  };
8515
8514
 
8516
8515
  // Get a reference to the active layer, so listeners to hit events can interact
@@ -8529,7 +8528,7 @@
8529
8528
  self.setPinning = function(val) {
8530
8529
  if (pinnedOn != val) {
8531
8530
  pinnedOn = val;
8532
- triggerHitEvent('change');
8531
+ triggerChangeEvent();
8533
8532
  }
8534
8533
  };
8535
8534
 
@@ -8537,7 +8536,7 @@
8537
8536
  // turnOn('selection');
8538
8537
  transientIds = ids || [];
8539
8538
  if (active) {
8540
- triggerHitEvent('change');
8539
+ triggerChangeEvent();
8541
8540
  }
8542
8541
  };
8543
8542
 
@@ -8552,9 +8551,9 @@
8552
8551
  self.triggerChangeEvent();
8553
8552
  };
8554
8553
 
8555
- self.triggerChangeEvent = function() {
8556
- triggerHitEvent('change');
8557
- };
8554
+ self.triggerChangeEvent = triggerChangeEvent;
8555
+
8556
+ self.getHitState = getHitState;
8558
8557
 
8559
8558
  self.clearDrawingId = function() {
8560
8559
  self.setDrawingId(-1);
@@ -8566,14 +8565,14 @@
8566
8565
  if (p2 && p2[0] == p[0] && p2[1] == p[1]) return;
8567
8566
  storedData.hit_coordinates = p;
8568
8567
  storedData.hit_type = type || '';
8569
- triggerHitEvent('change');
8568
+ triggerChangeEvent();
8570
8569
  };
8571
8570
 
8572
8571
  self.clearHoverVertex = function() {
8573
8572
  if (!storedData.hit_coordinates) return;
8574
8573
  delete storedData.hit_coordinates;
8575
8574
  delete storedData.hit_type;
8576
- triggerHitEvent('change');
8575
+ triggerChangeEvent();
8577
8576
  };
8578
8577
 
8579
8578
  self.clearSelection = function() {
@@ -8607,7 +8606,7 @@
8607
8606
  if (n < 2 || pinnedId() == -1) return;
8608
8607
  storedData.id = (pinnedId() + n + diff) % n;
8609
8608
  storedData.ids = [storedData.id];
8610
- triggerHitEvent('change');
8609
+ triggerChangeEvent();
8611
8610
  }
8612
8611
 
8613
8612
  // diff: 1 or -1
@@ -8617,7 +8616,7 @@
8617
8616
  var n = storedData.ids.length;
8618
8617
  if (i < 0 || n < 2) return;
8619
8618
  storedData.id = storedData.ids[(i + diff + n) % n];
8620
- triggerHitEvent('change');
8619
+ triggerChangeEvent();
8621
8620
  }
8622
8621
 
8623
8622
  // make sure popup is unpinned and turned off when switching editing modes
@@ -8644,7 +8643,6 @@
8644
8643
  mouse.on('drag', handlePointerEvent, null, priority);
8645
8644
  mouse.on('dragend', handlePointerEvent, null, priority);
8646
8645
 
8647
-
8648
8646
  mouse.on('click', function(e) {
8649
8647
  var pinned = storedData.pinned;
8650
8648
  if (!hitTest || !active) return;
@@ -8661,7 +8659,7 @@
8661
8659
  // a new point doesn't get made
8662
8660
  return;
8663
8661
  }
8664
- triggerHitEvent('click', e);
8662
+ triggerPointerEvent('click', e);
8665
8663
  }, null, priority);
8666
8664
 
8667
8665
  // Hits are re-detected on 'hover' (if hit detection is active)
@@ -8775,7 +8773,7 @@
8775
8773
  storedData = newData;
8776
8774
  gui.container.findChild('.map-layers').classed('symbol-hit', nonEmpty);
8777
8775
  if (active) {
8778
- triggerHitEvent('change');
8776
+ triggerChangeEvent();
8779
8777
  }
8780
8778
  }
8781
8779
 
@@ -8827,40 +8825,50 @@
8827
8825
  function handlePointerEvent(e) {
8828
8826
  if (eventIsEnabled(e.type)) {
8829
8827
  possiblyStopPropagation(e);
8830
- triggerHitEvent(e.type, e);
8828
+ triggerPointerEvent(e.type, e);
8831
8829
  }
8832
8830
  }
8833
8831
 
8832
+ function triggerChangeEvent() {
8833
+ self.dispatchEvent('change', getHitState());
8834
+ }
8835
+
8834
8836
  // evt: event data (may be a pointer event object, an ordinary object or null)
8835
- function triggerHitEvent(type, evt) {
8836
- var eventData = {
8837
- mode: interactionMode()
8838
- };
8837
+ function triggerPointerEvent(type, evt) {
8838
+ var eventData = getHitState();
8839
8839
  if (evt) {
8840
8840
  // data coordinates
8841
8841
  eventData.projected_coordinates = gui.map.pixelCoordsToProjectedCoords(evt.x, evt.y);
8842
8842
  eventData.lonlat_coordinates = gui.map.pixelCoordsToLngLatCoords(evt.x, evt.y);
8843
8843
  eventData.originalEvent = evt;
8844
8844
  eventData.overMap = isOverMap(evt);
8845
+ utils$1.defaults(eventData, evt.data);
8845
8846
  }
8847
+ // utils.defaults(eventData, evt && evt.data || {}, storedData);
8848
+ self.dispatchEvent(type, eventData);
8849
+ }
8850
+
8851
+ function getHitState() {
8852
+ var data = {
8853
+ mode: interactionMode()
8854
+ };
8846
8855
  // Merge stored hit data into the event data
8847
- utils$1.defaults(eventData, evt && evt.data || {}, storedData);
8848
- // utils.extend(eventData, storedData);
8856
+ utils$1.defaults(data, storedData);
8849
8857
  if (transientIds.length) {
8850
8858
  // add transient ids to any other hit ids
8851
- eventData.ids = utils$1.uniq(transientIds.concat(eventData.ids || []));
8859
+ data.ids = utils$1.uniq(transientIds.concat(data.ids || []));
8852
8860
  }
8853
8861
  // when drawing, we want the overlay layer to show the path being currently
8854
8862
  // drawn.
8855
8863
  if (drawingId >= 0) {
8856
- // eventData.ids = [drawingId];
8857
- // eventData.id = drawingId;
8858
- eventData.ids = utils$1.uniq(eventData.ids.concat([drawingId]));
8864
+ // data.ids = [drawingId];
8865
+ // data.id = drawingId;
8866
+ data.ids = utils$1.uniq(data.ids.concat([drawingId]));
8859
8867
  }
8860
8868
  if (pinnedOn) {
8861
- eventData.pinned = true;
8869
+ data.pinned = true;
8862
8870
  }
8863
- self.dispatchEvent(type, eventData);
8871
+ return data;
8864
8872
  }
8865
8873
 
8866
8874
  // Test if two hit data objects are equivalent
@@ -13567,12 +13575,14 @@ GUI and setting the size and crop of SVG output.</p><div><input type="text" clas
13567
13575
  }
13568
13576
 
13569
13577
  function initMap() {
13578
+ var accessToken = (window.location.hostname == 'localhost' ?
13579
+ params.localhost_key : params.production_key) || params.key;
13570
13580
  if (!enabled() || map || loading) return;
13571
13581
  loading = true;
13572
13582
  loadStylesheet(params.css);
13573
13583
  loadScript(params.js, function() {
13574
13584
  map = new window.mapboxgl.Map({
13575
- accessToken: params.key,
13585
+ accessToken: accessToken,
13576
13586
  logoPosition: 'bottom-left',
13577
13587
  container: mapEl.node(),
13578
13588
  style: activeStyle.url,
package/www/mapshaper.js CHANGED
@@ -46041,7 +46041,7 @@ ${svg}
46041
46041
  });
46042
46042
  }
46043
46043
 
46044
- var version = "0.6.104";
46044
+ var version = "0.6.105";
46045
46045
 
46046
46046
  // Parse command line args into commands and run them
46047
46047
  // Function takes an optional Node-style callback. A Promise is returned if no callback is given.