mapshaper 0.6.69 → 0.6.71

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/www/mapshaper.js CHANGED
@@ -1819,6 +1819,21 @@
1819
1819
  return [xmin, ymin, xmax, ymax];
1820
1820
  }
1821
1821
 
1822
+ function getUnfilteredArcLength(arcId, arcs) {
1823
+ var data = arcs.getVertexData();
1824
+ return data.nn[arcId];
1825
+ }
1826
+
1827
+ function getUnfilteredArcCoords(arcId, arcs) {
1828
+ var data = arcs.getVertexData();
1829
+ var coords = [];
1830
+ var start = data.ii[arcId];
1831
+ var n = data.nn[arcId];
1832
+ for (var i=0; i<n; i++) {
1833
+ coords.push([data.xx[start + i], data.yy[start + i]]);
1834
+ }
1835
+ return coords;
1836
+ }
1822
1837
 
1823
1838
  function findArcIdFromVertexId(i, ii) {
1824
1839
  // binary search
@@ -1836,6 +1851,22 @@
1836
1851
  return lower; // assumes dataset is not empty
1837
1852
  }
1838
1853
 
1854
+ function deleteLastArc(arcs) {
1855
+ var data = arcs.getVertexData();
1856
+ var arcId = arcs.size() - 1;
1857
+ var arcLen = data.nn[arcId];
1858
+ var n = data.xx.length;
1859
+ var z = arcs.getRetainedInterval();
1860
+ var xx2 = new Float64Array(data.xx.buffer, 0, n-arcLen);
1861
+ var yy2 = new Float64Array(data.yy.buffer, 0, n-arcLen);
1862
+ var nn2 = new Int32Array(data.nn.buffer, 0, arcs.size() - 1);
1863
+ var zz2 = arcs.isFlat() ?
1864
+ null :
1865
+ new Float64Array(data.zz.buffer, 0, n-arcLen);
1866
+ arcs.updateVertexData(nn2, xx2, yy2, zz2);
1867
+ arcs.setRetainedInterval(z);
1868
+ }
1869
+
1839
1870
  function deleteVertex(arcs, i) {
1840
1871
  var data = arcs.getVertexData();
1841
1872
  var nn = data.nn;
@@ -1866,12 +1897,25 @@
1866
1897
  arcs.setRetainedInterval(z);
1867
1898
  }
1868
1899
 
1900
+ function appendEmptyArc(arcs) {
1901
+ var data = arcs.getVertexData();
1902
+ var nn = utils.extendBuffer(data.nn, data.nn.length + 1, data.nn.length);
1903
+ arcs.updateVertexData(nn, data.xx, data.yy, data.zz);
1904
+ }
1905
+
1906
+ // adds vertex to last arc
1907
+ // (used when adding lines in the GUI)
1908
+ // p: [x, y] point in display coordinates
1909
+ function appendVertex(arcs, p) {
1910
+ var i = arcs.getPointCount(); // one past the last idx
1911
+ insertVertex(arcs, i, p);
1912
+ }
1913
+
1869
1914
  function insertVertex(arcs, i, p) {
1870
1915
  var data = arcs.getVertexData();
1871
1916
  var nn = data.nn;
1872
1917
  var n = data.xx.length;
1873
1918
  var count = 0;
1874
- var found = false;
1875
1919
  var xx2, yy2, zz2;
1876
1920
  // avoid re-allocating memory on each insertion
1877
1921
  if (data.xx.buffer.byteLength >= data.xx.length * 8 + 8) {
@@ -1884,13 +1928,21 @@
1884
1928
  if (!arcs.isFlat()) {
1885
1929
  zz2 = new Float64Array(new ArrayBuffer((n + 1) * 8), 0, n+1);
1886
1930
  }
1887
- for (var j=0; j<nn.length; j++) {
1888
- count += nn[j];
1889
- if (count >= i && !found) { // TODO: confirm this
1890
- nn[j] = nn[j] + 1;
1891
- found = true;
1931
+ if (i < 0 || i > n) {
1932
+ error('Out-of-range vertex insertion index:', i);
1933
+ } else if (i == n) {
1934
+ // appending vertex to last arc
1935
+ nn[nn.length - 1]++;
1936
+ } else {
1937
+ for (var j=0; j<nn.length; j++) {
1938
+ count += nn[j];
1939
+ if (count >= i) { // TODO: confirm this
1940
+ nn[j] = nn[j] + 1;
1941
+ break;
1942
+ }
1892
1943
  }
1893
1944
  }
1945
+
1894
1946
  utils.copyElements(data.xx, 0, xx2, 0, i);
1895
1947
  utils.copyElements(data.yy, 0, yy2, 0, i);
1896
1948
  utils.copyElements(data.xx, i, xx2, i+1, n-i);
@@ -1962,8 +2014,13 @@
1962
2014
  __proto__: null,
1963
2015
  absArcId: absArcId,
1964
2016
  calcArcBounds: calcArcBounds,
2017
+ getUnfilteredArcLength: getUnfilteredArcLength,
2018
+ getUnfilteredArcCoords: getUnfilteredArcCoords,
1965
2019
  findArcIdFromVertexId: findArcIdFromVertexId,
2020
+ deleteLastArc: deleteLastArc,
1966
2021
  deleteVertex: deleteVertex,
2022
+ appendEmptyArc: appendEmptyArc,
2023
+ appendVertex: appendVertex,
1967
2024
  insertVertex: insertVertex,
1968
2025
  countFilteredVertices: countFilteredVertices,
1969
2026
  filterVertexData: filterVertexData
@@ -6661,11 +6718,16 @@
6661
6718
  nn = arcData.nn,
6662
6719
  xx = arcData.xx,
6663
6720
  yy = arcData.yy,
6664
- nodeData;
6721
+ nodeData,
6722
+ globalFilter;
6665
6723
 
6666
6724
  // Accessor function for arcs
6667
6725
  Object.defineProperty(this, 'arcs', {value: arcs});
6668
6726
 
6727
+ this.setArcFilter = function(f) {
6728
+ globalFilter = f;
6729
+ };
6730
+
6669
6731
  this.toArray = function() {
6670
6732
  var chains = getNodeChains(),
6671
6733
  flags = new Uint8Array(chains.length),
@@ -6744,15 +6806,19 @@
6744
6806
  // Returned ids lead into the node (as opposed to outwards from it)
6745
6807
  // An optional filter function receives the directed id (positive or negative)
6746
6808
  // of each connected arc and excludes arcs for which the filter returns false.
6747
- // The filter is also applied to the initial arc; if false, no arcs are returned.
6809
+ // // removed: The filter is also applied to the initial arc; if false, no arcs are returned.
6748
6810
  //
6749
- this.getConnectedArcs = function(arcId, filter) {
6811
+ this.getConnectedArcs = function(arcId, localFilter) {
6750
6812
  var ids = [];
6751
- var filtered = !!filter;
6752
6813
  var nextId = nextConnectedArc(arcId);
6753
- if (filtered && !filter(arcId)) ;
6814
+ // kludge: return empty result if arc fails global test
6815
+ // ... applying the local filter causes tests to fail
6816
+ if (globalFilter && !globalFilter(arcId)) {
6817
+ return [];
6818
+ }
6754
6819
  while (nextId != arcId) {
6755
- if (!filtered || filter(nextId)) {
6820
+ // if (!filtered || filter && filter(nextId) ) {
6821
+ if ((!localFilter || localFilter(nextId)) && (!globalFilter || globalFilter(nextId))) {
6756
6822
  ids.push(nextId);
6757
6823
  }
6758
6824
  nextId = nextConnectedArc(nextId);
@@ -13511,12 +13577,19 @@
13511
13577
  function parseSizeParam(p) {
13512
13578
  var str = String(p),
13513
13579
  num = parseFloat(str),
13514
- units = /px|pix/.test(str) && 'px' || /pt|point/.test(str) && 'pt' ||
13515
- /in/.test(str) && 'in' || !isNaN(+str) && 'px' || null;
13516
- if (isNaN(num) || !units) {
13580
+ units = /px|pix/.test(str) && 'px' ||
13581
+ /pt|point/.test(str) && 'pt' ||
13582
+ /in/.test(str) && 'in' ||
13583
+ /cm/.test(str) && 'cm' ||
13584
+ !isNaN(+str) && 'px' || // px is the default
13585
+ null;
13586
+ var px = units == 'in' && num * 72 ||
13587
+ units == 'cm' && Math.round(num * 28.3465) ||
13588
+ num;
13589
+ if (px > 0 === false || !units) {
13517
13590
  stop('Invalid size:', str);
13518
13591
  }
13519
- return units == 'in' && num * 72 || num;
13592
+ return px;
13520
13593
  }
13521
13594
 
13522
13595
  // Return coeff. for converting a distance measure to dataset coordinates
@@ -41315,6 +41388,8 @@ ${svg}
41315
41388
  }
41316
41389
  requirePolygonLayer(lyr);
41317
41390
  var nodes = addIntersectionCuts(dataset, opts);
41391
+ // ignore arcs that don't belong to this layer
41392
+ nodes.setArcFilter(getArcPresenceTest(lyr.shapes, nodes.arcs));
41318
41393
  var mosaicIndex = new MosaicIndex(lyr, nodes, {flat: false});
41319
41394
  var mosaicShapes = mosaicIndex.mosaic;
41320
41395
  var records2;
@@ -42425,6 +42500,8 @@ ${svg}
42425
42500
 
42426
42501
  function createPolygonLayer(lyr, dataset, opts) {
42427
42502
  var nodes = closeUndershoots(lyr, dataset, opts);
42503
+ // ignore arcs that don't belong to this layer
42504
+ nodes.setArcFilter(getArcPresenceTest(lyr.shapes, nodes.arcs));
42428
42505
  var data = buildPolygonMosaic(nodes);
42429
42506
  return {
42430
42507
  geometry_type: 'polygon',
@@ -45415,7 +45492,7 @@ ${svg}
45415
45492
  });
45416
45493
  }
45417
45494
 
45418
- var version = "0.6.69";
45495
+ var version = "0.6.71";
45419
45496
 
45420
45497
  // Parse command line args into commands and run them
45421
45498
  // Function takes an optional Node-style callback. A Promise is returned if no callback is given.
package/www/page.css CHANGED
@@ -59,7 +59,8 @@ body {
59
59
  .save-menu-link,
60
60
  .save-menu-btn,
61
61
  .add-field-btn,
62
- .nav-menu-item {
62
+ .nav-menu-item,
63
+ .edit-data-btn {
63
64
  color: #10699b;
64
65
  }
65
66
 
@@ -560,7 +561,7 @@ body.dragover #import-options-drop-area .drop-area {
560
561
  white-space: pre-line;
561
562
  margin: 0 0 7px 0;
562
563
  line-height: 1.2;
563
- font-size: 90%;
564
+ /* font-size: 90%; */
564
565
  }
565
566
 
566
567
 
@@ -816,7 +817,7 @@ img.close-btn {
816
817
 
817
818
  .close2-btn {
818
819
  display: inline-block;
819
- background-color: #f1f1f1;
820
+ background-color: #eee;
820
821
  background-image: url("images/close2.png");
821
822
  background-size: cover;
822
823
  float: right;
@@ -829,7 +830,7 @@ img.close-btn {
829
830
  }
830
831
 
831
832
  .close2-btn:hover {
832
- background-color: #ddd;
833
+ background-color: #d5d5d5;
833
834
  }
834
835
 
835
836
  .pin-all img {
@@ -1193,7 +1194,7 @@ div.basemap-style-btn.active img {
1193
1194
  }
1194
1195
 
1195
1196
  .map-layers.add-points,
1196
- .map-layers.draw-lines {
1197
+ .map-layers.edit-lines {
1197
1198
  cursor: crosshair;
1198
1199
  }
1199
1200
 
@@ -1364,20 +1365,23 @@ div.basemap-style-btn.active img {
1364
1365
  padding: 1px 2px 3px 2px;
1365
1366
  }
1366
1367
 
1367
- .add-field-btn {
1368
+ .add-field-btn,
1369
+ .edit-data-btn {
1368
1370
  display: inline-block;
1369
1371
  font-size: 12px;
1370
- margin-top: 2px;
1372
+ margin-top: 3px;
1371
1373
  }
1372
1374
 
1373
1375
  .save-menu-btn:hover,
1374
- .add-field-btn:hover {
1376
+ .add-field-btn:hover,
1377
+ .edit-data-btn:hover {
1375
1378
  color: black;
1376
1379
  }
1377
1380
 
1378
1381
  .save-menu-link,
1379
1382
  .save-menu-btn,
1380
- .add-field-btn {
1383
+ .add-field-btn,
1384
+ .edit-data-btn {
1381
1385
  cursor: pointer;
1382
1386
  }
1383
1387