Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Infrastructure
iso19139.MERIDIAN
Commits
0c2fdc0c
Commit
0c2fdc0c
authored
Apr 11, 2019
by
Kim Mortimer
Browse files
Adding first elements of BoundingPolygon processing
parent
31e2732d
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/plugin/iso19139.MERIDIAN/index-fields/index.xsl
View file @
0c2fdc0c
...
...
@@ -611,7 +611,7 @@
</xsl:when>
<xsl:otherwise>
<geom>
<xsl:text>
{"type": "
p
olygon",
</xsl:text>
<xsl:text>
{"type": "
P
olygon",
</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>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment