Get rid of olx.js and typedef.js typedefs for ol

This commit is contained in:
Andreas Hocevar
2018-03-08 18:42:57 +01:00
parent 8f0ffe2043
commit 95d6251dbb
198 changed files with 2262 additions and 2698 deletions

View File

@@ -6,23 +6,54 @@ import FormatType from './format/FormatType.js';
/**
* @param {string|ol.FeatureUrlFunction} url Feature URL service.
* @param {ol.format.Feature} format Feature format.
* @param {function(this:ol.VectorTile, Array.<ol.Feature>, ol.proj.Projection, ol.Extent)|function(this:ol.source.Vector, Array.<ol.Feature>)} success
* {@link module:ol/source/Vector~Vector} sources use a function of this type to
* load features.
*
* This function takes an {@link module:ol/extent~Extent} representing the area to be loaded,
* a `{number}` representing the resolution (map units per pixel) and an
* {@link module:ol/proj/Projection~Projection} for the projection as
* arguments. `this` within the function is bound to the
* {@link module:ol/source/Vector~Vector} it's called from.
*
* The function is responsible for loading the features and adding them to the
* source.
* @typedef {function(this:module:ol/source/Vector~Vector, module:ol/extent~Extent, number,
* module:ol/proj/Projection~Projection)} FeatureLoader
* @api
*/
/**
* {@link module:ol/source/Vector~Vector} sources use a function of this type to
* get the url to load features from.
*
* This function takes an {@link module:ol/extent~Extent} representing the area
* to be loaded, a `{number}` representing the resolution (map units per pixel)
* and an {@link module:ol/proj/Projection~Projection} for the projection as
* arguments and returns a `{string}` representing the URL.
* @typedef {function(module:ol/extent~Extent, number, module:ol/proj/Projection~Projection): string} FeatureUrlFunction
* @api
*/
/**
* @param {string|module:ol/featureloader~FeatureUrlFunction} url Feature URL service.
* @param {module:ol/format/Feature~Feature} format Feature format.
* @param {function(this:module:ol/VectorTile~VectorTile, Array.<module:ol/Feature~Feature>, module:ol/proj/Projection~Projection, module:ol/extent~Extent)|function(this:module:ol/source/Vector~Vector, Array.<module:ol/Feature~Feature>)} success
* Function called with the loaded features and optionally with the data
* projection. Called with the vector tile or source as `this`.
* @param {function(this:ol.VectorTile)|function(this:ol.source.Vector)} failure
* @param {function(this:module:ol/VectorTile~VectorTile)|function(this:module:ol/source/Vector~Vector)} failure
* Function called when loading failed. Called with the vector tile or
* source as `this`.
* @return {ol.FeatureLoader} The feature loader.
* @return {module:ol/featureloader~FeatureLoader} The feature loader.
*/
export function loadFeaturesXhr(url, format, success, failure) {
return (
/**
* @param {ol.Extent} extent Extent.
* @param {module:ol/extent~Extent} extent Extent.
* @param {number} resolution Resolution.
* @param {ol.proj.Projection} projection Projection.
* @this {ol.source.Vector|ol.VectorTile}
* @param {module:ol/proj/Projection~Projection} projection Projection.
* @this {module:ol/source/Vector~Vector|module:ol/VectorTile~VectorTile}
*/
function(extent, resolution, projection) {
const xhr = new XMLHttpRequest();
@@ -79,17 +110,18 @@ export function loadFeaturesXhr(url, format, success, failure) {
* Create an XHR feature loader for a `url` and `format`. The feature loader
* loads features (with XHR), parses the features, and adds them to the
* vector source.
* @param {string|ol.FeatureUrlFunction} url Feature URL service.
* @param {ol.format.Feature} format Feature format.
* @return {ol.FeatureLoader} The feature loader.
* @param {string|module:ol/featureloader~FeatureUrlFunction} url Feature URL service.
* @param {module:ol/format/Feature~Feature} format Feature format.
* @return {module:ol/featureloader~FeatureLoader} The feature loader.
* @api
*/
export function xhr(url, format) {
return loadFeaturesXhr(url, format,
/**
* @param {Array.<ol.Feature>} features The loaded features.
* @param {ol.proj.Projection} dataProjection Data projection.
* @this {ol.source.Vector}
* @param {Array.<module:ol/Feature~Feature>} features The loaded features.
* @param {module:ol/proj/Projection~Projection} dataProjection Data
* projection.
* @this {module:ol/source/Vector~Vector}
*/
function(features, dataProjection) {
this.addFeatures(features);