Hello
I installed Math::Polygon and it is very nice but am having what I hope
is a problem with my ignorant syntax/usage rather than a bug, but I hope
someone will be able to tell me how to fix it.
I have some polygons coordinates in one file and another data file with
coordinates like 89.000,34.02334 in it and I want to check if the
coordinate is inside the polygon.
But when I try to use the "contains" function, here is what it says:
-----------------
Can't use string ("-80.89629636533394,29.7967418838") as an ARRAY ref
while "strict refs" in use at /Library/Perl/5.8.6/Math/Polygon/Calc.pm
line 304.
-----------------
I have pasted below a simplified version of my test program that
produces a similar error as above.
Can anyone tell me where the problem is? I am sure it has to do with
'escaping' something, but I just don't know what or how.
Thank you
Mark Hunnibell
--
Dist Name: Math-Polygon-1.00
Perl Version: perl, v5.8.6 built for darwin-thread-multi-2level
OS: Mac OS X 10.4 (Tiger)
--
#!/usr/bin/perl
use Math::Polygon;
$coordinates = "-82.39824720054879,26.94012565034653,0
-82.22443797267536,26.41777663135604,0
-81.75327922278925,25.79351665334116,0
-82.39824720054879,26.94012565034653";
@coords = split(/,0 /, $coordinates);
my $polygon = Math::Polygon->new(points => \@coords);
$latlong = "-80.89629636533394,29.7967418838";
my @ll = split(/\,/, $latlong);
my $countinside += $polygon->contains(\@ll);
print $countinside;