@dra2020/baseclient 1.0.64 → 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.
@@ -6814,24 +6814,30 @@ function featureRewind(f, options) {
6814
6814
  // Only applies to multi-polygons with no holes
6815
6815
  let d = Util.depthof(f.geometry.coordinates);
6816
6816
  let windings = polyRingWindings(f);
6817
- if (options.validateHoles && d === 5 && windings.length) {
6818
- // If there are explicit holes, don't look for implicit ones
6819
- let nHoles = 0;
6820
- windings.forEach(w => { if (w.iRing)
6821
- nHoles++; });
6822
- if (nHoles == 0 && !misWound(windings[0])) {
6823
- // Looking for pattern: of (G (B*))*
6824
- // To convert to ((GH*))*
6825
- 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
+ }
6826
6833
  let polys = f.geometry.coordinates;
6827
- let iPoly;
6828
- for (; iWinding < windings.length; iWinding++) {
6834
+ let iPoly = 0;
6835
+ for (let iWinding = 0; iWinding < windings.length; iWinding++) {
6829
6836
  let good = !misWound(windings[iWinding]);
6830
- if (!good && iWinding == 0) // First is miswound - no good
6831
- break;
6832
6837
  if (good)
6833
6838
  iPoly = iWinding;
6834
6839
  else {
6840
+ // If hole, add to previous poly
6835
6841
  polys[iPoly].push(polys[iWinding][0]);
6836
6842
  polys[iWinding] = null;
6837
6843
  }