mapshaper 0.6.69 → 0.6.70

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
@@ -6661,11 +6661,16 @@
6661
6661
  nn = arcData.nn,
6662
6662
  xx = arcData.xx,
6663
6663
  yy = arcData.yy,
6664
- nodeData;
6664
+ nodeData,
6665
+ globalFilter;
6665
6666
 
6666
6667
  // Accessor function for arcs
6667
6668
  Object.defineProperty(this, 'arcs', {value: arcs});
6668
6669
 
6670
+ this.setArcFilter = function(f) {
6671
+ globalFilter = f;
6672
+ };
6673
+
6669
6674
  this.toArray = function() {
6670
6675
  var chains = getNodeChains(),
6671
6676
  flags = new Uint8Array(chains.length),
@@ -6744,15 +6749,19 @@
6744
6749
  // Returned ids lead into the node (as opposed to outwards from it)
6745
6750
  // An optional filter function receives the directed id (positive or negative)
6746
6751
  // 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.
6752
+ // // removed: The filter is also applied to the initial arc; if false, no arcs are returned.
6748
6753
  //
6749
- this.getConnectedArcs = function(arcId, filter) {
6754
+ this.getConnectedArcs = function(arcId, localFilter) {
6750
6755
  var ids = [];
6751
- var filtered = !!filter;
6752
6756
  var nextId = nextConnectedArc(arcId);
6753
- if (filtered && !filter(arcId)) ;
6757
+ // kludge: return empty result if arc fails global test
6758
+ // ... applying the local filter causes tests to fail
6759
+ if (globalFilter && !globalFilter(arcId)) {
6760
+ return [];
6761
+ }
6754
6762
  while (nextId != arcId) {
6755
- if (!filtered || filter(nextId)) {
6763
+ // if (!filtered || filter && filter(nextId) ) {
6764
+ if ((!localFilter || localFilter(nextId)) && (!globalFilter || globalFilter(nextId))) {
6756
6765
  ids.push(nextId);
6757
6766
  }
6758
6767
  nextId = nextConnectedArc(nextId);
@@ -41315,6 +41324,8 @@ ${svg}
41315
41324
  }
41316
41325
  requirePolygonLayer(lyr);
41317
41326
  var nodes = addIntersectionCuts(dataset, opts);
41327
+ // ignore arcs that don't belong to this layer
41328
+ nodes.setArcFilter(getArcPresenceTest(lyr.shapes, nodes.arcs));
41318
41329
  var mosaicIndex = new MosaicIndex(lyr, nodes, {flat: false});
41319
41330
  var mosaicShapes = mosaicIndex.mosaic;
41320
41331
  var records2;
@@ -42425,6 +42436,8 @@ ${svg}
42425
42436
 
42426
42437
  function createPolygonLayer(lyr, dataset, opts) {
42427
42438
  var nodes = closeUndershoots(lyr, dataset, opts);
42439
+ // ignore arcs that don't belong to this layer
42440
+ nodes.setArcFilter(getArcPresenceTest(lyr.shapes, nodes.arcs));
42428
42441
  var data = buildPolygonMosaic(nodes);
42429
42442
  return {
42430
42443
  geometry_type: 'polygon',
@@ -45415,7 +45428,7 @@ ${svg}
45415
45428
  });
45416
45429
  }
45417
45430
 
45418
- var version = "0.6.69";
45431
+ var version = "0.6.70";
45419
45432
 
45420
45433
  // Parse command line args into commands and run them
45421
45434
  // Function takes an optional Node-style callback. A Promise is returned if no callback is given.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mapshaper",
3
- "version": "0.6.69",
3
+ "version": "0.6.70",
4
4
  "description": "A tool for editing vector datasets for mapping and GIS.",
5
5
  "keywords": [
6
6
  "shapefile",
package/www/mapshaper.js CHANGED
@@ -6661,11 +6661,16 @@
6661
6661
  nn = arcData.nn,
6662
6662
  xx = arcData.xx,
6663
6663
  yy = arcData.yy,
6664
- nodeData;
6664
+ nodeData,
6665
+ globalFilter;
6665
6666
 
6666
6667
  // Accessor function for arcs
6667
6668
  Object.defineProperty(this, 'arcs', {value: arcs});
6668
6669
 
6670
+ this.setArcFilter = function(f) {
6671
+ globalFilter = f;
6672
+ };
6673
+
6669
6674
  this.toArray = function() {
6670
6675
  var chains = getNodeChains(),
6671
6676
  flags = new Uint8Array(chains.length),
@@ -6744,15 +6749,19 @@
6744
6749
  // Returned ids lead into the node (as opposed to outwards from it)
6745
6750
  // An optional filter function receives the directed id (positive or negative)
6746
6751
  // 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.
6752
+ // // removed: The filter is also applied to the initial arc; if false, no arcs are returned.
6748
6753
  //
6749
- this.getConnectedArcs = function(arcId, filter) {
6754
+ this.getConnectedArcs = function(arcId, localFilter) {
6750
6755
  var ids = [];
6751
- var filtered = !!filter;
6752
6756
  var nextId = nextConnectedArc(arcId);
6753
- if (filtered && !filter(arcId)) ;
6757
+ // kludge: return empty result if arc fails global test
6758
+ // ... applying the local filter causes tests to fail
6759
+ if (globalFilter && !globalFilter(arcId)) {
6760
+ return [];
6761
+ }
6754
6762
  while (nextId != arcId) {
6755
- if (!filtered || filter(nextId)) {
6763
+ // if (!filtered || filter && filter(nextId) ) {
6764
+ if ((!localFilter || localFilter(nextId)) && (!globalFilter || globalFilter(nextId))) {
6756
6765
  ids.push(nextId);
6757
6766
  }
6758
6767
  nextId = nextConnectedArc(nextId);
@@ -41315,6 +41324,8 @@ ${svg}
41315
41324
  }
41316
41325
  requirePolygonLayer(lyr);
41317
41326
  var nodes = addIntersectionCuts(dataset, opts);
41327
+ // ignore arcs that don't belong to this layer
41328
+ nodes.setArcFilter(getArcPresenceTest(lyr.shapes, nodes.arcs));
41318
41329
  var mosaicIndex = new MosaicIndex(lyr, nodes, {flat: false});
41319
41330
  var mosaicShapes = mosaicIndex.mosaic;
41320
41331
  var records2;
@@ -42425,6 +42436,8 @@ ${svg}
42425
42436
 
42426
42437
  function createPolygonLayer(lyr, dataset, opts) {
42427
42438
  var nodes = closeUndershoots(lyr, dataset, opts);
42439
+ // ignore arcs that don't belong to this layer
42440
+ nodes.setArcFilter(getArcPresenceTest(lyr.shapes, nodes.arcs));
42428
42441
  var data = buildPolygonMosaic(nodes);
42429
42442
  return {
42430
42443
  geometry_type: 'polygon',
@@ -45415,7 +45428,7 @@ ${svg}
45415
45428
  });
45416
45429
  }
45417
45430
 
45418
- var version = "0.6.69";
45431
+ var version = "0.6.70";
45419
45432
 
45420
45433
  // Parse command line args into commands and run them
45421
45434
  // Function takes an optional Node-style callback. A Promise is returned if no callback is given.