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

simplify some code based on closed polygons

I was mistaken in thinking that GML would not have closed polygons - it apparently does. So all the special cases I have are unnecessary. Separator should be valid since we use xslt2
parent 35fba70c
......@@ -693,8 +693,6 @@
<xsl:for-each select="gml:exterior/gml:LinearRing/gml:pos">
<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-before(gml:exterior/gml:LinearRing/gml:pos[1], '\s'), ', ', substring-after(gml:exterior/gml:LinearRing/gml:pos[1], '\s'), ']')"/>
</xsl:when>
<xsl:when test="./gml:exterior/gml:LinearRing/gml:pointProperty">
<!--pretty much the same as the above except deeper inside
......@@ -702,25 +700,20 @@
<xsl:for-each select="gml:exterior/gml:LinearRing/gml:pointProperty/gml:Point/gml:pos">
<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-before(gml:exterior/gml:LinearRing/gml:pointProperty/gml:Point/gml:pos[1], '\s'), ', ', substring-after(gml:exterior/gml:LinearRing/gml:pointProperty/gml:Point/gml:pos[1], '\s'), ']')"/>
</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="tokenizedPos" as="xs:string*" select="tokenize(gml:exterior/gml:LinearRing/gml:posList, '\s')"/>
<xsl:value-of
select="
MER:ByTupleEncloseWithBracket($tokenizedPos)
substring(MER:ByTupleEncloseWithBracket($tokenizedPos),1,string-length(MER:ByTupleEncloseWithBracket($tokenizedPos))-1)
"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="concat('[', $tokenizedPos[1], ', ', $tokenizedPos[2], ']')"/>
</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:value-of select="concat('[', . , ']')" separator=","/>
</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 -->
......@@ -737,8 +730,6 @@
<xsl:for-each select="gml:LinearRing/gml:pos">
<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-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">
......@@ -748,8 +739,6 @@
<xsl:for-each select="gml:LinearRing/gml:pointProperty/gml:Point/gml:pos">
<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-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">
......@@ -758,10 +747,8 @@
<xsl:variable name="tokenizedPos" as="xs:string*" select="tokenize(gml:LinearRing/gml:posList, '\s')"/>
<xsl:value-of
select="
MER:ByTupleEncloseWithBracket($tokenizedPos)
substring(MER:ByTupleEncloseWithBracket($tokenizedPos),1,string-length(MER:ByTupleEncloseWithBracket($tokenizedPos))-1)
"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="concat('[', $tokenizedPos[1], ', ', $tokenizedPos[2], ']')"/>
<xsl:text>]</xsl:text>
</xsl:when>
<xsl:when test="./gml:LinearRing/gml:coordinates">
......@@ -769,9 +756,8 @@
[</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:value-of select="concat('[', . , ']')" separator=", "/>
</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>
......
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