Skip to content

Commit

Permalink
Fix broken tests and fix failure when using only one polygon in a mul…
Browse files Browse the repository at this point in the history
…tipolygon
  • Loading branch information
alranel committed Apr 7, 2013
1 parent 46169a5 commit 0217463
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/poly2av.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ int add_ring(AV* theAv, polygon& poly, const int ring_index)
elem = av_fetch(theAv, i, 0);
if (!SvROK(*elem)
|| SvTYPE(SvRV(*elem)) != SVt_PVAV
|| av_len((AV*)SvRV(*elem)) < 1)
|| av_len((AV*)SvRV(*elem)) != 1) // require two coordinates per point
{
return 0;
}
Expand Down Expand Up @@ -113,7 +113,7 @@ perl2polygon(pTHX_ AV* theAv)
elem = av_fetch(theAv, i, 0);
if (!SvROK(*elem)
|| SvTYPE(SvRV(*elem)) != SVt_PVAV
|| av_len((AV*)SvRV(*elem)) < 1)
|| av_len((AV*)SvRV(*elem)) < 1) // require at least two points in ring
{
delete retval;
return NULL;
Expand Down Expand Up @@ -141,7 +141,7 @@ perl2multi_polygon(pTHX_ AV* theAv)
elem = av_fetch(theAv, i, 0);
if (!SvROK(*elem)
|| SvTYPE(SvRV(*elem)) != SVt_PVAV
|| av_len((AV*)SvRV(*elem)) < 1)
|| av_len((AV*)SvRV(*elem)) < 0) // require at least one polygon
{
delete retval;
return NULL;
Expand Down
7 changes: 5 additions & 2 deletions t/01_basic.t
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,15 @@ use Boost::Geometry::Utils qw(polygon_multi_linestring_intersection
[ [10, 15], [14, 15] ],
[ [16, 15], [20, 15] ],
];
my $expected_noholes = [
[ [10, 15], [20, 15] ],
];
is_deeply polygon_multi_linestring_intersection([$square], $multilinestring),
$expected, 'multiple linestring clipping against polygon with no holes';
$expected_noholes, 'multiple linestring clipping against polygon with no holes';
is_deeply polygon_multi_linestring_intersection($polygon, $multilinestring),
$expected, 'multiple linestring clipping';
is_deeply multi_polygon_multi_linestring_intersection([[$square]], $multilinestring),
$expected, 'multiple linestring clipping against multiple polygons with no holes';
$expected_noholes, 'multiple linestring clipping against multiple polygons with no holes';
is_deeply multi_polygon_multi_linestring_intersection([$polygon], $multilinestring),
$expected, 'multiple linestring clipping against multiple polygons';
}
Expand Down

0 comments on commit 0217463

Please sign in to comment.