@dra2020/baseclient 1.0.62 → 1.0.65

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.
@@ -1565,21 +1565,7 @@ function geoEnsureID(col, options) {
1565
1565
  exports.geoEnsureID = geoEnsureID;
1566
1566
  function geoNormalizeFeature(f, options) {
1567
1567
  options = Util.shallowAssignImmutable({}, options);
1568
- if (f && f.geometry && f.geometry.type === 'MultiPolygon' && f.geometry.coordinates) {
1569
- let multiPoly = f.geometry.coordinates;
1570
- // Convert degenerate MultiPolygon to Polygon
1571
- if (multiPoly.length == 1) {
1572
- f.geometry.type = 'Polygon';
1573
- f.geometry.coordinates = multiPoly[0];
1574
- }
1575
- }
1576
- else if (f && f.geometry && f.geometry.type === 'Point' && f.geometry.coordinates) {
1577
- while (Array.isArray(f.geometry.coordinates[0]))
1578
- f.geometry.coordinates = f.geometry.coordinates[0];
1579
- }
1580
- else if (options.checkRewind)
1581
- // Various tools do not guarantee valid GeoJSON winding rules. Verify it since internal processing
1582
- // assumes it is correct.
1568
+ if (options.checkRewind)
1583
1569
  Poly.featureRewind(f);
1584
1570
  return f;
1585
1571
  }
@@ -6828,24 +6814,30 @@ function featureRewind(f, options) {
6828
6814
  // Only applies to multi-polygons with no holes
6829
6815
  let d = Util.depthof(f.geometry.coordinates);
6830
6816
  let windings = polyRingWindings(f);
6831
- if (options.validateHoles && d === 5 && windings.length) {
6832
- // If there are explicit holes, don't look for implicit ones
6833
- let nHoles = 0;
6834
- windings.forEach(w => { if (w.iRing)
6835
- nHoles++; });
6836
- if (nHoles == 0 && !misWound(windings[0])) {
6837
- // Looking for pattern: of (G (B*))*
6838
- // To convert to ((GH*))*
6839
- let iWinding = 0;
6817
+ if (options.validateHoles && d === 5 && windings.length > 1) {
6818
+ // First winding needs to be correct so we have a poly to add holes to
6819
+ if (!misWound(windings[0])) {
6820
+ // Flatten everything out and then rebuild hole structure based on windings
6821
+ let nHoles = 0;
6822
+ windings.forEach(w => { nHoles += w.iRing ? 1 : 0; });
6823
+ if (nHoles) {
6824
+ let c = [];
6825
+ f.geometry.coordinates.forEach((poly) => {
6826
+ poly.forEach((ring) => {
6827
+ c.push([ring]);
6828
+ });
6829
+ });
6830
+ f.geometry.coordinates = c;
6831
+ windings = polyRingWindings(f);
6832
+ }
6840
6833
  let polys = f.geometry.coordinates;
6841
- let iPoly;
6842
- for (; iWinding < windings.length; iWinding++) {
6834
+ let iPoly = 0;
6835
+ for (let iWinding = 0; iWinding < windings.length; iWinding++) {
6843
6836
  let good = !misWound(windings[iWinding]);
6844
- if (!good && iWinding == 0) // First is miswound - no good
6845
- break;
6846
6837
  if (good)
6847
6838
  iPoly = iWinding;
6848
6839
  else {
6840
+ // If hole, add to previous poly
6849
6841
  polys[iPoly].push(polys[iWinding][0]);
6850
6842
  polys[iWinding] = null;
6851
6843
  }
@@ -8786,22 +8778,7 @@ function ringsCancel(outerPoly, innerRing) {
8786
8778
  return true;
8787
8779
  }
8788
8780
  function correctGeometry(f) {
8789
- if (f && f.geometry && f.geometry.type === 'MultiPolygon' && f.geometry.coordinates) {
8790
- let multiPoly = f.geometry.coordinates;
8791
- // Convert degenerate MultiPolygon to Polygon
8792
- if (multiPoly.length == 1) {
8793
- f.geometry.type = 'Polygon';
8794
- f.geometry.coordinates = multiPoly[0];
8795
- }
8796
- }
8797
- if (f && f.geometry && f.geometry.type === 'Point' && f.geometry.coordinates) {
8798
- while (Array.isArray(f.geometry.coordinates[0]))
8799
- f.geometry.coordinates = f.geometry.coordinates[0];
8800
- }
8801
- else
8802
- // TopoJSON does not guarantee proper winding order which messes up later processing. Fix it.
8803
- P.featureRewind(f, { validateHoles: false });
8804
- return f;
8781
+ return P.featureRewind(f, { validateHoles: false });
8805
8782
  }
8806
8783
  function topoContiguity(topo) {
8807
8784
  let objects = Object.values(topo.objects);