mapshaper 0.6.7 → 0.6.9
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 +66 -1
- package/package.json +1 -1
- package/www/mapshaper-gui.js +8 -1
- package/www/mapshaper.js +66 -1
- package/CHANGELOG.md +0 -1413
package/mapshaper.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function () {
|
|
2
2
|
|
|
3
|
-
var VERSION = "0.6.
|
|
3
|
+
var VERSION = "0.6.9";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var utils = /*#__PURE__*/Object.freeze({
|
|
@@ -9809,6 +9809,30 @@
|
|
|
9809
9809
|
}
|
|
9810
9810
|
|
|
9811
9811
|
if (hasPaths) {
|
|
9812
|
+
|
|
9813
|
+
ctx.bboxContainsPoint = function(x, y) {
|
|
9814
|
+
var bounds = arcs.getMultiShapeBounds(_ids);
|
|
9815
|
+
return bounds.containsPoint(x, y);
|
|
9816
|
+
};
|
|
9817
|
+
|
|
9818
|
+
ctx.bboxIntersectsRectangle = function(a, b, c, d) {
|
|
9819
|
+
var bbox = arcs.getMultiShapeBounds(_ids);
|
|
9820
|
+
var rect = Bounds.from(a, b, c, d);
|
|
9821
|
+
return rect.intersects(bbox);
|
|
9822
|
+
};
|
|
9823
|
+
|
|
9824
|
+
ctx.bboxContainsRectangle = function(a, b, c, d) {
|
|
9825
|
+
var bbox = arcs.getMultiShapeBounds(_ids);
|
|
9826
|
+
var rect = Bounds.from(a, b, c, d);
|
|
9827
|
+
return bbox.contains(rect);
|
|
9828
|
+
};
|
|
9829
|
+
|
|
9830
|
+
ctx.bboxContainedByRectangle = function(a, b, c, d) {
|
|
9831
|
+
var bbox = arcs.getMultiShapeBounds(_ids);
|
|
9832
|
+
var rect = Bounds.from(a, b, c, d);
|
|
9833
|
+
return rect.contains(bbox);
|
|
9834
|
+
};
|
|
9835
|
+
|
|
9812
9836
|
addGetters(ctx, {
|
|
9813
9837
|
// TODO: count hole/s + containing ring as one part
|
|
9814
9838
|
partCount: function() {
|
|
@@ -14850,6 +14874,7 @@
|
|
|
14850
14874
|
href: d.href || ''
|
|
14851
14875
|
}
|
|
14852
14876
|
};
|
|
14877
|
+
if (d.fill) o.properties.fill = d.fill;
|
|
14853
14878
|
return o;
|
|
14854
14879
|
}
|
|
14855
14880
|
|
|
@@ -19564,6 +19589,10 @@ ${svg}
|
|
|
19564
19589
|
describe: 'a pair of values (0-100) for limiting a color ramp',
|
|
19565
19590
|
type: 'numbers'
|
|
19566
19591
|
})
|
|
19592
|
+
.option('range', {
|
|
19593
|
+
// describe: 'a pair of numbers defining the effective data range',
|
|
19594
|
+
type: 'numbers'
|
|
19595
|
+
})
|
|
19567
19596
|
.option('null-value', {
|
|
19568
19597
|
describe: 'value (or color) to use for invalid or missing data'
|
|
19569
19598
|
})
|
|
@@ -29917,10 +29946,25 @@ ${svg}
|
|
|
29917
29946
|
}
|
|
29918
29947
|
|
|
29919
29948
|
var ascending = getAscendingNumbers(dataValues);
|
|
29949
|
+
if (opts.range) {
|
|
29950
|
+
ascending = applyDataRange(ascending, opts.range);
|
|
29951
|
+
}
|
|
29920
29952
|
var nullCount = dataValues.length - ascending.length;
|
|
29921
29953
|
var minVal = ascending[0];
|
|
29922
29954
|
var maxVal = ascending[ascending.length - 1];
|
|
29923
29955
|
|
|
29956
|
+
// kludge
|
|
29957
|
+
var clamp = opts.range ? function(val) {
|
|
29958
|
+
if (val < opts.range[0]) val = opts.range[0];
|
|
29959
|
+
if (val > opts.range[1]) val = opts.range[1];
|
|
29960
|
+
return val;
|
|
29961
|
+
} : null;
|
|
29962
|
+
|
|
29963
|
+
if (opts.range) {
|
|
29964
|
+
minVal = opts.range[0];
|
|
29965
|
+
maxVal = opts.range[1];
|
|
29966
|
+
}
|
|
29967
|
+
|
|
29924
29968
|
if (numBreaks === 0) {
|
|
29925
29969
|
breaks = [];
|
|
29926
29970
|
} else if (opts.breaks) {
|
|
@@ -29948,6 +29992,7 @@ ${svg}
|
|
|
29948
29992
|
}
|
|
29949
29993
|
classToValue = getOutputFunction(classValues, nullValue, opts);
|
|
29950
29994
|
classifier = function(val) {
|
|
29995
|
+
if (clamp) val = clamp(val);
|
|
29951
29996
|
return classToValue(dataToClass(val));
|
|
29952
29997
|
};
|
|
29953
29998
|
|
|
@@ -30132,6 +30177,26 @@ ${svg}
|
|
|
30132
30177
|
return arr;
|
|
30133
30178
|
}
|
|
30134
30179
|
|
|
30180
|
+
function applyDataRange(values, range) {
|
|
30181
|
+
var minval = range[0];
|
|
30182
|
+
var maxval = range[1];
|
|
30183
|
+
if (maxval > minval === false) {
|
|
30184
|
+
stop('Invalid data range:', range);
|
|
30185
|
+
}
|
|
30186
|
+
var values2 = values.map(function(val) {
|
|
30187
|
+
if (val < minval) val = minval;
|
|
30188
|
+
if (val > maxval) val = maxval;
|
|
30189
|
+
return val;
|
|
30190
|
+
});
|
|
30191
|
+
if (values2[0] < minval) {
|
|
30192
|
+
values2.unshift(minval);
|
|
30193
|
+
}
|
|
30194
|
+
if (values2[values2.length - 1] < maxval) {
|
|
30195
|
+
values2.push(maxval);
|
|
30196
|
+
}
|
|
30197
|
+
return values2;
|
|
30198
|
+
}
|
|
30199
|
+
|
|
30135
30200
|
function getAscendingNumbers(values) {
|
|
30136
30201
|
var numbers = values.filter(utils.isFiniteNumber);
|
|
30137
30202
|
utils.genericSort(numbers, true);
|
package/package.json
CHANGED
package/www/mapshaper-gui.js
CHANGED
|
@@ -1187,7 +1187,13 @@
|
|
|
1187
1187
|
// FF: supports pasting JSON and CSV from the clipboard but not files.
|
|
1188
1188
|
// Single files of all types are pasted as a string and an image/png
|
|
1189
1189
|
// Multiple files are pasted as a string containing a list of file names
|
|
1190
|
-
|
|
1190
|
+
|
|
1191
|
+
// import text from the clipboard (could be csv, json, etc)
|
|
1192
|
+
// formatted text can be available as both text/plain and text/html (e.g.
|
|
1193
|
+
// a JSON data object copied from a GitHub issue).
|
|
1194
|
+
//
|
|
1195
|
+
if (types.includes('text/plain')) {
|
|
1196
|
+
// if (types == 'text/plain') {
|
|
1191
1197
|
// text from clipboard (supported by Chrome, FF, Safari)
|
|
1192
1198
|
// TODO: handle FF case of string containing multiple file names.
|
|
1193
1199
|
files = [pastedTextToFile(e.clipboardData.getData('text/plain'))];
|
|
@@ -7698,6 +7704,7 @@
|
|
|
7698
7704
|
var node2;
|
|
7699
7705
|
o.properties.transform = getSvgSymbolTransform(xy, ext);
|
|
7700
7706
|
o.properties['data-id'] = id;
|
|
7707
|
+
o.properties.class = 'mapshaper-svg-symbol';
|
|
7701
7708
|
// o.properties['class'] = 'selected';
|
|
7702
7709
|
g.innerHTML = internal.svg.stringify(o);
|
|
7703
7710
|
node2 = g.firstChild;
|
package/www/mapshaper.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function () {
|
|
2
2
|
|
|
3
|
-
var VERSION = "0.6.
|
|
3
|
+
var VERSION = "0.6.9";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var utils = /*#__PURE__*/Object.freeze({
|
|
@@ -9809,6 +9809,30 @@
|
|
|
9809
9809
|
}
|
|
9810
9810
|
|
|
9811
9811
|
if (hasPaths) {
|
|
9812
|
+
|
|
9813
|
+
ctx.bboxContainsPoint = function(x, y) {
|
|
9814
|
+
var bounds = arcs.getMultiShapeBounds(_ids);
|
|
9815
|
+
return bounds.containsPoint(x, y);
|
|
9816
|
+
};
|
|
9817
|
+
|
|
9818
|
+
ctx.bboxIntersectsRectangle = function(a, b, c, d) {
|
|
9819
|
+
var bbox = arcs.getMultiShapeBounds(_ids);
|
|
9820
|
+
var rect = Bounds.from(a, b, c, d);
|
|
9821
|
+
return rect.intersects(bbox);
|
|
9822
|
+
};
|
|
9823
|
+
|
|
9824
|
+
ctx.bboxContainsRectangle = function(a, b, c, d) {
|
|
9825
|
+
var bbox = arcs.getMultiShapeBounds(_ids);
|
|
9826
|
+
var rect = Bounds.from(a, b, c, d);
|
|
9827
|
+
return bbox.contains(rect);
|
|
9828
|
+
};
|
|
9829
|
+
|
|
9830
|
+
ctx.bboxContainedByRectangle = function(a, b, c, d) {
|
|
9831
|
+
var bbox = arcs.getMultiShapeBounds(_ids);
|
|
9832
|
+
var rect = Bounds.from(a, b, c, d);
|
|
9833
|
+
return rect.contains(bbox);
|
|
9834
|
+
};
|
|
9835
|
+
|
|
9812
9836
|
addGetters(ctx, {
|
|
9813
9837
|
// TODO: count hole/s + containing ring as one part
|
|
9814
9838
|
partCount: function() {
|
|
@@ -14850,6 +14874,7 @@
|
|
|
14850
14874
|
href: d.href || ''
|
|
14851
14875
|
}
|
|
14852
14876
|
};
|
|
14877
|
+
if (d.fill) o.properties.fill = d.fill;
|
|
14853
14878
|
return o;
|
|
14854
14879
|
}
|
|
14855
14880
|
|
|
@@ -19564,6 +19589,10 @@ ${svg}
|
|
|
19564
19589
|
describe: 'a pair of values (0-100) for limiting a color ramp',
|
|
19565
19590
|
type: 'numbers'
|
|
19566
19591
|
})
|
|
19592
|
+
.option('range', {
|
|
19593
|
+
// describe: 'a pair of numbers defining the effective data range',
|
|
19594
|
+
type: 'numbers'
|
|
19595
|
+
})
|
|
19567
19596
|
.option('null-value', {
|
|
19568
19597
|
describe: 'value (or color) to use for invalid or missing data'
|
|
19569
19598
|
})
|
|
@@ -29917,10 +29946,25 @@ ${svg}
|
|
|
29917
29946
|
}
|
|
29918
29947
|
|
|
29919
29948
|
var ascending = getAscendingNumbers(dataValues);
|
|
29949
|
+
if (opts.range) {
|
|
29950
|
+
ascending = applyDataRange(ascending, opts.range);
|
|
29951
|
+
}
|
|
29920
29952
|
var nullCount = dataValues.length - ascending.length;
|
|
29921
29953
|
var minVal = ascending[0];
|
|
29922
29954
|
var maxVal = ascending[ascending.length - 1];
|
|
29923
29955
|
|
|
29956
|
+
// kludge
|
|
29957
|
+
var clamp = opts.range ? function(val) {
|
|
29958
|
+
if (val < opts.range[0]) val = opts.range[0];
|
|
29959
|
+
if (val > opts.range[1]) val = opts.range[1];
|
|
29960
|
+
return val;
|
|
29961
|
+
} : null;
|
|
29962
|
+
|
|
29963
|
+
if (opts.range) {
|
|
29964
|
+
minVal = opts.range[0];
|
|
29965
|
+
maxVal = opts.range[1];
|
|
29966
|
+
}
|
|
29967
|
+
|
|
29924
29968
|
if (numBreaks === 0) {
|
|
29925
29969
|
breaks = [];
|
|
29926
29970
|
} else if (opts.breaks) {
|
|
@@ -29948,6 +29992,7 @@ ${svg}
|
|
|
29948
29992
|
}
|
|
29949
29993
|
classToValue = getOutputFunction(classValues, nullValue, opts);
|
|
29950
29994
|
classifier = function(val) {
|
|
29995
|
+
if (clamp) val = clamp(val);
|
|
29951
29996
|
return classToValue(dataToClass(val));
|
|
29952
29997
|
};
|
|
29953
29998
|
|
|
@@ -30132,6 +30177,26 @@ ${svg}
|
|
|
30132
30177
|
return arr;
|
|
30133
30178
|
}
|
|
30134
30179
|
|
|
30180
|
+
function applyDataRange(values, range) {
|
|
30181
|
+
var minval = range[0];
|
|
30182
|
+
var maxval = range[1];
|
|
30183
|
+
if (maxval > minval === false) {
|
|
30184
|
+
stop('Invalid data range:', range);
|
|
30185
|
+
}
|
|
30186
|
+
var values2 = values.map(function(val) {
|
|
30187
|
+
if (val < minval) val = minval;
|
|
30188
|
+
if (val > maxval) val = maxval;
|
|
30189
|
+
return val;
|
|
30190
|
+
});
|
|
30191
|
+
if (values2[0] < minval) {
|
|
30192
|
+
values2.unshift(minval);
|
|
30193
|
+
}
|
|
30194
|
+
if (values2[values2.length - 1] < maxval) {
|
|
30195
|
+
values2.push(maxval);
|
|
30196
|
+
}
|
|
30197
|
+
return values2;
|
|
30198
|
+
}
|
|
30199
|
+
|
|
30135
30200
|
function getAscendingNumbers(values) {
|
|
30136
30201
|
var numbers = values.filter(utils.isFiniteNumber);
|
|
30137
30202
|
utils.genericSort(numbers, true);
|