mapshaper 0.7.16 → 0.7.17
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 +95 -13
- package/package.json +1 -1
- package/www/index.html +6 -1
- package/www/mapshaper-gui.js +6202 -10733
- package/www/mapshaper.js +95 -13
- package/www/page.css +406 -16
package/mapshaper.js
CHANGED
|
@@ -18595,6 +18595,7 @@
|
|
|
18595
18595
|
icon: null,
|
|
18596
18596
|
'icon-color': 'color',
|
|
18597
18597
|
'icon-size': 'number',
|
|
18598
|
+
'label-pos': 'labelposition',
|
|
18598
18599
|
'label-text': null, // leaving this null
|
|
18599
18600
|
'letter-spacing': 'measure',
|
|
18600
18601
|
'line-height': 'measure',
|
|
@@ -18646,6 +18647,20 @@
|
|
|
18646
18647
|
'fill,font-family,font-size,text-anchor,font-weight,font-style,font-stretch,letter-spacing,dominant-baseline'.split(',')))
|
|
18647
18648
|
};
|
|
18648
18649
|
|
|
18650
|
+
var labelPositionFields = ['label-pos', 'dx', 'dy', 'text-anchor'];
|
|
18651
|
+
|
|
18652
|
+
var labelPositionStyles = {
|
|
18653
|
+
n: {dx: 0, dy: '-0.45em', 'text-anchor': 'middle'},
|
|
18654
|
+
s: {dx: 0, dy: '1.05em', 'text-anchor': 'middle'},
|
|
18655
|
+
e: {dx: '0.4em', dy: '0.25em', 'text-anchor': 'start'},
|
|
18656
|
+
w: {dx: '-0.4em', dy: '0.25em', 'text-anchor': 'end'},
|
|
18657
|
+
ne: {dx: '0.35em', dy: '-0.15em', 'text-anchor': 'start'},
|
|
18658
|
+
se: {dx: '0.35em', dy: '0.7em', 'text-anchor': 'start'},
|
|
18659
|
+
nw: {dx: '-0.35em', dy: '-0.15em', 'text-anchor': 'end'},
|
|
18660
|
+
sw: {dx: '-0.35em', dy: '0.7em', 'text-anchor': 'end'},
|
|
18661
|
+
c: {dx: 0, dy: '0.25em', 'text-anchor': 'middle'}
|
|
18662
|
+
};
|
|
18663
|
+
|
|
18649
18664
|
// symType: point, polygon, polyline, label
|
|
18650
18665
|
function applyStyleAttributes(svgObj, symType, rec, filter) {
|
|
18651
18666
|
var fields = findStylePropertiesBySymbolGeom(Object.keys(rec || {}), symType);
|
|
@@ -18777,6 +18792,8 @@
|
|
|
18777
18792
|
val = parseBoolean(strVal);
|
|
18778
18793
|
} else if (type == 'inlinecss') {
|
|
18779
18794
|
val = strVal; // TODO: validate
|
|
18795
|
+
} else if (type == 'labelposition') {
|
|
18796
|
+
val = parseLabelPosition(strVal);
|
|
18780
18797
|
}
|
|
18781
18798
|
// else {
|
|
18782
18799
|
// // unknown type -- assume literal value
|
|
@@ -18808,6 +18825,26 @@
|
|
|
18808
18825
|
return null;
|
|
18809
18826
|
}
|
|
18810
18827
|
|
|
18828
|
+
function parseLabelPosition(str) {
|
|
18829
|
+
var pos = String(str).trim();
|
|
18830
|
+
return /^(n|s|e|w|ne|se|nw|sw|c)$/i.test(pos) ? pos : null;
|
|
18831
|
+
}
|
|
18832
|
+
|
|
18833
|
+
function getLabelPositionStyle(pos) {
|
|
18834
|
+
pos = parseLabelPosition(pos);
|
|
18835
|
+
if (!pos) return null;
|
|
18836
|
+
return Object.assign({'label-pos': pos}, labelPositionStyles[pos.toLowerCase()]);
|
|
18837
|
+
}
|
|
18838
|
+
|
|
18839
|
+
function setLabelPositionStyle(rec, pos) {
|
|
18840
|
+
var style = getLabelPositionStyle(pos);
|
|
18841
|
+
if (!style) return false;
|
|
18842
|
+
labelPositionFields.forEach(function(field) {
|
|
18843
|
+
rec[field] = style[field];
|
|
18844
|
+
});
|
|
18845
|
+
return true;
|
|
18846
|
+
}
|
|
18847
|
+
|
|
18811
18848
|
function isSvgMeasure(o) {
|
|
18812
18849
|
return utils.isFiniteNumber(o) || utils.isString(o) && /^-?[.0-9]+[a-z]*$/.test(o);
|
|
18813
18850
|
}
|
|
@@ -18826,6 +18863,7 @@
|
|
|
18826
18863
|
__proto__: null,
|
|
18827
18864
|
applyStyleAttributes: applyStyleAttributes,
|
|
18828
18865
|
findStylePropertiesBySymbolGeom: findStylePropertiesBySymbolGeom,
|
|
18866
|
+
getLabelPositionStyle: getLabelPositionStyle,
|
|
18829
18867
|
getSymbolDataAccessor: getSymbolDataAccessor,
|
|
18830
18868
|
getSymbolPropertyAccessor: getSymbolPropertyAccessor,
|
|
18831
18869
|
isSupportedSvgStyleProperty: isSupportedSvgStyleProperty,
|
|
@@ -18833,9 +18871,12 @@
|
|
|
18833
18871
|
isSvgColor: isSvgColor,
|
|
18834
18872
|
isSvgMeasure: isSvgMeasure,
|
|
18835
18873
|
isSvgNumber: isSvgNumber,
|
|
18874
|
+
labelPositionFields: labelPositionFields,
|
|
18836
18875
|
mightBeExpression: mightBeExpression,
|
|
18837
18876
|
parseBoolean: parseBoolean,
|
|
18838
|
-
|
|
18877
|
+
parseLabelPosition: parseLabelPosition,
|
|
18878
|
+
parseSvgMeasure: parseSvgMeasure,
|
|
18879
|
+
setLabelPositionStyle: setLabelPositionStyle
|
|
18839
18880
|
});
|
|
18840
18881
|
|
|
18841
18882
|
function toLabelString(val) {
|
|
@@ -18957,7 +18998,7 @@
|
|
|
18957
18998
|
|
|
18958
18999
|
function renderIcon(d) {
|
|
18959
19000
|
var type = d.icon || 'circle';
|
|
18960
|
-
var r = getIconRadius(d);
|
|
19001
|
+
var r = getIconRadius(d, type);
|
|
18961
19002
|
if (r > 0 === false) return empty();
|
|
18962
19003
|
if (type == 'circle') return circle(getIconStyleData(d, r));
|
|
18963
19004
|
if (type == 'square') return square(getIconStyleData(d, r), 0, 0);
|
|
@@ -18967,10 +19008,18 @@
|
|
|
18967
19008
|
return empty();
|
|
18968
19009
|
}
|
|
18969
19010
|
|
|
18970
|
-
function getIconRadius(d) {
|
|
18971
|
-
|
|
18972
|
-
if (d
|
|
18973
|
-
|
|
19011
|
+
function getIconRadius(d, type) {
|
|
19012
|
+
var size;
|
|
19013
|
+
if (d['icon-size'] > 0 === false) {
|
|
19014
|
+
return d.r > 0 ? d.r : 5;
|
|
19015
|
+
}
|
|
19016
|
+
size = d['icon-size'];
|
|
19017
|
+
if (type == 'circle' || type == 'ring') {
|
|
19018
|
+
size -= 1;
|
|
19019
|
+
} else if (type == 'star') {
|
|
19020
|
+
size += 1;
|
|
19021
|
+
}
|
|
19022
|
+
return size / 2;
|
|
18974
19023
|
}
|
|
18975
19024
|
|
|
18976
19025
|
function getIconStyleData(d, r) {
|
|
@@ -31669,6 +31718,9 @@ ${svg}
|
|
|
31669
31718
|
.option('label-text', {
|
|
31670
31719
|
describe: 'label text (set this to export points as labels)'
|
|
31671
31720
|
})
|
|
31721
|
+
.option('label-pos', {
|
|
31722
|
+
describe: 'label position; one of: n, s, e, w, ne, se, nw, sw, c'
|
|
31723
|
+
})
|
|
31672
31724
|
.option('text-anchor', {
|
|
31673
31725
|
describe: 'label alignment; one of: start, end, middle (default)'
|
|
31674
31726
|
})
|
|
@@ -56649,9 +56701,7 @@ ${svg}
|
|
|
56649
56701
|
lyr.data.getFields().filter(isSupportedSvgStyleProperty).forEach(lyr.data.deleteField, lyr.data);
|
|
56650
56702
|
}
|
|
56651
56703
|
table = getLayerDataTable(lyr);
|
|
56652
|
-
fields =
|
|
56653
|
-
return optName.replace('_', '-');
|
|
56654
|
-
}).filter(isSupportedSvgStyleProperty);
|
|
56704
|
+
fields = getStyleFields(opts);
|
|
56655
56705
|
hasNewFields = fields.some(function(field) {
|
|
56656
56706
|
return !table.fieldExists(field);
|
|
56657
56707
|
});
|
|
@@ -56672,11 +56722,14 @@ ${svg}
|
|
|
56672
56722
|
table.getRecords().forEach(function(rec, i) {
|
|
56673
56723
|
if (filterFn && !filterFn(i)) {
|
|
56674
56724
|
// make sure field exists if record is excluded by filter
|
|
56675
|
-
|
|
56676
|
-
rec[svgName] = undefined;
|
|
56677
|
-
}
|
|
56725
|
+
setUndefinedFields(rec, svgName == 'label-pos' ? labelPositionFields : [svgName]);
|
|
56678
56726
|
} else {
|
|
56679
56727
|
rec[svgName] = accessor(i);
|
|
56728
|
+
if (svgName == 'label-pos') {
|
|
56729
|
+
if (!setLabelPositionStyle(rec, rec['label-pos'])) {
|
|
56730
|
+
stop$1('Unexpected value for label-pos:', rec['label-pos']);
|
|
56731
|
+
}
|
|
56732
|
+
}
|
|
56680
56733
|
}
|
|
56681
56734
|
});
|
|
56682
56735
|
});
|
|
@@ -56689,6 +56742,35 @@ ${svg}
|
|
|
56689
56742
|
}
|
|
56690
56743
|
};
|
|
56691
56744
|
|
|
56745
|
+
function getStyleFields(opts) {
|
|
56746
|
+
var fields = [];
|
|
56747
|
+
Object.keys(opts).forEach(function(optName) {
|
|
56748
|
+
var svgName = optName.replace('_', '-');
|
|
56749
|
+
if (!isSupportedSvgStyleProperty(svgName)) return;
|
|
56750
|
+
addField(fields, svgName);
|
|
56751
|
+
if (svgName == 'label-pos') {
|
|
56752
|
+
labelPositionFields.forEach(function(field) {
|
|
56753
|
+
addField(fields, field);
|
|
56754
|
+
});
|
|
56755
|
+
}
|
|
56756
|
+
});
|
|
56757
|
+
return fields;
|
|
56758
|
+
}
|
|
56759
|
+
|
|
56760
|
+
function addField(fields, field) {
|
|
56761
|
+
if (fields.indexOf(field) == -1) {
|
|
56762
|
+
fields.push(field);
|
|
56763
|
+
}
|
|
56764
|
+
}
|
|
56765
|
+
|
|
56766
|
+
function setUndefinedFields(rec, fields) {
|
|
56767
|
+
fields.forEach(function(field) {
|
|
56768
|
+
if (field in rec === false) {
|
|
56769
|
+
rec[field] = undefined;
|
|
56770
|
+
}
|
|
56771
|
+
});
|
|
56772
|
+
}
|
|
56773
|
+
|
|
56692
56774
|
var roundCoord$1 = getRoundingFunction(0.01);
|
|
56693
56775
|
|
|
56694
56776
|
function getSymbolFillColor(d) {
|
|
@@ -58166,7 +58248,7 @@ ${svg}
|
|
|
58166
58248
|
});
|
|
58167
58249
|
}
|
|
58168
58250
|
|
|
58169
|
-
var version = "0.7.
|
|
58251
|
+
var version = "0.7.17";
|
|
58170
58252
|
|
|
58171
58253
|
// Parse command line args into commands and run them
|
|
58172
58254
|
// Function takes an optional Node-style callback. A Promise is returned if no callback is given.
|
package/package.json
CHANGED
package/www/index.html
CHANGED
|
@@ -47,6 +47,10 @@
|
|
|
47
47
|
</g>
|
|
48
48
|
</svg>
|
|
49
49
|
|
|
50
|
+
<svg id="text-tool-icon" xmlns="http://www.w3.org/2000/svg" width="15" height="22" viewBox="0 0 15 22">
|
|
51
|
+
<path d="M13.4125,6.1758c-.0735,0-.1704.0087-.3023.0225-.35.0418-1.1581.0841-1.6018.0841H3.4416c-.4199,0-1.2035-.0418-1.5848-.0845-.1272-.0133-.2242-.022-.2977-.022-.5733,0-.5733.5104-.5733.678v3.8421h.9614c.8167,0,1.1245-.4428,1.2361-.7083.43-1.0372.9151-1.2196,1.775-1.2196h.6348v8.7486c0,.3918-.0528.4281-.463.7111l-.0919.0634c-.4874.3427-.6362.5765-.6362,1.0014v1.1346h6.1463v-1.1346c0-.4222-.1617-.6753-.6992-1.0441-.435-.3023-.4708-.3266-.4708-.7318v-8.7486h.6353c.8439,0,1.3253.1833,1.7754,1.2205.1851.4428.6307.7074,1.1925.7074h1.0042v-3.8421c0-.1677,0-.678-.5733-.678Z"/>
|
|
52
|
+
</svg>
|
|
53
|
+
|
|
50
54
|
<!-- adjusted height -->
|
|
51
55
|
<svg id="pointer-icon" version="1.1" xmlns="http://www.w3.org/2000/svg" width="15" height="22" viewBox="0 0 15 20"><rect x="7.4126" y="11.0354" width="3.9102" height="7.9841" transform="translate(-5.8889 6.0377) rotate(-27.5536)" fill="#30d4ef"/><polygon points="2.57 2.086 2.718 16.056 13.944 10.198 2.57 2.086" fill="#30d4ef"/></svg>
|
|
52
56
|
|
|
@@ -102,8 +106,9 @@
|
|
|
102
106
|
<label class="history-toggle-btn history-menu-item"><input type="checkbox" class="checkbox history-undo-checkbox">enable undo</label>
|
|
103
107
|
<div class="history-menu-note"></div>
|
|
104
108
|
<div class="history-clear-btn history-menu-item" role="menuitem">clear undo history</div>
|
|
105
|
-
<div class="history-menu-separator"></div>
|
|
106
109
|
<div class="history-command-log-btn history-menu-item" role="menuitem">view command history</div>
|
|
110
|
+
<div class="history-create-snapshot-btn history-menu-item" role="menuitem">create snapshot</div>
|
|
111
|
+
<div class="history-snapshot-list"></div>
|
|
107
112
|
</div>
|
|
108
113
|
</div>
|
|
109
114
|
</div>
|