/usr/share/doc/libmapscript-perl/examples/buffer.pl is in libmapscript-perl 6.4.1-5+deb8u3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | #!/usr/bin/perl
#
# Script : buffer.pl
#
# Purpose: Applies buffer to shapefile dataset using geos support
# buffer units as are per units of data
#
# $Id$
#
use strict;
use warnings;
use POSIX;
use XBase;
use mapscript;
use Getopt::Long;
use File::Copy;
my ($infile, $outfile, $buffer);
GetOptions("input=s", \$infile, "output=s", \$outfile, "buffer=n", \$buffer);
if(!$infile or !$outfile or !$buffer) {
print "Usage: $0 --input=[filename] --output=[filename] --buffer=[native units]\n";
exit 0;
}
die "Tolerance must be greater than zero." unless $buffer > 0;
# initialize counters for reporting
my $incount = 0;
my $outcount = 0;
# open the input shapefile
my $inSHP = new mapscript::shapefileObj($infile, -1) or die "Unable to open shapefile $infile.";
# create the output shapefile
unlink "$outfile.shp";
unlink "$outfile.shx";
unlink "$outfile.dbf";
my $outSHP = new mapscript::shapefileObj($outfile, $inSHP->{type}) or die "Unable to create shapefile '$outfile'. $!\n";
copy("$infile.dbf", "$outfile.dbf") or die "Can't copy file $infile.dbf to $outfile.dbf: $!\n";
my $inshape = new mapscript::shapeObj(-1); # something to hold shapes
for(my $i=0; $i<$inSHP->{numshapes}; $i++) {
$inSHP->get($i, $inshape);
my $outshape = new mapscript::shapeObj(-1);
print "buffering feature: $i\n";
$outshape = $inshape->buffer($buffer) or die "Unable to buffer feature #$i: $!\n"; # in native map units
$outSHP->add($outshape);
undef($outshape); # free memory associated with shape
} # for each shape
$outSHP = ''; # write the file
undef $inSHP;
undef $outSHP;
|