mapshaper 0.5.83 → 0.5.84
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/CHANGELOG.md +3 -0
- package/mapshaper.js +43 -33
- package/package.json +1 -1
- package/www/mapshaper.js +43 -33
package/CHANGELOG.md
CHANGED
package/mapshaper.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function () {
|
|
2
2
|
|
|
3
|
-
var VERSION = "0.5.
|
|
3
|
+
var VERSION = "0.5.83";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var utils = /*#__PURE__*/Object.freeze({
|
|
@@ -13719,7 +13719,7 @@
|
|
|
13719
13719
|
'stem-curve': 'number', // degrees of arc
|
|
13720
13720
|
'stem-taper': 'number',
|
|
13721
13721
|
'stem-length': 'number',
|
|
13722
|
-
'min-stem': 'number',
|
|
13722
|
+
'min-stem-ratio': 'number',
|
|
13723
13723
|
'arrow-scaling': 'number',
|
|
13724
13724
|
effect: null // e.g. "fade"
|
|
13725
13725
|
}, stylePropertyTypes);
|
|
@@ -38063,6 +38063,17 @@ ${svg}
|
|
|
38063
38063
|
// return [stem, head];
|
|
38064
38064
|
// }
|
|
38065
38065
|
|
|
38066
|
+
// function getStickArrowTip(totalLen, curve) {
|
|
38067
|
+
// // curve/2 intersects the arrowhead at 90deg (trigonometry)
|
|
38068
|
+
// var theta = Math.abs(curve/2) / 180 * Math.PI;
|
|
38069
|
+
// var dx = totalLen * Math.sin(theta) * (curve > 0 ? -1 : 1);
|
|
38070
|
+
// var dy = totalLen * Math.cos(theta);
|
|
38071
|
+
// return [dx, dy];
|
|
38072
|
+
// }
|
|
38073
|
+
|
|
38074
|
+
// function addPoints(a, b) {
|
|
38075
|
+
// return [a[0] + b[0], a[1] + b[1]];
|
|
38076
|
+
// }
|
|
38066
38077
|
|
|
38067
38078
|
function getFilledArrowCoords(d) {
|
|
38068
38079
|
var direction = d.rotation || d.direction || 0,
|
|
@@ -38081,7 +38092,7 @@ ${svg}
|
|
|
38081
38092
|
coords = calcStraightArrowCoords(size.stemLen, size.headLen, stemDx, headDx, baseDx);
|
|
38082
38093
|
} else {
|
|
38083
38094
|
if (direction > 0) stemCurve = -stemCurve;
|
|
38084
|
-
coords = getCurvedArrowCoords(size.stemLen, size.headLen,
|
|
38095
|
+
coords = getCurvedArrowCoords(size.stemLen, size.headLen, stemCurve, stemDx, headDx, baseDx);
|
|
38085
38096
|
}
|
|
38086
38097
|
|
|
38087
38098
|
rotateCoords(coords, direction);
|
|
@@ -38098,34 +38109,25 @@ ${svg}
|
|
|
38098
38109
|
|
|
38099
38110
|
function calcArrowSize(d) {
|
|
38100
38111
|
var totalLen = d.radius || d.length || d.r || 0,
|
|
38101
|
-
unscaledStemWidth = d['stem-width'] || 2,
|
|
38102
|
-
unscaledHeadWidth = d['head-width'] || unscaledStemWidth * 3,
|
|
38103
|
-
unscaledHeadLen = d['head-length'] || calcHeadLength(unscaledHeadWidth, d),
|
|
38104
38112
|
scale = 1,
|
|
38105
|
-
o =
|
|
38113
|
+
o = initArrowSize(d); // calc several parameters
|
|
38106
38114
|
|
|
38107
38115
|
if (totalLen > 0) {
|
|
38108
|
-
scale = calcScale(totalLen,
|
|
38109
|
-
o.
|
|
38110
|
-
o.
|
|
38111
|
-
o.
|
|
38116
|
+
scale = calcScale(totalLen, o.headLen, d);
|
|
38117
|
+
o.stemWidth *= scale;
|
|
38118
|
+
o.headWidth *= scale;
|
|
38119
|
+
o.headLen *= scale;
|
|
38112
38120
|
o.stemLen = totalLen - o.headLen;
|
|
38113
|
-
|
|
38114
|
-
} else {
|
|
38115
|
-
o.headWidth = unscaledHeadWidth;
|
|
38116
|
-
o.headLen = unscaledHeadLen;
|
|
38117
|
-
o.stemWidth = unscaledStemWidth;
|
|
38118
|
-
o.stemLen = d['stem-length'] || 0;
|
|
38119
38121
|
}
|
|
38120
38122
|
|
|
38121
|
-
if (
|
|
38123
|
+
if (o.headWidth < o.stemWidth) {
|
|
38122
38124
|
stop('Arrow head must be at least as wide as the stem.');
|
|
38123
38125
|
}
|
|
38124
38126
|
return o;
|
|
38125
38127
|
}
|
|
38126
38128
|
|
|
38127
38129
|
function calcScale(totalLen, headLen, d) {
|
|
38128
|
-
var minStemRatio = d['min-stem'] >= 0 ? d['min-stem'] : 0;
|
|
38130
|
+
var minStemRatio = d['min-stem-ratio'] >= 0 ? d['min-stem-ratio'] : 0;
|
|
38129
38131
|
var stemLen = d['stem-length'] || 0;
|
|
38130
38132
|
var maxHeadPct = 1 - minStemRatio;
|
|
38131
38133
|
var headPct = headLen / totalLen;
|
|
@@ -38139,23 +38141,31 @@ ${svg}
|
|
|
38139
38141
|
return scale;
|
|
38140
38142
|
}
|
|
38141
38143
|
|
|
38142
|
-
|
|
38143
|
-
|
|
38144
|
-
|
|
38145
|
-
|
|
38146
|
-
|
|
38147
|
-
|
|
38148
|
-
|
|
38149
|
-
|
|
38150
|
-
|
|
38151
|
-
|
|
38144
|
+
function initArrowSize(d) {
|
|
38145
|
+
var sizeRatio = getHeadSizeRatio(d['head-angle'] || 40); // length to width
|
|
38146
|
+
var o = {
|
|
38147
|
+
stemWidth: d['stem-width'] || 2,
|
|
38148
|
+
stemLen: d['stem-length'] || 0,
|
|
38149
|
+
headWidth: d['head-width'],
|
|
38150
|
+
headLen: d['head-length']
|
|
38151
|
+
};
|
|
38152
|
+
if (!o.headWidth) {
|
|
38153
|
+
if (o.headLen) {
|
|
38154
|
+
o.headWidth = o.headLen / sizeRatio;
|
|
38155
|
+
} else {
|
|
38156
|
+
o.headWidth = o.stemWidth * 3; // assumes stemWidth has been set
|
|
38157
|
+
}
|
|
38158
|
+
}
|
|
38159
|
+
if (!o.headLen) {
|
|
38160
|
+
o.headLen = o.headWidth * sizeRatio;
|
|
38161
|
+
}
|
|
38162
|
+
return o;
|
|
38152
38163
|
}
|
|
38153
38164
|
|
|
38154
38165
|
|
|
38155
|
-
|
|
38156
|
-
|
|
38157
|
-
|
|
38158
|
-
return headWidth * headRatio;
|
|
38166
|
+
// Returns ratio of head length to head width
|
|
38167
|
+
function getHeadSizeRatio(headAngle) {
|
|
38168
|
+
return 1 / Math.tan(Math.PI * headAngle / 180 / 2) / 2;
|
|
38159
38169
|
}
|
|
38160
38170
|
|
|
38161
38171
|
function getCurvedArrowCoords(stemLen, headLen, curvature, stemDx, headDx, baseDx) {
|
package/package.json
CHANGED
package/www/mapshaper.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function () {
|
|
2
2
|
|
|
3
|
-
var VERSION = "0.5.
|
|
3
|
+
var VERSION = "0.5.83";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var utils = /*#__PURE__*/Object.freeze({
|
|
@@ -13719,7 +13719,7 @@
|
|
|
13719
13719
|
'stem-curve': 'number', // degrees of arc
|
|
13720
13720
|
'stem-taper': 'number',
|
|
13721
13721
|
'stem-length': 'number',
|
|
13722
|
-
'min-stem': 'number',
|
|
13722
|
+
'min-stem-ratio': 'number',
|
|
13723
13723
|
'arrow-scaling': 'number',
|
|
13724
13724
|
effect: null // e.g. "fade"
|
|
13725
13725
|
}, stylePropertyTypes);
|
|
@@ -38063,6 +38063,17 @@ ${svg}
|
|
|
38063
38063
|
// return [stem, head];
|
|
38064
38064
|
// }
|
|
38065
38065
|
|
|
38066
|
+
// function getStickArrowTip(totalLen, curve) {
|
|
38067
|
+
// // curve/2 intersects the arrowhead at 90deg (trigonometry)
|
|
38068
|
+
// var theta = Math.abs(curve/2) / 180 * Math.PI;
|
|
38069
|
+
// var dx = totalLen * Math.sin(theta) * (curve > 0 ? -1 : 1);
|
|
38070
|
+
// var dy = totalLen * Math.cos(theta);
|
|
38071
|
+
// return [dx, dy];
|
|
38072
|
+
// }
|
|
38073
|
+
|
|
38074
|
+
// function addPoints(a, b) {
|
|
38075
|
+
// return [a[0] + b[0], a[1] + b[1]];
|
|
38076
|
+
// }
|
|
38066
38077
|
|
|
38067
38078
|
function getFilledArrowCoords(d) {
|
|
38068
38079
|
var direction = d.rotation || d.direction || 0,
|
|
@@ -38081,7 +38092,7 @@ ${svg}
|
|
|
38081
38092
|
coords = calcStraightArrowCoords(size.stemLen, size.headLen, stemDx, headDx, baseDx);
|
|
38082
38093
|
} else {
|
|
38083
38094
|
if (direction > 0) stemCurve = -stemCurve;
|
|
38084
|
-
coords = getCurvedArrowCoords(size.stemLen, size.headLen,
|
|
38095
|
+
coords = getCurvedArrowCoords(size.stemLen, size.headLen, stemCurve, stemDx, headDx, baseDx);
|
|
38085
38096
|
}
|
|
38086
38097
|
|
|
38087
38098
|
rotateCoords(coords, direction);
|
|
@@ -38098,34 +38109,25 @@ ${svg}
|
|
|
38098
38109
|
|
|
38099
38110
|
function calcArrowSize(d) {
|
|
38100
38111
|
var totalLen = d.radius || d.length || d.r || 0,
|
|
38101
|
-
unscaledStemWidth = d['stem-width'] || 2,
|
|
38102
|
-
unscaledHeadWidth = d['head-width'] || unscaledStemWidth * 3,
|
|
38103
|
-
unscaledHeadLen = d['head-length'] || calcHeadLength(unscaledHeadWidth, d),
|
|
38104
38112
|
scale = 1,
|
|
38105
|
-
o =
|
|
38113
|
+
o = initArrowSize(d); // calc several parameters
|
|
38106
38114
|
|
|
38107
38115
|
if (totalLen > 0) {
|
|
38108
|
-
scale = calcScale(totalLen,
|
|
38109
|
-
o.
|
|
38110
|
-
o.
|
|
38111
|
-
o.
|
|
38116
|
+
scale = calcScale(totalLen, o.headLen, d);
|
|
38117
|
+
o.stemWidth *= scale;
|
|
38118
|
+
o.headWidth *= scale;
|
|
38119
|
+
o.headLen *= scale;
|
|
38112
38120
|
o.stemLen = totalLen - o.headLen;
|
|
38113
|
-
|
|
38114
|
-
} else {
|
|
38115
|
-
o.headWidth = unscaledHeadWidth;
|
|
38116
|
-
o.headLen = unscaledHeadLen;
|
|
38117
|
-
o.stemWidth = unscaledStemWidth;
|
|
38118
|
-
o.stemLen = d['stem-length'] || 0;
|
|
38119
38121
|
}
|
|
38120
38122
|
|
|
38121
|
-
if (
|
|
38123
|
+
if (o.headWidth < o.stemWidth) {
|
|
38122
38124
|
stop('Arrow head must be at least as wide as the stem.');
|
|
38123
38125
|
}
|
|
38124
38126
|
return o;
|
|
38125
38127
|
}
|
|
38126
38128
|
|
|
38127
38129
|
function calcScale(totalLen, headLen, d) {
|
|
38128
|
-
var minStemRatio = d['min-stem'] >= 0 ? d['min-stem'] : 0;
|
|
38130
|
+
var minStemRatio = d['min-stem-ratio'] >= 0 ? d['min-stem-ratio'] : 0;
|
|
38129
38131
|
var stemLen = d['stem-length'] || 0;
|
|
38130
38132
|
var maxHeadPct = 1 - minStemRatio;
|
|
38131
38133
|
var headPct = headLen / totalLen;
|
|
@@ -38139,23 +38141,31 @@ ${svg}
|
|
|
38139
38141
|
return scale;
|
|
38140
38142
|
}
|
|
38141
38143
|
|
|
38142
|
-
|
|
38143
|
-
|
|
38144
|
-
|
|
38145
|
-
|
|
38146
|
-
|
|
38147
|
-
|
|
38148
|
-
|
|
38149
|
-
|
|
38150
|
-
|
|
38151
|
-
|
|
38144
|
+
function initArrowSize(d) {
|
|
38145
|
+
var sizeRatio = getHeadSizeRatio(d['head-angle'] || 40); // length to width
|
|
38146
|
+
var o = {
|
|
38147
|
+
stemWidth: d['stem-width'] || 2,
|
|
38148
|
+
stemLen: d['stem-length'] || 0,
|
|
38149
|
+
headWidth: d['head-width'],
|
|
38150
|
+
headLen: d['head-length']
|
|
38151
|
+
};
|
|
38152
|
+
if (!o.headWidth) {
|
|
38153
|
+
if (o.headLen) {
|
|
38154
|
+
o.headWidth = o.headLen / sizeRatio;
|
|
38155
|
+
} else {
|
|
38156
|
+
o.headWidth = o.stemWidth * 3; // assumes stemWidth has been set
|
|
38157
|
+
}
|
|
38158
|
+
}
|
|
38159
|
+
if (!o.headLen) {
|
|
38160
|
+
o.headLen = o.headWidth * sizeRatio;
|
|
38161
|
+
}
|
|
38162
|
+
return o;
|
|
38152
38163
|
}
|
|
38153
38164
|
|
|
38154
38165
|
|
|
38155
|
-
|
|
38156
|
-
|
|
38157
|
-
|
|
38158
|
-
return headWidth * headRatio;
|
|
38166
|
+
// Returns ratio of head length to head width
|
|
38167
|
+
function getHeadSizeRatio(headAngle) {
|
|
38168
|
+
return 1 / Math.tan(Math.PI * headAngle / 180 / 2) / 2;
|
|
38159
38169
|
}
|
|
38160
38170
|
|
|
38161
38171
|
function getCurvedArrowCoords(stemLen, headLen, curvature, stemDx, headDx, baseDx) {
|