Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/2.4' into merge24
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Aug 23, 2019
2 parents 847ade4 + b60bad8 commit c7bf16c
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 32 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ then visit https://localhost:3000/contribs/gmf/examples/.
To run the GeoMapFish applications:

```
serve-gmf-apps
make serve-gmf-apps
```

then visit them using
Expand Down
2 changes: 0 additions & 2 deletions contribs/gmf/apps/desktop/Controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import gmfControllersAbstractDesktopController, {AbstractDesktopController}
import appBase from '../appmodule.js';
import EPSG2056 from '@geoblocks/proj/src/EPSG_2056.js';
import EPSG21781 from '@geoblocks/proj/src/EPSG_21781.js';
import olSourceVector from 'ol/source/Vector.js';

if (!window.requestAnimationFrame) {
alert('Your browser is not supported, please update it or use another one. You will be redirected.\n\n'
Expand Down Expand Up @@ -112,7 +111,6 @@ const module = angular.module('Appdesktop', [
gmfControllersAbstractDesktopController.name,
]);

module.value('ngeoSnappingSource', new olSourceVector());

module.value('gmfContextualdatacontentTemplateUrl', 'gmf/contextualdata');
module.run(
Expand Down
2 changes: 2 additions & 0 deletions contribs/gmf/src/controllers/AbstractDesktopController.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,5 +279,7 @@ module.controller('AbstractDesktopController', AbstractDesktopController);
module.value('ngeoMeasurePrecision', 3);
module.value('ngeoMeasureDecimals', 0);

module.value('ngeoSnappingTolerance', 20);
module.value('ngeoSnappingSource', new olSourceVector());

export default module;
6 changes: 5 additions & 1 deletion contribs/gmf/src/controllers/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ function bootstrap(module) {
const interface_ = $('meta[name=interface]')[0].getAttribute('content');
const dynamicUrl_ = $('meta[name=dynamicUrl]')[0].getAttribute('content');
const search = document.location ? document.location.search || '' : '';
const dynamicUrl = `${dynamicUrl_}?interface=${interface_}&query=${encodeURIComponent(search)}`;
const dynamicUrl = `${dynamicUrl_}?interface=${interface_}&query=${encodeURIComponent(
search
)}&path=${encodeURIComponent(
document.location.pathname
)}`;
const request = $.ajax(dynamicUrl, {
'dataType': 'json',
'xhrFields': {
Expand Down
2 changes: 2 additions & 0 deletions contribs/gmf/src/datasource/Manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,7 @@ export class DatasourceManager {
const name = gmfLayer.name;
const timeAttributeName = meta.timeAttribute;
const visible = meta.isChecked === true;
const ogcAttributes = ogcServer ? ogcServer.attributes : null;

/** @type {import('./OGC').OGCOptions} */
const options = {
Expand All @@ -608,6 +609,7 @@ export class DatasourceManager {
identifierAttribute,
name,
ogcType,
ogcAttributes,
snappable,
timeAttributeName,
visible,
Expand Down
3 changes: 2 additions & 1 deletion contribs/gmf/src/datasource/OGC.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import ngeoDatasourceOGC from 'ngeo/datasource/OGC.js';
* @property {Array<import('ngeo/rule/Rule.js').default>} [filterRules] A list of filter rules to apply
* to this data source using the filter condition.
* @property {boolean} [filtrable] Whether the data source is filtrable or not.
* @property {string} [geometryName] The name of the geometry attribute.
* @property {string} [ogcImageType] The type of images to fetch by queries by the (WMS) or (WMTS).
* @property {Array<import('ngeo/datasource/OGC').WMSLayer>} [wmsLayers] A list of layer definitions that are used by WMS queries.
* These are **not** used by the (WMTS) queries (the wmtsLayers is used by WMTS queries).
Expand All @@ -34,6 +33,8 @@ import ngeoDatasourceOGC from 'ngeo/datasource/OGC.js';
* These are **not** used by the (WMTS) queries (the wmtsLayers is used by WMTS queries).
* @property {string} [ogcServerType] The type of OGC server.
* @property {string} [ogcType] The type data source. Can be: 'WMS' or 'WMTS'.
* @property {?Object<string, Object<string, import('gmf/themes.js').GmfOgcServerAttribute>>} [ogcAttributes]
* The attributes of the OGC server.
* @property {boolean} [snappable] Whether the geometry from this data source can be used to snap the geometry
* of features from other data sources that are being edited. Defaults to `false`.
* @property {boolean} [snappingToEdges] Determines whether external features can be snapped to the edges of
Expand Down
6 changes: 2 additions & 4 deletions contribs/gmf/src/editing/Snapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import angular from 'angular';
import gmfLayertreeTreeManager from 'gmf/layertree/TreeManager.js';
import gmfThemeThemes, {ThemeNodeType, getSnappingConfig} from 'gmf/theme/Themes.js';
import ngeoLayertreeController, {getFirstParentTree} from 'ngeo/layertree/Controller.js';
import {DEFAULT_GEOMETRY_NAME} from 'ngeo/datasource/OGC.js';
import {getUid as olUtilGetUid} from 'ol/util.js';
import * as olEvents from 'ol/events.js';
import olCollection from 'ol/Collection.js';
Expand Down Expand Up @@ -276,7 +277,6 @@ EditingSnappingService.prototype.registerTreeCtrl_ = function(treeCtrl) {
featureNS: ogcServer.wfsFeatureNS,
featurePrefix: 'feature',
features: new olCollection(),
geometryName: ogcServer.geometryName,
interaction: null,
maxFeatures: 50,
requestDeferred: null,
Expand Down Expand Up @@ -563,7 +563,7 @@ EditingSnappingService.prototype.loadItemFeatures_ = function(item) {
featureTypes: featureTypes,
outputFormat: 'GML3',
bbox: extent,
geometryName: item.geometryName,
geometryName: DEFAULT_GEOMETRY_NAME,
maxFeatures: item.maxFeatures
};

Expand All @@ -590,7 +590,6 @@ EditingSnappingService.prototype.loadItemFeatures_ = function(item) {
this.refreshSnappingSource_();
}
});

};


Expand Down Expand Up @@ -639,7 +638,6 @@ EditingSnappingService.prototype.refreshSnappingSource_ = function() {
* @property {string} featureNS
* @property {string} featurePrefix
* @property {import("ol/Collection.js").default<import("ol/Feature.js").default<import("ol/geom/Geometry.js").default>>} features
* @property {string} geometryName
* @property {?import("ol/interaction/Snap.js").default} interaction
* @property {number} maxFeatures
* @property {?angular.IDeferred<void>} requestDeferred
Expand Down
7 changes: 6 additions & 1 deletion contribs/gmf/src/themes.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,15 @@
* @typedef {Object<string, GmfOgcServer>} GmfOgcServers
*/

/**
* @typedef {Object} GmfOgcServerAttribute
* @property {string} namespace The attribute namespace.
* @property {string} type The attribute type (in namspace).
*/

/**
* @typedef {Object} GmfOgcServer
* @property {boolean} credential
* @property {string} [geometryName='geometry'] Geometry name.
* @property {string} imageType 'image/png' or 'image/jpeg'.
* @property {boolean} isSingleTile
* @property {string} [namespace] Namespace
Expand All @@ -159,6 +163,7 @@
* @property {string} urlWfs The WFS URL.
* @property {string} [wfsFeatureNS] WFS feature namespace
* @property {boolean} wfsSupport
* @property {Object<string, Object<string, GmfOgcServerAttribute>>} attributes
*/

/**
Expand Down
41 changes: 24 additions & 17 deletions src/datasource/OGC.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,15 @@ export const WMSInfoFormat = {
* @property {Array<import('ngeo/rule/Rule.js').default>} [filterRules] A list of filter rules to apply to
* this data source using the filter condition.
* @property {boolean} [filtrable] Whether the data source is filtrable or not.
* @property {string} [geometryName] The name of the geometry attribute.
* @property {string} [ogcImageType] The type of images to fetch by queries by the (WMS) or (WMTS).
* @property {WMSLayer[]} [wmsLayers] A list of layer definitions that are used by WMS queries.
* These are **not** used by the (WMTS) queries (the wmtsLayers is used by WMTS queries).
* @property {WFSLayer[]} [wfsLayers] A list of layer definitions that are used by WFS queries.
* These are **not** used by the (WMTS) queries (the wmtsLayers is used by WMTS queries).
* @property {string} [ogcServerType] The type of OGC server.
* @property {string} [ogcType] The type data source. Can be: 'WMS' or 'WMTS'.
* @property {?Object<string, Object<string, import('gmf/themes.js').GmfOgcServerAttribute>>} [ogcAttributes]
* The attributes of the OGC server.
* @property {boolean} [snappable] Whether the geometry from this data source can be used to snap the geometry
* of features from other data sources that are being edited. Defaults to `false`.
* @property {boolean} [snappingToEdges] Determines whether external features can be snapped to the edges of
Expand Down Expand Up @@ -194,7 +195,7 @@ export const WMSInfoFormat = {
* @private
* @hidden
*/
const DEFAULT_GEOMETRY_NAME = 'geom';
export const DEFAULT_GEOMETRY_NAME = 'geom';


/**
Expand Down Expand Up @@ -280,7 +281,7 @@ class OGC extends ngeoDatasourceDataSource {
* @type {string}
* @private
*/
this.geometryName_ = options.geometryName || DEFAULT_GEOMETRY_NAME;
this.geometryName_ = DEFAULT_GEOMETRY_NAME;

/**
* The type of images to fetch by queries by the (WMS) or (WMTS) .
Expand Down Expand Up @@ -321,6 +322,13 @@ class OGC extends ngeoDatasourceDataSource {
*/
this.ogcType_ = options.ogcType || Type.WMS;

/**
* The attributes of the OGC server.
* @type {?Object<string, Object<string, import('gmf/themes.js').GmfOgcServerAttribute>>}
* @private
*/
this.ogcAttributes_ = options.ogcAttributes;

/**
* Whether the geometry from this data source can be used to snap the
* geometry of features from other data sources that are being edited.
Expand Down Expand Up @@ -571,13 +579,6 @@ class OGC extends ngeoDatasourceDataSource {
// === Static property getters/setters ===
// =======================================

/**
* @inheritDoc
*/
getAttributes() {
return super.attributes;
}

/**
* @param {Array<import('ngeo/format/Attribute.js').Attribute>} attributes Attributes
*/
Expand All @@ -594,9 +595,19 @@ class OGC extends ngeoDatasourceDataSource {
}

/**
* @return {string} Geometry name
* @param {?string} layer The layer name.
* @return {?string} Geometry name
*/
get geometryName() {
geometryName(layer) {
if (!this.ogcAttributes_ || !layer) {
return this.geometryName_;
}
const attributes = this.ogcAttributes_[layer];
for (const attribute in attributes) {
if (attributes[attribute].namespace == 'http://www.opengis.net/gml') {
return attribute;
}
}
return this.geometryName_;
}

Expand Down Expand Up @@ -1016,18 +1027,14 @@ class OGC extends ngeoDatasourceDataSource {
* @private
*/
updateGeometryNameFromAttributes_() {
let geometryName = DEFAULT_GEOMETRY_NAME;

if (this.attributes) {
for (const attribute of this.attributes) {
if (attribute.type === ngeoFormatAttributeType.GEOMETRY) {
geometryName = attribute.name;
this.geometryName_ = attribute.name;
break;
}
}
}

this.geometryName_ = geometryName;
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/filter/RuleHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -581,12 +581,16 @@ export class RuleHelper {
filter = olFormatFilter.or.apply(null, conditions);
}
} else if (spatialTypes.includes(operator)) {
const geometryName = dataSource.geometryName;
const featureNames = dataSource.getFiltrableWFSLayerName();
const geometryName = dataSource.geometryName(featureNames ? featureNames[0] : null);
if (rule instanceof ngeoRuleGeometry) {
const geometry = rule.geometry;
if (!geometry) {
throw new Error('Missing geometry');
}
if (geometryName === null) {
throw new Error('Missing geometryName');
}
if (operator === rsot.CONTAINS) {
filter = olFormatFilter.contains(
geometryName,
Expand Down
2 changes: 1 addition & 1 deletion src/map/LayerHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ LayerHelper.prototype.createBasicWMSLayerFromDataSource = function(
throw new Error('Missing url');
}

const layerNames = dataSource.getWFSLayerNames().join(',');
const layerNames = dataSource.getWMSLayerNames().join(',');
const serverType = dataSource.ogcServerType;
const imageType = dataSource.ogcImageType;

Expand Down
10 changes: 7 additions & 3 deletions src/query/Querent.js
Original file line number Diff line number Diff line change
Expand Up @@ -577,13 +577,17 @@ export class Querent {

// (3) Build query options
for (const dataSource of dataSources) {
const currentFeatureTypes = dataSource.getInRangeWFSLayerNames(resolution, true);

// (a) Create common options, if not done yet
if (!getFeatureCommonOptions) {
const featureNS = dataSource.wfsFeatureNS;
const featurePrefix = dataSource.wfsFeaturePrefix;
const geometryName = dataSource.geometryName;
const geometryName = dataSource.geometryName(currentFeatureTypes[0]);
const outputFormat = dataSource.wfsOutputFormat;
if (!geometryName) {
throw new Error('Missing geometryName');
}

getFeatureCommonOptions = {
bbox,
Expand All @@ -602,7 +606,7 @@ export class Querent {
}

// (b) Add queryable layer names in featureTypes array
featureTypes = featureTypes.concat(dataSource.getInRangeWFSLayerNames(resolution, true));
featureTypes = featureTypes.concat(currentFeatureTypes);

// (c) Add filter, if any. If the case, then only one data source
// is expected to be used for this request.
Expand Down Expand Up @@ -638,10 +642,10 @@ export class Querent {
getFeatureCommonOptions.filter = filter;
}
}

if (!getFeatureCommonOptions) {
throw new Error('Missing getFeatureCommonOptions');
}

getFeatureCommonOptions.featureTypes = featureTypes;
if (!url) {
throw new Error('Missing url');
Expand Down

0 comments on commit c7bf16c

Please sign in to comment.