Skip to content

Commit 89b6902

Browse files
committed
remove whitespace in coordinates
1 parent 73ce2af commit 89b6902

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/KML.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ function KMLFile(doc::XML.Node)
157157
KMLFile(map(object, XML.children(doc[i])))
158158
end
159159

160+
Base.parse(::Type{KMLFile}, s::AbstractString) = KMLFile(XML.parse(s, Node))
161+
160162
Writable = Union{KMLFile, KMLElement, Node}
161163

162164
write(io::IO, o::Writable; kw...) = XML.write(io, Node(o); kw...)

src/parsing.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#-----------------------------------------------------------------------------# XML.Node ←→ KMLElement
22
typetag(T) = replace(string(T), r"([a-zA-Z]*\.)" => "", "_" => ":")
3-
tuple2string(x) = replace(string(x), "), (" => "\n", "[(" => "", ")]" => "", ')' => "", '(' => "")
3+
4+
coordinate_string(x::Tuple) = join(x, ',')
5+
coordinate_string(x::Vector) = join(coordinate_string.(x), '\n')
46

57
# KMLElement → Node
68
Node(o::T) where {T<:Enums.AbstractKMLEnum} = XML.Element(typetag(T), o.value)
@@ -18,7 +20,7 @@ function Node(o::T) where {names, T <: KMLElement{names}}
1820
elseif field == :outerBoundaryIs
1921
push!(children, XML.Element(:outerBoundaryIs, Node(val)))
2022
elseif field == :coordinates
21-
push!(children, XML.Element("coordinates", tuple2string(val)))
23+
push!(children, XML.Element("coordinates", coordinate_string(val)))
2224
elseif val isa KMLElement
2325
push!(children, Node(val))
2426
elseif val isa Vector{<:KMLElement}

0 commit comments

Comments
 (0)