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

Merge remote-tracking branch 'origin/2.4' #4927

Merged
merged 13 commits into from
Jun 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contribs/gmf/apps/desktop_alt/Controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class Controller extends AbstractDesktopController {
* @param {JQueryEventObject} event keydown event.
*/
onKeydown(event) {
if (event.ctrlKey && event.key === 'p') {
if (event && event.ctrlKey && event.key === 'p') {
this.printPanelActive = true;
event.preventDefault();
}
Expand Down
4 changes: 2 additions & 2 deletions contribs/gmf/src/controllers/AbstractAppController.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ export function AbstractAppController(config, map, $scope, $injector) {
if (!themeName) {
throw new Error('Missing themeName');
}
this.gmfThemeManager.updateCurrentTheme(themeName, previousThemeName);
this.gmfThemeManager.updateCurrentTheme(themeName, previousThemeName, true);
}
this.setDefaultBackground_(null);
this.updateHasEditableLayers_();
Expand Down Expand Up @@ -711,7 +711,7 @@ AbstractAppController.prototype.initLanguage = function() {
const browserLanguage = /** @type {string|undefined} */
(this.getBrowserLanguage(Object.keys(this.langUrls)));
const urlLanguage = /** @type {string|undefined} */
(this.stateManager.getInitialValue('lang'));
(this.stateManager.getInitialStringValue('lang'));

if (urlLanguage !== undefined && urlLanguage in this.langUrls) {
this.switchLanguage(urlLanguage);
Expand Down
2 changes: 1 addition & 1 deletion contribs/gmf/src/datasource/ExternalDataSourcesManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ export class ExternalDatSourcesManager {
id: id,
name: layer.Title,
ogcImageType: ogcImageType,
ogcLayers: [{
wmsLayers: [{
name: layer.Name,
queryable: queryable
}],
Expand Down
33 changes: 28 additions & 5 deletions contribs/gmf/src/datasource/Manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,8 @@ export class DatasourceManager {
const ogcType = gmfLayer.type;
let maxResolution = 0;
let minResolution = 0;
let ogcLayers;
let wmsLayers;
let wfsLayers;
let ogcServer;
let wmtsLayer;
let wmtsUrl;
Expand All @@ -482,7 +483,13 @@ export class DatasourceManager {
// OGC Layers
const layers = meta.queryLayers || meta.wmsLayers;
if (layers) {
ogcLayers = layers.split(',').map((layer) => {
wmsLayers = layers.split(',').map((layer) => {
return {
name: layer,
queryable: true
};
});
wfsLayers = layers.split(',').map((layer) => {
return {
maxResolution: maxResolution,
minResolution: minResolution,
Expand All @@ -506,7 +513,20 @@ export class DatasourceManager {
minResolution = gmfLayerWMS.minResolutionHint;

// OGC Layers
ogcLayers = gmfLayerWMS.childLayers.map((childLayer) => {
let queryable = false;
for (const wfslayer of gmfLayerWMS.childLayers) {
if (wfslayer.queryable) {
queryable = true;
break;
}
}
wmsLayers = gmfLayerWMS.layers.split(',').map((childLayer) => {
return {
name: childLayer,
queryable: queryable,
};
});
wfsLayers = gmfLayerWMS.childLayers.map((childLayer) => {
return {
maxResolution: childLayer.maxResolutionHint,
minResolution: childLayer.minResolutionHint,
Expand Down Expand Up @@ -601,8 +621,11 @@ export class DatasourceManager {
if (ogcImageType) {
options.ogcImageType = ogcImageType;
}
if (ogcLayers) {
options.ogcLayers = ogcLayers;
if (wmsLayers) {
options.wmsLayers = wmsLayers;
}
if (wfsLayers) {
options.wfsLayers = wfsLayers;
}
if (ogcServerType) {
options.ogcServerType = ogcServerType;
Expand Down
6 changes: 4 additions & 2 deletions contribs/gmf/src/datasource/OGC.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ import ngeoDatasourceOGC from 'ngeo/datasource/OGC.js';
* @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').OGCLayer>} [ogcLayers] A list of layer definitions that
* are used by (WMS) and (WFS) queries.
* @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).
* @property {Array<import('ngeo/datasource/OGC').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'.
Expand Down
2 changes: 1 addition & 1 deletion contribs/gmf/src/datasource/WFSAliases.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class DatasourceWFSAlias {
// Only QGIS Server supports WFS aliases
if (dataSource.ogcServerType === ServerType.QGISSERVER &&
dataSource.wfsUrl_ &&
dataSource.getOGCLayerNames().length == 1 &&
dataSource.getWFSLayerNames().length == 1 &&
!dataSource.attributes) {
// Trigger an additional WFS DescribeFeatureType request to get
// datasource attributes, including aliases.
Expand Down
10 changes: 5 additions & 5 deletions contribs/gmf/src/filters/filterselectorComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ class FilterSelectorController {
*
* 1) have its name in the list of filtrable layer node names
* 2) support WFS
* 3) have only one ogcLayers defined
* 3) have only one wfsLayers defined
* 4) the ogcLayer must be queryable
*
* If 1) is true but not any of the others, then the server has not been
Expand Down Expand Up @@ -527,14 +527,14 @@ class FilterSelectorController {
}

// (3) The DS must have only one ogcLayer
if (!dataSource.ogcLayers || !dataSource.ogcLayers.length) {
if (!dataSource.wfsLayers || !dataSource.wfsLayers.length) {
msgs.push(gettext.getString(
'The data source must have only 1 ogcLayer defined.'
'The data source must have only 1 wfsLayer defined.'
));
} else if (!dataSource.ogcLayers[0].queryable) {
} else if (!dataSource.wfsLayers[0].queryable) {
// (4) The ogcLayer must be queryable
msgs.push(gettext.getString(
'The ogcLayer within the data source must be queryable.'
'The wfsLayer within the data source must be queryable.'
));
}

Expand Down
1 change: 1 addition & 0 deletions contribs/gmf/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const COORDINATES_LAYER_NAME = 'gmfCoordinatesLayerName';
*/
export const PermalinkParam = {
BG_LAYER: 'baselayer_ref',
BG_LAYER_OPACITY: 'baselayer_opacity',
EXTERNAL_DATASOURCES_NAMES: 'eds_n',
EXTERNAL_DATASOURCES_URLS: 'eds_u',
FEATURES: 'rl_features',
Expand Down
2 changes: 1 addition & 1 deletion contribs/gmf/src/layertree/TreeManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ LayertreeTreeManager.prototype.setFirstLevelGroups = function(firstLevelGroups)
* group.
* @param {boolean=} opt_add if true, force to use the 'add' mode this time.
* @param {boolean=} opt_silent if true notifyCantAddGroups_ is not called.
* @return{boolean} True if the group has been added. False otherwise.
* @return {boolean} True if the group has been added. False otherwise.
*/
LayertreeTreeManager.prototype.addFirstLevelGroups = function(firstLevelGroups, opt_add, opt_silent) {
/** @type {import('gmf/themes.js').GmfGroup[]} */
Expand Down
48 changes: 41 additions & 7 deletions contribs/gmf/src/permalink/Permalink.js
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,8 @@ export function PermalinkService(
this.ngeoBackgroundLayerMgr_,
'change',
this.handleBackgroundLayerManagerChange_,
this);
this
);
}

// visibility
Expand Down Expand Up @@ -890,7 +891,6 @@ PermalinkService.prototype.setMap = function(map) {
this.registerMap_(map, null);
}
}

};


Expand Down Expand Up @@ -996,8 +996,7 @@ PermalinkService.prototype.unregisterMap_ = function() {


/**
* Get the background layer object to use to initialize the map from the
* state manager.
* Get the background layer object to use to initialize the map from the state manager.
* @param {Array<import("ol/layer/Base.js").default>} layers Array of background layer objects.
* @return {?import("ol/layer/Base.js").default} Background layer.
*/
Expand All @@ -1014,6 +1013,16 @@ PermalinkService.prototype.getBackgroundLayer = function(layers) {
};


/**
* Get the background layer opacity to use to initialize the map from the state manager.
* @return {?number} Opacity.
*/
PermalinkService.prototype.getBackgroundLayerOpacity = function() {
const opacity_ = this.ngeoStateManager_.getInitialNumberValue(PermalinkParam.BG_LAYER_OPACITY);
return opacity_ === undefined ? null : opacity_ / 100;
};


/**
* Called when the background layer changes. Update the state using the
* background layer label, i.e. its name.
Expand All @@ -1037,6 +1046,31 @@ PermalinkService.prototype.handleBackgroundLayerManagerChange_ = function() {
const object = {};
object[PermalinkParam.BG_LAYER] = layerName;
this.ngeoStateManager_.updateState(object);

const backgroundLayer = this.ngeoBackgroundLayerMgr_.getOpacityBgLayer(this.map_);
if (backgroundLayer) {
const opacity = this.getBackgroundLayerOpacity();
if (opacity !== null) {
backgroundLayer.setOpacity(opacity);
} else {
const opacity = backgroundLayer.getOpacity();
/** @type {Object<string, string>} */
const object = {};
object[PermalinkParam.BG_LAYER_OPACITY] = `${opacity * 100}`;
this.ngeoStateManager_.updateState(object);
}
olEvents.listen(
backgroundLayer,
'change:opacity',
() => {
const opacity = backgroundLayer.getOpacity();
/** @type {Object<string, string>} */
const object = {};
object[PermalinkParam.BG_LAYER_OPACITY] = `${opacity * 100}`;
this.ngeoStateManager_.updateState(object);
}
);
}
};


Expand Down Expand Up @@ -1476,9 +1510,9 @@ PermalinkService.prototype.initExternalDataSources_ = function() {

const promises = [];

const layerNamesString = this.ngeoStateManager_.getInitialValue(
const layerNamesString = this.ngeoStateManager_.getInitialStringValue(
PermalinkParam.EXTERNAL_DATASOURCES_NAMES);
const urlsString = this.ngeoStateManager_.getInitialValue(
const urlsString = this.ngeoStateManager_.getInitialStringValue(
PermalinkParam.EXTERNAL_DATASOURCES_URLS);

if (layerNamesString && urlsString) {
Expand Down Expand Up @@ -1724,7 +1758,7 @@ PermalinkService.prototype.setExternalDataSourcesState_ = function() {
// External WMS data sources always have only one OGC layer name,
// as they are created using a single Capability Layer object that
// has only 1 layer name
const layerName = wmsDataSource.getOGCLayerNames()[0];
const layerName = wmsDataSource.getWFSLayerNames()[0];
wmsGroupLayerNames.push(layerName);
}
}
Expand Down
9 changes: 8 additions & 1 deletion contribs/gmf/src/query/window.scss
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ div.ngeo-displaywindow {
flex-direction: column;
width: 100%;
height: 100%;
padding: $app-margin;
text-align: left;
white-space: nowrap;
overflow: hidden;
Expand All @@ -76,6 +75,14 @@ div.ngeo-displaywindow {
.content-template-container {
overflow: auto;
}
.header {
padding: $app-margin $app-margin 0 $app-margin;
}
.details {
padding: 0 $app-margin $app-margin $app-margin;
// small margin so that the scrollbar and the window resize are not in conflict.
margin-right: $half-app-margin;
}
}
}
.animation-container-detailed {
Expand Down
2 changes: 1 addition & 1 deletion contribs/gmf/src/query/windowComponent.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
ng-animate-swap="ctrl.animate"
class="slide-animation gmf-animatable">

<div class="header">
<div class="header ui-draggable-handle">
<p
class="title"
>{{ctrl.source.label | translate}}</p>
Expand Down
13 changes: 7 additions & 6 deletions contribs/gmf/src/query/windowComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,14 +324,15 @@ QueryWindowController.prototype.$onInit = function() {
}
highlightFeaturesOverlay.setStyle(highlightFeatureStyle);

const windowContainer = this.element_.find('.gmf-displayquerywindow .windowcontainer');
if (this.desktop) {
this.element_.find('.gmf-displayquerywindow .windowcontainer').draggable({
'cancel': 'input,textarea,button,select,option,tr',
'containment': this.draggableContainment
windowContainer.draggable({
handle: '.header',
containment: this.draggableContainment
});
this.element_.find('.gmf-displayquerywindow .windowcontainer').resizable({
'minHeight': 240,
'minWidth': 240
windowContainer.resizable({
minHeight: 240,
minWidth: 240
});
}
};
Expand Down
5 changes: 3 additions & 2 deletions contribs/gmf/src/theme/Manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,16 @@ ThemeManagerService.prototype.isLoading = function() {
/**
* @param {string} themeName wanted theme name.
* @param {string} fallbackThemeName fallback theme name.
* @param {boolean=} opt_silent if true notifyCantAddGroups_ is not called.
* @export
*/
ThemeManagerService.prototype.updateCurrentTheme = function(themeName, fallbackThemeName) {
ThemeManagerService.prototype.updateCurrentTheme = function(themeName, fallbackThemeName, opt_silent) {
this.gmfThemes_.getThemesObject().then((themes) => {
if (!themeName && this.modeFlush) {
// In flush mode load current theme private groups
const fallbackTheme = findThemeByName(themes, fallbackThemeName);
if (fallbackTheme) {
this.gmfTreeManager_.addFirstLevelGroups(fallbackTheme.children, false, false);
this.gmfTreeManager_.addFirstLevelGroups(fallbackTheme.children, false, opt_silent);
}
}
if (themeName) {
Expand Down
12 changes: 10 additions & 2 deletions examples/bboxquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@ function MainController($scope, ngeoDataSources) {
visible: true,
wfsFeatureNS: MAPSERVER_WFS_FEATURE_NS,
wfsUrl: MAPSERVER_PROXY,
ogcLayers: [{
wmsLayers: [{
name: 'bus_stop',
queryable: true
}],
wfsLayers: [{
name: 'bus_stop',
queryable: true
}]
Expand All @@ -148,7 +152,11 @@ function MainController($scope, ngeoDataSources) {
visible: true,
wfsFeatureNS: MAPSERVER_WFS_FEATURE_NS,
wfsUrl: MAPSERVER_PROXY,
ogcLayers: [{
wmsLayers: [{
name: 'information',
queryable: true
}],
wfsLayers: [{
name: 'information',
queryable: true
}]
Expand Down
12 changes: 10 additions & 2 deletions examples/mapquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,11 @@ function MainController($scope, ngeoDataSources, ngeoToolActivateMgr) {
name: 'bus_stop',
visible: true,
wmsUrl: MAPSERVER_PROXY,
ogcLayers: [{
wmsLayers: [{
name: 'bus_stop',
queryable: true
}],
wfsLayers: [{
name: 'bus_stop',
queryable: true
}]
Expand All @@ -158,7 +162,11 @@ function MainController($scope, ngeoDataSources, ngeoToolActivateMgr) {
name: 'information',
visible: true,
wmsUrl: MAPSERVER_PROXY,
ogcLayers: [{
wmsLayers: [{
name: 'information',
queryable: true
}],
wfsLayers: [{
name: 'information',
queryable: true
}]
Expand Down
2 changes: 1 addition & 1 deletion src/datasource/Helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class DatasourceHelper {
this.ngeoQuerent_.wfsDescribeFeatureType(dataSource).then((featureType_) => {
// We know, at this point, that there's only one definition that
// was returned. Just to be sure, let's do a bunch of assertions.
const ogcLayerName = dataSource.getOGCLayerNames()[0];
const ogcLayerName = dataSource.getWFSLayerNames()[0];
console.assert(typeof ogcLayerName == 'string', 'The data source should have only one ogcLayer.');
const featureType = /** @type {Object<string, *>} */(/** @type {unknown} */(featureType_));
for (const element of featureType.element) {
Expand Down
Loading