@dra2020/baseclient 1.0.63 → 1.0.66

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
  }
@@ -6856,10 +6848,13 @@ function featureRewind(f, options) {
6856
6848
  if (f.geometry.coordinates.length == 1) {
6857
6849
  f.geometry.type = 'Polygon';
6858
6850
  f.geometry.coordinates = f.geometry.coordinates[0];
6851
+ d = 4;
6859
6852
  }
6860
6853
  }
6861
6854
  // OK, now go through each ring
6862
6855
  let polys = f.geometry.coordinates;
6856
+ if (d == 4)
6857
+ polys = [polys];
6863
6858
  windings = polyRingWindings(f);
6864
6859
  windings.forEach((w) => {
6865
6860
  let good = !misWound(w);