mapshaper 0.6.37 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  (function () {
2
2
 
3
- var VERSION = "0.6.37";
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
@@ -42518,11 +42534,8 @@ ${svg}
42518
42534
  var radius = getSymbolRadius(d);
42519
42535
  // TODO: remove duplication with svg-symbols.js
42520
42536
  if (+opts.scale) radius *= +opts.scale;
42521
- return {
42522
- type: 'circle',
42523
- fill: getSymbolFillColor(d),
42524
- r: radius
42525
- };
42537
+ var sym = { type: 'circle', r: radius };
42538
+ return applySymbolStyles(sym, d);
42526
42539
  }
42527
42540
 
42528
42541
  function getPolygonCoords(d) {
@@ -42614,11 +42627,13 @@ ${svg}
42614
42627
  var radii = parseRings(d.radii || '2').map(function(r) { return r * scale; });
42615
42628
  var solidCenter = utils.isOdd(radii.length);
42616
42629
  var color = getSymbolFillColor(d);
42630
+ var opacity = opts.opacity || undefined;
42617
42631
  var parts = [];
42618
42632
  if (solidCenter) {
42619
42633
  parts.push({
42620
42634
  type: 'circle',
42621
42635
  fill: color,
42636
+ opacity: opacity,
42622
42637
  r: radii.shift()
42623
42638
  });
42624
42639
  }
@@ -42627,6 +42642,7 @@ ${svg}
42627
42642
  type: 'circle',
42628
42643
  fill: 'none', // TODO remove default black fill so this is not needed
42629
42644
  stroke: color,
42645
+ opacity: opacity,
42630
42646
  'stroke-width': roundToTenths(radii[i+1] - radii[i]),
42631
42647
  r: roundToTenths(radii[i+1] * 0.5 + radii[i] * 0.5)
42632
42648
  });
@@ -42674,19 +42690,18 @@ ${svg}
42674
42690
  if (geojsonType == 'MultiPolygon' || geojsonType == 'Polygon') {
42675
42691
  sym = {
42676
42692
  type: 'polygon',
42677
- fill: getSymbolFillColor(properties),
42678
42693
  coordinates: geojsonType == 'Polygon' ? coords : flattenMultiPolygonCoords(coords)
42679
42694
  };
42680
42695
  } else if (geojsonType == 'LineString' || geojsonType == 'MultiLineString') {
42681
42696
  sym = {
42682
42697
  type: 'polyline',
42683
- stroke: getSymbolStrokeColor(properties),
42684
42698
  'stroke-width': properties['stroke-width'] || 2,
42685
42699
  coordinates: geojsonType == 'LineString' ? [coords] : coords
42686
42700
  };
42687
42701
  } else {
42688
42702
  error('Unsupported type:', geojsonType);
42689
42703
  }
42704
+ applySymbolStyles(sym, properties);
42690
42705
  roundCoordsForSVG(sym.coordinates);
42691
42706
  return sym;
42692
42707
  }
@@ -42746,6 +42761,7 @@ ${svg}
42746
42761
  scaleAndShiftCoords(coords, metersPerPx, shp[0]);
42747
42762
  if (d.fill) rec.fill = d.fill;
42748
42763
  if (d.stroke) rec.stroke = d.stroke;
42764
+ if (d.opacity) rec.opacity = d.opacity;
42749
42765
  return createGeometry(coords, geojsonType);
42750
42766
  } else {
42751
42767
  rec['svg-symbol'] = makePathSymbol(coords, d, geojsonType);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mapshaper",
3
- "version": "0.6.37",
3
+ "version": "0.6.38",
4
4
  "description": "A tool for editing vector datasets for mapping and GIS.",
5
5
  "keywords": [
6
6
  "shapefile",
package/www/mapshaper.js CHANGED
@@ -1,6 +1,6 @@
1
1
  (function () {
2
2
 
3
- var VERSION = "0.6.37";
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
@@ -42518,11 +42534,8 @@ ${svg}
42518
42534
  var radius = getSymbolRadius(d);
42519
42535
  // TODO: remove duplication with svg-symbols.js
42520
42536
  if (+opts.scale) radius *= +opts.scale;
42521
- return {
42522
- type: 'circle',
42523
- fill: getSymbolFillColor(d),
42524
- r: radius
42525
- };
42537
+ var sym = { type: 'circle', r: radius };
42538
+ return applySymbolStyles(sym, d);
42526
42539
  }
42527
42540
 
42528
42541
  function getPolygonCoords(d) {
@@ -42614,11 +42627,13 @@ ${svg}
42614
42627
  var radii = parseRings(d.radii || '2').map(function(r) { return r * scale; });
42615
42628
  var solidCenter = utils.isOdd(radii.length);
42616
42629
  var color = getSymbolFillColor(d);
42630
+ var opacity = opts.opacity || undefined;
42617
42631
  var parts = [];
42618
42632
  if (solidCenter) {
42619
42633
  parts.push({
42620
42634
  type: 'circle',
42621
42635
  fill: color,
42636
+ opacity: opacity,
42622
42637
  r: radii.shift()
42623
42638
  });
42624
42639
  }
@@ -42627,6 +42642,7 @@ ${svg}
42627
42642
  type: 'circle',
42628
42643
  fill: 'none', // TODO remove default black fill so this is not needed
42629
42644
  stroke: color,
42645
+ opacity: opacity,
42630
42646
  'stroke-width': roundToTenths(radii[i+1] - radii[i]),
42631
42647
  r: roundToTenths(radii[i+1] * 0.5 + radii[i] * 0.5)
42632
42648
  });
@@ -42674,19 +42690,18 @@ ${svg}
42674
42690
  if (geojsonType == 'MultiPolygon' || geojsonType == 'Polygon') {
42675
42691
  sym = {
42676
42692
  type: 'polygon',
42677
- fill: getSymbolFillColor(properties),
42678
42693
  coordinates: geojsonType == 'Polygon' ? coords : flattenMultiPolygonCoords(coords)
42679
42694
  };
42680
42695
  } else if (geojsonType == 'LineString' || geojsonType == 'MultiLineString') {
42681
42696
  sym = {
42682
42697
  type: 'polyline',
42683
- stroke: getSymbolStrokeColor(properties),
42684
42698
  'stroke-width': properties['stroke-width'] || 2,
42685
42699
  coordinates: geojsonType == 'LineString' ? [coords] : coords
42686
42700
  };
42687
42701
  } else {
42688
42702
  error('Unsupported type:', geojsonType);
42689
42703
  }
42704
+ applySymbolStyles(sym, properties);
42690
42705
  roundCoordsForSVG(sym.coordinates);
42691
42706
  return sym;
42692
42707
  }
@@ -42746,6 +42761,7 @@ ${svg}
42746
42761
  scaleAndShiftCoords(coords, metersPerPx, shp[0]);
42747
42762
  if (d.fill) rec.fill = d.fill;
42748
42763
  if (d.stroke) rec.stroke = d.stroke;
42764
+ if (d.opacity) rec.opacity = d.opacity;
42749
42765
  return createGeometry(coords, geojsonType);
42750
42766
  } else {
42751
42767
  rec['svg-symbol'] = makePathSymbol(coords, d, geojsonType);