I have a project where I want to make a map using GPS coordinates, and I want to convert the coordinates to XY values using Javascript, or at least sin and cos. So, my question is, how can I use sin and cos in xsl stylesheets. I am using Internet Explorer for the generator. So far it works fine.
My current stylesheet looks like this:
<?xml version="1.0"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://ift.tt/tCZ8VR"
xmlns:gpx="http://ift.tt/JMGbbd">
<!-- xmlns:msxsl="urn:schemas-microsoft-com:xslt" -->
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes" />
<xsl:variable name="midx" select="800" /> <!-- longitude -->
<xsl:variable name="midy" select="1100" /> <!-- latitude -->
<xsl:template name="longitude">
<xsl:param name="lon"/>
<xsl:param name="lat"/>
<!-- <xsl:value-of select="result:getResult(string(.))"/> -->
<xsl:value-of select="($lon - 42.881) * 100000"/>
</xsl:template>
<xsl:template name="latitude">
<xsl:param name="lon"/>
<xsl:param name="lat"/>
<xsl:value-of select="1700 - (($lat - 36.904) * 100000)"/>
</xsl:template>
<xsl:template match="/">
<xsl:apply-templates select="gpx:gpx"/>
</xsl:template>
<xsl:template match="gpx:gpx">
<html><body>
<svg xmlns="http://ift.tt/nvqhV5" width="100%" height="100%" >
<xsl:apply-templates select="gpx:trk"/>
<xsl:apply-templates select="gpx:wpt"/>
</svg>
</body></html>
</xsl:template>
<xsl:template match="gpx:wpt">
<circle stroke="black" stroke-width="3" fill="red" r="10">
<xsl:attribute name="cx">
<xsl:call-template name="longitude"><xsl:with-param name="lon" select="@lon"/><xsl:with-param name="lat" select="@lat"/></xsl:call-template>
<!-- <xsl:value-of select="(@lon - 42.881) * 100000"/> -->
</xsl:attribute>
<xsl:attribute name="cY">
<xsl:call-template name="latitude"><xsl:with-param name="lon" select="@lon"/><xsl:with-param name="lat" select="@lat"/></xsl:call-template>
<!-- <xsl:value-of select="1700 - ((@lat - 36.904) * 100000)"/> -->
</xsl:attribute>
</circle>
<text>
<xsl:attribute name="x">
<xsl:call-template name="longitude"><xsl:with-param name="lon" select="@lon"/><xsl:with-param name="lat" select="@lat"/></xsl:call-template>
</xsl:attribute>
<xsl:attribute name="y">
<xsl:call-template name="latitude"><xsl:with-param name="lon" select="@lon"/><xsl:with-param name="lat" select="@lat"/></xsl:call-template>
</xsl:attribute>
<xsl:value-of select="name" />
</text>
</xsl:template>
<xsl:template match="gpx:trk">
<xsl:apply-templates select="gpx:trkseg"/>
</xsl:template>
<xsl:template match="gpx:trkseg">
<polyline style="fill:none;stroke:black;stroke-width:1">
<xsl:attribute name="points">
<xsl:for-each select="gpx:trkpt">
<!-- <xsl:value-of select="(@lon - 42.881) * 100000"/>,<xsl:value-of select="1700 - ((@lat - 36.904) * 100000)"/> -->
<!-- <trkpt lat="36.91445553" lon="42.89106168"> -->
<xsl:call-template name="longitude"><xsl:with-param name="lon" select="@lon"/><xsl:with-param name="lat" select="@lat"/></xsl:call-template>
<xsl:text>,</xsl:text>
<xsl:call-template name="latitude"><xsl:with-param name="lon" select="@lon"/><xsl:with-param name="lat" select="@lat"/></xsl:call-template>
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:attribute>
</polyline>
</xsl:template>
</xsl:stylesheet>
No comments:
Post a Comment