thin.pl patch

Homme Zwaagstra hrz at GEODATA.SOTON.AC.UK
Tue Sep 27 08:49:53 EDT 2005


Hello,

I could not get the thin.pl shapefile generalisation script
(http://mapserver.gis.umn.edu/user_utilities/thin.pl) to work without
the attached patch. I'm no perl expert, but the changes are simple and
involve the mapscript library. I'm using mapserver 4.6.1.

Kind regards,

Homme Zwaagstra.
-------------- next part --------------
--- thin.pl
+++ thin.pl
@@ -33,25 +33,25 @@
 $outcount = 0;
 
 # open the input shapefile
-$inSHP = new shapefileObj($infile, -1) or die "Unable to open shapefile $infile.";
+$inSHP = new mapscript::shapefileObj($infile, -1) or die "Unable to open shapefile $infile.";
 die "Cannot thin point/multipoint shapefiles." unless ($inSHP->{type} == 5 or $inSHP->{type} == 3);
 
 # create the output shapefile
 system("rm $outfile.*");
-$outSHP = new shapefileObj($outfile, $inSHP->{type}) or die "Unable to create shapefile '$outfile'. ", $mapscript::ms_error->{message};
+$outSHP = new mapscript::shapefileObj($outfile, $inSHP->{type}) or die "Unable to create shapefile '$outfile'. ", $mapscript::ms_error->{message};
 system("cp $infile.dbf $outfile.dbf");
 
-$inshape = new shapeObj(-1); # something to hold shapes
+$inshape = new mapscript::shapeObj(-1); # something to hold shapes
 
 for($i=0; $i<$inSHP->{numshapes}; $i++) {
 
   $inSHP->get($i, $inshape);
-  $outshape = new shapeObj(-1);
+  $outshape = new mapscript::shapeObj(-1);
   
   for($j=0; $j<$inshape->{numlines}; $j++) {
 
     $inpart = $inshape->get($j);
-    $outpart = new lineObj();
+    $outpart = new mapscript::lineObj();
 
     @stack = ();
 
@@ -77,7 +77,7 @@
       for (($aIndex+1) .. ($fIndex-1)) {
 
 	$point = $inpart->get($_);	
-	$dist = $point->distanceToLine($anchor, $fPoint);
+	$dist = $point->distanceToSegment($anchor, $fPoint);
 
 	if($dist >= $max) {
 	  $max = $dist;


More information about the mapserver-users mailing list