Great work Cybarber,
After a cursory glance through your KML conversion XSL, AFAICT the only time you need to do
dirty things in your XSL is when you are calculating "distCosineLaw". Javas Xalan (and other XSL engines) support the
EXSLT Extensions for maths and stuff. Which is also slightly dirty but it will enable your XSL to be used beyond MS IE.
WARNING: non XSL coders avert eyes now.
Adding
xmlns:math="http://exslt.org/math" to the stylesheet element will let you do add a template with something like:
Code:
<xsl:template name="distCosineLaw">
<xsl:param name="lo1" />
<xsl:param name="la1" />
<xsl:param name="lo2" />
<xsl:param name="la2" />
<xsl:variable name="R">6371000</xsl:variable>
<xsl:variable name="ratio">
<xsl:value-of select="(math:constant('PI',10)) div 180" />
</xsl:variable>
<xsl:variable name="lon1">
<xsl:value-of select="lo1 * $ratio" />
</xsl:variable>
<xsl:variable name="lat1">
<xsl:value-of select="la1 * $ratio" />
</xsl:variable>
<xsl:variable name="lon2">
<xsl:value-of select="lo2 * $ratio" />
</xsl:variable>
<xsl:variable name="lat2">
<xsl:value-of select="la2 * $ratio" />
</xsl:variable>
<xsl:value-of select="math:acos(math:sin($lat1) * math:sin($lat2) + math:cos($lat1) * math:cos($lat2) * math:cos($lon2 - $lon1)) * R" />
</xsl:template>
This could then be called using something like:
Code:
<xsl:variable name="distancedelta">
<xsl:call-template name="distCosineLaw">
<xsl:with-param name="lo1">
<xsl:value-of select="number(/gpx:gpx/gpx:wpt[$presib - 1]/@lon|/gpx10:gpx/gpx10:wpt[$presib - 1]/@lon)" />
</xsl:with-param>
<xsl:with-param name="la1">
<xsl:value-of select="number(/gpx:gpx/gpx:wpt[$presib - 1]/@lat|/gpx10:gpx/gpx10:wpt[$presib - 1]/@lat)" />
</xsl:with-param>
<xsl:with-param name="lo2">
<xsl:value-of select="number(/gpx:gpx/gpx:wpt[$presib]/@lon|/gpx10:gpx/gpx10:wpt[$presib - 1]/@lon)" />
</xsl:with-param>
<xsl:with-param name="la2">
<xsl:value-of select="number(/gpx:gpx/gpx:wpt[$presib]/@lat|/gpx10:gpx/gpx10:wpt[$presib - 1]/@lat)" />
</xsl:with-param>
</xsl:call-template>
</xsl:variable>
HTH
Mark