diff options
author | Mathias Mayrhofer <mtmayr@mtmayr.com> | 2020-02-23 13:09:14 +0100 |
---|---|---|
committer | Mathias Mayrhofer <mtmayr@mtmayr.com> | 2020-02-23 13:09:14 +0100 |
commit | ae0b9a9782c7b781e688191018a66d5c1554437a (patch) | |
tree | e29a5928ed5c19c73b1f9f908cc2730cc1c8683f /kml/convert_xml_kml.xsl | |
parent | 21ed8cf5c8dc2fe6353a5065016a0e781ca4e126 (diff) |
Implementing KML export for GoogleEarth
Diffstat (limited to 'kml/convert_xml_kml.xsl')
-rw-r--r-- | kml/convert_xml_kml.xsl | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/kml/convert_xml_kml.xsl b/kml/convert_xml_kml.xsl new file mode 100644 index 0000000..3217143 --- /dev/null +++ b/kml/convert_xml_kml.xsl @@ -0,0 +1,142 @@ +<?xml version='1.0' encoding='UTF-8'?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> + +<xsl:template match="root"> + <kml xmlns="http://www.opengis.net/kml/2.2"> + <Document> + <name>Funkfeuer Graz</name> + <Style id="ffstyle_offline"> + <IconStyle id="myicon"> + <color>a0ffffff</color> + <scale>0.5</scale> + <Icon><href>https://juwelierkassa.at/dots/dot_red.png</href></Icon> + <hotSpot x="0.5" y="0.5" xunits="fraction" yunits="fraction"/> + </IconStyle> + <LabelStyle id="mylab"> + <color>a000ffff</color> + <scale>0.8</scale> + </LabelStyle> + </Style> + <Style id="ffstyle_online"> + <IconStyle id="myicon"> + <color>f0ffffff</color> + <scale>0.5</scale> + <Icon><href>https://juwelierkassa.at/dots/dot_green.png</href></Icon> + <hotSpot x="0.5" y="0.5" xunits="fraction" yunits="fraction"/> + </IconStyle> + <LabelStyle id="mylab"> + <color>f000ffff</color> + <scale>0.9</scale> + </LabelStyle> + </Style> + <Style id="ffstyle_link"> + <LabelStyle id="mylab_link"> + <color>f099ffff</color> + <scale>0.9</scale> + </LabelStyle> + <LineStyle> + <color>7099ff00</color> + <width>1</width> + </LineStyle> + <PolyStyle> + <color>70eeff00</color> + <colorMode>normal</colorMode> + <fill>1</fill> + </PolyStyle> + </Style> + <Style id="ffstyle_vpn"> + <LabelStyle id="mylab_vpn"> + <color>f0ff99ff</color> + <scale>0.9</scale> + </LabelStyle> + <LineStyle> + <color>709900ff</color> + <width>1</width> + </LineStyle> + <PolyStyle> + <color>70ee00ff</color> + <colorMode>normal</colorMode> + <fill>1</fill> + </PolyStyle> + </Style> + <xsl:apply-templates select="nodes"/> + <xsl:apply-templates select="links"/> + </Document> + </kml> +</xsl:template> + +<xsl:template match="nodes"> + <Folder> + <name>Online</name> + <visibility>1</visibility> + <xsl:apply-templates select="node" mode="online"/> + </Folder> + <Folder> + <name>Offline</name> + <visibility>0</visibility> + <xsl:apply-templates select="node" mode="offline"/> + </Folder> +</xsl:template> + +<xsl:template match="links"> + <Folder> + <name>Links</name> + <visibility>1</visibility> + <xsl:apply-templates select="link" mode="links"/> + </Folder> +</xsl:template> + +<xsl:template match="node" mode="online"> + <xsl:if test="@state='online' or @state='tunnel'"> + <Placemark id="{@id}"> + <name><xsl:value-of select="@name"/></name> + <description><br><xsl:value-of select="@gallery_link"/></br><br><xsl:value-of select="@router_links"/></br><br>#<xsl:value-of select="@id"/> = <xsl:value-of select="@state"/></br></description> + <styleUrl>#ffstyle_online</styleUrl> + <Point> + <extrude>1</extrude> + <altitudeMode>relativeToGround</altitudeMode> + <coordinates> + <xsl:value-of select="@lng"/>,<xsl:value-of select="@lat"/>,60 + </coordinates> + </Point> + </Placemark> + </xsl:if> +</xsl:template> + +<xsl:template match="node" mode="offline"> + <xsl:if test="@state='offline'"> + <Placemark id="{@id}"> + <name><xsl:value-of select="@name"/></name> + <description><br><xsl:value-of select="@gallery_link"/></br><br><xsl:value-of select="@router_links"/></br><br>#<xsl:value-of select="@id"/> = <xsl:value-of select="@state"/></br></description> + <visibility>0</visibility> + <styleUrl>#ffstyle_offline</styleUrl> + <Point> + <extrude>1</extrude> + <altitudeMode>relativeToGround</altitudeMode> + <coordinates> + <xsl:value-of select="@lng"/>,<xsl:value-of select="@lat"/>,60 + </coordinates> + </Point> + </Placemark> + </xsl:if> +</xsl:template> + +<xsl:template match="link" mode="links"> + <Placemark id="{@id}"> + <name><xsl:value-of select="@from"/> - <xsl:value-of select="@to"/> [<xsl:value-of select="@value"/>]</name> + <styleUrl> + <xsl:choose><xsl:when test="@value='-1'">#ffstyle_vpn</xsl:when><xsl:otherwise>#ffstyle_link</xsl:otherwise></xsl:choose> + </styleUrl> + <LineString> + <extrude>1</extrude> + <tessellate>1</tessellate> + <altitudeMode>relativeToGround</altitudeMode> + <coordinates> + <xsl:value-of select="@lngfrom"/>,<xsl:value-of select="@latfrom"/>,50 + <xsl:value-of select="@lngto"/>,<xsl:value-of select="@latto"/>,50 + </coordinates> + </LineString> + </Placemark> +</xsl:template> + +</xsl:stylesheet> |