Subject: | bug in Gpc2polygons function (and fix) |
Hi...this bug in distribution Math-Geometry-Planar-1.12 is very simple:
Starting at line 1986 in Planar.pm, in the subroutine Gpc2polygons, you have this code:
if ($obj->isinside($polygon[0])) {
$obj->add_polygons($inner[$i]);
splice @inner,$i,1;
}
$i++;
However, I think you want to do this:
if ($obj->isinside($polygon[0])) {
$obj->add_polygons($inner[$i]);
splice @inner,$i,1;
} else {
$i++;
}
that is, only increment the counter if you don't splice! Otherwise, some of the "holes" you're trying to insert into polygons get missed.
I was losing some "holes" in operations I was doing, but when I made this change in my copy of Planar.pm, it worked perfectly!
thanks and best regards
Christopher Petti, PhD.
Matrix Semiconductor, Inc
3230 Scott Blvd.
Santa Clara, CA 95054
office: 408 969 4835 mobile: 408 410 1479
fax: 408 969 4849
email: cpetti@matrixsemi.com