mapshaper 0.6.73 → 0.6.74
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 +26 -33
- package/package.json +1 -1
- package/www/mapshaper-gui.js +22 -5
- package/www/mapshaper.js +26 -33
package/mapshaper.js
CHANGED
|
@@ -5553,43 +5553,35 @@
|
|
|
5553
5553
|
}
|
|
5554
5554
|
|
|
5555
5555
|
function initBounds() {
|
|
5556
|
-
var
|
|
5557
|
-
_bb =
|
|
5558
|
-
_allBounds =
|
|
5559
|
-
}
|
|
5560
|
-
|
|
5561
|
-
function calcArcBounds2(xx, yy, nn) {
|
|
5562
|
-
var numArcs = nn.length,
|
|
5563
|
-
bb = new Float64Array(numArcs * 4),
|
|
5564
|
-
bounds = new Bounds(),
|
|
5565
|
-
arcOffs = 0,
|
|
5566
|
-
arcLen,
|
|
5567
|
-
j, b;
|
|
5556
|
+
var numArcs = _nn.length;
|
|
5557
|
+
_bb = new Float64Array(numArcs * 4);
|
|
5558
|
+
_allBounds = new Bounds();
|
|
5568
5559
|
for (var i=0; i<numArcs; i++) {
|
|
5569
|
-
|
|
5570
|
-
if (arcLen > 0) {
|
|
5571
|
-
j = i * 4;
|
|
5572
|
-
b = calcArcBounds(xx, yy, arcOffs, arcLen);
|
|
5573
|
-
bb[j++] = b[0];
|
|
5574
|
-
bb[j++] = b[1];
|
|
5575
|
-
bb[j++] = b[2];
|
|
5576
|
-
bb[j] = b[3];
|
|
5577
|
-
arcOffs += arcLen;
|
|
5578
|
-
bounds.mergeBounds(b);
|
|
5579
|
-
}
|
|
5560
|
+
initArcBounds(i);
|
|
5580
5561
|
}
|
|
5581
|
-
return {
|
|
5582
|
-
bb: bb,
|
|
5583
|
-
bounds: bounds
|
|
5584
|
-
};
|
|
5585
5562
|
}
|
|
5586
5563
|
|
|
5564
|
+
function initArcBounds(i) {
|
|
5565
|
+
var arcLen = _nn[i];
|
|
5566
|
+
var arcOffs = _ii[i];
|
|
5567
|
+
var j = i * 4;
|
|
5568
|
+
var b = calcArcBounds(_xx, _yy, arcOffs, arcLen);
|
|
5569
|
+
_bb[j++] = b[0];
|
|
5570
|
+
_bb[j++] = b[1];
|
|
5571
|
+
_bb[j++] = b[2];
|
|
5572
|
+
_bb[j] = b[3];
|
|
5573
|
+
_allBounds.mergeBounds(b);
|
|
5574
|
+
}
|
|
5575
|
+
|
|
5576
|
+
this.updateArcBounds = function(arcId) {
|
|
5577
|
+
initArcBounds(arcId);
|
|
5578
|
+
};
|
|
5579
|
+
|
|
5587
5580
|
this.updateVertexData = function(nn, xx, yy, zz) {
|
|
5588
5581
|
initXYData(nn, xx, yy);
|
|
5589
5582
|
initZData(zz || null);
|
|
5590
5583
|
};
|
|
5591
5584
|
|
|
5592
|
-
|
|
5593
5585
|
this.getCopy = function() {
|
|
5594
5586
|
var copy = new ArcCollection(new Int32Array(_nn), new Float64Array(_xx),
|
|
5595
5587
|
new Float64Array(_yy));
|
|
@@ -13194,13 +13186,14 @@
|
|
|
13194
13186
|
|
|
13195
13187
|
|
|
13196
13188
|
function snapVerticesToPoint(ids, p, arcs, final) {
|
|
13189
|
+
var data = arcs.getVertexData();
|
|
13197
13190
|
ids.forEach(function(idx) {
|
|
13191
|
+
if (final) {
|
|
13192
|
+
// recalculate bounding box for arc
|
|
13193
|
+
arcs.updateArcBounds(findArcIdFromVertexId(idx, data.ii));
|
|
13194
|
+
}
|
|
13198
13195
|
setVertexCoords(p[0], p[1], idx, arcs);
|
|
13199
13196
|
});
|
|
13200
|
-
if (final) {
|
|
13201
|
-
// kludge to get dataset to recalculate internal bounding boxes
|
|
13202
|
-
arcs.transformPoints(function() {});
|
|
13203
|
-
}
|
|
13204
13197
|
}
|
|
13205
13198
|
|
|
13206
13199
|
|
|
@@ -45492,7 +45485,7 @@ ${svg}
|
|
|
45492
45485
|
});
|
|
45493
45486
|
}
|
|
45494
45487
|
|
|
45495
|
-
var version = "0.6.
|
|
45488
|
+
var version = "0.6.74";
|
|
45496
45489
|
|
|
45497
45490
|
// Parse command line args into commands and run them
|
|
45498
45491
|
// Function takes an optional Node-style callback. A Promise is returned if no callback is given.
|
package/package.json
CHANGED
package/www/mapshaper-gui.js
CHANGED
|
@@ -9262,6 +9262,7 @@
|
|
|
9262
9262
|
} else {
|
|
9263
9263
|
rec = getMultiRecord(recIds, table);
|
|
9264
9264
|
}
|
|
9265
|
+
rec = rec || {};
|
|
9265
9266
|
utils$1.forEachProperty(rec, function(v, k) {
|
|
9266
9267
|
// missing GeoJSON fields are set to undefined on import; skip these
|
|
9267
9268
|
if (v === undefined) return;
|
|
@@ -9817,18 +9818,20 @@
|
|
|
9817
9818
|
function finishPolygons() {
|
|
9818
9819
|
// step1: make a polyline layer containing just newly drawn paths
|
|
9819
9820
|
var target = hit.getHitTarget();
|
|
9820
|
-
|
|
9821
|
+
var newShapeCount = target.arcs.size() - initialArcCount;
|
|
9822
|
+
if (newShapeCount <= 0) return; // no paths added
|
|
9821
9823
|
var polygonLyr = target.source.layer;
|
|
9822
9824
|
var polygonRecords = polygonLyr.data ? polygonLyr.data.getRecords() : null;
|
|
9825
|
+
var initialShapeCount = polygonLyr.shapes.length - newShapeCount;
|
|
9823
9826
|
var templateRecord;
|
|
9824
9827
|
if (polygonRecords) {
|
|
9825
9828
|
// use one of the newly created records as a template (they should all be the same)
|
|
9826
9829
|
templateRecord = polygonRecords.pop();
|
|
9827
|
-
polygonRecords.splice(
|
|
9830
|
+
polygonRecords.splice(initialShapeCount); // remove new records
|
|
9828
9831
|
}
|
|
9829
9832
|
var polylineLyr = {
|
|
9830
9833
|
geometry_type: 'polyline',
|
|
9831
|
-
shapes: polygonLyr.shapes.splice(
|
|
9834
|
+
shapes: polygonLyr.shapes.splice(initialShapeCount) // move new shapes to polyline layer
|
|
9832
9835
|
};
|
|
9833
9836
|
|
|
9834
9837
|
// step2: convert polylines to polygons
|
|
@@ -9840,9 +9843,10 @@
|
|
|
9840
9843
|
|
|
9841
9844
|
// step3: add new polygons to the original polygons
|
|
9842
9845
|
outputLayers[0].shapes.forEach(function(shp) {
|
|
9846
|
+
var rec = polygonRecords ? internal.copyRecord(templateRecord) : null;
|
|
9843
9847
|
polygonLyr.shapes.push(shp);
|
|
9844
9848
|
if (polygonRecords) {
|
|
9845
|
-
polygonRecords.push(
|
|
9849
|
+
polygonRecords.push(rec);
|
|
9846
9850
|
}
|
|
9847
9851
|
});
|
|
9848
9852
|
|
|
@@ -11760,6 +11764,10 @@ GUI and setting the size and crop of SVG output.</p><div><input type="text" clas
|
|
|
11760
11764
|
|
|
11761
11765
|
// Only generate low-detail arcs for larger datasets
|
|
11762
11766
|
if (size > 5e5) {
|
|
11767
|
+
update();
|
|
11768
|
+
}
|
|
11769
|
+
|
|
11770
|
+
function update() {
|
|
11763
11771
|
if (unfilteredArcs.getVertexData().zz) {
|
|
11764
11772
|
// Use precalculated simplification data for vertex filtering, if available
|
|
11765
11773
|
filteredArcs = initFilteredArcs(unfilteredArcs);
|
|
@@ -11783,6 +11791,14 @@ GUI and setting the size and crop of SVG output.</p><div><input type="text" clas
|
|
|
11783
11791
|
|
|
11784
11792
|
// TODO: better job of detecting arc change... e.g. revision number
|
|
11785
11793
|
unfilteredArcs.getScaledArcs = function(ext) {
|
|
11794
|
+
// check for changes in the number of arcs (probably due to editing)
|
|
11795
|
+
if (filteredArcs && filteredArcs.size() != unfilteredArcs.size()) {
|
|
11796
|
+
// arc count has changed... probably due to editing
|
|
11797
|
+
update();
|
|
11798
|
+
if (filteredArcs.size() != unfilteredArcs.size()) {
|
|
11799
|
+
throw Error('Internal error');
|
|
11800
|
+
}
|
|
11801
|
+
}
|
|
11786
11802
|
if (filteredArcs) {
|
|
11787
11803
|
// match simplification of unfiltered arcs
|
|
11788
11804
|
filteredArcs.setRetainedInterval(unfilteredArcs.getRetainedInterval());
|
|
@@ -12490,7 +12506,8 @@ GUI and setting the size and crop of SVG output.</p><div><input type="text" clas
|
|
|
12490
12506
|
}
|
|
12491
12507
|
|
|
12492
12508
|
function getStrictBounds() {
|
|
12493
|
-
if (internal.isWebMercator(map.getDisplayCRS())) {
|
|
12509
|
+
// if (internal.isWebMercator(map.getDisplayCRS())) {
|
|
12510
|
+
if (_dynamicCRS && internal.isWebMercator(map.getDisplayCRS())) {
|
|
12494
12511
|
return getMapboxBounds();
|
|
12495
12512
|
}
|
|
12496
12513
|
return null;
|
package/www/mapshaper.js
CHANGED
|
@@ -5553,43 +5553,35 @@
|
|
|
5553
5553
|
}
|
|
5554
5554
|
|
|
5555
5555
|
function initBounds() {
|
|
5556
|
-
var
|
|
5557
|
-
_bb =
|
|
5558
|
-
_allBounds =
|
|
5559
|
-
}
|
|
5560
|
-
|
|
5561
|
-
function calcArcBounds2(xx, yy, nn) {
|
|
5562
|
-
var numArcs = nn.length,
|
|
5563
|
-
bb = new Float64Array(numArcs * 4),
|
|
5564
|
-
bounds = new Bounds(),
|
|
5565
|
-
arcOffs = 0,
|
|
5566
|
-
arcLen,
|
|
5567
|
-
j, b;
|
|
5556
|
+
var numArcs = _nn.length;
|
|
5557
|
+
_bb = new Float64Array(numArcs * 4);
|
|
5558
|
+
_allBounds = new Bounds();
|
|
5568
5559
|
for (var i=0; i<numArcs; i++) {
|
|
5569
|
-
|
|
5570
|
-
if (arcLen > 0) {
|
|
5571
|
-
j = i * 4;
|
|
5572
|
-
b = calcArcBounds(xx, yy, arcOffs, arcLen);
|
|
5573
|
-
bb[j++] = b[0];
|
|
5574
|
-
bb[j++] = b[1];
|
|
5575
|
-
bb[j++] = b[2];
|
|
5576
|
-
bb[j] = b[3];
|
|
5577
|
-
arcOffs += arcLen;
|
|
5578
|
-
bounds.mergeBounds(b);
|
|
5579
|
-
}
|
|
5560
|
+
initArcBounds(i);
|
|
5580
5561
|
}
|
|
5581
|
-
return {
|
|
5582
|
-
bb: bb,
|
|
5583
|
-
bounds: bounds
|
|
5584
|
-
};
|
|
5585
5562
|
}
|
|
5586
5563
|
|
|
5564
|
+
function initArcBounds(i) {
|
|
5565
|
+
var arcLen = _nn[i];
|
|
5566
|
+
var arcOffs = _ii[i];
|
|
5567
|
+
var j = i * 4;
|
|
5568
|
+
var b = calcArcBounds(_xx, _yy, arcOffs, arcLen);
|
|
5569
|
+
_bb[j++] = b[0];
|
|
5570
|
+
_bb[j++] = b[1];
|
|
5571
|
+
_bb[j++] = b[2];
|
|
5572
|
+
_bb[j] = b[3];
|
|
5573
|
+
_allBounds.mergeBounds(b);
|
|
5574
|
+
}
|
|
5575
|
+
|
|
5576
|
+
this.updateArcBounds = function(arcId) {
|
|
5577
|
+
initArcBounds(arcId);
|
|
5578
|
+
};
|
|
5579
|
+
|
|
5587
5580
|
this.updateVertexData = function(nn, xx, yy, zz) {
|
|
5588
5581
|
initXYData(nn, xx, yy);
|
|
5589
5582
|
initZData(zz || null);
|
|
5590
5583
|
};
|
|
5591
5584
|
|
|
5592
|
-
|
|
5593
5585
|
this.getCopy = function() {
|
|
5594
5586
|
var copy = new ArcCollection(new Int32Array(_nn), new Float64Array(_xx),
|
|
5595
5587
|
new Float64Array(_yy));
|
|
@@ -13194,13 +13186,14 @@
|
|
|
13194
13186
|
|
|
13195
13187
|
|
|
13196
13188
|
function snapVerticesToPoint(ids, p, arcs, final) {
|
|
13189
|
+
var data = arcs.getVertexData();
|
|
13197
13190
|
ids.forEach(function(idx) {
|
|
13191
|
+
if (final) {
|
|
13192
|
+
// recalculate bounding box for arc
|
|
13193
|
+
arcs.updateArcBounds(findArcIdFromVertexId(idx, data.ii));
|
|
13194
|
+
}
|
|
13198
13195
|
setVertexCoords(p[0], p[1], idx, arcs);
|
|
13199
13196
|
});
|
|
13200
|
-
if (final) {
|
|
13201
|
-
// kludge to get dataset to recalculate internal bounding boxes
|
|
13202
|
-
arcs.transformPoints(function() {});
|
|
13203
|
-
}
|
|
13204
13197
|
}
|
|
13205
13198
|
|
|
13206
13199
|
|
|
@@ -45492,7 +45485,7 @@ ${svg}
|
|
|
45492
45485
|
});
|
|
45493
45486
|
}
|
|
45494
45487
|
|
|
45495
|
-
var version = "0.6.
|
|
45488
|
+
var version = "0.6.74";
|
|
45496
45489
|
|
|
45497
45490
|
// Parse command line args into commands and run them
|
|
45498
45491
|
// Function takes an optional Node-style callback. A Promise is returned if no callback is given.
|