Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support of WFS attributes aliases #3191

Merged
merged 3 commits into from
Dec 14, 2017
Merged

Support of WFS attributes aliases #3191

merged 3 commits into from
Dec 14, 2017

Conversation

asaunier
Copy link
Member

@asaunier asaunier commented Nov 30, 2017

Some WFS backends such as QGIS Server may provide alias attributes for results of WFS requests. They are made available through a WFS DescribeFeatureType request. For instance:

...
<element alias="Vitesse" type="integer" name="Speed"/>
...

This PR aims to display those aliases if any in the query results window. See https://jira.camptocamp.com/browse/GEORD-21

Still to do:

  • get the aliases if any when showing the query results
  • support layers added using the WMS browser
  • figure out if the code in the gmf.WFSAliases service really deserves a distinct service or if it can be moved for instance to gmf.datasource.DataSourcesManager
  • make sure WMS GFI are supported
  • tests?

@asaunier
Copy link
Member Author

asaunier commented Dec 1, 2017

d93b471 adds attributes aliases to the query results. Problem: original attributes are not removed:
capture du 2017-12-01 18-21-39
(another problem: the attributes order is not preserved)

How could we remove the original attributes? By creating new features instead of editing the existing one?

Another approach: directly filtering when passing the features to the querywindow partial:

gmf.DisplayquerywindowController.prototype.getFeatureValues = function() {
if (!this.feature) {
return null;
}
return ngeo.FeatureHelper.getFilteredFeatureValues(this.feature);
};

like in
ngeo.FeatureHelper.getFilteredFeatureValues = function(feature) {
const properties = feature.getProperties();
delete properties['boundedBy'];
delete properties[feature.getGeometryName()];
delete properties['ngeo_feature_type_'];
return properties;
};

Problem: the list of alias is stored in the dataSource objects and not sure it is available here.

@asaunier
Copy link
Member Author

asaunier commented Dec 5, 2017

Thanks to @llienher I have been able to fix the issue reported at #3191 (comment) => aliases are now correctly handled when performing a WFS GetFeature request on a layer available in the application's themes.

I am now investigating the case of external layers added through the "import layer" tool (available in the "desktop_alt" app). As for now I have figured out that:

  • only WMS GFI request are supported for external layers, not WFS GetFeature requests (on the other hand it seems "internal" layers are only requested in GMF using WFS GetFeature, right?)
  • data sources created by the external datasource manager do not provide ogcServerType info:
    dataSource = new ngeo.datasource.OGC({
    id: id,
    name: layer['Title'],
    ogcImageType: ogcImageType,
    ogcLayers: [{
    name: layer['Name'],
    queryable: queryable
    }],
    ogcType: ngeo.datasource.OGC.Type.WMS,
    visible: true,
    wmsInfoFormat: wmsInfoFormat,
    wmsUrl: url
    });
    => the default mapserver type is then always used, including for the "qgisserver" test layer I am using. This is a problem because the aliases are only retrieved for "qgisserver" layers. I have not found how to get the real servertype in this part yet.
  • If I force the servertype to "qgisserver", the WFS DescribeFeatureType (required to get the aliases) is blocked saying the WFS requests are not supported for this WMS layer, see https://github.com/camptocamp/ngeo/blob/master/src/services/querent.js#L191-L195 (dataSource.supportsAttributes is false).

@asaunier
Copy link
Member Author

asaunier commented Dec 6, 2017

After more investigations about supporting aliases in external layers, I see several problems:

  • the ogcServerType is not provided when creating a dataSource for external layers in the gmf.datasource.ExternalDataSourcesManager. Not sure it is easy to have this information (for internal layers, the server type is provided by the "themes" service I think).
  • external layers are imported as WMS layers, with no WFS support by default: when trying to make the WFS DescribeFeatureType request to get the list of attributes and aliases, the querent fails because the data source does not support WFS (no wfsUrl), see
    wfsDescribeFeatureType(dataSource) {
    goog.asserts.assert(
    dataSource.supportsAttributes,
    `The data source must support WFS, have a single OGCLayer that
    is queryable in order to issue WFS DescribeFeatureType requests`
    );
    and

    ngeo/src/datasource/ogc.js

    Lines 714 to 737 in c0f412e

    get supportsWFS() {
    return this.wfsUrl !== undefined;
    }
    /**
    * To be able to do advanced operations on a data source, such as editing
    * or filtering, a data source must be bound to 1 set of attributes.
    * These attributes are the ones defined by an ogcLayer. This means that
    * to be considered to support having attributes defined, you either need
    * to define them directly when creating the data source, or if you let
    * the querent service get them for you using a WFS DescribeFeatureType
    * request, the data source must have only 1 ogcLayer set, which must
    * be queryable.
    * @return {boolean} Supports attributes.
    * @export
    */
    get supportsAttributes() {
    return this.attributes !== null || (
    this.supportsWFS &&
    this.ogcLayers !== null &&
    this.ogcLayers.length === 1 &&
    this.ogcLayers[0].queryable === true
    );
    }

Perhaps we could give up the support of aliases for external layers? At least in a first version of the tool.

@asaunier asaunier changed the title [WIP] Support of WFS attributes aliases Support of WFS attributes aliases Dec 6, 2017
@asaunier asaunier merged commit 73174b9 into master Dec 14, 2017
@asaunier asaunier deleted the wfsaliases branch December 14, 2017 11:41
@sbrunner sbrunner added this to the 2.3 milestone Apr 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants