geonetwork / core-geonetwork

GeoNetwork is a catalog application to manage spatially referenced resources. It provides powerful metadata editing and search functions as well as an interactive web map viewer. It is currently used in numerous Spatial Data Infrastructure initiatives across the world.
http://geonetwork-opensource.org/
GNU General Public License v2.0
412 stars 487 forks source link

Can't be added a WFS online resource pointing to the service, without defining an specific layer #1740

Open josegar74 opened 7 years ago

josegar74 commented 7 years ago

In old versions of Geonetwork afaik, was possible to just provide the capabilities link of the service and when adding to the map open the layer selection with all the WFS layers. I think there were 2 protocols to deal with this:

This functionality seem not being available in 3.0.x+ versions. In 3.2.x:

After adding the online resource from previous popup, from the metadata editor, the name can be removed, but the detail page when trying to add to the map shows an error as can't find any layer with empty name.

archaeogeek commented 7 years ago

Also a problem for WMS services too (WMS layers work OK)

fxprunayre commented 7 years ago

Indeed, some improvements required:

image

image

josegar74 commented 7 years ago

The problem about not displaying the panel automatically for WxS services (no layers), seem related to this code:

https://github.com/geonetwork/core-geonetwork/blob/develop/web-ui/src/main/resources/catalog/components/viewer/wmsimport/WmsImportDirective.js#L130

it returns an array of length 0, causing not executed the code to open the panel. Checking it.

But also it's important to define how should work this feature, for the time being in 3.2.x, it's managed as a service end-point (no layer) if the gmd:name is empty (as that field is managed as the layer name.

That is not very nice, I think should be used the protocol value instead.

josegar74 commented 7 years ago

@fgravin Please, can you check about this code: https://github.com/geonetwork/core-geonetwork/blob/develop/web-ui/src/main/resources/catalog/components/viewer/wmsimport/WmsImportDirective.js#L130

I can't find any reference to data-gn-import-button in any other code except in that javascript line, so not very clear what is supposed to do. Seems that tries to find the panel with the WMS add layer to open it, but maybe the html has changed and the javascript was not updated?

fgravin commented 7 years ago

Sorry i don't remember the code, i don't think i wrote it. My original commit was https://github.com/geonetwork/core-geonetwork/commit/1cbf7c9967ae41b99c3d9cc6ca2b5c475cd46875 I think it was kind of hack for Maria's needs to highlight the panel.

Because unfortunatly, and it is a mistake from today's perspective, the right panel UI is not bound to a model, it is pure js. So, we cannot easly open menus from the model, we must do it the DOM way.

gn-import-button seems like an old directive attribute, can't find it either so i would say this part of the code is useless from now.

Delawen commented 7 years ago

Yes, I think it was a hack to open automatically the panel and do what we need to fix now.

josegar74 commented 7 years ago

Described actual behaviour and a proposal to improve the Add to Map option in GeoNetwork.

Actual behaviour

For WMS resources the following protocols are available in GeoNetwork:

For WFS resources:

Actually the Add to Map option works like this for resources with WMS/WFS protocols:

1) If the online resource has a gmd:name value is used as the layer name to be loaded in the map

2) If the online resource doesn't have a gmd:name value, it opens the map with the WMS/WFS dialog using the service url so the user can select the layer to load

This doesn't work actually, there's a bug related to this.

3) Add to map works differently in the search results and the metadata detail page.

Previous items (1 and 2) couple the gmd:name with the layer name and requires to be empty if want to point to the service so the user can select the layer.

Proposal

Here's a proposal to work similar to what was develop for old versions of GeoNetwork, that seem was not migrated to GeoNetwork 3+:

1) Use the protocol value, in previous versions of GeoNetwork if the protocol contained -http-get-capabilities, it was opened the WMS/WFS dialog in the map viewer so the user could select the layer, independently of the gmd:name value that could be used as a friendly service name.

2) For the other protocols, if the gmd:name is filled use it as a layer name, otherwise work as 1)

3) I would not rely in the protocol containing -http-get-capabilities, but make this configurable in the config.js, by default having:

mapLayerProtocols: ['OGC:WMS', 'OGC:WMS-1.1.1-http-get-map', 'OGC:WMS-1.3.0-http-get-map', 'OGC:WFS'],
mapServiceProtocols: ['OGC:WMS-1.3.0-http-get-capabilities', 'OGC:WMS-1.1.1-http-get-capabilities', 'OGC:WFS-1.0.0-http-get-capabilities']

Note that some implementations rely for the name of the layer adding it to the service url, although this is not a valid GetCapabilities url. Maybe something to support also.


@fxprunayre, @fgravin please check if this makes sense and provide any suggestion for improvement, before starting any implementation.

fxprunayre commented 7 years ago

I would not rely in the protocol containing -http-get-capabilities

+1.

this configurable in the config.js

FYI, I'm currently working on a single config file for the UI instead of the current mix of option some in JS, some in DB (cf. https://github.com/geonetwork/core-geonetwork/wiki/JS-API-Proposal). This is still early draft work.

mapLayerProtocols & mapServiceProtocols

Those options should probably go in the gnSearchSettings object as they will be used by the search app mainly. You could use regex instead of the array maybe ? (OGC:WMS*|OGC:WFS)

Other ideas discussed before which could be also supported:

josegar74 commented 7 years ago

You could use regex instead of the array maybe ? (OGC:WMS*|OGC:WFS)

The idea behind using the arrays is to define which protocols should be handle to load in the map a single layer or the capabilities document, so the user has to select the layer.

it could be good to even be able to override the addToMap function and be able to easily customize it to do something else (eg. open a custom mapviewer app) ?

This happens with quite code, would be useful to be able to override it for custom actions, but I don't have very clear how this can be accomplished in AngularJs.

fgravin commented 7 years ago

This happens with quite code, would be useful to be able to override it for custom actions, but I don't have very clear how this can be accomplished in AngularJs.

Could override gnRelatedResources from config app no ? https://github.com/geonetwork/core-geonetwork/blob/develop/web-ui/src/main/resources/catalog/components/metadataactions/RelatedResourcesService.js

josegar74 commented 7 years ago

@fgravin, I guess should be possible in the AngularJs code, as in javascript you can override code.

But in AngularJs, or at least in the app implemented in GeoNetwork I have no clue (but this is my problem possibly, due to a lack of knowledge about this). For example, not clear whats the order of loading of the files so can be sure where to put the overridden code (probably adding it to config.js or module.js can be fine?), how to do an override of methods in a service or directive (if thats possible), etc.

josegar74 commented 7 years ago

@fgravin I have created a branch to implement the proposal I described in previous comments and also fix the opening of the Add Layer to Map from the metadata detail page for service urls.

But I just notice the Add Layer to Map has no panel to add WFS layers. I tried in the WMS layer panel to use a WFS url, but as expected doesn't work. Do you know why WFS layers can't be added from the map viewer? Is there any technical issue? Otherwise I would like to implement this.

From the metadata details page, WFS layers seem can be added, looks strange that can't be added from the Add Layer to Map panel.

I found in https://github.com/geonetwork/core-geonetwork/blob/3.2.x/web-ui/src/main/resources/catalog/components/viewer/wmsimport/WmsImportDirective.js#L71 there's some support for WFS, and that adding the following snippet to https://github.com/geonetwork/core-geonetwork/blob/3.2.x/web-ui/src/main/resources/catalog/components/viewer/partials/mainviewer.html#L104-L124:

        <tab heading="{{'LayerWFS' | translate}}"
             active="addLayerTabs.wfs">
          <div gn-wms-import="wfs"
               gn-wms-import-map="map"
               services-list-from-catalog="true"></div>
        </tab>

Shows up a panel to add WFS layers. Unfortunately seem it's not supported in https://github.com/geonetwork/core-geonetwork/blob/3.2.x/web-ui/src/main/resources/catalog/components/common/ows/OWSService.js causing this error:

TypeError: gnOwsCapabilities[(("get" + type.toUpperCase(...)) + "Capabilities")] is not a function
    at Scope.scope.load (WmsImportDirective.js:160)
    at fn (eval at compile (angular.js:14138), <anonymous>:4:203)

Any advice about this is appreciated as not clear why not supporting WFS layers.


Also when I add a WMS url, even if works displaying the layers, I get the following error in the console:

No 'Access-Control-Allow-Origin' header is present on the requested resource. 
Origin 'http://localhost:8080' is therefore not allowed access.

I can't find any documentation about how to setup this to avoid these messages, maybe you or @fxprunayre know about this. The only stuff I found is this https://github.com/geonetwork/core-geonetwork/pull/1748, that seem using a system setting, but would be good to have in the documentation also (I could not find it at least in http://geonetwork-opensource.org/manuals/trunk/eng/users/)

fgravin commented 7 years ago

Hi,

No technical reason for not supporting WFS, just not needed it i guess. Sure you can add a tab in Add Layer To Map, you pointed on that wfs was supported in https://github.com/geonetwork/core-geonetwork/blob/3.2.x/web-ui/src/main/resources/catalog/components/viewer/wmsimport/WmsImportDirective.js#L71, i didn't know about that and i don't have clear idea about when it could be used.

Anyway, there is no WFSCapabilities in ol3, i guess gnOwsCapabilities is based on ol.format.WMSCapabilities, maybe JSONIX supports it.

josegar74 commented 7 years ago

Thanks for the feedback. The usage of this panel is related to the changes I described to support WFS url services in the metadata.

So if using a WFS url without specifying the layer name, should be opened the Add To Layer panel with the WFS url, displaying the list of WFS features.

I checked that there is no WFSCapabilities in ol3, whats is "curious" at least, that was related to my question about if any technical issue to implement this panel. Will check about how to implement this with JSONIX.

Delawen commented 7 years ago

f06ee87a5759112acb3a4885b769565c30233edc

fgravin commented 6 years ago

what is the state of this ? Closing ?

archaeogeek commented 6 years ago

This is still a problem and needs further work in 3.2 and 3.4. Please don't close it just yet