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

Fix types in editing, draw, datasource and ngeo root #4562

Merged
merged 5 commits into from
Jan 30, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions contribs/gmf/src/datasource/ExternalDataSourcesManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class ExternalDatSourcesManager {
/**
* The collection of DataSources from ngeo. When this service creates
* a data source, its gets added to that collection.
* @type {!DataSources}
* @type {!import('ngeo/datasource/DataSource.js').DataSources}
* @private
*/
this.dataSources_ = ngeoDataSources.collection;
Expand Down Expand Up @@ -374,7 +374,7 @@ export class ExternalDatSourcesManager {


// (2) Add data source in WMS group, unless it's already in there.
// Will also add the data source to the `ngeo.DataSources` collection.
// Will also add the data source to the `import('ngeo/datasource/DataSource.js').DataSources` collection.
// If the group is created, its inner OL layer is also added to the map.
let wmsGroup = this.getWMSGroup(url);
if (wmsGroup) {
Expand Down
6 changes: 3 additions & 3 deletions contribs/gmf/src/datasource/Helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Helper {
// === Other properties ===

/**
* @type {DataSources}
* @type {import('ngeo/datasource/DataSource.js').DataSources}
* @protected
*/
this.collection_;
Expand All @@ -57,11 +57,11 @@ class Helper {
}

/**
* @return {DataSources} Data sources collection.
* @return {import('ngeo/datasource/DataSource.js').DataSources} Data sources collection.
* @export
*/
get collection() {
return /** @type {DataSources} */ (
return /** @type {import('ngeo/datasource/DataSource.js').DataSources} */ (
this.ngeoDataSourcesHelper_.collection
);
}
Expand Down
2 changes: 1 addition & 1 deletion contribs/gmf/src/datasource/Manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class DatasourceManager {
* The collection of DataSources from ngeo, which gets updated by this
* service. When the theme changes, first we remove all data sources, then
* the 'active' data source are added here.
* @type {DataSources}
* @type {import('ngeo/datasource/DataSource.js').DataSources}
* @private
*/
this.dataSources_ = ngeoDataSources.collection;
Expand Down
2 changes: 1 addition & 1 deletion contribs/gmf/src/filters/filterselectorComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class Controller {
this.filtrableLayerNodeNames_ = null;

/**
* @type {DataSources}
* @type {import('ngeo/datasource/DataSource.js').DataSources}
* @private
*/
this.gmfDataSources_ = gmfDataSourcesHelper.collection;
Expand Down
6 changes: 3 additions & 3 deletions contribs/gmf/src/layertree/datasourceGroupTreeComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class Controller {
this.scope_ = $scope;

/**
* @type {!DataSources}
* @type {!import('ngeo/datasource/DataSource.js').DataSources}
* @private
*/
this.dataSources_ = ngeoDataSources.collection;
Expand Down Expand Up @@ -105,7 +105,7 @@ class Controller {
}

/**
* Remove all data sources from the `ngeo.datasource.DataSources` collection, which
* Remove all data sources from the `import('ngeo/datasource/DataSource.js').DataSources` collection, which
* will automatically remove them from the Group. The group itself
* is going to be removed as well, destroying this component in the process.
* @export
Expand All @@ -118,7 +118,7 @@ class Controller {

/**
* @param {!import("ngeo/datasource/DataSource.js").default} dataSource Data source to remove from
* the `ngeo.DataSources` collection.
* the `import('ngeo/datasource/DataSource.js').DataSources` collection.
* @export
*/
removeDataSource(dataSource) {
Expand Down
14 changes: 1 addition & 13 deletions contribs/gmf/src/themes.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
/**
* Externs for the GeoMapFish "themes" web service.
*/

/**
* @typedef {Object} DimensionFilterConfig
* @property {string} field
* @property {string} [value]
*/


/**
* Dimensions applied by filters configuration.
* @typedef {Object.<string, DimensionFilterConfig>} DimensionsFiltersConfig
* The GeoMapFish "themes" web service.
*/


Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"@types/bootstrap": "4.2.1",
"@types/cesium": "1.47.3",
"@types/d3": "5.7.0",
"@types/file-saver": "2.0.0",
"@types/googlemaps": "3.30.16",
"@types/jquery": "3.3.29",
"@types/jquery.ui.datetimepicker": "0.3.29",
Expand Down
8 changes: 2 additions & 6 deletions src/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import olOverlayPositioning from 'ol/OverlayPositioning.js';
export default class extends olOverlay {
/**
* @param {MenuOptions=} menuOptions Menu options.
* @param {olx.OverlayOptions=} options Overlay options.
* @param {import('ol/Overlay.js').Options=} options Overlay options.
*/
constructor(menuOptions, options = {}) {
super(options);
Expand Down Expand Up @@ -214,12 +214,8 @@ export default class extends olOverlay {
*/
handleMapPointerMove_(evt) {
const target = evt.originalEvent.target;
console.assert(target instanceof Element);

const element = this.getElement();
console.assert(element instanceof Element);

if (element.contains(target)) {
if (target instanceof Element && element instanceof Element && element.contains(target)) {
evt.coordinate = [Infinity, Infinity];
evt.pixel = [Infinity, Infinity];
}
Expand Down
15 changes: 6 additions & 9 deletions src/Popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import olOverlay from 'ol/Overlay.js';
* An openlayers overlay that uses bootstrap popover to produce a popup
* for maps.
*
* @constructor
* @extends {import("ol/Overlay.js").default}
* @param {olx.OverlayOptions=} opt_options Overlay options.
* @param {import('ol/Overlay.js').Options=} opt_options Overlay options.
*/
export default class extends olOverlay {
constructor(options = {}) {
Expand Down Expand Up @@ -60,18 +58,17 @@ export default class extends olOverlay {
window.setTimeout(() => {
$(element)
.popover({
'content': contentEl,
'html': true,
'placement': 'top',
'template': [
content: contentEl.get()[0],
html: true,
placement: 'top',
template: [
'<div class="popover ngeo-popover" role="tooltip">',
' <div class="arrow"></div>',
' <h3 class="popover-header"></h3>',
' <div class="popover-body"></div>',
'</div>'
].join('')
})
.popover('show');
}).popover('show');
}, 0);

this.closeEl_.one('click', () => {
Expand Down
89 changes: 51 additions & 38 deletions src/WFSDescribeFeatureType.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,72 +13,84 @@ const NAMESPACE_URIS_ = [
];


/**
* @typedef {Object.<string, import("ol/xml.js").Parser>} parserStructure
*/


/**
* typedef {Object.<string, parserStructure>} parsersStructure
* @typedef {Object<string, Object<string, import("ol/xml.js").Parser>>} parsersStructure
*/

/**
* @param {Array<string>} namespaceURIs Namespace URIs.
* @param {parserStructure} structure Structure.
* @return {Object<string, parserStructure>} Namespaced structure.
*/
function makeStructureNS(namespaceURIs, structure) {
return /** @type {parsersStructure} */(/** @type {any} */(olXml.makeStructureNS(namespaceURIs, structure)));
}

/**
* @const
* @type {!Object.<string, !Object.<string, !import("ol/XmlParser.js").default>>}
* @type {parsersStructure}
* @private
*/
const PARSERS_ = olXml.makeStructureNS(
const PARSERS_ = makeStructureNS(
NAMESPACE_URIS_, {
'element': olXml.makeObjectPropertyPusher(
readElement_
),
'complexType': olXml.makeObjectPropertyPusher(
readComplexType_
)
});
element: olXml.makeObjectPropertyPusher(readElement_),
complexType: olXml.makeObjectPropertyPusher(readComplexType_)
}
);


/**
* @const
* @type {!Object.<string, !Object.<string, !import("ol/XmlParser.js").default>>}
* @type {parsersStructure}
* @private
*/
const COMPLEX_TYPE_PARSERS_ = olXml.makeStructureNS(
const COMPLEX_TYPE_PARSERS_ = makeStructureNS(
NAMESPACE_URIS_, {
'complexContent': olXml.makeObjectPropertySetter(
readComplexContent_
)
});
complexContent: olXml.makeObjectPropertySetter(readComplexContent_)
}
);


/**
* @const
* @type {!Object.<string, !Object.<string, !import("ol/XmlParser.js").default>>}
* @type {parsersStructure}
* @private
*/
const COMPLEX_CONTENT_PARSERS_ = olXml.makeStructureNS(
const COMPLEX_CONTENT_PARSERS_ = makeStructureNS(
NAMESPACE_URIS_, {
'extension': olXml.makeObjectPropertySetter(
readExtension_
)
});
extension: olXml.makeObjectPropertySetter(readExtension_)
}
);


/**
* @const
* @type {!Object.<string, !Object.<string, !import("ol/XmlParser.js").default>>}
* @type {parsersStructure}
* @private
*/
const EXTENSION_PARSERS_ = olXml.makeStructureNS(
const EXTENSION_PARSERS_ = makeStructureNS(
NAMESPACE_URIS_, {
'sequence': olXml.makeObjectPropertySetter(
readSequence_
)
});
sequence: olXml.makeObjectPropertySetter(readSequence_)
}
);


/**
* @const
* @type {!Object.<string, !Object.<string, !import("ol/XmlParser.js").default>>}
* @type {parsersStructure}
* @private
*/
const SEQUENCE_PARSERS_ = olXml.makeStructureNS(
const SEQUENCE_PARSERS_ = makeStructureNS(
NAMESPACE_URIS_, {
'element': olXml.makeObjectPropertyPusher(
readElement_
)
});
element: olXml.makeObjectPropertyPusher(readElement_)
}
);


/**
Expand Down Expand Up @@ -132,11 +144,12 @@ WFSDescribeFeatureType.prototype.readFromNode = function(node) {

/**
* @private
* @param {Node} node Node.
* @param {Element} node Node.
* @param {Array.<*>} objectStack Object stack.
* @return {!Object.<string, string>} Attributes.
*/
function readElement_(node, objectStack) {
/** @type {!Object.<string, string>} */
const attributes = {};
for (let i = 0, len = node.attributes.length; i < len; i++) {
const attribute = node.attributes.item(i);
Expand All @@ -152,7 +165,7 @@ function readElement_(node, objectStack) {

/**
* @private
* @param {Node} node Node.
* @param {Element} node Node.
* @param {Array.<*>} objectStack Object stack.
* @return {!Object.<string, string>} Object.
*/
Expand All @@ -172,7 +185,7 @@ function readComplexType_(node, objectStack) {

/**
* @private
* @param {Node} node Node.
* @param {Element} node Node.
* @param {Array.<*>} objectStack Object stack.
* @return {!Object.<string, string>} Object.
*/
Expand All @@ -190,7 +203,7 @@ function readComplexContent_(

/**
* @private
* @param {Node} node Node.
* @param {Element} node Node.
* @param {Array.<*>} objectStack Object stack.
* @return {!Object.<string, string>} Object.
*/
Expand All @@ -206,7 +219,7 @@ function readExtension_(node, objectStack) {

/**
* @private
* @param {Node} node Node.
* @param {Element} node Node.
* @param {Array.<*>} objectStack Object stack.
* @return {!Object.<string, string>} Object.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/datasource/DataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class DataSource {
* required for the `inRange` property to be dynamic, otherwise its
* value is always `true` by default.
*
* The synchronization is made in the `ngeo.datasource.DataSources`
* The synchronization is made in the `import('ngeo/datasource/DataSource.js').DataSources`
* service.
*
* @type {boolean}
Expand Down
11 changes: 6 additions & 5 deletions src/datasource/DataSources.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class DataSource {
constructor() {

/**
* @type {DataSources}
* @type {import('ngeo/datasource/DataSource.js').DataSources}
* @private
*/
this.collection_ = new olCollection();
Expand Down Expand Up @@ -105,10 +105,11 @@ export class DataSource {
*/
handleViewResolutionChange_(evt) {
const view = evt.target;
console.assert(view instanceof olView);
const resolution = view.getResolution();
console.assert(typeof resolution == 'number');
this.syncDataSourcesToResolution_(resolution);
if (view instanceof olView) {
const resolution = view.getResolution();
console.assert(typeof resolution == 'number');
this.syncDataSourcesToResolution_(resolution);
}
}

/**
Expand Down
15 changes: 12 additions & 3 deletions src/datasource/File.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,19 @@ import olSourceVector from 'ol/source/Vector.js';
/**
* The options required to create a `File`.
*
* @typedef {Object} DataSourceOptions
* extends DataSourceOptions
* @typedef {Object} FileOptions
* @property {import("ol/Collection.js").default.<!import("ol/Feature.js").default>} [features] Collection of `import("ol/Feature.js").default` objects.
* @extends DataSourceOptions
*/
* @property {Array.<import('ngeo/format/Attribute.js').Attribute>} [attributes] (DataSourceOptions)
* @property {import('ngeo/datasource/OGC.js').DimensionsFiltersConfig} [dimensionsFiltersConfig] (DataSourceOptions)
* @property {number} id (DataSourceOptions)
* @property {string} [identifierAttribute] (DataSourceOptions)
* @property {boolean} [inRange] (DataSourceOptions)
* @property {number} [minResolution] (DataSourceOptions)
* @property {number} [maxResolution] (DataSourceOptions)
* @property {string} name (DataSourceOptions)
* @property {boolean} [visible=false] (DataSourceOptions)
*/

export default class extends ngeoDatasourceDataSource {

Expand Down