/usr/share/doc/libmapscript-perl/examples/RFC24.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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | #!/usr/bin/perl
use mapscript;
$file=$ARGV[0];
# utility
sub assertNotNull {
my ($o, $test) = @_;
if ($o) {
print $test . " PASSED\n";
} else {
print $test . " FAILED\n";
}
}
sub dumpHash {
my ($hashmap) = @_;
print "Dumping hashmap: $hashmap\n";
for my $k ( keys %$hashmap ) {
print "\t".$k.": ".$hashmap{$k}."\n";
}
}
# layerObj
sub testGetLayerObj {
my $map = new mapscript::mapObj($file);
my $layer = $map->getLayer(1);
$map = undef;
assertNotNull( $layer->{map} , "testGetLayerObj");
#$layer->{map}->draw()->save("/tmp/map.png");
}
sub testGetLayerObjByName {
my $map = new mapscript::mapObj($file);
my $layer = $map->getLayerByName("POLYGON");
$map = undef;
assertNotNull( $layer->{map} , "testGetLayerObjByName");
}
sub testLayerObj {
my $map = new mapscript::mapObj($file);
my $layer = new mapscript::layerObj($map);
$map = undef;
assertNotNull( $layer->{map} , "testLayerObj");
}
sub testInsertLayerObj {
my $map = new mapscript::mapObj($file);
my $layer = new mapscript::layerObj(undef);
my $position = $map->insertLayer($layer);
$map = undef;
assertNotNull( $position == 7 , "testInsertLayerObj position");
assertNotNull( $layer->{map} , "testInsertLayerObj notnull");
}
# classObj
sub testGetClassObj {
#dumpHash(mapscript::getPARENT_PTRS());
my $map = new mapscript::mapObj($file);
my $layer = $map->getLayer(1);
my $clazz = $layer->getClass(0);
#dumpHash(mapscript::getPARENT_PTRS());
#$clazz->{layer}->{map}->draw()->save("/tmp/map1.png");
#print "parent layer=".$clazz->{layer}."\n";
$map = undef; $layer=undef;
#print "parent layer=".$clazz->{layer}."\n";
assertNotNull( $clazz->{layer} , "testGetClassObj");
#$clazz->{layer}->{map}->draw()->save("/tmp/map2.png");
#dumpHash(mapscript::getPARENT_PTRS());
}
sub testClassObj {
my $map = new mapscript::mapObj($file);
my $layer = $map->getLayer(1);
my $clazz = new mapscript::classObj($layer);
$map = undef; $layer=undef;
assertNotNull( $clazz->{layer} , "testClassObj");
}
sub testInsertClassObj {
my $map = new mapscript::mapObj($file);
my $layer = $map->getLayer(1);
my $clazz = new mapscript::classObj(undef);
my $position = $layer->insertClass($clazz);
$map = undef; $layer=undef;
assertNotNull( $position == 2 , "testInsertClassObj position");
assertNotNull( $clazz->{layer} , "testInsertClassObj notnull");
}
if ( ! $file ) {
print "Usage: RFC24.pl file.map\n";
exit 1;
}
testGetLayerObj;
testGetLayerObjByName;
testLayerObj;
testInsertLayerObj;
testGetClassObj;
testClassObj;
testInsertClassObj;
$hashmap=mapscript::getPARENT_PTRS();
assertNotNull( keys( %$hashmap )==0 , "checking that hashmap of parent ptrs is empty");
print "No of keys:".keys( %$hashmap )."\n";
dumpHash($hashmap);
|