Skip to content

Commit 3db93bb

Browse files
committed
fix parsing for KML file that has tag that's not in the official KML spec. Add test for it. Bump version
1 parent 188db06 commit 3db93bb

File tree

4 files changed

+86
-3
lines changed

4 files changed

+86
-3
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "KML"
22
uuid = "1284bf3a-1e3d-4f4e-a7a9-b9d235a28f35"
33
authors = ["Josh Day <[email protected]> and contributors"]
4-
version = "0.2.0"
4+
version = "0.2.1"
55

66
[deps]
77
GeoInterface = "cf35fbd7-0cd7-5166-be24-54bfbe79505f"
@@ -12,7 +12,7 @@ XML = "72c71f33-b9b6-44de-8c94-c961784809e2"
1212
[compat]
1313
GeoInterface = "1"
1414
OrderedCollections = "1"
15-
XML = "0.2.1"
15+
XML = "0.2.2"
1616
julia = "1"
1717

1818
[extras]

src/parsing.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function add_element!(o::Union{Object,KMLElement}, child::Node)
6666
elseif hasfield(typeof(o), sym) && XML.is_simple(child)
6767
autosetfield!(o, sym, XML.value(only(child)))
6868
else
69-
error("Not possible: $o with child $child")
69+
@warn "Unhandled case encountered while trying to add child with tag `$sym` to parent `$o`."
7070
end
7171

7272
@label child_is_object

test/outside_spec.kml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
3+
<Document>
4+
<name>Projeto sem título</name>
5+
<gx:CascadingStyle kml:id="__managed_style_0B291C52A029C66B9D3A">
6+
<Style>
7+
<IconStyle>
8+
<scale>1.2</scale>
9+
<Icon>
10+
<href>https://earth.google.com/earth/rpc/cc/icon?color=1976d2&amp;id=2000&amp;scale=4</href>
11+
</Icon>
12+
<hotSpot x="64" y="128" xunits="pixels" yunits="insetPixels"/>
13+
</IconStyle>
14+
<LabelStyle>
15+
</LabelStyle>
16+
<LineStyle>
17+
<color>ff2dc0fb</color>
18+
<width>4.8</width>
19+
</LineStyle>
20+
<PolyStyle>
21+
<color>40ffffff</color>
22+
</PolyStyle>
23+
<BalloonStyle>
24+
<displayMode>hide</displayMode>
25+
</BalloonStyle>
26+
</Style>
27+
</gx:CascadingStyle>
28+
<gx:CascadingStyle kml:id="__managed_style_11AFF9711829C66B9D39">
29+
<Style>
30+
<IconStyle>
31+
<Icon>
32+
<href>https://earth.google.com/earth/rpc/cc/icon?color=1976d2&amp;id=2000&amp;scale=4</href>
33+
</Icon>
34+
<hotSpot x="64" y="128" xunits="pixels" yunits="insetPixels"/>
35+
</IconStyle>
36+
<LabelStyle>
37+
</LabelStyle>
38+
<LineStyle>
39+
<color>ff2dc0fb</color>
40+
<width>3.2</width>
41+
</LineStyle>
42+
<PolyStyle>
43+
<color>40ffffff</color>
44+
</PolyStyle>
45+
<BalloonStyle>
46+
<displayMode>hide</displayMode>
47+
</BalloonStyle>
48+
</Style>
49+
</gx:CascadingStyle>
50+
<StyleMap id="__managed_style_00254AB49929C66B9D39">
51+
<Pair>
52+
<key>normal</key>
53+
<styleUrl>#__managed_style_11AFF9711829C66B9D39</styleUrl>
54+
</Pair>
55+
<Pair>
56+
<key>highlight</key>
57+
<styleUrl>#__managed_style_0B291C52A029C66B9D3A</styleUrl>
58+
</Pair>
59+
</StyleMap>
60+
<Placemark id="071A4A8B4B29C66B9D31">
61+
<name>Paris</name>
62+
<LookAt>
63+
<longitude>2.35305860314984</longitude>
64+
<latitude>48.85888950685469</latitude>
65+
<altitude>48.6490130605162</altitude>
66+
<heading>0</heading>
67+
<tilt>0</tilt>
68+
<gx:fovy>35</gx:fovy>
69+
<range>1171.460583500157</range>
70+
<altitudeMode>absolute</altitudeMode>
71+
</LookAt>
72+
<styleUrl>#__managed_style_00254AB49929C66B9D39</styleUrl>
73+
<Point>
74+
<coordinates>2.3522452888908,48.86064210524571,77.02254166273858</coordinates>
75+
</Point>
76+
</Placemark>
77+
</Document>
78+
</kml>

test/runtests.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,8 @@ end
4747
file2 = read(temp, KMLFile)
4848
@test file == file2
4949
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)