mapshaper 0.6.36 → 0.6.38
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 +46 -24
- package/package.json +1 -1
- package/www/mapshaper.js +46 -24
package/mapshaper.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function () {
|
|
2
2
|
|
|
3
|
-
var VERSION = "0.6.
|
|
3
|
+
var VERSION = "0.6.38";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var utils = /*#__PURE__*/Object.freeze({
|
|
@@ -24574,6 +24574,10 @@ ${svg}
|
|
|
24574
24574
|
.option('stroke-width', {
|
|
24575
24575
|
describe: 'symbol line width (linear symbols only)'
|
|
24576
24576
|
})
|
|
24577
|
+
.option('opacity', {
|
|
24578
|
+
describe: 'symbol opacity',
|
|
24579
|
+
type: 'number'
|
|
24580
|
+
})
|
|
24577
24581
|
.option('geographic', {
|
|
24578
24582
|
old_alias: 'polygons',
|
|
24579
24583
|
describe: 'make geographic shapes instead of SVG objects',
|
|
@@ -42281,6 +42285,18 @@ ${svg}
|
|
|
42281
42285
|
return d.stroke || d.fill || 'magenta';
|
|
42282
42286
|
}
|
|
42283
42287
|
|
|
42288
|
+
function applySymbolStyles(sym, d) {
|
|
42289
|
+
if (sym.type == 'polyline') {
|
|
42290
|
+
sym.stroke = getSymbolStrokeColor(d);
|
|
42291
|
+
} else {
|
|
42292
|
+
sym.fill = getSymbolFillColor(d);
|
|
42293
|
+
}
|
|
42294
|
+
if (d.opacity) {
|
|
42295
|
+
sym.opacity = d.opacity;
|
|
42296
|
+
}
|
|
42297
|
+
return sym;
|
|
42298
|
+
}
|
|
42299
|
+
|
|
42284
42300
|
function getSymbolRadius(d) {
|
|
42285
42301
|
if (d.radius === 0 || d.length === 0 || d.r === 0) return 0;
|
|
42286
42302
|
return d.radius || d.length || d.r || 5; // use a default value
|
|
@@ -42346,7 +42362,7 @@ ${svg}
|
|
|
42346
42362
|
headDx = size.headWidth / 2,
|
|
42347
42363
|
stemDx = size.stemWidth / 2,
|
|
42348
42364
|
baseDx = stemDx * (1 - stemTaper),
|
|
42349
|
-
|
|
42365
|
+
coords, dx, dy;
|
|
42350
42366
|
|
|
42351
42367
|
if (curvature) {
|
|
42352
42368
|
// make curved stem
|
|
@@ -42359,11 +42375,11 @@ ${svg}
|
|
|
42359
42375
|
dy = stemLen * Math.cos(theta / 2);
|
|
42360
42376
|
|
|
42361
42377
|
if (stickArrow) {
|
|
42362
|
-
|
|
42378
|
+
coords = getCurvedStemCoords(-ax, -ay, dx, dy);
|
|
42363
42379
|
} else {
|
|
42364
42380
|
var leftStem = getCurvedStemCoords(-ax, -ay, -stemDx + dx, dy);
|
|
42365
42381
|
var rightStem = getCurvedStemCoords(ax, ay, stemDx + dx, dy);
|
|
42366
|
-
|
|
42382
|
+
coords = leftStem.concat(rightStem.reverse());
|
|
42367
42383
|
}
|
|
42368
42384
|
|
|
42369
42385
|
} else {
|
|
@@ -42371,23 +42387,26 @@ ${svg}
|
|
|
42371
42387
|
dx = 0;
|
|
42372
42388
|
dy = stemLen;
|
|
42373
42389
|
if (stickArrow) {
|
|
42374
|
-
|
|
42390
|
+
coords = [[0, 0], [0, stemLen]];
|
|
42375
42391
|
} else {
|
|
42376
|
-
|
|
42392
|
+
coords = [[-baseDx, 0], [baseDx, 0]];
|
|
42377
42393
|
}
|
|
42378
42394
|
}
|
|
42379
42395
|
|
|
42380
42396
|
if (stickArrow) {
|
|
42381
42397
|
// make stick arrow
|
|
42382
|
-
|
|
42383
|
-
|
|
42398
|
+
coords = [coords]; // MultiLineString coords
|
|
42399
|
+
if (headLen > 0) {
|
|
42400
|
+
coords.push([[-headDx + dx, stemLen - headLen], [dx, stemLen], [headDx + dx, stemLen - headLen]]);
|
|
42401
|
+
}
|
|
42384
42402
|
} else {
|
|
42385
42403
|
// make filled arrow
|
|
42386
42404
|
// coordinates go counter clockwise, starting from the leftmost head coordinate
|
|
42387
|
-
|
|
42388
|
-
|
|
42389
|
-
|
|
42390
|
-
|
|
42405
|
+
coords.push([stemDx + dx, dy]);
|
|
42406
|
+
if (headLen > 0) {
|
|
42407
|
+
coords.push([headDx + dx, dy], [dx, headLen + dy], [-headDx + dx, dy]);
|
|
42408
|
+
}
|
|
42409
|
+
coords.push([-stemDx + dx, dy], coords[0].concat()); // close path
|
|
42391
42410
|
coords = [coords]; // Polygon coords
|
|
42392
42411
|
}
|
|
42393
42412
|
|
|
@@ -42416,7 +42435,6 @@ ${svg}
|
|
|
42416
42435
|
var totalLen = Math.max(d.radius || d.length || d.r || 0, 0),
|
|
42417
42436
|
scale = 1,
|
|
42418
42437
|
o = initArrowSize(d); // calc several parameters
|
|
42419
|
-
|
|
42420
42438
|
if (totalLen >= 0) {
|
|
42421
42439
|
scale = calcScale(totalLen, o.headLen, d);
|
|
42422
42440
|
o.stemWidth *= scale;
|
|
@@ -42425,7 +42443,7 @@ ${svg}
|
|
|
42425
42443
|
o.stemLen = stickArrow ? totalLen : totalLen - o.headLen;
|
|
42426
42444
|
}
|
|
42427
42445
|
|
|
42428
|
-
if (o.headWidth < o.stemWidth) {
|
|
42446
|
+
if (o.headWidth < o.stemWidth && o.headWidth > 0) {
|
|
42429
42447
|
stop('Arrow head must be at least as wide as the stem.');
|
|
42430
42448
|
}
|
|
42431
42449
|
return o;
|
|
@@ -42454,14 +42472,18 @@ ${svg}
|
|
|
42454
42472
|
headWidth: d['head-width'],
|
|
42455
42473
|
headLen: d['head-length']
|
|
42456
42474
|
};
|
|
42457
|
-
if (
|
|
42458
|
-
|
|
42475
|
+
if (o.headWidth === 0) {
|
|
42476
|
+
o.headLen = 0;
|
|
42477
|
+
} else if (o.headWidth > 0 === false) {
|
|
42478
|
+
if (o.headLen > 0) {
|
|
42459
42479
|
o.headWidth = o.headLen / sizeRatio;
|
|
42480
|
+
} else if (o.headLen === 0) {
|
|
42481
|
+
o.headWidth = 0;
|
|
42460
42482
|
} else {
|
|
42461
42483
|
o.headWidth = o.stemWidth * 3; // assumes stemWidth has been set
|
|
42462
42484
|
}
|
|
42463
42485
|
}
|
|
42464
|
-
if (
|
|
42486
|
+
if (o.headLen >= 0 === false) {
|
|
42465
42487
|
o.headLen = o.headWidth * sizeRatio;
|
|
42466
42488
|
}
|
|
42467
42489
|
return o;
|
|
@@ -42512,11 +42534,8 @@ ${svg}
|
|
|
42512
42534
|
var radius = getSymbolRadius(d);
|
|
42513
42535
|
// TODO: remove duplication with svg-symbols.js
|
|
42514
42536
|
if (+opts.scale) radius *= +opts.scale;
|
|
42515
|
-
|
|
42516
|
-
|
|
42517
|
-
fill: getSymbolFillColor(d),
|
|
42518
|
-
r: radius
|
|
42519
|
-
};
|
|
42537
|
+
var sym = { type: 'circle', r: radius };
|
|
42538
|
+
return applySymbolStyles(sym, d);
|
|
42520
42539
|
}
|
|
42521
42540
|
|
|
42522
42541
|
function getPolygonCoords(d) {
|
|
@@ -42608,11 +42627,13 @@ ${svg}
|
|
|
42608
42627
|
var radii = parseRings(d.radii || '2').map(function(r) { return r * scale; });
|
|
42609
42628
|
var solidCenter = utils.isOdd(radii.length);
|
|
42610
42629
|
var color = getSymbolFillColor(d);
|
|
42630
|
+
var opacity = opts.opacity || undefined;
|
|
42611
42631
|
var parts = [];
|
|
42612
42632
|
if (solidCenter) {
|
|
42613
42633
|
parts.push({
|
|
42614
42634
|
type: 'circle',
|
|
42615
42635
|
fill: color,
|
|
42636
|
+
opacity: opacity,
|
|
42616
42637
|
r: radii.shift()
|
|
42617
42638
|
});
|
|
42618
42639
|
}
|
|
@@ -42621,6 +42642,7 @@ ${svg}
|
|
|
42621
42642
|
type: 'circle',
|
|
42622
42643
|
fill: 'none', // TODO remove default black fill so this is not needed
|
|
42623
42644
|
stroke: color,
|
|
42645
|
+
opacity: opacity,
|
|
42624
42646
|
'stroke-width': roundToTenths(radii[i+1] - radii[i]),
|
|
42625
42647
|
r: roundToTenths(radii[i+1] * 0.5 + radii[i] * 0.5)
|
|
42626
42648
|
});
|
|
@@ -42668,19 +42690,18 @@ ${svg}
|
|
|
42668
42690
|
if (geojsonType == 'MultiPolygon' || geojsonType == 'Polygon') {
|
|
42669
42691
|
sym = {
|
|
42670
42692
|
type: 'polygon',
|
|
42671
|
-
fill: getSymbolFillColor(properties),
|
|
42672
42693
|
coordinates: geojsonType == 'Polygon' ? coords : flattenMultiPolygonCoords(coords)
|
|
42673
42694
|
};
|
|
42674
42695
|
} else if (geojsonType == 'LineString' || geojsonType == 'MultiLineString') {
|
|
42675
42696
|
sym = {
|
|
42676
42697
|
type: 'polyline',
|
|
42677
|
-
stroke: getSymbolStrokeColor(properties),
|
|
42678
42698
|
'stroke-width': properties['stroke-width'] || 2,
|
|
42679
42699
|
coordinates: geojsonType == 'LineString' ? [coords] : coords
|
|
42680
42700
|
};
|
|
42681
42701
|
} else {
|
|
42682
42702
|
error('Unsupported type:', geojsonType);
|
|
42683
42703
|
}
|
|
42704
|
+
applySymbolStyles(sym, properties);
|
|
42684
42705
|
roundCoordsForSVG(sym.coordinates);
|
|
42685
42706
|
return sym;
|
|
42686
42707
|
}
|
|
@@ -42740,6 +42761,7 @@ ${svg}
|
|
|
42740
42761
|
scaleAndShiftCoords(coords, metersPerPx, shp[0]);
|
|
42741
42762
|
if (d.fill) rec.fill = d.fill;
|
|
42742
42763
|
if (d.stroke) rec.stroke = d.stroke;
|
|
42764
|
+
if (d.opacity) rec.opacity = d.opacity;
|
|
42743
42765
|
return createGeometry(coords, geojsonType);
|
|
42744
42766
|
} else {
|
|
42745
42767
|
rec['svg-symbol'] = makePathSymbol(coords, d, geojsonType);
|
package/package.json
CHANGED
package/www/mapshaper.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function () {
|
|
2
2
|
|
|
3
|
-
var VERSION = "0.6.
|
|
3
|
+
var VERSION = "0.6.38";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var utils = /*#__PURE__*/Object.freeze({
|
|
@@ -24574,6 +24574,10 @@ ${svg}
|
|
|
24574
24574
|
.option('stroke-width', {
|
|
24575
24575
|
describe: 'symbol line width (linear symbols only)'
|
|
24576
24576
|
})
|
|
24577
|
+
.option('opacity', {
|
|
24578
|
+
describe: 'symbol opacity',
|
|
24579
|
+
type: 'number'
|
|
24580
|
+
})
|
|
24577
24581
|
.option('geographic', {
|
|
24578
24582
|
old_alias: 'polygons',
|
|
24579
24583
|
describe: 'make geographic shapes instead of SVG objects',
|
|
@@ -42281,6 +42285,18 @@ ${svg}
|
|
|
42281
42285
|
return d.stroke || d.fill || 'magenta';
|
|
42282
42286
|
}
|
|
42283
42287
|
|
|
42288
|
+
function applySymbolStyles(sym, d) {
|
|
42289
|
+
if (sym.type == 'polyline') {
|
|
42290
|
+
sym.stroke = getSymbolStrokeColor(d);
|
|
42291
|
+
} else {
|
|
42292
|
+
sym.fill = getSymbolFillColor(d);
|
|
42293
|
+
}
|
|
42294
|
+
if (d.opacity) {
|
|
42295
|
+
sym.opacity = d.opacity;
|
|
42296
|
+
}
|
|
42297
|
+
return sym;
|
|
42298
|
+
}
|
|
42299
|
+
|
|
42284
42300
|
function getSymbolRadius(d) {
|
|
42285
42301
|
if (d.radius === 0 || d.length === 0 || d.r === 0) return 0;
|
|
42286
42302
|
return d.radius || d.length || d.r || 5; // use a default value
|
|
@@ -42346,7 +42362,7 @@ ${svg}
|
|
|
42346
42362
|
headDx = size.headWidth / 2,
|
|
42347
42363
|
stemDx = size.stemWidth / 2,
|
|
42348
42364
|
baseDx = stemDx * (1 - stemTaper),
|
|
42349
|
-
|
|
42365
|
+
coords, dx, dy;
|
|
42350
42366
|
|
|
42351
42367
|
if (curvature) {
|
|
42352
42368
|
// make curved stem
|
|
@@ -42359,11 +42375,11 @@ ${svg}
|
|
|
42359
42375
|
dy = stemLen * Math.cos(theta / 2);
|
|
42360
42376
|
|
|
42361
42377
|
if (stickArrow) {
|
|
42362
|
-
|
|
42378
|
+
coords = getCurvedStemCoords(-ax, -ay, dx, dy);
|
|
42363
42379
|
} else {
|
|
42364
42380
|
var leftStem = getCurvedStemCoords(-ax, -ay, -stemDx + dx, dy);
|
|
42365
42381
|
var rightStem = getCurvedStemCoords(ax, ay, stemDx + dx, dy);
|
|
42366
|
-
|
|
42382
|
+
coords = leftStem.concat(rightStem.reverse());
|
|
42367
42383
|
}
|
|
42368
42384
|
|
|
42369
42385
|
} else {
|
|
@@ -42371,23 +42387,26 @@ ${svg}
|
|
|
42371
42387
|
dx = 0;
|
|
42372
42388
|
dy = stemLen;
|
|
42373
42389
|
if (stickArrow) {
|
|
42374
|
-
|
|
42390
|
+
coords = [[0, 0], [0, stemLen]];
|
|
42375
42391
|
} else {
|
|
42376
|
-
|
|
42392
|
+
coords = [[-baseDx, 0], [baseDx, 0]];
|
|
42377
42393
|
}
|
|
42378
42394
|
}
|
|
42379
42395
|
|
|
42380
42396
|
if (stickArrow) {
|
|
42381
42397
|
// make stick arrow
|
|
42382
|
-
|
|
42383
|
-
|
|
42398
|
+
coords = [coords]; // MultiLineString coords
|
|
42399
|
+
if (headLen > 0) {
|
|
42400
|
+
coords.push([[-headDx + dx, stemLen - headLen], [dx, stemLen], [headDx + dx, stemLen - headLen]]);
|
|
42401
|
+
}
|
|
42384
42402
|
} else {
|
|
42385
42403
|
// make filled arrow
|
|
42386
42404
|
// coordinates go counter clockwise, starting from the leftmost head coordinate
|
|
42387
|
-
|
|
42388
|
-
|
|
42389
|
-
|
|
42390
|
-
|
|
42405
|
+
coords.push([stemDx + dx, dy]);
|
|
42406
|
+
if (headLen > 0) {
|
|
42407
|
+
coords.push([headDx + dx, dy], [dx, headLen + dy], [-headDx + dx, dy]);
|
|
42408
|
+
}
|
|
42409
|
+
coords.push([-stemDx + dx, dy], coords[0].concat()); // close path
|
|
42391
42410
|
coords = [coords]; // Polygon coords
|
|
42392
42411
|
}
|
|
42393
42412
|
|
|
@@ -42416,7 +42435,6 @@ ${svg}
|
|
|
42416
42435
|
var totalLen = Math.max(d.radius || d.length || d.r || 0, 0),
|
|
42417
42436
|
scale = 1,
|
|
42418
42437
|
o = initArrowSize(d); // calc several parameters
|
|
42419
|
-
|
|
42420
42438
|
if (totalLen >= 0) {
|
|
42421
42439
|
scale = calcScale(totalLen, o.headLen, d);
|
|
42422
42440
|
o.stemWidth *= scale;
|
|
@@ -42425,7 +42443,7 @@ ${svg}
|
|
|
42425
42443
|
o.stemLen = stickArrow ? totalLen : totalLen - o.headLen;
|
|
42426
42444
|
}
|
|
42427
42445
|
|
|
42428
|
-
if (o.headWidth < o.stemWidth) {
|
|
42446
|
+
if (o.headWidth < o.stemWidth && o.headWidth > 0) {
|
|
42429
42447
|
stop('Arrow head must be at least as wide as the stem.');
|
|
42430
42448
|
}
|
|
42431
42449
|
return o;
|
|
@@ -42454,14 +42472,18 @@ ${svg}
|
|
|
42454
42472
|
headWidth: d['head-width'],
|
|
42455
42473
|
headLen: d['head-length']
|
|
42456
42474
|
};
|
|
42457
|
-
if (
|
|
42458
|
-
|
|
42475
|
+
if (o.headWidth === 0) {
|
|
42476
|
+
o.headLen = 0;
|
|
42477
|
+
} else if (o.headWidth > 0 === false) {
|
|
42478
|
+
if (o.headLen > 0) {
|
|
42459
42479
|
o.headWidth = o.headLen / sizeRatio;
|
|
42480
|
+
} else if (o.headLen === 0) {
|
|
42481
|
+
o.headWidth = 0;
|
|
42460
42482
|
} else {
|
|
42461
42483
|
o.headWidth = o.stemWidth * 3; // assumes stemWidth has been set
|
|
42462
42484
|
}
|
|
42463
42485
|
}
|
|
42464
|
-
if (
|
|
42486
|
+
if (o.headLen >= 0 === false) {
|
|
42465
42487
|
o.headLen = o.headWidth * sizeRatio;
|
|
42466
42488
|
}
|
|
42467
42489
|
return o;
|
|
@@ -42512,11 +42534,8 @@ ${svg}
|
|
|
42512
42534
|
var radius = getSymbolRadius(d);
|
|
42513
42535
|
// TODO: remove duplication with svg-symbols.js
|
|
42514
42536
|
if (+opts.scale) radius *= +opts.scale;
|
|
42515
|
-
|
|
42516
|
-
|
|
42517
|
-
fill: getSymbolFillColor(d),
|
|
42518
|
-
r: radius
|
|
42519
|
-
};
|
|
42537
|
+
var sym = { type: 'circle', r: radius };
|
|
42538
|
+
return applySymbolStyles(sym, d);
|
|
42520
42539
|
}
|
|
42521
42540
|
|
|
42522
42541
|
function getPolygonCoords(d) {
|
|
@@ -42608,11 +42627,13 @@ ${svg}
|
|
|
42608
42627
|
var radii = parseRings(d.radii || '2').map(function(r) { return r * scale; });
|
|
42609
42628
|
var solidCenter = utils.isOdd(radii.length);
|
|
42610
42629
|
var color = getSymbolFillColor(d);
|
|
42630
|
+
var opacity = opts.opacity || undefined;
|
|
42611
42631
|
var parts = [];
|
|
42612
42632
|
if (solidCenter) {
|
|
42613
42633
|
parts.push({
|
|
42614
42634
|
type: 'circle',
|
|
42615
42635
|
fill: color,
|
|
42636
|
+
opacity: opacity,
|
|
42616
42637
|
r: radii.shift()
|
|
42617
42638
|
});
|
|
42618
42639
|
}
|
|
@@ -42621,6 +42642,7 @@ ${svg}
|
|
|
42621
42642
|
type: 'circle',
|
|
42622
42643
|
fill: 'none', // TODO remove default black fill so this is not needed
|
|
42623
42644
|
stroke: color,
|
|
42645
|
+
opacity: opacity,
|
|
42624
42646
|
'stroke-width': roundToTenths(radii[i+1] - radii[i]),
|
|
42625
42647
|
r: roundToTenths(radii[i+1] * 0.5 + radii[i] * 0.5)
|
|
42626
42648
|
});
|
|
@@ -42668,19 +42690,18 @@ ${svg}
|
|
|
42668
42690
|
if (geojsonType == 'MultiPolygon' || geojsonType == 'Polygon') {
|
|
42669
42691
|
sym = {
|
|
42670
42692
|
type: 'polygon',
|
|
42671
|
-
fill: getSymbolFillColor(properties),
|
|
42672
42693
|
coordinates: geojsonType == 'Polygon' ? coords : flattenMultiPolygonCoords(coords)
|
|
42673
42694
|
};
|
|
42674
42695
|
} else if (geojsonType == 'LineString' || geojsonType == 'MultiLineString') {
|
|
42675
42696
|
sym = {
|
|
42676
42697
|
type: 'polyline',
|
|
42677
|
-
stroke: getSymbolStrokeColor(properties),
|
|
42678
42698
|
'stroke-width': properties['stroke-width'] || 2,
|
|
42679
42699
|
coordinates: geojsonType == 'LineString' ? [coords] : coords
|
|
42680
42700
|
};
|
|
42681
42701
|
} else {
|
|
42682
42702
|
error('Unsupported type:', geojsonType);
|
|
42683
42703
|
}
|
|
42704
|
+
applySymbolStyles(sym, properties);
|
|
42684
42705
|
roundCoordsForSVG(sym.coordinates);
|
|
42685
42706
|
return sym;
|
|
42686
42707
|
}
|
|
@@ -42740,6 +42761,7 @@ ${svg}
|
|
|
42740
42761
|
scaleAndShiftCoords(coords, metersPerPx, shp[0]);
|
|
42741
42762
|
if (d.fill) rec.fill = d.fill;
|
|
42742
42763
|
if (d.stroke) rec.stroke = d.stroke;
|
|
42764
|
+
if (d.opacity) rec.opacity = d.opacity;
|
|
42743
42765
|
return createGeometry(coords, geojsonType);
|
|
42744
42766
|
} else {
|
|
42745
42767
|
rec['svg-symbol'] = makePathSymbol(coords, d, geojsonType);
|