Debian Codegraph @

t/02.kml2wkt.t

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 use strict;
2 use warnings;
3 use Test::Base;
4
5 use Geo::Converter::WKT2KML;
6
7 plan tests => 1*blocks;
8
9 filters {
10 input => [qw/chomp/],
11 expected => [qw/chomp/],
12 };
13
14 run {
15 my $block = shift;
16
17 is (kml2wkt($block->expected),$block->input);
18 };
19
20 __END__
21
22 === test point
23 --- input
24 POINT(6 10)
25 --- expected
26 <Point><coordinates>6,10</coordinates></Point>
27
28 === test linestring
29 --- input
30 LINESTRING(3 4,10 50,20 25)
31 --- expected
32 <LineString><coordinates>3,4
33 10,50
34 20,25</coordinates></LineString>
35
36 === test polygon
37 --- input
38 POLYGON((1 1,5 1,5 5,1 5,1 1),(2 2,3 2,3 3,2 3,2 2))
39 --- expected
40 <Polygon>
41 <outerBoundaryIs><LinearRing><coordinates>1,1
42 5,1
43 5,5
44 1,5
45 1,1</coordinates></LinearRing></outerBoundaryIs>
46 <innerBoundaryIs><LinearRing><coordinates>2,2
47 3,2
48 3,3
49 2,3
50 2,2</coordinates></LinearRing></innerBoundaryIs>
51 </Polygon>
52
53 === test multipoint
54 --- input
55 MULTIPOINT(3.5 5.6,4.8 10.5)
56 --- expected
57 <MultiGeometry>
58 <Point><coordinates>3.5,5.6</coordinates></Point>
59 <Point><coordinates>4.8,10.5</coordinates></Point>
60 </MultiGeometry>
61
62 === test multilinestring
63 --- input
64 MULTILINESTRING((3 4,10 50,20 25),(-5 -8,-10 -8,-15 -4))
65 --- expected
66 <MultiGeometry>
67 <LineString><coordinates>3,4
68 10,50
69 20,25</coordinates></LineString>
70 <LineString><coordinates>-5,-8
71 -10,-8
72 -15,-4</coordinates></LineString>
73 </MultiGeometry>
74
75 === test multipolygon
76 --- input
77 MULTIPOLYGON(((1 1,5 1,5 5,1 5,1 1),(2 2,3 2,3 3,2 3,2 2)),((3 3,6 2,6 4,3 3)))
78 --- expected
79 <MultiGeometry>
80 <Polygon>
81 <outerBoundaryIs><LinearRing><coordinates>1,1
82 5,1
83 5,5
84 1,5
85 1,1</coordinates></LinearRing></outerBoundaryIs>
86 <innerBoundaryIs><LinearRing><coordinates>2,2
87 3,2
88 3,3
89 2,3
90 2,2</coordinates></LinearRing></innerBoundaryIs>
91 </Polygon>
92 <Polygon>
93 <outerBoundaryIs><LinearRing><coordinates>3,3
94 6,2
95 6,4
96 3,3</coordinates></LinearRing></outerBoundaryIs>
97 </Polygon>
98 </MultiGeometry>
99
100 === test geometrycollection
101 --- input
102 GEOMETRYCOLLECTION(LINESTRING(4 6,7 10),POINT(4 6))
103 --- expected
104 <MultiGeometry>
105 <Point><coordinates>4,6</coordinates></Point>
106 <LineString><coordinates>4,6
107 7,10</coordinates></LineString>
108 </MultiGeometry>
109
110 === test polygon
111 --- input
112 POINT(135.52 -34.56)
113 --- expected
114 <Point><coordinates>135.52,-34.56</coordinates></Point>
115
116 === test multipolygon
117 --- input
118 MULTIPOINT(-94.6 -20.4,135.87 25.90)
119 --- expected
120 <MultiGeometry>
121 <Point><coordinates>-94.6,-20.4</coordinates></Point>
122 <Point><coordinates>135.87,25.90</coordinates></Point>
123 </MultiGeometry>
124
125 === test linestring
126 --- input
127 LINESTRING(135.52 -34.56,134.25 24.67,133.25 24.45)
128 --- expected
129 <LineString><coordinates>135.52,-34.56
130 134.25,24.67
131 133.25,24.45</coordinates></LineString>
132
133 === test multilinestring
134 --- input
135 MULTILINESTRING((-94.6 -20.4,135.87 25.90),(135.52 -34.56,134.25 24.67),(135.52 -34.56,134.25 24.67,23.89 56.76))
136 --- expected
137 <MultiGeometry>
138 <LineString><coordinates>-94.6,-20.4
139 135.87,25.90</coordinates></LineString>
140 <LineString><coordinates>135.52,-34.56
141 134.25,24.67</coordinates></LineString>
142 <LineString><coordinates>135.52,-34.56
143 134.25,24.67
144 23.89,56.76</coordinates></LineString>
145 </MultiGeometry>
146
147 === test polygon-outeronly
148 --- input
149 POLYGON((135.52 -34.56,134.25 24.67,133.25 24.45,135.52 -34.56))
150 --- expected
151 <Polygon>
152 <outerBoundaryIs><LinearRing><coordinates>135.52,-34.56
153 134.25,24.67
154 133.25,24.45
155 135.52,-34.56</coordinates></LinearRing></outerBoundaryIs>
156 </Polygon>
157
158 === test polygon-outin
159 --- input
160 POLYGON((135.52 -34.56,134.25 24.67,133.25 24.45,135.52 -34.56),(-94.6 -20.4,135.87 25.90),(135.52 -34.56,134.25 24.67))
161 --- expected
162 <Polygon>
163 <outerBoundaryIs><LinearRing><coordinates>135.52,-34.56
164 134.25,24.67
165 133.25,24.45
166 135.52,-34.56</coordinates></LinearRing></outerBoundaryIs>
167 <innerBoundaryIs><LinearRing><coordinates>-94.6,-20.4
168 135.87,25.90</coordinates></LinearRing></innerBoundaryIs>
169 <innerBoundaryIs><LinearRing><coordinates>135.52,-34.56
170 134.25,24.67</coordinates></LinearRing></innerBoundaryIs>
171 </Polygon>
172
173