Commit 36a9571d authored by Kim Mortimer's avatar Kim Mortimer
Browse files

Points not handled correctly

parent b642bcec
......@@ -34,8 +34,8 @@
xmlns:dwc="http://rs.tdwg.org/dwc/terms/"
xmlns:dwr="http://rs.tdwg.org/dwc/dwcrecord/"
xmlns:geonet="http://www.fao.org/geonetwork"
xmlns:gml="http://www.opengis.net/gml/3.2"
xmlns:MER="https://meridian.cs.dal.ca/"
xmlns:gml="http://www.opengis.net/gml/3.2"
xmlns:MER="https://meridian.cs.dal.ca/"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:daobs="http://daobs.org"
xmlns:saxon="http://saxon.sf.net/"
......@@ -135,9 +135,9 @@
To reduce the risk that our Discovery layer reads in 'citations' from things that are not actually citations,
I use a check for a controlled leading string that would be unlikely to be present in other records. -->
<document>
<xsl:if test="./gmd:identificationInfo/MER:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:otherCitationDetails/gco:CharacterString[starts-with(text(),'MERIDIAN-CITE-AS: ')]">
<xsl:value-of select="./gmd:identificationInfo/MER:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:otherCitationDetails/gco:CharacterString"/>
</xsl:if>
<xsl:if test="./gmd:identificationInfo/MER:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:otherCitationDetails/gco:CharacterString[starts-with(text(),'MERIDIAN-CITE-AS: ')]">
<xsl:value-of select="./gmd:identificationInfo/MER:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:otherCitationDetails/gco:CharacterString"/>
</xsl:if>
</document>
<uuid>
<xsl:value-of select="$identifier"/>
......@@ -646,23 +646,25 @@
<!--<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="contains(@srsName, 'WGS 84') or contains(@srsName, 'WGS84') or contains(@srsName, '') or contains(@srsName, '/4326') or not(@gml:srsName)">
<!-- if it's a polygon it has an exterior -->
<!-- initialize geoJson -->
<xsl:if test="ends-with(@srsName, '84') or ends-with(@srsName, '4326') or not(@srsName)">
<!-- if it's not in WGS 84 we can't convert to geoJson
if it's a polygon it has an exterior
initialize geoJson
<geojson>
<xsl:text>{"type": "Polygon",</xsl:text>
<xsl:text>"coordinates": [
[</xsl:text>
<xsl:choose>
<!-- determine what type of coordinates are being used -->
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 -->
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(. ,'\s'), ', ', substring-before(., '\s'), ']')" separator=","/>
</xsl:for-each>
......@@ -670,8 +672,8 @@
<xsl:value-of select="concat('[', substring-after(gml:exterior/gml:LinearRing/gml:pos[1], '\s'), ', ', substring-before(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 -->
<!-- TODO: Figure out how to compute handedness of the polygon -->
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(. ,'\s'), ', ', substring-before(., '\s'), ']')" separator=","/>
</xsl:for-each>
......@@ -679,12 +681,12 @@
<xsl:value-of select="concat('[', substring-after(gml:exterior/gml:LinearRing/gml:pointProperty/gml:Point/gml:pos[1], '\s'), ', ', substring-before(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 -->
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:when>
<xsl:otherwise>
<!-- deprecated coordinates, pointRep - do nothing -->
deprecated coordinates, pointRep - do nothing
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
......@@ -694,7 +696,7 @@
<xsl:when test="./gml:LinearRing/gml:pos">
<xsl:text>],
[</xsl:text>
<!-- TODO: Figure out how to compute handedness of the polygon -->
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:for-each>
......@@ -705,7 +707,7 @@
<xsl:when test="./gml:LinearRing/gml:pointProperty">
<xsl:text>],
[</xsl:text>
<!-- TODO: Figure out how to compute handedness of the polygon -->
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:for-each>
......@@ -720,7 +722,7 @@
<xsl:text>]</xsl:text>
</xsl:when>
<xsl:otherwise>
<!-- interior loops but deprecated - do nothing -->
interior loops but deprecated - do nothing
</xsl:otherwise>
</xsl:choose>
......@@ -731,17 +733,20 @@
</xsl:otherwise>
</xsl:choose>
<xsl:text>] }</xsl:text>
</geojson>
</xsl:if>
</geojson>-->
</xsl:if>
</xsl:for-each>
<xsl:for-each select=".//gmd:EX_BoundingPolygon/gmd:polygon/gml:Point">
<xsl:if test="ends-with(@srsName, '84') or ends-with(@srsName, '4326') or not(@srsName)">
<geojson>
<xsl:text>{"type": "Point",</xsl:text>
<xsl:text>"coordinates": </xsl:text>
<xsl:value-of select="concat('[', substring-after(. ,'\s'), ', ', substring-before(., '\s'), ']')"/>
<xsl:value-of select="concat('[', substring-before(. ,' '), ', ', substring-after(., ' '), ']')"/>
<xsl:text>}</xsl:text>
</geojson>
</xsl:if>
</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