index.js
function determineParents() {
    var featuresWithoutParent = [];
    for (var i = 0; i < output.features.length; i++) {
      debugAll("Output ring " + i + " has parent " + output.features[i].properties.parent);
      if (output.features[i].properties.parent == -1) featuresWithoutParent.push(i);
    }
    debugAll("The following output ring(s) have no parent: " + featuresWithoutParent);
    if (featuresWithoutParent.length > 1) {
      for (var i = 0; i < featuresWithoutParent.length; i++) {
        var parent = -1;
        var parentArea = Infinity;
        for (var j = 0; j < output.features.length; j++) {
          if (featuresWithoutParent[i] == j) continue
          if (inside(helpers.point(output.features[featuresWithoutParent[i]].geometry.coordinates[0][0]), output.features[j], true)) {
            if (area(output.features[j]) < parentArea) {
              parent = j;
              debugAll("Ring "+featuresWithoutParent[i]+" lies inside output ring "+j);
            }
          }
        }
        output.features[featuresWithoutParent[i]].properties.parent = parent;
        debugAll("Ring "+featuresWithoutParent[i]+" is assigned parent "+parent);
      }
    }
  }
function determineParents() {
    var featuresWithoutParent = [];
    for (var i = 0; i < output.features.length; i++) {
      debugAll("Output ring " + i + " has parent " + output.features[i].properties.parent);
      if (output.features[i].properties.parent == -1) featuresWithoutParent.push(i);
    }
    debugAll("The following output ring(s) have no parent: " + featuresWithoutParent);
    if (featuresWithoutParent.length > 1) {
      for (var i = 0; i < featuresWithoutParent.length; i++) {
        var parent = -1;
        var parentArea = Infinity;
        for (var j = 0; j < output.features.length; j++) {
          if (featuresWithoutParent[i] == j) continue
          if (inside(helpers.point(output.features[featuresWithoutParent[i]].geometry.coordinates[0][0]), output.features[j], true)) {
            if (area(output.features[j]) < parentArea) {
              parent = j;
              debugAll("Ring "+featuresWithoutParent[i]+" lies inside output ring "+j);
            }
          }
        }
        output.features[featuresWithoutParent[i]].properties.parent = parent;
        debugAll("Ring "+featuresWithoutParent[i]+" is assigned parent "+parent);
      }
    }
  }
function determineParents ( ) { var featuresWithoutParent = [ ] ; for ( var i = 0 ; i < output . features . length ; i ++ ) { debugAll ( "Output ring " + i + " has parent " + output . features [ i ] . properties . parent ) ; if ( output . features [ i ] . properties . parent == - 1 ) featuresWithoutParent . push ( i ) ; } debugAll ( "The following output ring(s) have no parent: " + featuresWithoutParent ) ; if ( featuresWithoutParent . length > 1 ) { for ( var i = 0 ; i < featuresWithoutParent . length ; i ++ ) { var parent = - 1 ; var parentArea = Infinity ; for ( var j = 0 ; j < output . features . length ; j ++ ) { if ( featuresWithoutParent [ i ] == j ) continue if ( inside ( helpers . point ( output . features [ featuresWithoutParent [ i ] ] . geometry . coordinates [ 0 ] [ 0 ] ) , output . features [ j ] , true ) ) { if ( area ( output . features [ j ] ) < parentArea ) { parent = j ; debugAll ( "Ring " + featuresWithoutParent [ i ] + " lies inside output ring " + j ) ; } } } output . features [ featuresWithoutParent [ i ] ] . properties . parent = parent ; debugAll ( "Ring " + featuresWithoutParent [ i ] + " is assigned parent " + parent ) ; } } }
These functions are also used if no intersections are found
These functions are also used if no intersections are found