Skip to content

Commit

Permalink
Merge pull request #4581 from camptocamp/fix-ngeo-examples
Browse files Browse the repository at this point in the history
Fix types error in ngeo examples
  • Loading branch information
sbrunner committed Feb 1, 2019
2 parents 4ce708d + e24dc69 commit 4cd87ff
Show file tree
Hide file tree
Showing 25 changed files with 94 additions and 61 deletions.
2 changes: 1 addition & 1 deletion api/src/Themes.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export function createWMSLayer(config, ogcServer) {
const layer = new TileLayer({
source: new TileWMS({
url: ogcServer.url,
projection: undefined,
projection: undefined, // should be removed in next OL version
params: {
'LAYERS': config.layers
},
Expand Down
2 changes: 1 addition & 1 deletion contribs/gmf/src/controllers/AbstractDesktopController.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export class AbstractDesktopController extends AbstractAPIController {
ngeoToolActivateMgr.registerTool('mapTools', googleStreetViewActivate, false);

/**
* @type {ScaleselectorOptions}
* @type {import('ngeo/map/scaleselector.js').ScaleselectorOptions}
* @export
*/
this.scaleSelectorOptions = {
Expand Down
2 changes: 1 addition & 1 deletion contribs/gmf/src/controllers/AbstractMobileController.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class AbstractMobileController extends AbstractAppController {
});

/**
* @type {MobileGeolocationDirectiveOptions}
* @type {import('ngeo/geolocation/mobile.js').MobileGeolocationDirectiveOptions}
* @export
*/
this.mobileGeolocationOptions = {
Expand Down
2 changes: 1 addition & 1 deletion contribs/gmf/src/objectediting/Query.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ ObjectEditingQuery.prototype.getFeatureInfo = function(layerInfo, coordinate, ma

const wmsSource = new olSourceImageWMS({
url: ogcServer.url,
projection: undefined,
projection: undefined, // should be removed in next OL version
params: {
layers: layersParam
}
Expand Down
1 change: 1 addition & 0 deletions examples/backgroundlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ function MainController($scope) {
*/
const overlay = new olLayerImage({
source: new olSourceImageWMS({
projection: undefined, // should be removed in next OL version
url: 'https://wms.geo.admin.ch',
params: {'LAYERS': 'ch.swisstopo.dreiecksvermaschung'},
serverType: 'mapserver'
Expand Down
1 change: 1 addition & 0 deletions examples/backgroundlayerdropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ function MainController($scope) {
*/
const overlay = new olLayerImage({
source: new olSourceImageWMS({
projection: undefined, // should be removed in next OL version
url: 'https://wms.geo.admin.ch',
params: {'LAYERS': 'ch.swisstopo.dreiecksvermaschung'},
serverType: 'mapserver'
Expand Down
10 changes: 6 additions & 4 deletions examples/bboxquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,17 @@ function MainController($scope, ngeoDataSources) {
this.queryActive = true;

const informationLayer = new olLayerImage({
'source': new olSourceImageWMS({
'url': MAPSERVER_PROXY,
source: new olSourceImageWMS({
projection: undefined, // should be removed in next OL version
url: MAPSERVER_PROXY,
params: {'LAYERS': 'information'}
})
});

const busStopLayer = new olLayerImage({
'source': new olSourceImageWMS({
'url': MAPSERVER_PROXY,
source: new olSourceImageWMS({
projection: undefined, // should be removed in next OL version
url: MAPSERVER_PROXY,
params: {'LAYERS': 'bus_stop'}
})
});
Expand Down
5 changes: 3 additions & 2 deletions examples/colorpicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ function ColorPickerController() {

/**
* The colors set.
* @type {Array.<string>}
* @type {Array<Array<string>>}
* @const
* @export
*/
this.colors = [
['red', 'yellow', 'green', 'lightgreen', 'lightblue', 'orange', 'purple'],
['#ffffff', '#f7f7f7', '#c3c3c3', '#000000']];
['#ffffff', '#f7f7f7', '#c3c3c3', '#000000']
];

}

Expand Down
2 changes: 1 addition & 1 deletion examples/common_dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ import 'bootstrap/dist/css/bootstrap.css';
if (window.location.protocol === 'http:' && window.location.hostname !== 'localhost') {
const restOfUrl = window.location.href.substr(5);
/** @type {Location} */
window.location = `https:${restOfUrl}`;
window.location.href = `https:${restOfUrl}`;
}
2 changes: 1 addition & 1 deletion examples/control.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function MainController() {
});

/**
* @type {import('ol/control/Control.js').default").default}
* @type {import('ol/control/Control.js').default}
* @export
*/
this.control = new olControlMousePosition({
Expand Down
2 changes: 1 addition & 1 deletion examples/desktopgeolocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function MainController($scope, ngeoFeatureOverlayMgr) {
});

/**
* @type {DesktopGeolocationDirectiveOptions}
* @type {import('ngeo/geolocation/desktop.js').DesktopGeolocationDirectiveOptions}
* @export
*/
this.desktopGeolocationOptions = {
Expand Down
34 changes: 21 additions & 13 deletions examples/elevationProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function MainController($http, $scope) {
layers: [
new olLayerImage({
source: new olSourceImageWMS({
projection: undefined, // should be removed in next OL version
url: 'http://wms.geo.admin.ch/',
crossOrigin: 'anonymous',
attributions: '&copy; ' +
Expand Down Expand Up @@ -131,19 +132,17 @@ function MainController($http, $scope) {
* Factory for creating simple getter functions for extractors.
* If the value is in a child property, the opt_childKey must be defined.
* The type parameter is used by closure to type the returned function.
* @param {T} type An object of the expected result type.
* @param {any} type An object of the expected result type.
* @param {string} key Key used for retrieving the value.
* @param {string=} opt_childKey Key of a child object.
* @template T
* @return {function(Object): T} Getter function.
* @return {function(Object): any} Getter function.
*/
const typedFunctionsFactory = function(type, key, opt_childKey) {
return (
/**
* @param {Object} item
* @return {T}
* @template T
*/
/**
* @param {Object} item
* @return {any}
*/
function(item) {
if (opt_childKey !== undefined) {
item = item[opt_childKey];
Expand All @@ -169,14 +168,23 @@ function MainController($http, $scope) {
};


/** @type function({Object}): number */
const sort = typedFunctionsFactory(types.number, 'sort');
/** @type function({Object}): string */
const id = typedFunctionsFactory(types.string, 'id');
/** @type function({Object}): number */
const dist = typedFunctionsFactory(types.number, 'dist');
/** @type function({Object}): string */
const title = typedFunctionsFactory(types.string, 'title');

/**
* @type {PoiExtractor}
* @type {import('ngeo/profile/elevationComponent.js').PoiExtractor}
*/
const poiExtractor = {
sort: typedFunctionsFactory(types.number, 'sort'),
id: typedFunctionsFactory(types.string, 'id'),
dist: typedFunctionsFactory(types.number, 'dist'),
title: typedFunctionsFactory(types.string, 'title'),
sort,
id,
dist,
title,
/**
* @param {Object} item POI.
* @param {number=} opt_z Z value.
Expand Down
2 changes: 1 addition & 1 deletion examples/importfeatures.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ MainController.prototype.importKml_ = function(kml) {
const extent = vectorSource.getExtent();
const mapSize = map.getSize();
if (mapSize && !olExtent.isEmpty(extent)) {
map.getView().fit(extent, mapSize);
map.getView().fit(extent, {size: mapSize});
}
};

Expand Down
6 changes: 3 additions & 3 deletions examples/interactionbtngroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function MainController(ngeoFeatureOverlayMgr) {
* @export
*/
this.drawPolygon = new olInteractionDraw(
/** @type {olx.interaction.DrawOptions} */ ({
/** @type {import('ol/interaction/Draw.js').Options} */ ({
type: 'Polygon',
features: features
}));
Expand All @@ -100,7 +100,7 @@ function MainController(ngeoFeatureOverlayMgr) {
* @export
*/
this.drawPoint = new olInteractionDraw(
/** @type {olx.interaction.DrawOptions} */ ({
/** @type {import('ol/interaction/Draw.js').Options} */ ({
type: 'Point',
features: features
}));
Expand All @@ -115,7 +115,7 @@ function MainController(ngeoFeatureOverlayMgr) {
* @export
*/
this.drawLine = new olInteractionDraw(
/** @type {olx.interaction.DrawOptions} */ ({
/** @type {import('ol/interaction/Draw.js').Options} */ ({
type: 'LineString',
features: features
}));
Expand Down
4 changes: 4 additions & 0 deletions examples/layerorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ function MainController($scope) {
/** @type {import("ol/layer/Tile.js").default} */
const boundaries = new olLayerTile({
source: new olSourceTileWMS({
projection: undefined, // should be removed in next OL version
url: 'https://wms.geo.admin.ch',
params: {'LAYERS': 'ch.swisstopo.swissboundaries3d-gemeinde-flaeche.fill'},
serverType: 'mapserver'
Expand All @@ -53,6 +54,7 @@ function MainController($scope) {
/** @type {import("ol/layer/Tile.js").default} */
const waterBodies = new olLayerTile({
source: new olSourceTileWMS({
projection: undefined, // should be removed in next OL version
url: 'https://wms.geo.admin.ch',
params: {'LAYERS': 'ch.swisstopo.geologie-gravimetrischer_atlas'},
serverType: 'mapserver'
Expand All @@ -63,6 +65,7 @@ function MainController($scope) {
/** @type {import("ol/layer/Tile.js").default} */
const cities = new olLayerTile({
source: new olSourceTileWMS({
projection: undefined, // should be removed in next OL version
url: 'https://wms.geo.admin.ch',
params: {'LAYERS': 'ch.swisstopo.dreiecksvermaschung'},
serverType: 'mapserver'
Expand Down Expand Up @@ -97,6 +100,7 @@ function MainController($scope) {
*/
this.roads_ = new olLayerTile({
source: new olSourceTileWMS({
projection: undefined, // should be removed in next OL version
url: 'https://wms.geo.admin.ch',
params: {'LAYERS': 'ch.bafu.laerm-strassenlaerm_tag'},
serverType: 'mapserver'
Expand Down
2 changes: 1 addition & 1 deletion examples/layertree.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function LayertreeController($http, $sce, appGetLayer, ngeoCreatePopup) {

/**
* @private
* @type {import("ngeo/message/Popup.js").default}
* @type {import("ngeo/message/Popup.js").MessagePopup}
*/
this.infoPopup_ = ngeoCreatePopup();

Expand Down
6 changes: 2 additions & 4 deletions examples/locationsearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ appmodule.component('appLocationSearch', locationSearchComponent);

/**
* @constructor
* @param {import("ngeo/search/createLocationSearchBloodhound.js").default.Function} ngeoCreateLocationSearchBloodhound Bloodhound service.
* @param {import("ngeo/search/createLocationSearchBloodhound.js").Function} ngeoCreateLocationSearchBloodhound Bloodhound service.
* @ngInject
*/
function SearchController(ngeoCreateLocationSearchBloodhound) {
Expand Down Expand Up @@ -97,7 +97,7 @@ function SearchController(ngeoCreateLocationSearchBloodhound) {


/**
* @param {import("ngeo/search/createLocationSearchBloodhound.js").default.Function} ngeoCreateLocationSearchBloodhound
* @param {import("ngeo/search/createLocationSearchBloodhound.js").Function} ngeoCreateLocationSearchBloodhound
* Bloodhound service.
* @param {number} limit Limit.
* @return {Bloodhound} The bloodhound engine.
Expand Down Expand Up @@ -126,8 +126,6 @@ SearchController.prototype.createAndInitBloodhound_ = function(ngeoCreateLocatio
* @param {JQueryEventObject} event Event.
* @param {Object} suggestion Suggestion.
* @param {Twitter.Typeahead.Dataset} dataset Dataset.
* @this {app.locationsearch.SearchController}
* @private
*/
function select_(event, suggestion, dataset) {
const feature = /** @type {import("ol/Feature.js").default} */ (suggestion);
Expand Down
3 changes: 2 additions & 1 deletion examples/mapfishprint.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ function MainController($timeout, ngeoCreatePrint, ngeoPrintUtils) {
new olLayerImage({
source: new olSourceImageWMS({
url: MAPSERVER_PROXY,
projection: undefined, // should be removed in next OL version
params: {
'LAYERS': 'osm'
},
Expand All @@ -88,7 +89,7 @@ function MainController($timeout, ngeoCreatePrint, ngeoPrintUtils) {
source: new olSourceVector({
url: 'data/polygon-swizerland.json',
format: new olFormatGeoJSON({
defaultDataProjection: EPSG21781
dataProjection: EPSG21781
})
})
})
Expand Down
10 changes: 6 additions & 4 deletions examples/mapquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,17 @@ function MainController($scope, ngeoDataSources, ngeoToolActivateMgr) {
this.queryActive = true;

const busStopLayer = new olLayerImage({
'source': new olSourceImageWMS({
'url': MAPSERVER_PROXY,
source: new olSourceImageWMS({
url: MAPSERVER_PROXY,
projection: undefined, // should be removed in next OL version
params: {'LAYERS': 'bus_stop'}
})
});

const informationLayer = new olLayerImage({
'source': new olSourceImageWMS({
'url': MAPSERVER_PROXY,
source: new olSourceImageWMS({
url: MAPSERVER_PROXY,
projection: undefined, // should be removed in next OL version
params: {'LAYERS': 'information'}
})
});
Expand Down
2 changes: 1 addition & 1 deletion examples/mobilegeolocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function MainController($scope, ngeoFeatureOverlayMgr) {
});

/**
* @type {MobileGeolocationDirectiveOptions}
* @type {import('ngeo/geolocation/mobile.js').MobileGeolocationDirectiveOptions}
* @export
*/
this.mobileGeolocationOptions = {
Expand Down
24 changes: 12 additions & 12 deletions examples/permalink.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module.component('appMap', mapComponent);

/**
* @param {import("ngeo/statemanager/Location.js").StatemanagerLocation} ngeoLocation ngeo Location service.
* @param {import("ngeo/misc/debounce.js").miscDebounce<function(): void>} ngeoDebounce ngeo Debounce factory.
* @param {import("ngeo/misc/debounce.js").miscDebounce<function(import("ol/events/Event.js").default): void>} ngeoDebounce ngeo Debounce factory.
* @constructor
* @ngInject
*/
Expand All @@ -66,7 +66,7 @@ function MapComponentController(ngeoLocation, ngeoDebounce) {
this.ngeoLocation_ = ngeoLocation;

/**
* @type {import("ngeo/misc/debounce.js").miscDebounce<function(): void>}
* @type {import("ngeo/misc/debounce.js").miscDebounce<function(import("ol/events/Event.js").default): void>}
* @private
*/
this.ngeoDebounce_ = ngeoDebounce;
Expand All @@ -77,8 +77,8 @@ module.controller('AppMapController', MapComponentController);
MapComponentController.prototype.$onInit = function() {
const view = this.map.getView();

let zoom = this.ngeoLocation_.getParam('z');
zoom = zoom !== undefined ? +zoom : 4;
const zoom_ = this.ngeoLocation_.getParam('z');
const zoom = zoom_ !== undefined ? +zoom_ : 4;

const x = this.ngeoLocation_.getParam('x');
const y = this.ngeoLocation_.getParam('y');
Expand All @@ -89,9 +89,9 @@ MapComponentController.prototype.$onInit = function() {
view.setZoom(zoom);

this.ngeoLocation_.updateParams({
'z': zoom,
'x': Math.round(center[0]),
'y': Math.round(center[1])
'z': `${zoom}`,
'x': `${Math.round(center[0])}`,
'y': `${Math.round(center[1])}`
});

view.on('propertychange',
Expand All @@ -102,9 +102,9 @@ MapComponentController.prototype.$onInit = function() {
(e) => {
const center = view.getCenter();
const params = {
'z': view.getZoom(),
'x': Math.round(center[0]),
'y': Math.round(center[1])
'z': `${view.getZoom()}`,
'x': `${Math.round(center[0])}`,
'y': `${Math.round(center[1])}`
};
this.ngeoLocation_.updateParams(params);
}, 300, /* invokeApply */ true));
Expand Down Expand Up @@ -189,9 +189,9 @@ DrawComponentController.prototype.$onInit = function() {
this.map.addInteraction(this.interaction);
interaction(this.interaction);

this.interaction.on('drawend', function(e) {
this.interaction.on('drawend', (e) => {
e.feature.set('id', ++this.featureSeq_);
}, this);
});

// Deal with the encoding and decoding of features in the URL.

Expand Down

0 comments on commit 4cd87ff

Please sign in to comment.