Skip to content

Commit b76616d

Browse files
committed
fix #12
1 parent 36b7f4d commit b76616d

File tree

3 files changed

+38
-8
lines changed

3 files changed

+38
-8
lines changed

src/parsing.jl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,17 @@ function autosetfield!(o::Union{Object,KMLElement}, sym::Symbol, x::String)
104104
T <: Number && return setfield!(o, sym, parse(T, x))
105105
T <: AbstractString && return setfield!(o, sym, x)
106106
T <: Enums.AbstractKMLEnum && return setfield!(o, sym, T(x))
107+
# if sym == :coordinates
108+
# val = occursin('\n', x) ?
109+
# [Tuple(parse.(Float64, split(s, ','))) for s in split(x, '\n')] :
110+
# Tuple(parse.(Float64, split(x, ',')))
111+
# return setfield!(o, sym, val)
112+
# end
107113
if sym == :coordinates
108-
val = occursin('\n', x) ?
109-
[Tuple(parse.(Float64, split(s, ','))) for s in split(x, '\n')] :
110-
Tuple(parse.(Float64, split(x, ',')))
114+
val = [Tuple(parse.(Float64, split(v, ','))) for v in split(x)]
115+
if length(val) == 1
116+
val = val[1]
117+
end
111118
return setfield!(o, sym, val)
112119
end
113120
setfield!(o, sym, x)

test/issue12.kml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<kml xmlns:kml="http://www.opengis.net/kml/2.2">
3+
<Document>
4+
<name>tmp.kml</name>
5+
<Placemark>
6+
<name>tmp</name>
7+
<styleUrl>#m_ylw-pushpin</styleUrl>
8+
<Polygon>
9+
<tessellate>1</tessellate>
10+
<outerBoundaryIs>
11+
<LinearRing>
12+
<coordinates>
13+
-50.80770360421555,27.50794679203254,0 -46.63827492868646,32.0230059721323,0 -54.85996847570588,35.7028706316008,0 -50.80770360421555,27.50794679203254,0
14+
</coordinates>
15+
</LinearRing>
16+
</outerBoundaryIs>
17+
</Polygon>
18+
</Placemark>
19+
</Document>
20+
</kml>

test/runtests.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ using GeoInterface
33
using Test
44
using XML
55

6+
@testset "Issue Coverage" begin
7+
# https://github.com/JuliaComputing/KML.jl/issues/8
8+
@test_warn "Unhandled case" read(joinpath(@__DIR__, "outside_spec.kml"), KMLFile)
9+
10+
# https://github.com/JuliaComputing/KML.jl/issues/12
11+
@test read(joinpath(@__DIR__, "issue12.kml"), KMLFile) isa KMLFile
12+
end
13+
614
@testset "Empty Constructors" begin
715
for T in KML.all_concrete_subtypes(KML.Object)
816
@test T() isa T
@@ -47,8 +55,3 @@ end
4755
file2 = read(temp, KMLFile)
4856
@test file == file2
4957
end
50-
51-
@testset "Issue Coverage" begin
52-
# https://github.com/JuliaComputing/KML.jl/issues/8
53-
@test_warn "Unhandled case" read(joinpath(@__DIR__, "outside_spec.kml"), KMLFile)
54-
end

0 commit comments

Comments
 (0)