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
e8bb004f
Commit
e8bb004f
authored
Sep 27, 2019
by
Kim Mortimer
Browse files
Polygons!
parent
9299bc6a
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/plugin/iso19139.MERIDIAN/index-fields/index.xsl
View file @
e8bb004f
...
...
@@ -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>
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