Skip to content
Permalink
Browse files
fix perl examples
  • Loading branch information
andy committed Apr 14, 2019
1 parent 774bc1d commit 37815bbf36fee339716f70247fbfbc68b86dfa5c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
@@ -1,6 +1,10 @@
#!/usr/bin/perl
use strict;
use warnings;
use mapscript;
$file=$ARGV[0];
use Data::Dumper;

my $file=$ARGV[0];

# utility
sub assertNotNull {
@@ -12,13 +16,6 @@ sub assertNotNull {
}
}

sub dumpHash {
my ($hashmap) = @_;
print "Dumping hashmap: $hashmap\n";
for my $k ( keys %$hashmap ) {
print "\t".$k.": ".$hashmap{$k}."\n";
}
}

# layerObj
sub testGetLayerObj {
@@ -49,7 +46,7 @@ sub testInsertLayerObj {
my $position = $map->insertLayer($layer);
$map = undef;
assertNotNull( $position == 7 , "testInsertLayerObj position");
assertNotNull( $layer->{map} , "testInsertLayerObj notnull");
assertNotNull( $layer->{map} , "testInsertLayerObj notnull");
}

# classObj
@@ -83,7 +80,7 @@ sub testInsertClassObj {
my $position = $layer->insertClass($clazz);
$map = undef; $layer=undef;
assertNotNull( $position == 2 , "testInsertClassObj position");
assertNotNull( $clazz->{layer} , "testInsertClassObj notnull");
assertNotNull( $clazz->{layer} , "testInsertClassObj notnull");
}

if ( ! $file ) {
@@ -99,8 +96,9 @@ sub testInsertClassObj {
testClassObj;
testInsertClassObj;

$hashmap=mapscript::getPARENT_PTRS();
my $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);
#dumpHash($hashmap);
print Dumper( $hashmap );

@@ -9,8 +9,6 @@

use strict;
use warnings;
use POSIX;
use XBase;
use mapscript;
use Getopt::Long;
use File::Copy;
@@ -19,7 +17,8 @@

GetOptions("infile1=s", \$infile1, "infile1_shpid=s", \$infile1_shpid, "infile2=s", \$infile2, "infile2_shpid=s", \$infile2_shpid);

if(!$infile1 or !$infile1_shpid or !$infile2 or !$infile2_shpid) {
# shpid can be zero, which looks false, so use defined()
if(!$infile1 or !defined($infile1_shpid) or !$infile2 or !defined($infile2_shpid)) {
print "Usage: $0 --infile1=[filename] --infile1_shpid=[shpid] --infile2=[filename] --infile2_shpid=[shpid]\n";
exit 0;
}
@@ -10,8 +10,6 @@

use strict;
use warnings;
use POSIX;
use XBase;
use mapscript;
use Getopt::Long;
use File::Copy;

0 comments on commit 37815bb

Please sign in to comment.