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/mapshaper.js +94 -17
- package/package.json +1 -1
- package/www/index.html +1 -0
- package/www/mapshaper-gui.js +1240 -659
- package/www/mapshaper.js +94 -17
- package/www/page.css +13 -9
package/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
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
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,
|
|
6811
|
+
this.getConnectedArcs = function(arcId, localFilter) {
|
|
6750
6812
|
var ids = [];
|
|
6751
|
-
var filtered = !!filter;
|
|
6752
6813
|
var nextId = nextConnectedArc(arcId);
|
|
6753
|
-
if
|
|
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' ||
|
|
13515
|
-
|
|
13516
|
-
|
|
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
|
|
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.
|
|
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/package.json
CHANGED
package/www/index.html
CHANGED
|
@@ -119,6 +119,7 @@
|
|
|
119
119
|
<div class="clip-btn btn dialog-btn">Clip</div>
|
|
120
120
|
<div class="erase-btn btn dialog-btn">Erase</div>
|
|
121
121
|
<div class="rect-btn btn dialog-btn">Rectangle</div>
|
|
122
|
+
<div class="frame-btn btn dialog-btn">Frame</div>
|
|
122
123
|
<div class="info-btn btn dialog-btn">Coords</div>
|
|
123
124
|
<!-- <div class="zoom-btn btn dialog-btn">Zoom In</div> -->
|
|
124
125
|
<div class="cancel-btn btn dialog-btn">Cancel</div>
|