Skip to content

Commit

Permalink
Some fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Jun 6, 2019
1 parent 1ae1539 commit e89ba63
Show file tree
Hide file tree
Showing 97 changed files with 479 additions and 413 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ script:
- buildtools/test_examples.py 1/1
#- npm run typecheck
# Generate API doc
- '! (npm run typecheck|sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g"|grep ^src)'
- '! (npm run typecheck|grep -E "api|gmf|test/|examples")'
- "! (npm run typecheck|grep -v '^node_modules/'|grep '^[a-z]')"
- npm run doc
- npm run build-api

Expand Down
5 changes: 3 additions & 2 deletions api/src/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,10 @@ class Map {
}
this.map_.addControl(new OverviewMap({
collapsed: !options.miniMapExpanded,
layers: [],
view: new View({
projection: this.view_.getProjection(),
resolutions
resolutions,
})
}));
}
Expand Down Expand Up @@ -151,7 +152,7 @@ class Map {

/**
* @private
* @type {VectorSource}
* @type {VectorSource<import("ol/geom/Geometry.js").default>}
*/
this.vectorSource_ = new VectorSource();

Expand Down
4 changes: 2 additions & 2 deletions api/src/Querent.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ import olFormatWFS from 'ol/format/WFS.js';
*
* @param {string} layer Name of the layer to query
* @param {string[]} ids List of ids
* @return {Promise<Array<import('ol/Feature.js').default>>} Promise.
* @return {Promise<Array<import('ol/Feature.js').default<import("ol/geom/Geometry.js").default>>>} Promise.
* @hidden
*/
export function getFeaturesFromLayer(layer, ids) {
return new Promise((resolve, reject) => {
getOverlayDefs().then((overlayDefs) => {

/** @type {Array<import('ol/Feature.js').default>} */
/** @type {Array<import('ol/Feature.js').default<import("ol/geom/Geometry.js").default>>} */
let features = [];
const overlayDef = overlayDefs.get(layer);

Expand Down
32 changes: 18 additions & 14 deletions api/src/Themes.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ let overlayDefPromise;
* @return {Promise<Array<TileLayer|ImageLayer|GroupLayer>>} Promise
*/
export function getBackgroundLayers() {
return getThemesPromise().then((themes) => {
return getThemesPromise().then(themes => {
const promises = [];
for (const config of themes.background_layers) {
const layerConfig = /** @type {import('gmf/themes.js').GmfLayer} */(config);
Expand All @@ -61,32 +61,35 @@ export function getBackgroundLayers() {
return layer;
})
);
} else if (/** @type {import('gmf/themes.js').GmfGroup} */ (config).children) {
} else if (/** @type {import('gmf/themes.js').GmfGroup} */(config).children) {
// reverse children order
const reversed = /** @type {import('gmf/themes.js').GmfGroup} */ (config).children.slice().reverse();
const reversed = /** @type {import('gmf/themes.js').GmfGroup} */(config).children.slice().reverse();

// create all the layers for the layer group
const groupPromise = Promise.all(reversed.map((item) => {
const child = /** @type {import('gmf/themes.js').GmfLayer} */ (item);

/** @type {Promise<TileLayer|ImageLayer>[]} */
const groupPromises = reversed.map(item => {
const child = /** @type {import('gmf/themes.js').GmfLayer} */(item);
if (child.type === 'WMTS') {
const layerWMTS = /** @type {import('gmf/themes.js').GmfLayerWMTS} */ (child);
const layerWMTS = /** @type {import('gmf/themes.js').GmfLayerWMTS} */(child);
return createWMTSLayer(layerWMTS);
} else if (child.type === 'WMS') {
const layerWMS = /** @type {import('gmf/themes.js').GmfLayerWMS} */ (child);
const layerWMS = /** @type {import('gmf/themes.js').GmfLayerWMS} */(child);
return createWMSLayer(layerWMS, themes.ogcServers[child.ogcServer]);
}
throw new Error('Unknow layer type');
}));
promises.push(
groupPromise.then((layers) => {
});
const groupPromise = Promise.all(groupPromises);
promises.push(groupPromise.then(
layers => {
// create a layer group for the children.
const group = new GroupLayer({
layers: layers
layers
});
group.set('config.name', config.name);
return group;
})
);
}
));
}
}
return Promise.all(/** @type {Array<Promise<TileLayer|ImageLayer|GroupLayer>>} */ (promises));
Expand Down Expand Up @@ -154,11 +157,12 @@ export function writeOverlayDefs(config, ogcServers, opt_ogcServer) {
* Returns a list of OpenLayers layer objects from the given layer names.
*
* @param {string[]} layerNames List of layer names
* @return {Promise} Promise.
* @return {Promise<(TileLayer|ImageLayer)[]>} Promise.
* @hidden
*/
export function getOverlayLayers(layerNames) {
return getOverlayDefs().then((overlayDefs) => {
/** @type {Promise<TileLayer|ImageLayer>[]} */
const promises = [];
for (const layerName of layerNames) {

Expand Down
4 changes: 2 additions & 2 deletions contribs/gmf/apps/oeedit/Controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class Controller extends AbstractDesktopController {
});

/**
* @type {import("ol/Collection.js").default<import("ol/Feature.js").default>}
* @type {import("ol/Collection.js").default<import("ol/Feature.js").default<import("ol/geom/Geometry.js").default>>}
*/
this.sketchFeatures = new olCollection();

Expand Down Expand Up @@ -139,7 +139,7 @@ class Controller extends AbstractDesktopController {
this.oeLayerNodeId = gmfObjectEditingManager.getLayerNodeId();

/**
* @type {?import("ol/Feature.js").default}
* @type {?import("ol/Feature.js").default<import("ol/geom/Geometry.js").default>}
*/
this.oeFeature = null;

Expand Down
2 changes: 1 addition & 1 deletion contribs/gmf/examples/drawfeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module.constant('angularLocaleScript', '../build/angular-locale_{{locale}}.js');
/**
* @param {angular.IScope} $scope Angular scope.
* @param {import("ngeo/misc/FeatureHelper.js").FeatureHelper} ngeoFeatureHelper Gmf feature helper service.
* @param {import("ol/Collection.js").default<import("ol/Feature.js").default>} ngeoFeatures Collection of
* @param {import("ol/Collection.js").default<import("ol/Feature.js").default<import("ol/geom/Geometry.js").default>>} ngeoFeatures Collection of
* features.
* @param {import("ngeo/misc/ToolActivateMgr.js").ToolActivateMgr} ngeoToolActivateMgr Ngeo ToolActivate
* manager service.
Expand Down
4 changes: 2 additions & 2 deletions contribs/gmf/examples/editfeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function MainController($scope, gmfEditFeature, gmfUser) {
this.layerId_ = 113;

/**
* @type {?import("ol/Feature.js").default}
* @type {?olFeature<import("ol/geom/Geometry.js").default>}
*/
this.feature = null;

Expand Down Expand Up @@ -167,7 +167,7 @@ MainController.prototype.handleMapSingleClick_ = function(evt) {


/**
* @param {Array<import("ol/Feature.js").default>} features Features.
* @param {Array<olFeature<import("ol/geom/Geometry.js").default>>} features Features.
* @private
*/
MainController.prototype.handleGetFeatures_ = function(features) {
Expand Down
2 changes: 1 addition & 1 deletion contribs/gmf/examples/editfeatureselector.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function MainController($scope, gmfThemes, gmfTreeManager, gmfUser,
features: new olCollection()
}),
style: (feature, resolution) => ngeoFeatureHelper.createEditingStyles(
/** @type {import('ol/Feature.js').default} */(feature)
/** @type {import('ol/Feature.js').default<import("ol/geom/Geometry.js").default>} */(feature)
)
});

Expand Down
8 changes: 4 additions & 4 deletions contribs/gmf/examples/featurestyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ function MainController($scope, ngeoFeatureHelper) {
});

/**
* @type {?import("ol/Feature.js").default}
* @type {?olFeature<import("ol/geom/Geometry.js").default>}
*/
this.selectedFeature = null;

Expand All @@ -206,9 +206,9 @@ function MainController($scope, ngeoFeatureHelper) {
MainController.prototype.handleMapSingleClick_ = function(evt) {
const pixel = evt.pixel;

const feature = /** @type {import("ol/Feature.js").default} */(this.map.forEachFeatureAtPixel(
pixel, feature => feature
));
const feature = /** @type {olFeature<import("ol/geom/Geometry.js").default>} */(
this.map.forEachFeatureAtPixel(pixel, feature => feature)
);

if (this.selectedFeature) {
this.featureHelper_.setStyle(this.selectedFeature);
Expand Down
6 changes: 3 additions & 3 deletions contribs/gmf/examples/objectediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function MainController(gmfObjectEditingManager, gmfThemes,
projection.setExtent([485869.5728, 76443.1884, 837076.5648, 299941.7864]);

/**
* @type {import("ol/source/Vector.js").default}
* @type {import("ol/source/Vector.js").default<import("ol/geom/Geometry.js").default>}
* @private
*/
this.vectorSource_ = new olSourceVector({
Expand All @@ -90,7 +90,7 @@ function MainController(gmfObjectEditingManager, gmfThemes,
});

/**
* @type {import("ol/Collection.js").default<import("ol/Feature.js").default>}
* @type {import("ol/Collection.js").default<import("ol/Feature.js").default<import("ol/geom/Geometry.js").default>>}
*/
this.sketchFeatures = new olCollection();

Expand Down Expand Up @@ -161,7 +161,7 @@ function MainController(gmfObjectEditingManager, gmfThemes,
'mapTools', dummyToolActivate, false);

/**
* @type {?import("ol/Feature.js").default}
* @type {?import("ol/Feature.js").default<import("ol/geom/Geometry.js").default>}
*/
this.objectEditingFeature = null;

Expand Down
15 changes: 8 additions & 7 deletions contribs/gmf/examples/objecteditinghub.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,17 @@ function MainController($http, $q, $scope, gmfThemes, gmfXSDAttributes) {
this.selectedGmfLayerNode = null;

/**
* @type {Object<number, Array<import("ol/Feature.js").default>>}
* @type {Object<number, Array<import("ol/Feature.js").default<import("ol/geom/Geometry.js").default>>>}
*/
this.featuresCache_ = {};

/**
* @type {Array<import("ol/Feature.js").default>}
* @type {Array<import("ol/Feature.js").default<import("ol/geom/Geometry.js").default>>}
*/
this.features = [];

/**
* @type {?import("ol/Feature.js").default}
* @type {?import("ol/Feature.js").default<import("ol/geom/Geometry.js").default>}
*/
this.selectedFeature = null;

Expand Down Expand Up @@ -308,16 +308,17 @@ MainController.prototype.issueGetFeatures_ = function(gmfLayerNode) {
* @private
*/
MainController.prototype.handleGetFeatures_ = function(gmfLayerNode) {
const features = /** @type Array<import("ol/Feature.js").default> */ (
this.getFeaturesFromCache_(gmfLayerNode));
this.features = features;
this.features =
/** @type {Array<import("ol/Feature.js").default<import("ol/geom/Geometry.js").default>>} */ (
this.getFeaturesFromCache_(gmfLayerNode)
);
this.selectedFeature = this.features[0];
};


/**
* @param {import('gmf/themes.js').GmfLayerWMS} gmfLayerNode Layer node.
* @return {?Array<import("ol/Feature.js").default>} List of features
* @return {?Array<import("ol/Feature.js").default<import("ol/geom/Geometry.js").default>>} List of features
* @private
*/
MainController.prototype.getFeaturesFromCache_ = function(gmfLayerNode) {
Expand Down
2 changes: 1 addition & 1 deletion contribs/gmf/examples/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function MainController($scope, ngeoFeatureOverlayMgr) {
});

/**
* @type {import("ol/Collection.js").default<import("ol/Feature.js").default>}
* @type {import("ol/Collection.js").default<import("ol/Feature.js").default<import("ol/geom/LineString.js").default>>}
*/
const features = new olCollection();

Expand Down
2 changes: 1 addition & 1 deletion contribs/gmf/examples/xsdattributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function MainController($timeout, gmfThemes, gmfXSDAttributes) {
this.attributes = null;

/**
* @type {?import("ol/Feature.js").default}
* @type {?olFeature<import("ol/geom/Geometry.js").default>}
*/
this.feature = null;

Expand Down
4 changes: 1 addition & 3 deletions contribs/gmf/src/controllers/AbstractAPIController.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ export class AbstractAPIController extends AbstractAppController {
interactions: config.mapInteractions || olInteraction.defaults({
pinchRotate: true,
altShiftDragRotate: true
}),
loadTilesWhileAnimating: true,
loadTilesWhileInteracting: true
})
}), $scope, $injector);
}
}
Expand Down
2 changes: 1 addition & 1 deletion contribs/gmf/src/controllers/AbstractAppController.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export function AbstractAppController(config, map, $scope, $injector) {

/**
* Collection of features for the draw interaction
* @type {import("ol/Collection.js").default<import("ol/Feature.js").default>}
* @type {import("ol/Collection.js").default<import("ol/Feature.js").default<import("ol/geom/Geometry.js").default>>}
*/
const ngeoFeatures = $injector.get('ngeoFeatures');

Expand Down
4 changes: 2 additions & 2 deletions contribs/gmf/src/datasource/ExternalDataSourcesManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,15 +297,15 @@ export class ExternalDatSourcesManager {
}

/**
* @param {import("ol/layer/Layer.js").default} layer Layer.
* @param {import("ol/layer/Layer.js").default<import('ol/source/Source.js').default>} layer Layer.
* @private
*/
addLayer_(layer) {
this.layerGroup.getLayers().push(layer);
}

/**
* @param {import("ol/layer/Layer.js").default} layer Layer.
* @param {import("ol/layer/Layer.js").default<import('ol/source/Source.js').default>} layer Layer.
* @private
*/
removeLayer_(layer) {
Expand Down

0 comments on commit e89ba63

Please sign in to comment.