juliacomputing / kml.jl Goto Github PK
View Code? Open in Web Editor NEWWrite in Google Earth's KML format in pure Julia
License: MIT License
Write in Google Earth's KML format in pure Julia
License: MIT License
This issue is used to trigger TagBot; feel free to unsubscribe.
If you haven't already, you should update your TagBot.yml
to include issue comment triggers.
Please see this post on Discourse for instructions and more details.
If you'd like for me to do this for you, comment TagBot fix
on this issue.
I'll open a PR within a few hours, please be patient!
The Shapefile.jl and GeoJSON.jl packages implement the Tables.jl interface, so it would be interesting if KML.jl does as well.
Would this be in the development plans for KML.jl?
Thanks in advance to the maintainers for their attention.
Hello, I am trying to read files output from Google Earth Pro. I have sample output, a stack trace, and a possible solution
Sample input
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns:kml="http://www.opengis.net/kml/2.2">
<Document>
<name>tmp.kml</name>
<Placemark>
<name>tmp</name>
<styleUrl>#m_ylw-pushpin</styleUrl>
<Polygon>
<tessellate>1</tessellate>
<outerBoundaryIs>
<LinearRing>
<coordinates>
-50.80770360421555,27.50794679203254,0 -46.63827492868646,32.0230059721323,0 -54.85996847570588,35.7028706316008,0 -50.80770360421555,27.50794679203254,0
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
</Document>
</kml>
Stack trace
julia> scenario = read("tmp.kml", KML.KMLFile)
ERROR: ArgumentError: cannot parse "0 -46.63827492868646" as Float64
Stacktrace:
[1] _parse_failure(T::Type, s::SubString{String}, startpos::Int64, endpos::Int64)
@ Base ./parse.jl:373
[2] _parse_failure(T::Type, s::SubString{String})
@ Base ./parse.jl:373
[3] #tryparse_internal#509
@ ./parse.jl:369 [inlined]
[4] tryparse_internal
@ ./parse.jl:366 [inlined]
[5] #parse#510
@ ./parse.jl:379 [inlined]
[6] parse
@ ./parse.jl:379 [inlined]
[7] _broadcast_getindex_evalf
@ ./broadcast.jl:683 [inlined]
[8] _broadcast_getindex
@ ./broadcast.jl:666 [inlined]
[9] getindex
@ ./broadcast.jl:610 [inlined]
[10] macro expansion
@ ./broadcast.jl:974 [inlined]
[11] macro expansion
@ ./simdloop.jl:77 [inlined]
[12] copyto!
@ ./broadcast.jl:973 [inlined]
[13] copyto!
@ ./broadcast.jl:926 [inlined]
[14] copy
@ ./broadcast.jl:898 [inlined]
[15] materialize
@ ./broadcast.jl:873 [inlined]
[16] autosetfield!(o::KML.LinearRing, sym::Symbol, x::String)
@ KML ~/.julia/packages/KML/UtUHK/src/parsing.jl:108
[17] add_element!(o::KML.LinearRing, child::XML.Node)
@ KML ~/.julia/packages/KML/UtUHK/src/parsing.jl:69
[18] object(node::XML.Node)
@ KML ~/.julia/packages/KML/UtUHK/src/parsing.jl:46
[19] add_element!(o::KML.Polygon, child::XML.Node)
@ KML ~/.julia/packages/KML/UtUHK/src/parsing.jl:65
[20] object(node::XML.Node)
@ KML ~/.julia/packages/KML/UtUHK/src/parsing.jl:46
[21] add_element!(o::KML.Placemark, child::XML.Node)
@ KML ~/.julia/packages/KML/UtUHK/src/parsing.jl:55
[22] object(node::XML.Node)
@ KML ~/.julia/packages/KML/UtUHK/src/parsing.jl:46
[23] add_element!(o::KML.Document, child::XML.Node)
@ KML ~/.julia/packages/KML/UtUHK/src/parsing.jl:55
[24] object(node::XML.Node)
@ KML ~/.julia/packages/KML/UtUHK/src/parsing.jl:46
[25] iterate
@ ./generator.jl:47 [inlined]
[26] _collect(c::Vector{XML.Node}, itr::Base.Generator{Vector{XML.Node}, typeof(KML.object)}, #unused#::Base.EltypeUnknown, isz::Base.HasShape{1})
@ Base ./array.jl:802
[27] collect_similar
@ ./array.jl:711 [inlined]
[28] map
@ ./abstractarray.jl:3261 [inlined]
[29] KML.KMLFile(doc::XML.Node)
@ KML ~/.julia/packages/KML/UtUHK/src/KML.jl:157
[30] read(filename::String, #unused#::Type{KML.KMLFile})
@ KML ~/.julia/packages/KML/UtUHK/src/KML.jl:153
[31] top-level scope
@ REPL[5]:1
The autosetfield! function in parsing.jl appears to assume newlines between coordinate tuples which is not the case here. The following change works for me and appears to still work with Points. It includes spaces in the split and has a check for a single coordinate case. Original commented out.
if sym == :coordinates
val = [Tuple(parse.(Float64, split(v, ','))) for v in split(x)]
if length(val) == 1
val = val[1]
end
# val = occursin('\n', x) ?
# [Tuple(parse.(Float64, split(s, ','))) for s in split(x, '\n')] :
# [Tuple(parse.(Float64, split(x, ',')))]
return setfield!(o, sym, val)
end
Have a look and let me know if this solution works out. Thank you
I'm having an issue with the toolbox. I'm on Julia 1.9, with the current KML.jl and I have created a Placemark (in annex) and when I try to open with the toolbox I have the following error:
ArgumentError: invalid index: nothing of type Nothing
Stacktrace:
[1] to_index(i::Nothing)
@ Base .\indices.jl:300
[2] to_index(A::Vector{UInt8}, i::Nothing)
@ Base .\indices.jl:277
[3] _to_indices1(A::Vector{UInt8}, inds::Tuple{Base.OneTo{Int64}}, I1::Nothing)
@ Base .\indices.jl:359
[4] to_indices
@ .\indices.jl:354 [inlined]
[5] to_indices
@ .\indices.jl:345 [inlined]
[6] getindex
@ .\abstractarray.jl:1294 [inlined]
[7] get_attributes(data::Vector{UInt8}, i::Int64, j::Int64)
@ XML C:\Users\dfsma.julia\packages\XML\SrduN\src\raw.jl:126
[8] attributes(o::XML.Raw)
@ XML C:\Users\dfsma.julia\packages\XML\SrduN\src\raw.jl:164
[9] getproperty
@ C:\Users\dfsma.julia\packages\XML\SrduN\src\XML.jl:55 [inlined]
[10] Node(node::LazyNode)
@ XML C:\Users\dfsma.julia\packages\XML\SrduN\src\XML.jl:126
[11] iterate(g::Base.Generator{Vector{LazyNode}, Type{Node}}, s::Int64)
@ Base .\generator.jl:47
[12] collect_to!(dest::Vector{Node}, itr::Base.Generator{Vector{LazyNode}, Type{Node}}, offs::Int64, st::Int64)
@ Base .\array.jl:840
[13] collect_to_with_first!(dest::Vector{Node}, v1::Node, itr::Base.Generator{Vector{LazyNode}, Type{Node}}, st::Int64)
@ Base .\array.jl:818
[14] _collect(c::Vector{LazyNode}, itr::Base.Generator{Vector{LazyNode}, Type{Node}}, #unused#::Base.EltypeUnknown, isz::Base.HasShape{1})
@ Base .\array.jl:812
[15] collect_similar(cont::Vector{LazyNode}, itr::Base.Generator{Vector{LazyNode}, Type{Node}})
@ Base .\array.jl:711
[16] map(f::Type, A::Vector{LazyNode})
@ Base .\abstractarray.jl:3261
[17] Node(node::LazyNode)
@ XML C:\Users\dfsma.julia\packages\XML\SrduN\src\XML.jl:128
[18] iterate(g::Base.Generator{Vector{LazyNode}, Type{Node}}, s::Int64)
@ Base .\generator.jl:47
[19] collect_to!(dest::Vector{Node}, itr::Base.Generator{Vector{LazyNode}, Type{Node}}, offs::Int64, st::Int64)
@ Base .\array.jl:840
[20] collect_to_with_first!(dest::Vector{Node}, v1::Node, itr::Base.Generator{Vector{LazyNode}, Type{Node}}, st::Int64)
@ Base .\array.jl:818
[21] _collect(c::Vector{LazyNode}, itr::Base.Generator{Vector{LazyNode}, Type{Node}}, #unused#::Base.EltypeUnknown, isz::Base.HasShape{1})
@ Base .\array.jl:812
[22] collect_similar(cont::Vector{LazyNode}, itr::Base.Generator{Vector{LazyNode}, Type{Node}})
@ Base .\array.jl:711
[23] map(f::Type, A::Vector{LazyNode})
@ Base .\abstractarray.jl:3261
[24] Node(node::LazyNode)
@ XML C:\Users\dfsma.julia\packages\XML\SrduN\src\XML.jl:128
[25] iterate(g::Base.Generator{Vector{LazyNode}, Type{Node}}, s::Int64)
@ Base .\generator.jl:47
[26] collect_to!(dest::Vector{Node}, itr::Base.Generator{Vector{LazyNode}, Type{Node}}, offs::Int64, st::Int64)
@ Base .\array.jl:840
[27] collect_to_with_first!(dest::Vector{Node}, v1::Node, itr::Base.Generator{Vector{LazyNode}, Type{Node}}, st::Int64)
@ Base .\array.jl:818
[28] _collect(c::Vector{LazyNode}, itr::Base.Generator{Vector{LazyNode}, Type{Node}}, #unused#::Base.EltypeUnknown, isz::Base.HasShape{1})
@ Base .\array.jl:812
[29] collect_similar(cont::Vector{LazyNode}, itr::Base.Generator{Vector{LazyNode}, Type{Node}})
@ Base .\array.jl:711
[30] map(f::Type, A::Vector{LazyNode})
@ Base .\abstractarray.jl:3261
[31] Node(node::LazyNode)
@ XML C:\Users\dfsma.julia\packages\XML\SrduN\src\XML.jl:128
[32] iterate(::Base.Generator{Vector{LazyNode}, Type{Node}})
@ Base .\generator.jl:47
[33] _collect(c::Vector{LazyNode}, itr::Base.Generator{Vector{LazyNode}, Type{Node}}, #unused#::Base.EltypeUnknown, isz::Base.HasShape{1})
@ Base .\array.jl:802
[34] collect_similar(cont::Vector{LazyNode}, itr::Base.Generator{Vector{LazyNode}, Type{Node}})
@ Base .\array.jl:711
[35] map(f::Type, A::Vector{LazyNode})
@ Base .\abstractarray.jl:3261
[36] Node(node::LazyNode)
@ XML C:\Users\dfsma.julia\packages\XML\SrduN\src\XML.jl:128
[37] iterate(g::Base.Generator{Vector{LazyNode}, Type{Node}}, s::Int64)
@ Base .\generator.jl:47
[38] collect_to!(dest::Vector{Node}, itr::Base.Generator{Vector{LazyNode}, Type{Node}}, offs::Int64, st::Int64)
@ Base .\array.jl:840
[39] collect_to_with_first!(dest::Vector{Node}, v1::Node, itr::Base.Generator{Vector{LazyNode}, Type{Node}}, st::Int64)
@ Base .\array.jl:818
[40] _collect(c::Vector{LazyNode}, itr::Base.Generator{Vector{LazyNode}, Type{Node}}, #unused#::Base.EltypeUnknown, isz::Base.HasShape{1})
@ Base .\array.jl:812
[41] collect_similar(cont::Vector{LazyNode}, itr::Base.Generator{Vector{LazyNode}, Type{Node}})
@ Base .\array.jl:711
[42] map(f::Type, A::Vector{LazyNode})
@ Base .\abstractarray.jl:3261
[43] Node(node::LazyNode)
@ XML C:\Users\dfsma.julia\packages\XML\SrduN\src\XML.jl:128
[44] Node
@ C:\Users\dfsma.julia\packages\XML\SrduN\src\XML.jl:121 [inlined]
[45] read(filename::String, #unused#::Type{Node})
@ XML C:\Users\dfsma.julia\packages\XML\SrduN\src\XML.jl:132
[46] top-level scope
@ REPL[75]:1
Hello, I've been using this package since 0.1.0 (thanks for the development!) but since 0.2.0 I can't define lines that are readable by Google Earth.
An example of an output is:
<kml xmlns="http://earth.google.com/kml/2.2">
<Document>
<Folder>
<name>Barreras</name>
<Placemark>
<name>Barrera-LT01</name>
<LineString>
<coordinates>-70.78367300816775, -34.415271246424886
-70.78358070922826, -34.415403734874154</coordinates>
</LineString>
</Placemark>
</Folder>
</Document>
</kml>
I suppose the coordinates
tags and lack of indentation could be causing the problem. The code for generating this is working as expected in 0.1.1 but not in 0.2.x (none of them).
Could you check, please? The code hasn't problems working but points, but there are issues with 2 or more coordinates in an element. If you need more information, tell me please.
Thanks in advance
Felipe
When writing a KML Document to a file, the XML header is generated in a wrong order leading to invalid XML files. The header is generated as <?xml encoding="UTF-8" version="1.0"?>
, however the specification says, that the order has to be <?xml version="1.0" encoding="UTF-8"?>
.
I assume this comes from the "attributes" being defined in a Dict
, which is unorderes as far as I understood.
Line 142 in 32bb3fe
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.