Commit 0c2fdc0c authored by Kim Mortimer's avatar Kim Mortimer
Browse files

Adding first elements of BoundingPolygon processing

parent 31e2732d
......@@ -611,7 +611,7 @@
</xsl:when>
<xsl:otherwise>
<geom>
<xsl:text>{"type": "polygon",</xsl:text>
<xsl:text>{"type": "Polygon",</xsl:text>
<xsl:text>"coordinates": [</xsl:text>
<xsl:value-of select="concat('[', $w, ',', $s, ']')"/>
<xsl:text>,</xsl:text>
......@@ -638,6 +638,94 @@
<!--<xsl:value-of select="($e + $w) div 2"/>,<xsl:value-of select="($n + $s) div 2"/></field>-->
</xsl:for-each>
<xsl:for-each select=".//gmd:EX_BoundingPolygon/gmd:polygon/gml:Polygon">
<!-- if it's not in WGS 84 we can't convert to geoJson -->
<xsl:if test="@gml:srsName= 'WGS 84' or @gml:srsName = 'WGS84' or @gml:srsName = '' or not(@gml:srsName)">
<!-- if it's a polygon it has an exterior -->
<!-- initialize geoJson -->
<geom>
<xsl:text>{"type": "Polygon",</xsl:text>
<xsl:text>"coordinates": [
[</xsl:text>
<xsl:choose>
<!-- determine what type of coordinates are being used -->
<xsl:when test="./gml:exterior/gml:LinearRing/gml:pos">
<!-- read each position in the list -->
<!-- TODO: Figure out how to compute handedness of the polygon -->
<!-- also N.B. that a WGS 84 object is going to be in latitude, longitude but GeoJSON expects longitude, latitude -->
<!-- if it complains about separator we need to try an XSLT-1.0 implementation, I'm hopeful it might be 2.0 -->
<xsl:for-each select="gml:exterior/gml:LinearRing/gml:pos">
<xsl:value-of select="concat('[', substring-after(. ,' '), ', ', substring-before(., ' '), ']')" separator=","/>
</xsl:for-each>
</xsl:when>
<xsl:when test="./gml:exterior/gml:LinearRing/gml:pointProperty">
<!-- pretty much the same as the above except deeper inside -->
<!-- TODO: Figure out how to compute handedness of the polygon -->
<xsl:for-each select="gml:exterior/gml:LinearRing/gml:pointProperty/gml:Point/gml:pos">
<xsl:value-of select="concat('[', substring-after(. ,' '), ', ', substring-before(., ' '), ']')" separator=","/>
</xsl:for-each>
</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))"/>
</xsl:when>
<xsl:otherwise>
<!-- deprecated coordinates, pointRep - do nothing -->
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="./gml:interior">
<xsl:for-each select="gml:interior">
<xsl:choose>
<xsl:when test="./gml:LinearRing/gml:pos">
<xsl:text>],
[</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(. ,' '), ', ', substring-before(., ' '), ']')" separator=","/>
</xsl:for-each>
<xsl:text>]</xsl:text>
</xsl:when>
<xsl:when test="./gml:LinearRing/gml:pointProperty">
<xsl:text>],
[</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(. ,' '), ', ', substring-before(., ' '), ']')" separator=","/>
</xsl:for-each>
<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))"/>
<xsl:text>]</xsl:text>
</xsl:when>
<xsl:otherwise>
<!-- interior loops but deprecated - do nothing -->
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:text>]</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text>] }</xsl:text>
</geom>
</xsl:if>
</xsl:for-each>
<xsl:for-each select=".//gmd:EX_BoundingPolygon/gmd:polygon/gml:Point">
<geom>
<xsl:text>{"type": "Point",</xsl:text>
<xsl:text>"coordinates": </xsl:text>
<xsl:value-of select="concat('[', substring-after(. ,' '), ', ', substring-before(., ' '), ']')"/>
<xsl:text>}</xsl:text>
</geom>
</xsl:for-each>
</xsl:for-each>
......
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