Open Gys opened 1 week ago
I am using this struct now to read the file:
type Kml struct {
XMLName xml.Name `xml:"kml"`
Text string `xml:",chardata"`
Xmlns string `xml:"xmlns,attr"`
Gx string `xml:"gx,attr"`
Kml string `xml:"kml,attr"`
Atom string `xml:"atom,attr"`
Document struct {
Text string `xml:",chardata"`
Name struct {
Text string `xml:",chardata"`
} `xml:"name"`
StyleMap []struct {
Text string `xml:",chardata"`
ID string `xml:"id,attr"`
Pair []struct {
Text string `xml:",chardata"`
Key struct {
Text string `xml:",chardata"`
} `xml:"key"`
StyleUrl struct {
Text string `xml:",chardata"`
} `xml:"styleUrl"`
} `xml:"Pair"`
} `xml:"StyleMap"`
Style []struct {
Text string `xml:",chardata"`
ID string `xml:"id,attr"`
LineStyle struct {
Text string `xml:",chardata"`
Color struct {
Text string `xml:",chardata"`
} `xml:"color"`
Width struct {
Text string `xml:",chardata"`
} `xml:"width"`
} `xml:"LineStyle"`
BalloonStyle struct {
Chardata string `xml:",chardata"`
BgColor struct {
Text string `xml:",chardata"`
} `xml:"bgColor"`
Text struct {
Text string `xml:",chardata"`
} `xml:"text"`
} `xml:"BalloonStyle"`
IconStyle struct {
Text string `xml:",chardata"`
Icon struct {
Text string `xml:",chardata"`
Href struct {
Text string `xml:",chardata"`
} `xml:"href"`
} `xml:"Icon"`
} `xml:"IconStyle"`
} `xml:"Style"`
Folder []struct {
Text string `xml:",chardata"`
Name struct {
Text string `xml:",chardata"`
} `xml:"name"`
Open struct {
Text string `xml:",chardata"`
} `xml:"open"`
Folder []struct {
Text string `xml:",chardata"`
Name struct {
Text string `xml:",chardata"`
} `xml:"name"`
Placemark []struct {
Text string `xml:",chardata"`
Name struct {
Text string `xml:",chardata"`
} `xml:"name"`
Description struct {
Text string `xml:",chardata"`
} `xml:"description"`
StyleUrl struct {
Text string `xml:",chardata"`
} `xml:"styleUrl"`
MultiGeometry struct {
Text string `xml:",chardata"`
LineString struct {
Text string `xml:",chardata"`
Tessellate struct {
Text string `xml:",chardata"`
} `xml:"tessellate"`
Coordinates struct {
Text string `xml:",chardata"`
} `xml:"coordinates"`
} `xml:"LineString"`
} `xml:"MultiGeometry"`
BalloonVisibility struct {
Text string `xml:",chardata"`
} `xml:"balloonVisibility"`
Point struct {
Text string `xml:",chardata"`
Coordinates struct {
Text string `xml:",chardata"`
} `xml:"coordinates"`
} `xml:"Point"`
LineString struct {
Text string `xml:",chardata"`
Tessellate struct {
Text string `xml:",chardata"`
} `xml:"tessellate"`
Coordinates struct {
Text string `xml:",chardata"`
} `xml:"coordinates"`
} `xml:"LineString"`
} `xml:"Placemark"`
} `xml:"Folder"`
} `xml:"Folder"`
} `xml:"Document"`
}
Hi!
Indeed there do not seem to be many KML readers. Maybe because KML is formatted as XML which is (as a format) easy to parse.
I came across your reader while looking at a KML file with a little more complexity. I assume KML in the wild is more like this, also considering what the different KML writers are capable of. For example: https://pkg.go.dev/github.com/twpayne/go-kml/v3
Edit: I posted this because according to your reader this document is empty. But looking into your code I see your definition of KML is more extensive than I thought. Sorry for that. Still, the file below seems not to parse well with your code. The file imports into the mobile app Organic Maps without problems.