Skip to content

Commit

Permalink
add wfs url on right menu on TOC
Browse files Browse the repository at this point in the history
  • Loading branch information
volterra79 committed Jul 6, 2022
1 parent 0f7af4d commit 17d0fb2
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 6 deletions.
26 changes: 23 additions & 3 deletions src/app/core/layers/imagelayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,31 @@ proto.getStringBBox = function() {
return `${bbox.minx},${bbox.miny},${bbox.maxx},${bbox.maxy}`;
};

proto.isWfsActive = function(){
return Array.isArray(this.config.ows) && this.config.ows.find(ows_type => ows_type === 'WFS') !== undefined;
};

/**
* Metyhod to get wms url of the layer
* @returns {*}
*/
proto.getFullWmsUrl = function() {
const ProjectsRegistry = require('core/project/projectsregistry');
const metadata_wms_url = ProjectsRegistry.getCurrentProject().getState().metadata.wms_url;
return this.isExternalWMS() || !metadata_wms_url ? this.getWmsUrl() : metadata_wms_url ;
};

//used to Catalog layer menu
//used to Catalog layer menu to show wms url
proto.getCatalogWmsUrl = function(){
const ProjectsRegistry = require('core/project/projectsregistry');
const metadata_wms_url = ProjectsRegistry.getCurrentProject().getState().metadata.wms_url;
return this.isExternalWMS() || !metadata_wms_url ? `${this.getWmsUrl()}?service=WMS&version=1.3.0&request=GetCapabilities` : metadata_wms_url ;
const metadata_wms_url = ProjectsRegistry.getCurrentProject().getMetadata().wms_url;
const catalogWmsUrl = this.isExternalWMS() || !metadata_wms_url ? `${this.getWmsUrl()}?service=WMS&version=1.3.0&request=GetCapabilities` : metadata_wms_url ;
return catalogWmsUrl;
};

//used to Catalog layer menu to show wfs url
proto.getCatalogWfsUrl = function(){
return `${this.getWfsUrl()}?service=WFS&version=1.1.0&request=GetCapabilities`;
};

// values: map, legend
Expand All @@ -161,6 +175,12 @@ proto.getWmsUrl = function({type='map'}={}) {
return wmsUrl
};

proto.getWfsUrl = function() {
const ProjectsRegistry = require('core/project/projectsregistry');
return ProjectsRegistry.getCurrentProject().getMetadata().wms_url || this.config.wmsUrl;
};


/**
* Get query url based on type, external or same projection of map
* @returns {string}
Expand Down
4 changes: 4 additions & 0 deletions src/app/core/project/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ proto.getThumbnail = function() {
return this.state.thumbnail;
};

proto.getMetadata = function(){
return this.state.metadata || {};
};

proto.getState = function() {
return this.state;
};
Expand Down
14 changes: 13 additions & 1 deletion src/app/gui/catalog/vue/catalog.html
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
</div>
</li>
<li v-if="canShowWmsUrl(layerMenu.layer.id)">
<div @click.prevent.stop="copyWmsUrl($event, layerMenu.layer.id)" style="display: flex; max-width:300px; align-items: center;">
<div @click.prevent.stop="copyUrl({evt: $event, layerId:layerMenu.layer.id, type:'Wms'})" style="display: flex; max-width:300px; align-items: center;">
<span class="menu-icon" :class="g3wtemplate.getFontClass('map')"></span>
<div style="display: inline-flex; justify-content: space-between; width: 100%; align-items: baseline">
<span class="item-text catalog-menu-wms skin-tooltip-top" data-toggle="tooltip" v-t-tooltip="'sdk.catalog.menu.wms.copy'">WMS URL</span>
Expand All @@ -197,5 +197,17 @@
</div>
</div>
</li>
<li v-if="canShowWfsUrl(layerMenu.layer.id)">
<div @click.prevent.stop="copyUrl({evt: $event, layerId:layerMenu.layer.id, type:'Wfs'})" style="display: flex; max-width:300px; align-items: center;">
<span class="menu-icon" :class="g3wtemplate.getFontClass('map')"></span>
<div style="display: inline-flex; justify-content: space-between; width: 100%; align-items: baseline">
<span class="item-text catalog-menu-wms skin-tooltip-top" data-toggle="tooltip" v-t-tooltip="'sdk.catalog.menu.wms.copy'">WFS URL</span>
<span @click.prevent.stop="" class="bold catalog-menu-wms wms-url-tooltip skin-tooltip-top"
:class="g3wtemplate.getFontClass('eye')"
data-placement="top" data-toggle="tooltip" :title="getWfsUrl(layerMenu.layer.id)">
</span>
</div>
</div>
</li>
</ul>
</div>
13 changes: 11 additions & 2 deletions src/app/gui/catalog/vue/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ const vueComponentOptions = {
const originalLayer = CatalogLayersStoresRegistry.getLayerById(layerId);
return originalLayer ? (!!(!originalLayer.isType('table') && originalLayer.getFullWmsUrl())) : false;
},
canShowWfsUrl(layerId){
const originalLayer = CatalogLayersStoresRegistry.getLayerById(layerId);
return originalLayer && !originalLayer.isType('table') && originalLayer.isWfsActive();
},
canDownloadXls(layerId) {
const layer = CatalogLayersStoresRegistry.getLayerById(layerId);
return layer ? layer.isXlsDownlodable(): false;
Expand Down Expand Up @@ -247,8 +251,12 @@ const vueComponentOptions = {
const originalLayer = CatalogLayersStoresRegistry.getLayerById(layerId);
return originalLayer.getCatalogWmsUrl();
},
copyWmsUrl(evt, layerId) {
const url = this.getWmsUrl(layerId);
getWfsUrl(layerId) {
const originalLayer = CatalogLayersStoresRegistry.getLayerById(layerId);
return originalLayer.getCatalogWfsUrl();
},
copyUrl({evt, layerId, type}={}) {
const url = this[`get${type}Url`](layerId);
let ancorEement = document.createElement('a');
ancorEement.href = url;
const tempInput = document.createElement('input');
Expand All @@ -260,6 +268,7 @@ const vueComponentOptions = {
$(evt.target).attr('title', this.copywmsurltooltip).tooltip('fixTitle');
document.body.removeChild(tempInput);
ancorEement = null;
setTimeout(()=>this._hideMenu(), 600);
},
downloadGeoTIFF(layerId, map_extent=false){
const caller_download_id = ApplicationService.setDownload(true);
Expand Down

0 comments on commit 17d0fb2

Please sign in to comment.