use Geo::ShapeFile; use Math::Geometry::Planar; $zf = new Geo::ShapeFile("PLA_CDD_Zoning_1006"); $apn = new Geo::ShapeFile("CAD_AO_ParcelPoints_113006") ; # $shapefile = new Geo::ShapeFile("CAD_AO_Parcel_Polygon_1006") ; print "Load the Zoning Polygons\n" ; undef @zontext ; for $zidx (1 .. $zf->shapes()) { $zshape = $zf->get_shp_record($zidx); %db = $zf->get_dbf_record($zidx); $zoning = $db{"ZONING"} ; ($work = $db{"OVERLAY"}) =~ s/\_deleted//g ; $work =~ tr/\t\n\r//d ; $overlay = $work ; push @zontext, $zoning.$overlay ; undef @pts1 ; for $numprt (1 .. $zshape->num_parts) { @parts = $zshape->get_segments($numprt); $arrayline = '[' ; foreach $partarray (@parts) { $j = 0 ; foreach $partpoint (@$partarray) { ($j1,$xval,$j2,$yval) = split/\=|\,|\)/,$partpoint ; $arrayline .= "," if (++$j>1) ; $arrayline .= '[' ; $arrayline .= $xval .','. $yval.']' ; } } $arrayline .= ']' ; eval '$polypts[$zcnt] = $arrayline'; warn $@ if $@; ++$zcnt ; } } $outfn = "CCZone.txt" ; open (Outfile, ">$outfn") || die "Cannot open output file $outfn" ; $| = 1, select $_ for select Outfile ; # need to collect all shapes within all zoning area $i = 0 ; print "Zoning file version: " ; print $zf->file_version(),"\n" ; print "Zoning file records: " ; print $zf->records(),"\n" ; print "Zoning file shapes: " ; print $zf->shapes(),"\n" ; # $temp = ; print "Parcel file shapes: " ; print $apn->shapes(),"\n" ; print "Main processing...\n" ; for $parcels (1 .. $apn->shapes()) { $pshape = $apn->get_shp_record($parcels); $ppoint = $pshape->get_part(1) ; ($j1,$px,$j2,$py) = split/\=|\,|\)/,$ppoint ; %pids = $apn->get_dbf_record($parcels); #print $pids{"APN"},"\t" ; #print $px,",",$py,"\n" ; $thispoint = [$px, $py] ; print $parcels,"\n" if ($parcels%10==0) ; $zcnt = $zhit = 0 ; for $thispoly (@polypts) { print $thispoly,"\n" ; # how do I get the string to be an array reference??????? $polyg1 = Math::Geometry::Planar->new; # creates a new polygon object; $polyg1->points($thispoly) ; if ($polyg1->isinside($thispoint)) { printf ("%s\t%s\n",$pids{"APN"},$zontext[$zcnt]) if ($pids{"APN"}) ; printf (Outfile "%s\t%s\n",$pids{"APN"},$zontext[$zcnt]) if ($pids{"APN"}) ; ++$zhit ; } ++$zcnt ; } if (!$zhit) { print "No:",$pids{"APN"}," $px, $py\n" ; } } exit ;