Skip to content

Commit

Permalink
Move where -0 distance is precluded, based on feedback from @Fil.
Browse files Browse the repository at this point in the history
  • Loading branch information
curran committed Jun 4, 2020
1 parent 23edc6a commit cfa297f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions polylabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function polylabel(polygon, precision, debug) {
}

var poleOfInaccessibility = [bestCell.x, bestCell.y];
poleOfInaccessibility.distance = bestCell.d || 0;
poleOfInaccessibility.distance = bestCell.d;
return poleOfInaccessibility;
}

Expand Down Expand Up @@ -113,7 +113,7 @@ function pointToPolygonDist(x, y, polygon) {
}
}

return (inside ? 1 : -1) * Math.sqrt(minDistSq);
return minDistSq === 0 ? 0 : (inside ? 1 : -1) * Math.sqrt(minDistSq);
}

// get polygon centroid
Expand Down

0 comments on commit cfa297f

Please sign in to comment.