Skip to content

Commit

Permalink
Map / Layer manager / Add support for multilingual layer title. (#7121)
Browse files Browse the repository at this point in the history
* Map / Layer manager / Add support for multilingual layer title.

Metadata may be multilingual and provide multilingual layer name in the
online source description field. GetCapabilities document do not provide
multilingual support, so this adds the possibility to translate layer
name in maps.

A multilingual description in a link:

```xml
<gmd:onLine>
  <gmd:CI_OnlineResource>
    <gmd:linkage>
      <gmd:URL>https://data.apps.fao.org/map/gsrv/gsrv1/geonetwork/ows?SERVICE=WMS&amp;</gmd:URL>
    </gmd:linkage>
    <gmd:protocol>
      <gmx:MimeFileType type="">OGC:WMS</gmx:MimeFileType>
    </gmd:protocol>
    <gmd:name xsi:type="gmd:PT_FreeText_PropertyType">
      <gco:CharacterString>geonetwork:basins_296</gco:CharacterString>
      <gmd:PT_FreeText>
        <gmd:textGroup>
          <gmd:LocalisedCharacterString locale="#EN">geonetwork:basins_296</gmd:LocalisedCharacterString>
        </gmd:textGroup>
        <gmd:textGroup>
          <gmd:LocalisedCharacterString locale="#FR" />
        </gmd:textGroup>
      </gmd:PT_FreeText>
    </gmd:name>
    <gmd:description xsi:type="gmd:PT_FreeText_PropertyType">
      <gco:CharacterString>Hydrological basins in Africa</gco:CharacterString>
      <gmd:PT_FreeText>
        <gmd:textGroup>
          <gmd:LocalisedCharacterString locale="#EN">Hydrological basins in Africa</gmd:LocalisedCharacterString>
        </gmd:textGroup>
        <gmd:textGroup>
          <gmd:LocalisedCharacterString locale="#FR">Bassins versants en Afrique</gmd:LocalisedCharacterString>
        </gmd:textGroup>
      </gmd:PT_FreeText>
    </gmd:description>
  </gmd:CI_OnlineResource>
</gmd:onLine>
```

The description is retrieved from the metadata on load from the metadata
UUID which is attached to the layer (and saved in the OWS context
extension of the layer) using the service URL and the layer name.

This also allows to override layer name when a group of layer (eg.
`a,b,c`) is used in the online source name.

* Map / When loading a map, switch to layer tool panel.

* Map / Layer manager / Add support for multilingual layer title / Layer search.

* Map / Layer manager / Add support for multilingual layer title / Layer filter.

* Remove openTool after map load.

Configuration done in #7126
  • Loading branch information
fxprunayre committed Jun 13, 2023
1 parent 745d2d3 commit 6749a34
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1538,6 +1538,32 @@
return layer;
},

/**
* @ngdoc method
* @methodOf gn_map.service:gnMap
* @name gnMap#getLinkDescription
*
* @description
* Retrieve description of the link from the metadata
* record using the URL and layer name. The description
* may override GetCapabilities layer name and can also
* be multilingual.
*/
getLinkDescription: function (md, url, name) {
if (md) {
var link = md.getLinksByFilter(
"protocol:OGC:WMS" +
" AND url:" +
url.replace("?", "\\?") +
" AND name:" +
name
);
if (link.length === 1) {
return link[0].description !== "" ? link[0].description : undefined;
}
}
},

/**
* @ngdoc method
* @methodOf gn_map.service:gnMap
Expand Down Expand Up @@ -1615,6 +1641,12 @@
if (!createOnly) {
map.addLayer(olL);
}

olL.set(
"layerTitleFromMetadata",
$this.getLinkDescription(olL.get("md"), url, name)
);

gnWmsQueue.removeFromQueue(
url,
name,
Expand Down Expand Up @@ -1910,6 +1942,12 @@
if (!createOnly) {
map.addLayer(olL);
}

olL.set(
"layerTitleFromMetadata",
$this.getLinkDescription(olL.get("md"), url, name)
);

gnWmsQueue.removeFromQueue(url, name, map);
defer.resolve(olL);
};
Expand Down Expand Up @@ -2393,7 +2431,7 @@
feedLayerWithRelated: function (layer, linkGroup) {
var md = layer.get("md");

if (!linkGroup) {
if (!Number.isInteger(linkGroup)) {
console.warn(
"The layer has not been found in any group: " +
layer.getSource().getParams().LAYERS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
scope.currentLayer = l;
};
scope.getLabel = function (layer) {
return layer.get("label");
return layer.get("layerTitleFromMetadata") || layer.get("label");
};
scope.set = function () {
if (scope.layer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,18 @@
for="layer-{{$index}}"
data-ng-class="{'gn-map-layer-selected': layer.showInfo}"
>
<a data-ng-class="layer.get('errors').length > 0 ? 'text-danger' : ''">
{{layer.get('label')}}
<span class="clickable"
data-ng-class="layer.get('errors').length > 0 ? 'text-danger' : ''"
title="{{layer.get('label')}}"
>
{{layer.get('layerTitleFromMetadata') || layer.get('label')}}
<span
><em>
{{layer.get('currentStyle') ? '(' + (layer.get('currentStyle').Title ||
layer.get('currentStyle').Name) + ')' : ''}}
</em>
</span>
</a>
</span>
</label>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ <h3>
<a
data-ng-click="addToMap(link, md)"
href=""
title="{{'addLayerPrefix' | translate}} {{link.desc || link.name}} {{'addLayerPostfix' | translate}}"
title="{{'addLayerPrefix' | translate}} {{link.name}} {{'addLayerPostfix' | translate}}"
class="flex-row"
>
<span class="fa fa-fw fa-plus"></span>
<span>{{link.desc || link.name}}&nbsp;</span>
<span>{{link.description || link.name}}&nbsp;</span>
</a>
</li>
</ul>
Expand Down

0 comments on commit 6749a34

Please sign in to comment.