Commit e8bb004f authored by Kim Mortimer's avatar Kim Mortimer
Browse files

Polygons!

parent 9299bc6a
......@@ -694,13 +694,28 @@
</xsl:when>
<xsl:when test="./gml:exterior/gml:LinearRing/gml:posList">
<!--This is an unbroken list of coordinates so there is only one value to get -->
<xsl:variable name="temp" as="xs:string*" select="tokenize(gml:exterior/gml:LinearRing/gml:posList, '\s')"/>
<xsl:variable name="tokenizedPos" as="xs:string*" select="tokenize(gml:exterior/gml:LinearRing/gml:posList, '\s')"/>
<xsl:template name="fixListExt">
<xsl:value-of
select="
ByTupleEncloseWithBracket($tokenizedPos)
"/>
</xsl:template>
<xsl:text>,</xsl:text>
<xsl:value-of select="concat('[', $tokenizedPos[1], '\s'), ', ', $tokenizedPos[2], '\s'), ']')"/>
</xsl:when>
<xsl:when test="./gml:LinearRing/gml:coordinates">
<xsl:variable name="tokenizedCoord" as="xs:string*" select="tokenize(gml:LinearRing/gml:coordinates, '\s')"/>
<xsl:for-each select="tokenizedCoord">
<xsl:value-of select="concat('[', . , '],')"/>
</xsl:for-each>
<xsl:value-of select="concat('[', substring-before(tokenizedCoord[1], '\s'), ', ', substring-after(tokenizedCoord[1], '\s'), ']')"/>
</xsl:when>
<xsl:otherwise>
<!-- insert new function here to handle coordinates, but posRep shouldn't work -->
</xsl:otherwise>
</xsl:choose>
<!--<xsl:choose>
<xsl:choose>
<xsl:when test="./gml:interior">
<xsl:for-each select="gml:interior">
<xsl:choose>
......@@ -709,10 +724,10 @@
[</xsl:text>
TODO: Figure out how to compute handedness of the polygon
<xsl:for-each select="gml:LinearRing/gml:pos">
<xsl:value-of select="concat('[', substring-after(. ,'\s'), ', ', substring-before(., '\s'), ']')" separator=","/>
<xsl:value-of select="concat('[', substring-before(. ,'\s'), ', ', substring-after(., '\s'), ']')" separator=","/>
</xsl:for-each>
<xsl:text>,</xsl:text>
<xsl:value-of select="concat('[', substring-after(gml:LinearRing/gml:pos[1], '\s'), ', ', substring-before(gml:LinearRing/gml:pos[1], '\s'), ']')"/>
<xsl:value-of select="concat('[', substring-before(gml:LinearRing/gml:pos[1], '\s'), ', ', substring-after(gml:LinearRing/gml:pos[1], '\s'), ']')"/>
<xsl:text>]</xsl:text>
</xsl:when>
<xsl:when test="./gml:LinearRing/gml:pointProperty">
......@@ -720,29 +735,47 @@
[</xsl:text>
TODO: Figure out how to compute handedness of the polygon
<xsl:for-each select="gml:LinearRing/gml:pointProperty/gml:Point/gml:pos">
<xsl:value-of select="concat('[', substring-after(. ,'\s'), ', ', substring-before(., '\s'), ']')" separator=","/>
<xsl:value-of select="concat('[', substring-before(. ,'\s'), ', ', substring-after(., '\s'), ']')" separator=","/>
</xsl:for-each>
<xsl:text>,</xsl:text>
<xsl:value-of select="concat('[', substring-after(gml:LinearRing/gml:pointProperty/gml:Point/gml:pos[1], '\s'), ', ', substring-before(gml:LinearRing/gml:pointProperty/gml:Point/gml:pos[1], '\s'), ']')"/>
<xsl:value-of select="concat('[', substring-before(gml:LinearRing/gml:pointProperty/gml:Point/gml:pos[1], '\s'), ', ', substring-after(gml:LinearRing/gml:pointProperty/gml:Point/gml:pos[1], '\s'), ']')"/>
<xsl:text>]</xsl:text>
</xsl:when>
<xsl:when test="./gml:LinearRing/gml:posList">
<xsl:text>],
[</xsl:text>
<xsl:variable name="temp" as="xs:string*" select="tokenize(gml:LinearRing/gml:posList, '\s')"/>
<xsl:variable name="tokenizedPos" as="xs:string*" select="tokenize(gml:LinearRing/gml:posList, '\s')"/>
<xsl:template name="fixListInt">
<xsl:value-of
select="
ByTupleEncloseWithBracket($tokenizedPos)
"/>
</xsl:template>
<xsl:text>,</xsl:text>
<xsl:value-of select="concat('[', $tokenizedPos[1], '\s'), ', ', $tokenizedPos[2], '\s'), ']')"/>
<xsl:text>]</xsl:text>
</xsl:when>
<xsl:when test="./gml:LinearRing/gml:coordinates">
<xsl:text>],
[</xsl:text>
<xsl:variable name="tokenizedCoord" as="xs:string*" select="tokenize(gml:LinearRing/gml:coordinates, '\s')"/>
<xsl:for-each select="tokenizedCoord">
<xsl:value-of select="concat('[', . , '],')"/>
</xsl:for-each>
<xsl:value-of select="concat('[', substring-before(tokenizedCoord[1], '\s'), ', ', substring-after(tokenizedCoord[1], '\s'), ']')"/>
<xsl:text>]</xsl:text>
</xsl:when>
<xsl:otherwise>
interior loops but deprecated - do nothing
<!-- interior loops but deprecated - do nothing -->
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>-->
<xsl:otherwise>
<xsl:text>]</xsl:text>
<!--</xsl:otherwise>
</xsl:choose>-->
</xsl:otherwise>
</xsl:choose>
<xsl:text>] }</xsl:text>
</geojson>
<!-- how to determine the average location of a poylgon? -->
......@@ -1130,4 +1163,17 @@
</xsl:otherwise>
</xsl:choose>-->
</xsl:template>
<xsl:function name="ByTupleEncloseWithBracket">
<xsl:param name="items"/>
<xsl:sequence
select="if (empty($items))
then ()
else (encloseWithBracket(($items[1],$items[2])),
ByTupleEncloseWithBracket($items[position()>2]) )"
/>
</xsl:function>
<xsl:function name="encloseWithBracket">
<xsl:param name="items"/>
<xsl:value-of select="concat('[',string-join($items,','),']')"/>
</xsl:function>
</xsl:stylesheet>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment