File: RFC24.pl

package info (click to toggle)
mapserver 8.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 18,020 kB
  • sloc: ansic: 139,708; cpp: 111,541; python: 3,004; xml: 1,722; yacc: 1,108; cs: 997; lex: 747; sh: 606; java: 588; perl: 489; makefile: 370; tcl: 158; ruby: 55
file content (104 lines) | stat: -rw-r--r-- 2,662 bytes parent folder | download | duplicates (6)
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
#!/usr/bin/perl
use strict;
use warnings;
use mapscript;
use Data::Dumper;

my $file=$ARGV[0];

# utility
sub assertNotNull {
	my ($o, $test) = @_;
	if ($o) {
		print $test . "  PASSED\n";
	} else {
		print $test . "  FAILED\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;

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);
print Dumper( $hashmap );