Skip to content

Commit

Permalink
Editor / ISO / Compute extent from one keyword or add one extent from…
Browse files Browse the repository at this point in the history
… all keywords (geonetwork#5917)

* Add support to add an extent for a particular keyword
* Compute one extent based on all keywords
* Fix gcx:Anchor support
  • Loading branch information
fxprunayre authored Aug 19, 2021
1 parent 564acc6 commit 5f0ff19
Show file tree
Hide file tree
Showing 10 changed files with 120 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,14 @@
<xsl:variable name="isTypePlace" select="count(mri:type/mri:MD_KeywordTypeCode[@codeListValue='place']) > 0"/>
<xsl:if test="$isTypePlace">
<xsl:call-template name="render-batch-process-button">
<xsl:with-param name="process-label-key" select="'add-extent-from-geokeywords'"/>
<xsl:with-param name="process-name" select="'add-extent-from-geokeywords'"/>
<xsl:with-param name="process-params">{"replace": true}</xsl:with-param>
<xsl:with-param name="process-params">{"replace": "true"}</xsl:with-param>
</xsl:call-template>
<xsl:call-template name="render-batch-process-button">
<xsl:with-param name="process-label-key" select="'add-one-extent-from-geokeywords'"/>
<xsl:with-param name="process-name" select="'add-extent-from-geokeywords'"/>
<xsl:with-param name="process-params">{"replace": "true", "boundingAll": "true"}</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:when>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@
the metadata identifier (eg.
http://www.organization.org/catalogue/5391bf69-44bc-4ea0-8cc0-6cf6c3bc81ae).
</add-resource-idHelp>
<add-extent-from-geokeywords>Compute extent from keyword
</add-extent-from-geokeywords>
<add-extent-from-geokeywords>Add extent for each keywords</add-extent-from-geokeywords>
<add-one-extent-from-geokeywords>Add one extent from all keywords</add-one-extent-from-geokeywords>
<add-extent-from-geokeywordsHelp>Analyze each keyword of type place and add
matching extent.
</add-extent-from-geokeywordsHelp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
et l'identifiant de la fiche (eg.
http://www.organization.org/catalogue/5391bf69-44bc-4ea0-8cc0-6cf6c3bc81ae).
</add-resource-idHelp>
<add-extent-from-geokeywords>Calculer les emprises à partir des mots clés
</add-extent-from-geokeywords>
<add-extent-from-geokeywords>Ajouter les emprises correspondantes</add-extent-from-geokeywords>
<add-one-extent-from-geokeywords>Ajouter une emprise globale</add-one-extent-from-geokeywords>
<add-extent-from-geokeywordsHelp>Analyse les mots clés de type géographique et
ajoute les emprises correspondantes.
</add-extent-from-geokeywordsHelp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:geonet="http://www.fao.org/geonetwork"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:gco="http://standards.iso.org/iso/19115/-3/gco/1.0"
xmlns:gmx="http://www.isotc211.org/2005/gmx"
xmlns:gcx="http://standards.iso.org/iso/19115/-3/gcx/1.0"
xmlns:gex="http://standards.iso.org/iso/19115/-3/gex/1.0"
xmlns:srv="http://standards.iso.org/iso/19115/-3/srv/2.1"
xmlns:mdb="http://standards.iso.org/iso/19115/-3/mdb/2.0"
Expand All @@ -30,10 +30,14 @@

<!-- Replace or not existing extent -->
<xsl:param name="replace" select="'0'"/>
<xsl:param name="boundingAll" select="'0'"/>
<xsl:param name="addExtentFor" select="''"/>


<xsl:variable name="replaceMode"
select="geonet:parseBoolean($replace)"/>
<xsl:variable name="boundingAllMode"
select="geonet:parseBoolean($boundingAll)"/>
<xsl:variable name="serviceUrl"
select="concat(substring($gurl, 1, string-length($gurl)-4), 'api/registries/vocabularies/search?_content_type=xml&amp;q=')"/>

Expand All @@ -54,19 +58,22 @@
select="string-join($root//gex:EX_Extent/gex:description/gco:CharacterString, ' ')"/>

<xsl:variable name="geoKeywords"
select="$root//mri:descriptiveKeywords/mri:MD_Keywords/mri:keyword[
select="$root//mri:descriptiveKeywords/*/mri:keyword[
not(gco:CharacterString/@gco:nilReason)
and (not(contains($extentDescription, gco:CharacterString))
or not(contains($extentDescription, gmx:Anchor)))
and ../mri:type/mri:MD_KeywordTypeCode/@codeListValue='place']"/>
or not(contains($extentDescription, gcx:Anchor)))
and ../mri:type/*/@codeListValue='place']"/>
<xsl:if test="$geoKeywords">
<suggestion process="add-extent-from-geokeywords" id="{generate-id()}" category="keyword" target="extent">
<name><xsl:value-of select="geonet:i18n($add-extent-loc, 'a', $guiLang)"/><xsl:value-of select="string-join($geoKeywords/gco:CharacterString, ', ')"/>
<name><xsl:value-of select="geonet:i18n($add-extent-loc, 'a', $guiLang)"/><xsl:value-of select="string-join($geoKeywords/(gco:CharacterString|gcx:Anchor), ', ')"/>
<xsl:value-of select="geonet:i18n($add-extent-loc, 'b', $guiLang)"/></name>
<operational>true</operational>
<params>{"gurl":{"type":"string", "defaultValue":"<xsl:value-of select="$gurl"/>"},
"lang":{"type":"string", "defaultValue":"<xsl:value-of select="$lang"/>"},
"replace":{"type":"boolean", "defaultValue":"<xsl:value-of select="$replace"/>"}}</params>
"addExtentFor":{"type":"string", "defaultValue":""},
"boundingAll":{"type":"boolean", "defaultValue":"<xsl:value-of select="$boundingAll"/>"},
"replace":{"type":"boolean", "defaultValue":"<xsl:value-of select="$replace"/>"}}
</params>
</suggestion>
</xsl:if>

Expand Down Expand Up @@ -168,15 +175,37 @@
<xsl:template name="add-extent">
<!-- Only check keyword in main metadata language
TODO: support multilingual keyword -->
<xsl:for-each
select="mri:descriptiveKeywords/mri:MD_Keywords/mri:keyword[
normalize-space(gco:CharacterString) != '' and
not(gco:CharacterString/@gco:nilReason)]">
<xsl:call-template name="get-bbox">
<xsl:with-param name="word" select="gco:CharacterString"/>
</xsl:call-template>

</xsl:for-each>
<xsl:variable name="extentList">
<xsl:for-each
select="if ($addExtentFor = '')
then mri:descriptiveKeywords/*/mri:keyword[
normalize-space((gco:CharacterString|gcx:Anchor)) != ''
and not(gco:CharacterString/@gco:nilReason)
and ../mri:type/*/@codeListValue='place']
else mri:descriptiveKeywords/*/mri:keyword[
normalize-space((gco:CharacterString|gcx:Anchor)) = $addExtentFor]">
<xsl:call-template name="get-bbox">
<xsl:with-param name="word" select="gco:CharacterString"/>
</xsl:call-template>
</xsl:for-each>
</xsl:variable>

<xsl:choose>
<xsl:when test="$boundingAllMode">
<mri:extent>
<xsl:copy-of
select="geonet:make-iso-extent(
string(min($extentList//gex:westBoundLongitude)),
string(min($extentList//gex:southBoundLatitude)),
string(max($extentList//gex:eastBoundLongitude)),
string(max($extentList//gex:northBoundLatitude)),
string-join($extentList//gex:description, ', '))"/>
</mri:extent>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="$extentList"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>


Expand All @@ -191,7 +220,7 @@
<!-- It should be one but if one keyword is found in more
thant one thesaurus, then each will be processed.-->
<xsl:for-each select="$keyword/response/keyword">
<xsl:if test="geo and geo/west != '' and geo/south != '' and geo/east != '' and geo/north != ''">
<xsl:if test="geo and geo/west != '' and geo/south != '' and geo/east != '' and geo/north != '' and count(value[text() = $word]) = 1">
<mri:extent>
<xsl:copy-of select="geonet:make-iso19115-3-extent(geo/west, geo/south, geo/east, geo/north, $word)"/>
</mri:extent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@

<xsl:variable name="thesaurusTitleTranslated" select="$listOfThesaurus/thesaurus[title=$thesaurusTitle]/multilingualTitles/multilingualTitle[lang=$uiLang2code]/title" />
<xsl:variable name="thesaurusTitleForEditor" select="if (string($thesaurusTitleTranslated)) then $thesaurusTitleTranslated else $thesaurusTitle" />

<!-- The thesaurus key may be contained in the MD_Identifier field or
get it from the list of thesaurus based on its title.
-->
Expand Down Expand Up @@ -281,8 +281,14 @@
select="count(gmd:type/gmd:MD_KeywordTypeCode[@codeListValue='place']) > 0"/>
<xsl:if test="$isTypePlace">
<xsl:call-template name="render-batch-process-button">
<xsl:with-param name="process-label-key" select="'add-extent-from-geokeywords'"/>
<xsl:with-param name="process-name" select="'add-extent-from-geokeywords'"/>
<xsl:with-param name="process-params">{"replace": "true"}</xsl:with-param>
</xsl:call-template>
<xsl:call-template name="render-batch-process-button">
<xsl:with-param name="process-label-key" select="'add-one-extent-from-geokeywords'"/>
<xsl:with-param name="process-name" select="'add-extent-from-geokeywords'"/>
<xsl:with-param name="process-params">{"replace": true}</xsl:with-param>
<xsl:with-param name="process-params">{"replace": "true", "boundingAll": "true"}</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:when>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@
<add-resource-idHelp>Compose the resource identifier using the catalog URL and the metadata
identifier (eg. http://www.organization.org/catalogue/5391bf69-44bc-4ea0-8cc0-6cf6c3bc81ae).
</add-resource-idHelp>
<add-extent-from-geokeywords>Compute extent from keyword</add-extent-from-geokeywords>
<add-extent-from-geokeywords>Add extent for each keywords</add-extent-from-geokeywords>
<add-one-extent-from-geokeywords>Add one extent from all keywords</add-one-extent-from-geokeywords>
<add-extent-from-geokeywordsHelp>Analyze each keyword of type place and add matching extent.
</add-extent-from-geokeywordsHelp>
<classificationSection>Classification of data and services</classificationSection>
Expand Down
4 changes: 2 additions & 2 deletions schemas/iso19139/src/main/plugin/iso19139/loc/fre/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@
du catalogue ou l'URL du catalogue et l'identifiant de la fiche (eg.
http://www.organization.org/catalogue/5391bf69-44bc-4ea0-8cc0-6cf6c3bc81ae).
</add-resource-idHelp>
<add-extent-from-geokeywords>Calculer les emprises à partir des mots clés
</add-extent-from-geokeywords>
<add-extent-from-geokeywords>Ajouter les emprises correspondantes</add-extent-from-geokeywords>
<add-one-extent-from-geokeywords>Ajouter une emprise globale</add-one-extent-from-geokeywords>
<add-extent-from-geokeywordsHelp>Analyse les mots clés de type géographique et ajoute les emprises
correspondantes.
</add-extent-from-geokeywordsHelp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,14 @@

<!-- Replace or not existing extent -->
<xsl:param name="replace" select="'0'"/>
<xsl:param name="boundingAll" select="'0'"/>
<xsl:param name="addExtentFor" select="''"/>


<xsl:variable name="replaceMode"
select="geonet:parseBoolean($replace)"/>
<xsl:variable name="boundingAllMode"
select="geonet:parseBoolean($boundingAll)"/>
<xsl:variable name="serviceUrl"
select="concat(substring($gurl, 1, string-length($gurl)-4), 'api/registries/vocabularies/search?_content_type=xml&amp;q=')"/>

Expand Down Expand Up @@ -86,12 +90,14 @@
target="extent">
<name>
<xsl:value-of select="geonet:i18n($add-extent-loc, 'a', $guiLang)"/><xsl:value-of
select="string-join($geoKeywords/gco:CharacterString, ', ')"/>
select="string-join($geoKeywords/(gco:CharacterString|gmx:Anchor), ', ')"/>
<xsl:value-of select="geonet:i18n($add-extent-loc, 'b', $guiLang)"/>
</name>
<operational>true</operational>
<params>{"gurl":{"type":"string", "defaultValue":"<xsl:value-of select="$gurl"/>"},
"lang":{"type":"string", "defaultValue":"<xsl:value-of select="$lang"/>"},
"addExtentFor":{"type":"string", "defaultValue":""},
"boundingAll":{"type":"boolean", "defaultValue":"<xsl:value-of select="$boundingAll"/>"},
"replace":{"type":"boolean", "defaultValue":"<xsl:value-of select="$replace"/>"}}
</params>
</suggestion>
Expand Down Expand Up @@ -170,8 +176,9 @@
<xsl:when test="$replaceMode">
<xsl:for-each select="srv:extent|gmd:extent">
<xsl:if
test="gmd:EX_Extent/gmd:temporalElement or gmd:EX_Extent/gmd:verticalElement
or gmd:EX_Extent/gmd:geographicElement[gmd:EX_BoundingPolygon]">
test="gmd:EX_Extent/gmd:temporalElement
or gmd:EX_Extent/gmd:verticalElement
or gmd:EX_Extent/gmd:geographicElement[gmd:EX_BoundingPolygon]">
<xsl:copy>
<xsl:copy-of select="gmd:EX_Extent"/>
</xsl:copy>
Expand Down Expand Up @@ -216,16 +223,39 @@
<xsl:param name="srv" select="false()"/>
<!-- Only check keyword in main metadata language
TODO: support multilingual keyword -->
<xsl:for-each
select="gmd:descriptiveKeywords/gmd:MD_Keywords/gmd:keyword[
normalize-space(gco:CharacterString) != '' and
not(gco:CharacterString/@gco:nilReason)]">
<xsl:call-template name="get-bbox">
<xsl:with-param name="word" select="gco:CharacterString"/>
<xsl:with-param name="srv" select="$srv"/>
</xsl:call-template>

</xsl:for-each>
<xsl:variable name="extentList">
<xsl:for-each
select="if ($addExtentFor = '')
then gmd:descriptiveKeywords/*/gmd:keyword[
normalize-space((gco:CharacterString|gmx:Anchor)) != ''
and not(gco:CharacterString/@gco:nilReason)
and ../gmd:type/*/@codeListValue='place']
else gmd:descriptiveKeywords/*/gmd:keyword[
normalize-space((gco:CharacterString|gmx:Anchor)) = $addExtentFor]">
<xsl:call-template name="get-bbox">
<xsl:with-param name="word" select="gco:CharacterString|gmx:Anchor"/>
<xsl:with-param name="srv" select="$srv"/>
</xsl:call-template>
</xsl:for-each>
</xsl:variable>

<xsl:choose>
<xsl:when test="$boundingAllMode">
<xsl:element name="{if($srv) then 'srv:extent' else 'gmd:extent'}">
<xsl:copy-of
select="geonet:make-iso-extent(
string(min($extentList//gmd:westBoundLongitude)),
string(min($extentList//gmd:southBoundLatitude)),
string(max($extentList//gmd:eastBoundLongitude)),
string(max($extentList//gmd:northBoundLatitude)),
string-join($extentList//gmd:description, ', '))"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="$extentList"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>


Expand All @@ -236,25 +266,16 @@

<xsl:if test="normalize-space($word)!=''">
<!-- Get keyword information -->
<xsl:variable name="keyword" select="document(concat($serviceUrl, encode-for-uri($word)))"/>
<xsl:variable name="keyword"
select="document(concat($serviceUrl, encode-for-uri($word)))"/>
<!-- It should be one but if one keyword is found in more
thant one thesaurus, then each will be processed.-->
<xsl:for-each select="$keyword/response/keyword">
<xsl:if test="geo">
<xsl:choose>
<xsl:when test="$srv">
<srv:extent>
<xsl:copy-of
select="geonet:make-iso-extent(geo/west, geo/south, geo/east, geo/north, $word)"/>
</srv:extent>
</xsl:when>
<xsl:otherwise>
<gmd:extent>
<xsl:copy-of
select="geonet:make-iso-extent(geo/west, geo/south, geo/east, geo/north, $word)"/>
</gmd:extent>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="geo and geo/west != '' and geo/south != '' and geo/east != '' and geo/north != '' and count(value[text() = $word]) = 1">
<xsl:element name="{if($srv) then 'srv:extent' else 'gmd:extent'}">
<xsl:copy-of
select="geonet:make-iso-extent(geo/west, geo/south, geo/east, geo/north, $word)"/>
</xsl:element>
</xsl:if>
</xsl:for-each>
</xsl:if>
Expand Down
3 changes: 2 additions & 1 deletion web/src/main/webapp/xslt/ui-metadata/form-builder.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -1591,6 +1591,7 @@

<!-- Render batch process directive action -->
<xsl:template name="render-batch-process-button">
<xsl:param name="process-label-key"/>
<xsl:param name="process-name"/>
<xsl:param name="process-params"/>
<xsl:param name="btnClass" required="no"/>
Expand All @@ -1600,7 +1601,7 @@
<span data-gn-batch-process-button="{$process-name}"
data-params="{$process-params}"
data-icon="{$btnClass}"
data-name="{normalize-space($strings/*[name() = $process-name])}"
data-name="{normalize-space($strings/*[name() = $process-label-key])}"
data-help="{normalize-space($strings/*[name() = concat($process-name, 'Help')])}"/>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions web/src/main/webapp/xslt/ui-metadata/form-configurator.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
<xsl:choose>
<xsl:when test="@type = 'process' and @process">
<xsl:call-template name="render-batch-process-button">
<xsl:with-param name="process-label-key" select="if (@labelKey) then @labelKey else @process"/>
<xsl:with-param name="process-name" select="@process"/>
<xsl:with-param name="process-params" select="@params"/>
<xsl:with-param name="btnClass" select="@btnClass"/>
Expand Down

0 comments on commit 5f0ff19

Please sign in to comment.