line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package RDF::AllegroGraph::Utils; |
2
|
|
|
|
|
|
|
|
3
|
15
|
|
|
15
|
|
78371
|
use Data::Dumper; |
|
15
|
|
|
|
|
33
|
|
|
15
|
|
|
|
|
7079
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
require Exporter; |
6
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
7
|
|
|
|
|
|
|
@EXPORT_OK = qw(coord2literal); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub coord2literal { |
10
|
0
|
|
|
0
|
0
|
|
my $typeURI = shift; |
11
|
0
|
|
|
|
|
|
my $A = shift; |
12
|
0
|
|
|
|
|
|
my $B = shift; |
13
|
|
|
|
|
|
|
|
14
|
0
|
0
|
|
|
|
|
$typeURI = "<" . $typeURI . ">" unless $typeURI =~ /^<.+>$/; |
15
|
0
|
0
|
|
|
|
|
return $typeURI =~ /spherical/ |
16
|
|
|
|
|
|
|
? '"' . (sprintf "%+011.7f", $B) . (sprintf "%+012.7f", $A) . '"^^' . $typeURI |
17
|
|
|
|
|
|
|
: '"' . (sprintf "%+.7f", $A) . (sprintf "%+.7f", $B) . '"^^' . $typeURI |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub _hash_to_perl { |
21
|
0
|
|
|
0
|
|
|
my $h = shift; |
22
|
|
|
|
|
|
|
# warn "hash to perl ".Dumper $h; |
23
|
0
|
|
|
|
|
|
my $h2; |
24
|
0
|
|
|
|
|
|
foreach my $k (keys %$h) { |
25
|
|
|
|
|
|
|
# warn $k; |
26
|
0
|
|
|
|
|
|
$h2->{$k} = _data_to_perl ($h->{$k}); |
27
|
|
|
|
|
|
|
} |
28
|
0
|
|
|
|
|
|
return $h2; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _data_to_perl { |
32
|
0
|
|
|
0
|
|
|
my $d = shift; |
33
|
0
|
0
|
|
|
|
|
if ($d =~ q|"true"\^\^|) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
return 1; |
35
|
|
|
|
|
|
|
} elsif ($d =~ q|"false"\^\^|) { |
36
|
0
|
|
|
|
|
|
return undef; |
37
|
|
|
|
|
|
|
} elsif ($d =~ q|^<(.*)>$|) { |
38
|
0
|
|
|
|
|
|
return $1; |
39
|
|
|
|
|
|
|
} elsif ($d =~ q|^"(.*)"$|) { |
40
|
0
|
|
|
|
|
|
return $1; |
41
|
|
|
|
|
|
|
} elsif (JSON::XS::is_bool $d) { |
42
|
0
|
|
|
|
|
|
return $d; |
43
|
|
|
|
|
|
|
# return JSON::XS::true == $d; |
44
|
|
|
|
|
|
|
} else { |
45
|
0
|
|
|
|
|
|
return $d; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |