Skip to content

More complexity #1

Description

@Gys

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.

<?xml version='1.0' encoding='UTF-8'?>
<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'>
<Document>

	<name>Jacobswegen-wandelaars-ES-20240724</name>

	<!-- ======= Start Styles Routes ======= -->
	<StyleMap id="msn_Hoofdroute1">
		<Pair>
			<key>normal</key>
			<styleUrl>#sn_Hoofdroute1</styleUrl>
		</Pair>
		<Pair>
			<key>highlight</key>
			<styleUrl>#sh_Hoofdroute1</styleUrl>
		</Pair>
	</StyleMap>
	<Style id="sn_Hoofdroute1">
		<LineStyle>
			<color>ff00ffff</color>
			<width>4</width>
		</LineStyle>
		<BalloonStyle>
              <bgColor>004a88d4</bgColor>
              <text>
                <![CDATA[
                <b><font color="#BB0000" size="+1">$[name]</font></b>
                <br><br>
                <font face="Arial">$[description]</font>
                <!--$[geDirections]-->
                ]]>
              </text>
        </BalloonStyle>
	</Style>
	<Style id="sh_Hoofdroute1">
		<LineStyle>
			<color>ff00ffaa</color>
			<width>6</width>
		</LineStyle>
		<BalloonStyle>
              <bgColor>004a88d4</bgColor>
              <text>
                <![CDATA[
                <b><font color="#BB0000" size="+1">$[name]</font></b>
                <br><br>
                <font face="Arial">$[description]</font>
                <!--$[geDirections]-->
                ]]>
              </text>
        </BalloonStyle>
	</Style>

	<StyleMap id="msn_Hoofdroute2">
		<Pair>
			<key>normal</key>
			<styleUrl>#sn_Hoofdroute2</styleUrl>
		</Pair>
		<Pair>
			<key>highlight</key>
			<styleUrl>#sh_Hoofdroute2</styleUrl>
		</Pair>
	</StyleMap>
	<Style id="sn_Hoofdroute2">
		<LineStyle>
			<color>ff1c19d7</color>>
			<width>4</width>
		</LineStyle>
		<BalloonStyle>
              <bgColor>004a88d4</bgColor>
              <text>
                <![CDATA[
                <b><font color="#BB0000" size="+1">$[name]</font></b>
                <br><br>
                <font face="Arial">$[description]</font>
                <!--$[geDirections]-->
                ]]>
              </text>
        </BalloonStyle>
	</Style>
	<Style id="sh_Hoofdroute2">
		<LineStyle>
			<color>ff00ffaa</color>
			<width>6</width>
		</LineStyle>
		<BalloonStyle>
              <bgColor>004a88d4</bgColor>
              <text>
                <![CDATA[
                <b><font color="#BB0000" size="+1">$[name]</font></b>
                <br><br>
                <font face="Arial">$[description]</font>
                <!--$[geDirections]-->
                ]]>
              </text>
        </BalloonStyle>
	</Style>

	<StyleMap id="msn_Hoofdroute3">
		<Pair>
			<key>normal</key>
			<styleUrl>#sn_Hoofdroute3</styleUrl>
		</Pair>
		<Pair>
			<key>highlight</key>
			<styleUrl>#sh_Hoofdroute3</styleUrl>
		</Pair>
	</StyleMap>

	<Style id="sn_Hoofdroute3">
		<LineStyle>
			<color>ff0055ff</color>>
			<width>4</width>
		</LineStyle>
		<BalloonStyle>
              <bgColor>004a88d4</bgColor>
              <text>
                <![CDATA[
                <b><font color="#BB0000" size="+1">$[name]</font></b>
                <br><br>
                <font face="Arial">$[description]</font>
                <!--$[geDirections]-->
                ]]>
              </text>
        </BalloonStyle>
	</Style>
	<Style id="sh_Hoofdroute3">
		<LineStyle>
			<color>ff00ffaa</color>
			<width>6</width>
		</LineStyle>
		<BalloonStyle>
              <bgColor>004a88d4</bgColor>
              <text>
                <![CDATA[
                <b><font color="#BB0000" size="+1">$[name]</font></b>
                <br><br>
                <font face="Arial">$[description]</font>
                <!--$[geDirections]-->
                ]]>
              </text>
        </BalloonStyle>
	</Style>

	<StyleMap id="msn_Hoofdroute4">
		<Pair>
			<key>normal</key>
			<styleUrl>#sn_Hoofdroute4</styleUrl>
		</Pair>
		<Pair>
			<key>highlight</key>
			<styleUrl>#sh_Hoofdroute4</styleUrl>
		</Pair>
	</StyleMap>

	<Style id="sn_Hoofdroute4">
		<LineStyle>
			<color>ff701919</color>>
			<width>4</width>
		</LineStyle>
		<BalloonStyle>
              <bgColor>004a88d4</bgColor>
              <text>
                <![CDATA[
                <b><font color="#BB0000" size="+1">$[name]</font></b>
                <br><br>
                <font face="Arial">$[description]</font>
                <!--$[geDirections]-->
                ]]>
              </text>
        </BalloonStyle>
	</Style>
	<Style id="sh_Hoofdroute4">
		<LineStyle>
			<color>ff00ffaa</color>
			<width>6</width>
		</LineStyle>
		<BalloonStyle>
              <bgColor>004a88d4</bgColor>
              <text>
                <![CDATA[
                <b><font color="#BB0000" size="+1">$[name]</font></b>
                <br><br>
                <font face="Arial">$[description]</font>
                <!--$[geDirections]-->
                ]]>
              </text>
        </BalloonStyle>
	</Style>

	<StyleMap id="msn_Link">
		<Pair>
			<key>normal</key>
			<styleUrl>#sn_Link</styleUrl>
		</Pair>
		<Pair>
			<key>highlight</key>
			<styleUrl>#sh_Link</styleUrl>
		</Pair>
	</StyleMap>
	<Style id="sn_Link">
		<LineStyle>
			<color>ffb67b2c</color>>
			<width>4</width>
		</LineStyle>
		<BalloonStyle>
              <bgColor>004A88D4</bgColor>
              <text>
                <![CDATA[
                <b><font color="#BB0000" size="+1">$[name]</font></b>
                <br><br>
                <font face="Arial">$[description]</font>
                <!--$[geDirections]-->
                ]]>
              </text>
        </BalloonStyle>
	</Style>
	<Style id="sh_Link">
		<LineStyle>
			<color>ff00ffaa</color>
			<width>6</width>
		</LineStyle>
		<BalloonStyle>
              <bgColor>004A88D4</bgColor>
              <text>
                <![CDATA[
                <b><font color="#BB0000" size="+1">$[name]</font></b>
                <br><br>
                <font face="Arial">$[description]</font>
                <!--$[geDirections]-->
                ]]>
              </text>
        </BalloonStyle>
	</Style>

	<StyleMap id="msn_Variant">
		<Pair>
			<key>normal</key>
			<styleUrl>#sn_Variant</styleUrl>
		</Pair>
		<Pair>
			<key>highlight</key>
			<styleUrl>#sh_Variant</styleUrl>
		</Pair>
	</StyleMap>
	<Style id="sn_Variant">
		<LineStyle>
			<color>ffff00ff</color>>
			<width>4</width>
		</LineStyle>
		<BalloonStyle>
              <bgColor>004a88d4</bgColor>
              <text>
                <![CDATA[
                <b><font color="#BB0000" size="+1">$[name]</font></b>
                <br><br>
                <font face="Arial">$[description]</font>
                <!--$[geDirections]-->
                ]]>
              </text>
        </BalloonStyle>
	</Style>
	<Style id="sh_Variant">
		<LineStyle>
			<color>ff00ffaa</color>
			<width>6</width>
		</LineStyle>
		<BalloonStyle>
              <bgColor>004a88d4</bgColor>
              <text>
                <![CDATA[
                <b><font color="#BB0000" size="+1">$[name]</font></b>
                <br><br>
                <font face="Arial">$[description]</font>
                <!--$[geDirections]-->
                ]]>
              </text>
        </BalloonStyle>
	</Style>

	<StyleMap id="msn_NietInGebruik">
		<Pair>
			<key>normal</key>
			<styleUrl>#sn_NietInGebruik</styleUrl>
		</Pair>
		<Pair>
			<key>highlight</key>
			<styleUrl>#sh_NietInGebruik</styleUrl>
		</Pair>
	</StyleMap>
	<Style id="sn_NietInGebruik">
		<LineStyle>
			<color>ff294c75</color>>
			<width>4</width>
		</LineStyle>
		<BalloonStyle>
              <bgColor>004a88d4</bgColor>
              <text>
                <![CDATA[
                <b><font color="#BB0000" size="+1">$[name]</font></b>
                <br><br>
                <font face="Arial">$[description]</font>
                <!--$[geDirections]-->
                ]]>
              </text>
        </BalloonStyle>
	</Style>
	<Style id="sh_NietInGebruik">
		<LineStyle>
			<color>ff00ffaa</color>
			<width>6</width>
		</LineStyle>
		<BalloonStyle>
              <bgColor>004a88d4</bgColor>
              <text>
                <![CDATA[
                <b><font color="#BB0000" size="+1">$[name]</font></b>
                <br><br>
                <font face="Arial">$[description]</font>
                <!--$[geDirections]-->
                ]]>
              </text>
        </BalloonStyle>
	</Style>

	<Style id="placemark-yellow">
		<IconStyle>
			<Icon>
				<href>https://omaps.app/placemarks/placemark-yellow.png</href>
			</Icon>
		</IconStyle>
	</Style>

	<!-- ======= End Styles Routes ======= -->

	<!-- ======= Start Main Folder Spanje ======= -->
	<Folder>
		<name>Jacobswegen in Spanje</name>
		<open>1</open>

		<!-- ======= Start Hoofdroutes Spanje ======= -->
		<Folder>
			<name>Routes</name>

			<Placemark>
				<name>Camino Frances</name>
				<description>
					<![CDATA[Saint Jean Pied de Port - Santiago de Compostela: 761 km<br><br><a href="www.santiago.nl/downloads">Bron</a><br><a href="https://www.santiago.nl/product-categorie/gidsen/gidsen-spanje/">Diverse gidsen</a>]]>
				</description>
				<styleUrl>#msn_Hoofdroute1</styleUrl>
				<MultiGeometry>
					<LineString>
						<tessellate>1</tessellate>
						<coordinates>
							-1.23585,43.16339,191 -1.23641,43.1631,186 -1.23697,43.16281,178 -1.23721,43.16239,171 -1.23745,43.16197,171 ....

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions