PostGIS/Codec/WKT/Builder.pm

filter: Statementstmt 80.6% 25 / 31 Branchbran 71.4% 10 / 14 Conditioncond 50.0% 4 / 8 MC/DCmcdc 20.0% 1 / 5 Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 71.4% 45 / 63 CC 11 SCAR 19.3
CC
11
Cov
74%
_build_coords
9.8
build
5.1
BEGIN
1.0
CRAP 6.9
« PostGIS/Codec/WKB/Decoder.pm ↑ Summary PostGIS/Introspect.pm »
1 package DBIO::PostgreSQL::PostGIS::Codec::WKT::Builder;
2 # ABSTRACT: WKT builder for PostGIS geometry structures
3  
4 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7  
8 6 ▶sub build {
Subroutine build: called CC=5 SCAR=16.2
Pod documented
9 6 my ($class, $parsed) = @_;
10 6 ▶ my $type = uc($parsed->{type} // '');
Condition50%1/2
$parsed->{"type"} // ""
l!l
60
MC/DC0%0/1
$parsed->{"type"} // ""
$parsed->{"type"}
Truth table50%1/2
A
A= $parsed->{"type"}
Aresult
11
00
11 6 ▶ my $dim = $parsed->{has_z} ? ' Z' : '';
Branch: 1 branch
BranchTrueFalseTotal
$parsed->{'has_z'} ? : 1 5 6
12 6 ▶ $dim .= 'M' if $parsed->{has_m};
Branch: 1 branch
BranchTrueFalseTotal
if $parsed->{"has_m"} 0 6 6
13  
14 6 ▶ return "${type}${dim} EMPTY" if $parsed->{is_empty};
Branch: 1 branch
BranchTrueFalseTotal
if $parsed->{"is_empty"} 1 5 6
15  
16 5 my $body = $class->_build_coords($parsed->{type}, $parsed->{coords});
17 5 return "${type}${dim}($body)";
18 }
19  
20 5 ▶sub _build_coords {
Subroutine _build_coords: called CC=7 SCAR=22.9
21 5 my ($class, $type, $coords) = @_;
22 5 $type = lc($type);
23  
24 5 ▶ if ($type eq 'point') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "point") 2 3 5
25 2 return join(' ', @$coords);
26 }
27 3 ▶ if ($type eq 'linestring' || $type eq 'multipoint') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "linestring" or $type eq "multipoint") 1 2 3
Condition66%2/3
$type eq "linestring" or $type eq "multipoint"
l!l&&r!l&&!r
102
MC/DC50%1/2
$type eq "linestring" or $type eq "multipoint"
$type eq "linestring" $type eq "multipoint"
Truth table66%2/3
A or B
A= $type eq "linestring"B= $type eq "multipoint"
ABresult
1X1
011
000
28 1 return join(',', map { join(' ', @$_) } @$coords);
29 }
30 2 ▶ if ($type eq 'polygon' || $type eq 'multilinestring') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "polygon" or $type eq "multilinestring") 2 0 2
Condition33%1/3
$type eq "polygon" or $type eq "multilinestring"
l!l&&r!l&&!r
200
MC/DC0%0/2
$type eq "polygon" or $type eq "multilinestring"
$type eq "polygon" $type eq "multilinestring"
Truth table33%1/3
A or B
A= $type eq "polygon"B= $type eq "multilinestring"
ABresult
1X1
011
000
31 2 return join(',', map { '(' . join(',', map { join(' ', @$_) } @$_) . ')' } @$coords);
32 }
33 0 ▶ if ($type eq 'multipolygon') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "multipolygon") 0 0 0
34 return join(',',
35 map {
36 0 '(' . join(',', map { '(' . join(',', map { join(' ', @$_) } @$_) . ')' } @$_) . ')'
37 } @$coords
38 );
39 }
40 0 return '';
41 }
42  
43 7 1;
44  
45 __END__
46  
47 =pod
48  
49 =encoding UTF-8
50  
51 =head1 NAME
52  
53 DBIO::PostgreSQL::PostGIS::Codec::WKT::Builder - WKT builder for PostGIS geometry structures
54  
55 =head1 VERSION
56  
57 version 0.900001
58  
59 =head1 METHODS
60  
61 =head2 build
62  
63 my $wkt = DBIO::PostgreSQL::PostGIS::Codec::WKT::Builder->build($parsed);
64  
65 Accepts the hashref returned by L<DBIO::PostgreSQL::PostGIS::Codec::WKT::Parser/parse>
66 and returns a WKT string.
67  
68 =head1 AUTHOR
69  
70 DBIO Authors
71  
72 =head1 COPYRIGHT AND LICENSE
73  
74 Copyright (C) 2026 DBIO Authors
75  
76 This is free software; you can redistribute it and/or modify it under
77 the same terms as the Perl 5 programming language system itself.
78  
79 =cut
« PostGIS/Codec/WKB/Decoder.pm ↑ Summary PostGIS/Introspect.pm »