mapshaper 0.6.7 → 0.6.10

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/www/mapshaper.js CHANGED
@@ -1,6 +1,6 @@
1
1
  (function () {
2
2
 
3
- var VERSION = "0.6.7";
3
+ var VERSION = "0.6.10";
4
4
 
5
5
 
6
6
  var utils = /*#__PURE__*/Object.freeze({
@@ -8470,7 +8470,9 @@
8470
8470
  function getBoundsPrecisionForDisplay(bbox) {
8471
8471
  var w = Math.abs(bbox[2] - bbox[0]),
8472
8472
  h = Math.abs(bbox[3] - bbox[1]),
8473
- range = Math.min(w, h) + 1e-8,
8473
+ // switched to max bound, based on experience with shift-drag box info
8474
+ // range = Math.min(w, h) + 1e-8,
8475
+ range = Math.max(w, h) + 1e-8,
8474
8476
  digits = 0;
8475
8477
  while (range < 2000) {
8476
8478
  range *= 10;
@@ -9809,6 +9811,30 @@
9809
9811
  }
9810
9812
 
9811
9813
  if (hasPaths) {
9814
+
9815
+ ctx.bboxContainsPoint = function(x, y) {
9816
+ var bounds = arcs.getMultiShapeBounds(_ids);
9817
+ return bounds.containsPoint(x, y);
9818
+ };
9819
+
9820
+ ctx.bboxIntersectsRectangle = function(a, b, c, d) {
9821
+ var bbox = arcs.getMultiShapeBounds(_ids);
9822
+ var rect = Bounds.from(a, b, c, d);
9823
+ return rect.intersects(bbox);
9824
+ };
9825
+
9826
+ ctx.bboxContainsRectangle = function(a, b, c, d) {
9827
+ var bbox = arcs.getMultiShapeBounds(_ids);
9828
+ var rect = Bounds.from(a, b, c, d);
9829
+ return bbox.contains(rect);
9830
+ };
9831
+
9832
+ ctx.bboxContainedByRectangle = function(a, b, c, d) {
9833
+ var bbox = arcs.getMultiShapeBounds(_ids);
9834
+ var rect = Bounds.from(a, b, c, d);
9835
+ return rect.contains(bbox);
9836
+ };
9837
+
9812
9838
  addGetters(ctx, {
9813
9839
  // TODO: count hole/s + containing ring as one part
9814
9840
  partCount: function() {
@@ -14850,6 +14876,7 @@
14850
14876
  href: d.href || ''
14851
14877
  }
14852
14878
  };
14879
+ if (d.fill) o.properties.fill = d.fill;
14853
14880
  return o;
14854
14881
  }
14855
14882
 
@@ -19564,6 +19591,10 @@ ${svg}
19564
19591
  describe: 'a pair of values (0-100) for limiting a color ramp',
19565
19592
  type: 'numbers'
19566
19593
  })
19594
+ .option('range', {
19595
+ // describe: 'a pair of numbers defining the effective data range',
19596
+ type: 'numbers'
19597
+ })
19567
19598
  .option('null-value', {
19568
19599
  describe: 'value (or color) to use for invalid or missing data'
19569
19600
  })
@@ -29917,10 +29948,25 @@ ${svg}
29917
29948
  }
29918
29949
 
29919
29950
  var ascending = getAscendingNumbers(dataValues);
29951
+ if (opts.range) {
29952
+ ascending = applyDataRange(ascending, opts.range);
29953
+ }
29920
29954
  var nullCount = dataValues.length - ascending.length;
29921
29955
  var minVal = ascending[0];
29922
29956
  var maxVal = ascending[ascending.length - 1];
29923
29957
 
29958
+ // kludge
29959
+ var clamp = opts.range ? function(val) {
29960
+ if (val < opts.range[0]) val = opts.range[0];
29961
+ if (val > opts.range[1]) val = opts.range[1];
29962
+ return val;
29963
+ } : null;
29964
+
29965
+ if (opts.range) {
29966
+ minVal = opts.range[0];
29967
+ maxVal = opts.range[1];
29968
+ }
29969
+
29924
29970
  if (numBreaks === 0) {
29925
29971
  breaks = [];
29926
29972
  } else if (opts.breaks) {
@@ -29948,6 +29994,7 @@ ${svg}
29948
29994
  }
29949
29995
  classToValue = getOutputFunction(classValues, nullValue, opts);
29950
29996
  classifier = function(val) {
29997
+ if (clamp) val = clamp(val);
29951
29998
  return classToValue(dataToClass(val));
29952
29999
  };
29953
30000
 
@@ -30132,6 +30179,26 @@ ${svg}
30132
30179
  return arr;
30133
30180
  }
30134
30181
 
30182
+ function applyDataRange(values, range) {
30183
+ var minval = range[0];
30184
+ var maxval = range[1];
30185
+ if (maxval > minval === false) {
30186
+ stop('Invalid data range:', range);
30187
+ }
30188
+ var values2 = values.map(function(val) {
30189
+ if (val < minval) val = minval;
30190
+ if (val > maxval) val = maxval;
30191
+ return val;
30192
+ });
30193
+ if (values2[0] < minval) {
30194
+ values2.unshift(minval);
30195
+ }
30196
+ if (values2[values2.length - 1] < maxval) {
30197
+ values2.push(maxval);
30198
+ }
30199
+ return values2;
30200
+ }
30201
+
30135
30202
  function getAscendingNumbers(values) {
30136
30203
  var numbers = values.filter(utils.isFiniteNumber);
30137
30204
  utils.genericSort(numbers, true);
package/www/page.css CHANGED
@@ -184,6 +184,7 @@ body {
184
184
 
185
185
  .selection-tool-options .info-box {
186
186
  pointer-events: initial;
187
+ text-align: center;
187
188
  }
188
189
 
189
190
  /* --- Box tool dialog --------- */
@@ -200,6 +201,7 @@ body {
200
201
  }
201
202
 
202
203
  .box-tool-options .box-coords {
204
+ margin-top: 7px;
203
205
  pointer-events: initial;
204
206
  }
205
207
 
@@ -1241,8 +1243,14 @@ div.basemap-style-btn.active img {
1241
1243
  pointer-events: none;
1242
1244
  }
1243
1245
 
1244
- .zoom-box.zooming {
1245
- border-color: #1385B7;
1246
+ .zoom-box .handle {
1247
+ position: absolute;
1248
+ z-index: 16;
1249
+ /* cursor: pointer; */
1250
+ background: #cc6acc;
1251
+ pointer-events: all;
1252
+ width: 6px;
1253
+ height: 6px;
1246
1254
  }
1247
1255
 
1248
1256
  /* Simplification control ------------ */