Skip to content

Commit

Permalink
Merge pull request #4132 from camptocamp/merge23
Browse files Browse the repository at this point in the history
 Merge remote-tracking branch 'origin/2.3'
  • Loading branch information
sbrunner committed Aug 16, 2018
2 parents 49f8f3e + ae9ee73 commit 2daa683
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 22 deletions.
7 changes: 6 additions & 1 deletion buildtools/check-example.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,23 @@ page.onAlert = function(msg) {
console.log('alert: ' + msg);
exitCode = 2;
};

page.onResourceError = function(resourceError) {
if (resourceError.url.includes('tile.openstreetmap.org')) {
console.warn('Ignoring resource error from OpenStreetMap');
} else if (resourceError.url.includes('https://maps.googleapis.com/maps/api/js')) {
console.warn('Ignoring resource error from Google');
} else if (resourceError.url.includes('https://csi.gstatic.com/')) {
console.warn('Ignoring resource error from Google static');
} else if (resourceError.url.includes('cdn.polyfill.io')) {
console.warn('Ignoring resource error from polyfill.io');
} else if (resourceError.errorCode >= 400) {
console.log('Resource error: ' + resourceError.errorCode + ', ' + resourceError.url);
console.log('Resource error: ' + resourceError.errorCode + ', ' + resourceError.errorString + ', ' + resourceError.url);
exitCode = 2;
}
};
page.onResourceTimeout = page.onResourceError;
page.settings.resourceTimeout = 3000;
page.onUrlChanged = function(url) {
console.log('URL changed: ' + url);
};
Expand Down
8 changes: 8 additions & 0 deletions contribs/gmf/src/editing/Snapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,14 @@ exports.prototype.loadAllItems_ = function() {
};


/**
* Manually refresh all features
*/
exports.prototype.refresh = function() {
this.loadAllItems_();
};


/**
* For a specific cache item, issue a new WFS GetFeatures request. The returned
* features set in the item collection of features (they replace any existing
Expand Down
1 change: 1 addition & 0 deletions contribs/gmf/src/editing/editFeatureComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,7 @@ exports.Controller_.prototype.save = function() {
this.dirty = false;
this.pending = false;
this.handleEditFeature_(response);
this.gmfSnapping_.refresh();
},
(response) => {
this.showServerError = true;
Expand Down
4 changes: 2 additions & 2 deletions contribs/gmf/src/lidarprofile/Manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,8 @@ const exports = class {
const gettextCatalog = this.gettextCatalog;
const errorInfoTxt = gettextCatalog.getString('Lidar profile service error');
const errorOfflineTxt = gettextCatalog.getString('It might be offline');
const errorOutsideTxt = gettextCatalog.getString('Or did you attempt to draw a profile outside data extent ?');
const errorNoPointError = gettextCatalog.getString('Or did you attempt to draw such a small profile that no point was returned ?');
const errorOutsideTxt = gettextCatalog.getString('Or did you attempt to draw a profile outside data extent?');
const errorNoPointError = gettextCatalog.getString('Or did you attempt to draw such a small profile that no point was returned?');
return `
<div class="lidarprofile-error">
<p class="bold">${errorInfoTxt}</p>
Expand Down
17 changes: 9 additions & 8 deletions contribs/gmf/src/print/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,6 @@ exports.Controller_ = class {
*/
getLegend_(scale, dpi, bbox) {
const legend = {'classes': []};
let classes, layerNames, layerName, icons;
const gettextCatalog = this.gettextCatalog_;

// Get layers from layertree only.
Expand All @@ -1098,12 +1097,12 @@ exports.Controller_ = class {

// For each visible layer in reverse order, get the legend url.
layers.reverse().forEach((layer) => {
classes = [];
const classes = [];
if (layer.getVisible() && layer.getSource()) {
// For WMTS layers.
if (layer instanceof olLayerTile) {
layerName = `${layer.get('layerNodeName')}`;
icons = this.getMetadataLegendImage_(layerName);
const layerName = `${layer.get('layerNodeName')}`;
let icons = this.getMetadataLegendImage_(layerName);
if (!icons) {
icons = this.ngeoLayerHelper_.getWMTSLegendURL(layer);
}
Expand All @@ -1117,9 +1116,9 @@ exports.Controller_ = class {
} else {
const source = /** @type ol.source.ImageWMS */ (layer.getSource());
// For each name in a WMS layer.
layerNames = source.getParams()['LAYERS'].split(',');
const layerNames = source.getParams()['LAYERS'].split(',');
layerNames.forEach((name) => {
icons = this.getMetadataLegendImage_(name);
let icons = this.getMetadataLegendImage_(name);
if (!icons) {
icons = this.ngeoLayerHelper_.getWMSLegendURL(source.getUrl(), name,
scale, undefined, undefined, undefined, source.serverType_, dpi, bbox,
Expand All @@ -1129,10 +1128,12 @@ exports.Controller_ = class {
// Don't add classes without legend url or from layers without any
// active name.
if (icons && name.length !== 0) {
classes.push({
classes.push(Object.assign({
'name': gettextCatalog.getString(name),
'icons': [icons]
});
}, layer.getSource().serverType_ === 'qgis' ? {
'dpi': dpi,
} : {}));
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion contribs/gmf/src/raster/widgetComponent.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<li ng-repeat="elevationItem in ::ctrl.layers">
<a href ng-click="ctrl.selectedElevationLayer = elevationItem">
<span class="fa fa-fw" ng-class="{'fa-check': ctrl.selectedElevationLayer === elevationItem}"></span>
{{::elevationItem | translate}}
{{elevationItem | translate}}
</a>
</li>
</ul>
Expand Down
6 changes: 4 additions & 2 deletions contribs/gmf/src/theme/Themes.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ exports.prototype.getBgLayers = function() {
gmfLayerWMTS.url,
gmfLayerWMTS.layer || '',
gmfLayerWMTS.matrixSet,
gmfLayer.dimensions
gmfLayer.dimensions,
gmfLayerWMTS.metadata.customOpenLayersOptions
).then(callback.bind(null, gmfLayer)).then(null, (response) => {
let message = `Unable to build layer "${gmfLayerWMTS.layer}" from WMTSCapabilities: ${gmfLayerWMTS.url}\n`;
message += `OpenLayers error is "${response['message']}`;
Expand All @@ -290,7 +291,8 @@ exports.prototype.getBgLayers = function() {
server.type,
undefined, // time
gmfLayer.dimensions,
server.credential ? 'use-credentials' : 'anonymous'
server.credential ? 'use-credentials' : 'anonymous',
gmfLayerWMS.metadata.customOpenLayersOptions
));
}
googAsserts.fail(`Unsupported type: ${gmfLayer.type}`);
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@
"uglify-js": "3.4.7",
"uglifyjs-webpack-plugin": "1.3.0",
"url-loader": "1.1.0",
"url-polyfill": "1.0.13",
"webpack": "4.16.5",
"webpack-cli": "3.1.0",
"webpack-dev-server": "3.1.5",
Expand Down
18 changes: 11 additions & 7 deletions src/map/LayerHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,12 @@ exports.REFRESH_PARAM = 'random';
* @param {string=} opt_time time parameter for layer queryable by time/periode
* @param {Object.<string, string>=} opt_params WMS parameters.
* @param {string=} opt_crossOrigin crossOrigin.
* @param {Object=} opt_customOptions Some initial options.
* @return {ol.layer.Image} WMS Layer.
* @export
*/
exports.prototype.createBasicWMSLayer = function(sourceURL,
sourceLayersName, sourceFormat, opt_serverType, opt_time, opt_params, opt_crossOrigin) {
sourceLayersName, sourceFormat, opt_serverType, opt_time, opt_params, opt_crossOrigin, opt_customOptions) {

const params = {
'FORMAT': sourceFormat,
Expand All @@ -92,12 +93,13 @@ exports.prototype.createBasicWMSLayer = function(sourceURL,
// OpenLayers expects 'qgis' insteads of 'qgisserver'
olServerType = opt_serverType.replace('qgisserver', 'qgis');
}
const source = new olSourceImageWMS({
const options = Object.assign({}, opt_customOptions, {
url: sourceURL,
params: params,
serverType: olServerType,
crossOrigin: opt_crossOrigin
});
const source = new olSourceImageWMS(options);
if (opt_params) {
source.updateParams(opt_params);
}
Expand Down Expand Up @@ -156,11 +158,12 @@ exports.prototype.createBasicWMSLayerFromDataSource = function(
* @param {string} layerName The name of the layer.
* @param {string=} opt_matrixSet Optional WMTS matrix set.
* @param {Object.<string, string>=} opt_dimensions WMTS dimensions.
* @param {Object=} opt_customOptions Some initial options.
* @return {angular.$q.Promise.<ol.layer.Tile>} A Promise with a layer (with source) on success,
* no layer else.
* @export
*/
exports.prototype.createWMTSLayerFromCapabilitites = function(capabilitiesURL, layerName, opt_matrixSet, opt_dimensions) {
exports.prototype.createWMTSLayerFromCapabilitites = function(capabilitiesURL, layerName, opt_matrixSet, opt_dimensions, opt_customOptions) {
const parser = new olFormatWMTSCapabilities();
const layer = new olLayerTile({
preload: this.tilesPreloadingLimit_
Expand All @@ -173,12 +176,11 @@ exports.prototype.createWMTSLayerFromCapabilitites = function(capabilitiesURL, l
result = parser.read(response.data);
}
if (result) {
const options = optionsFromCapabilities(result, {
const options = Object.assign({}, opt_customOptions, optionsFromCapabilities(result, {
matrixSet: opt_matrixSet,
crossOrigin: 'anonymous',
layer: layerName
});
googAsserts.assert(options);
}));
const source = new olSourceWMTS(/** @type {olx.source.WMTSOptions} */ (options));
if (opt_dimensions && !olObj.isEmpty(opt_dimensions)) {
source.updateDimensions(opt_dimensions);
Expand Down Expand Up @@ -423,9 +425,11 @@ exports.prototype.getWMSLegendURL = function(url,
if (opt_dpi != undefined) {
queryString['DPI'] = opt_dpi;
}
if (opt_bbox != undefined && opt_srs != undefined) {
if (opt_bbox != undefined && opt_srs != undefined && opt_scale != undefined && opt_dpi != undefined && opt_legendRule == undefined) {
queryString['BBOX'] = opt_bbox.join(',');
queryString['SRS'] = opt_srs;
queryString['WIDTH'] = Math.round((opt_bbox[2] - opt_bbox[0]) / opt_scale * 39.37 * opt_dpi);
queryString['HEIGHT'] = Math.round((opt_bbox[3] - opt_bbox[1]) / opt_scale * 39.37 * opt_dpi);
}
}
return olUri.appendParams(url, queryString);
Expand Down

0 comments on commit 2daa683

Please sign in to comment.