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
51aa25ac
Commit
51aa25ac
authored
Oct 02, 2019
by
Kim Mortimer
Browse files
Extending bounding box to handle multipolygon
parent
523717c4
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/plugin/iso19139.MERIDIAN/index-fields/index.xsl
View file @
51aa25ac
...
...
@@ -669,83 +669,125 @@
</xsl:for-each>
<!-- TODO: index bounding polygon -->
<xsl:for-each
select=
".//gmd:EX_GeographicBoundingBox[
./gmd:westBoundLongitude/gco:Decimal castable as xs:decimal and
./gmd:eastBoundLongitude/gco:Decimal castable as xs:decimal and
./gmd:northBoundLatitude/gco:Decimal castable as xs:decimal and
./gmd:southBoundLatitude/gco:Decimal castable as xs:decimal
]"
>
<xsl:variable
name=
"format"
select=
"'#0.000000'"
></xsl:variable>
<xsl:variable
name=
"w"
select=
"format-number(./gmd:westBoundLongitude/gco:Decimal/text(), $format)"
/>
<xsl:variable
name=
"e"
select=
"format-number(./gmd:eastBoundLongitude/gco:Decimal/text(), $format)"
/>
<xsl:variable
name=
"n"
select=
"format-number(./gmd:northBoundLatitude/gco:Decimal/text(), $format)"
/>
<xsl:variable
name=
"s"
select=
"format-number(./gmd:southBoundLatitude/gco:Decimal/text(), $format)"
/>
<!-- Example: ENVELOPE(-10, 20, 15, 10) which is minX, maxX, maxY, minY order
http://wiki.apache.org/solr/SolrAdaptersForLuceneSpatial4
https://cwiki.apache.org/confluence/display/solr/Spatial+Search
bbox field type limited to one. TODO
<xsl:if test="position() = 1">
<bbox>
<xsl:text>ENVELOPE(</xsl:text>
<xsl:value-of select="$w"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="$e"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="$n"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="$s"/>
<xsl:text>)</xsl:text>
</field>
</xsl:if>
-->
<xsl:choose>
<xsl:when
test=
"-180 <= number($e) and number($e) <= 180 and
-180 <= number($w) and number($w) <= 180 and
-90 <= number($s) and number($s) <= 90 and
-90 <= number($n) and number($n) <= 90"
>
<xsl:if
test=
"count(.//gmd:EX_GeographicBoundingBox)"
>
<geojson>
<xsl:variable
name=
"isMulti"
>
<xsl:choose>
<xsl:when
test=
"$e = $w and $s = $n"
>
<location><xsl:value-of
select=
"concat($s, ',', $w)"
/></location>
</xsl:when>
<xsl:when
test=
"($e = $w and $s != $n) or ($e != $w and $s = $n)"
>
<!-- Probably an invalid bbox indexing a point only -->
<location><xsl:value-of
select=
"concat($s, ',', $w)"
/></location>
<xsl:when
test=
"count(.//gmd:EX_GeographicBoundingBox) = 1"
>
<xsl:text>
false
</xsl:text>
</xsl:when>
<xsl:otherwise>
<geojson>
<xsl:text>
{"type": "polygon",
</xsl:text>
<xsl:text>
"coordinates": [[
</xsl:text>
<xsl:value-of
select=
"concat('[', $w, ',', $s, ']')"
/>
<xsl:text>
,
</xsl:text>
<xsl:value-of
select=
"concat('[', $e, ',', $s, ']')"
/>
<xsl:text>
,
</xsl:text>
<xsl:value-of
select=
"concat('[', $e, ',', $n, ']')"
/>
<xsl:text>
,
</xsl:text>
<xsl:value-of
select=
"concat('[', $w, ',', $n, ']')"
/>
<xsl:text>
,
</xsl:text>
<xsl:value-of
select=
"concat('[', $w, ',', $s, ']')"
/>
<xsl:text>
]]}
</xsl:text>
</geojson>
<location><xsl:value-of
select=
"concat(
(number($s) + number($n)) div 2,
',',
(number($w) + number($e)) div 2)"
/></location>
<xsl:text>
true
</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
<!--<xsl:value-of select="($e + $w) div 2"/>,<xsl:value-of select="($n + $s) div 2"/></field>-->
</xsl:for-each>
</xsl:variable>
<xsl:choose>
<xsl:when
test=
"count(.//gmd:EX_GeographicBoundingBox) = 1"
>
<xsl:text>
{"type": "Polygon",
</xsl:text>
<xsl:text>
"coordinates": [
</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>
{"type": "MultiPolygon",
</xsl:text>
<xsl:text>
"coordinates": [
<!-- curly brace opened, 1 square brackets opened -->
</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:for-each
select=
".//gmd:EX_GeographicBoundingBox[
./gmd:westBoundLongitude/gco:Decimal castable as xs:decimal and
./gmd:eastBoundLongitude/gco:Decimal castable as xs:decimal and
./gmd:northBoundLatitude/gco:Decimal castable as xs:decimal and
./gmd:southBoundLatitude/gco:Decimal castable as xs:decimal
]"
>
<xsl:variable
name=
"format"
select=
"'#0.000000'"
></xsl:variable>
<xsl:variable
name=
"w"
select=
"format-number(./gmd:westBoundLongitude/gco:Decimal/text(), $format)"
/>
<xsl:variable
name=
"e"
select=
"format-number(./gmd:eastBoundLongitude/gco:Decimal/text(), $format)"
/>
<xsl:variable
name=
"n"
select=
"format-number(./gmd:northBoundLatitude/gco:Decimal/text(), $format)"
/>
<xsl:variable
name=
"s"
select=
"format-number(./gmd:southBoundLatitude/gco:Decimal/text(), $format)"
/>
<!-- Example: ENVELOPE(-10, 20, 15, 10) which is minX, maxX, maxY, minY order
http://wiki.apache.org/solr/SolrAdaptersForLuceneSpatial4
https://cwiki.apache.org/confluence/display/solr/Spatial+Search
bbox field type limited to one. TODO
<xsl:if test="position() = 1">
<bbox>
<xsl:text>ENVELOPE(</xsl:text>
<xsl:value-of select="$w"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="$e"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="$n"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="$s"/>
<xsl:text>)</xsl:text>
</field>
</xsl:if>
-->
<xsl:if
test=
"$isMulti = 'true'"
>
<xsl:text>
[
</xsl:text>
<!-- wraps the entire polygon component in a square bracket -->
</xsl:if>
<xsl:text>
[
</xsl:text>
<!-- wraps exterior -->
<xsl:value-of
select=
"concat('[', $w, ',', $s, ']')"
/>
<xsl:text>
,
</xsl:text>
<xsl:value-of
select=
"concat('[', $e, ',', $s, ']')"
/>
<xsl:text>
,
</xsl:text>
<xsl:value-of
select=
"concat('[', $e, ',', $n, ']')"
/>
<xsl:text>
,
</xsl:text>
<xsl:value-of
select=
"concat('[', $w, ',', $n, ']')"
/>
<xsl:text>
,
</xsl:text>
<xsl:value-of
select=
"concat('[', $w, ',', $s, ']')"
/>
<xsl:text>
]
</xsl:text>
<!-- closes the exterior -->
<xsl:if
test=
"$isMulti = 'true'"
>
<xsl:text>
]
</xsl:text>
<!-- closes the wrapping -->
</xsl:if>
<xsl:if
test=
"position() != last() and $isMulti = 'true'"
>
<xsl:text>
,
</xsl:text>
<!-- adds a comma to allow the next polygon -->
</xsl:if>
<!--<xsl:value-of select="($e + $w) div 2"/>,<xsl:value-of select="($n + $s) div 2"/></field>-->
<xsl:text>
]}
</xsl:text>
</xsl:for-each>
</geojson>
<xsl:for-each
select=
".//gmd:EX_GeographicBoundingBox[
./gmd:westBoundLongitude/gco:Decimal castable as xs:decimal and
./gmd:eastBoundLongitude/gco:Decimal castable as xs:decimal and
./gmd:northBoundLatitude/gco:Decimal castable as xs:decimal and
./gmd:southBoundLatitude/gco:Decimal castable as xs:decimal
]"
>
<xsl:variable
name=
"format"
select=
"'#0.000000'"
></xsl:variable>
<xsl:variable
name=
"w"
select=
"format-number(./gmd:westBoundLongitude/gco:Decimal/text(), $format)"
/>
<xsl:variable
name=
"e"
select=
"format-number(./gmd:eastBoundLongitude/gco:Decimal/text(), $format)"
/>
<xsl:variable
name=
"n"
select=
"format-number(./gmd:northBoundLatitude/gco:Decimal/text(), $format)"
/>
<xsl:variable
name=
"s"
select=
"format-number(./gmd:southBoundLatitude/gco:Decimal/text(), $format)"
/>
<xsl:choose>
<xsl:when
test=
"$e = $w and $s = $n"
>
<location><xsl:value-of
select=
"concat($s, ',', $w)"
/></location>
</xsl:when>
<xsl:when
test=
"($e = $w and $s != $n) or ($e != $w and $s = $n)"
>
<!-- Probably an invalid bbox indexing a point only -->
<location><xsl:value-of
select=
"concat($s, ',', $w)"
/></location>
</xsl:when>
<xsl:otherwise>
<location><xsl:value-of
select=
"concat(
(number($s) + number($n)) div 2,
',',
(number($w) + number($e)) div 2)"
/></location>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:if>
<xsl:if
test=
"count(.//gmd:EX_BoundingPolygon/gmd:polygon/gml:Polygon)>0 and count(.//gmd:EX_BoundingPolygon/gmd:polygon/gml:Point)=0"
>
<geojson>
<xsl:variable
name=
"isMulti"
>
...
...
@@ -766,7 +808,7 @@
</xsl:when>
<xsl:otherwise>
<xsl:text>
{"type": "MultiPolygon",
</xsl:text>
<xsl:text>
"coordinates": [
<!-- curly brace opened, 1
or 2
square brackets opened -->
<xsl:text>
"coordinates": [
<!-- curly brace opened, 1 square brackets opened -->
</xsl:text>
</xsl:otherwise>
</xsl:choose>
...
...
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