From 535e8f5e35e4f935cfd297acd9bd6da5e5d29558 Mon Sep 17 00:00:00 2001 From: Peter Robins Date: Wed, 4 May 2016 12:05:41 +0000 Subject: [PATCH] Move top-level typedefs to typedefs.js With one exception, those directly in the `ol` namespace can be moved without problem. Some left-over goog.requires are also removed. --- src/ol/animation.js | 1 - src/ol/attribution.js | 7 - src/ol/canvasfunction.js | 17 -- src/ol/centerconstraint.js | 7 - src/ol/color/color.js | 12 - src/ol/colorlike.js | 11 - src/ol/control/mousepositioncontrol.js | 1 - src/ol/coordinate.js | 20 -- src/ol/extent.js | 9 - src/ol/feature.js | 13 - src/ol/featureloader.js | 34 --- src/ol/framestate.js | 19 -- src/ol/geolocation.js | 1 - src/ol/imagecanvas.js | 11 - src/ol/imageloadfunction.js | 21 -- src/ol/interaction/dragpaninteraction.js | 2 +- src/ol/interaction/modifyinteraction.js | 1 - src/ol/interaction/pointerinteraction.js | 1 - src/ol/interaction/snapinteraction.js | 1 - src/ol/loadingstrategy.js | 10 - src/ol/map.js | 14 - src/ol/overlay.js | 1 - src/ol/pixel.js | 10 - src/ol/proj/proj.js | 1 - src/ol/raster/operation.js | 1 - src/ol/renderer/canvas/canvaslayerrenderer.js | 1 - src/ol/resolutionconstraint.js | 7 - src/ol/rotationconstraint.js | 7 - src/ol/size.js | 9 - src/ol/source/imagearcgisrestsource.js | 1 - src/ol/source/imagecanvassource.js | 1 - src/ol/source/imagemapguidesource.js | 1 - src/ol/source/imagestaticsource.js | 1 - src/ol/source/tileimagesource.js | 1 - src/ol/source/vectortilesource.js | 1 - src/ol/tilecoord.js | 10 - src/ol/tileloadfunction.js | 11 - src/ol/tilequeue.js | 7 - src/ol/tileurlfunction.js | 18 -- src/ol/transformfunction.js | 13 - src/ol/typedefs.js | 289 ++++++++++++++++++ src/ol/vectortile.js | 12 - tasks/build.js | 3 + 43 files changed, 293 insertions(+), 326 deletions(-) delete mode 100644 src/ol/canvasfunction.js delete mode 100644 src/ol/framestate.js delete mode 100644 src/ol/imageloadfunction.js delete mode 100644 src/ol/pixel.js delete mode 100644 src/ol/tileloadfunction.js delete mode 100644 src/ol/transformfunction.js create mode 100644 src/ol/typedefs.js diff --git a/src/ol/animation.js b/src/ol/animation.js index 4e9833b3fb..d8ccfa4dda 100644 --- a/src/ol/animation.js +++ b/src/ol/animation.js @@ -1,7 +1,6 @@ goog.provide('ol.animation'); goog.require('ol'); -goog.require('ol.PreRenderFunction'); goog.require('ol.ViewHint'); goog.require('ol.coordinate'); goog.require('ol.easing'); diff --git a/src/ol/attribution.js b/src/ol/attribution.js index 2552519f7f..ffd96e29ac 100644 --- a/src/ol/attribution.js +++ b/src/ol/attribution.js @@ -4,13 +4,6 @@ goog.require('ol.TileRange'); goog.require('ol.math'); -/** - * @typedef {string|Array.|ol.Attribution|Array.} - * @api - */ -ol.AttributionLike; - - /** * @classdesc * An attribution for a layer source. diff --git a/src/ol/canvasfunction.js b/src/ol/canvasfunction.js deleted file mode 100644 index db4820faa2..0000000000 --- a/src/ol/canvasfunction.js +++ /dev/null @@ -1,17 +0,0 @@ -goog.provide('ol.CanvasFunctionType'); - - -/** - * A function returning the canvas element (`{HTMLCanvasElement}`) - * used by the source as an image. The arguments passed to the function are: - * {@link ol.Extent} the image extent, `{number}` the image resolution, - * `{number}` the device pixel ratio, {@link ol.Size} the image size, and - * {@link ol.proj.Projection} the image projection. The canvas returned by - * this function is cached by the source. The this keyword inside the function - * references the {@link ol.source.ImageCanvas}. - * - * @typedef {function(this:ol.source.ImageCanvas, ol.Extent, number, - * number, ol.Size, ol.proj.Projection): HTMLCanvasElement} - * @api - */ -ol.CanvasFunctionType; diff --git a/src/ol/centerconstraint.js b/src/ol/centerconstraint.js index e1d1a9705a..9e8f8cddf0 100644 --- a/src/ol/centerconstraint.js +++ b/src/ol/centerconstraint.js @@ -1,15 +1,8 @@ goog.provide('ol.CenterConstraint'); -goog.provide('ol.CenterConstraintType'); goog.require('ol.math'); -/** - * @typedef {function((ol.Coordinate|undefined)): (ol.Coordinate|undefined)} - */ -ol.CenterConstraintType; - - /** * @param {ol.Extent} extent Extent. * @return {ol.CenterConstraintType} The constraint. diff --git a/src/ol/color/color.js b/src/ol/color/color.js index 4953ef43b2..c322252c37 100644 --- a/src/ol/color/color.js +++ b/src/ol/color/color.js @@ -3,7 +3,6 @@ // causes occasional loss of precision and rounding errors, especially in the // alpha channel. -goog.provide('ol.Color'); goog.provide('ol.color'); goog.require('goog.asserts'); @@ -13,17 +12,6 @@ goog.require('ol'); goog.require('ol.math'); -/** - * A color represented as a short array [red, green, blue, alpha]. - * red, green, and blue should be integers in the range 0..255 inclusive. - * alpha should be a float in the range 0..1 inclusive. If no alpha value is - * given then `1` will be used. - * @typedef {Array.} - * @api - */ -ol.Color; - - /** * This RegExp matches # followed by 3 or 6 hex digits. * @const diff --git a/src/ol/colorlike.js b/src/ol/colorlike.js index 2b6a430522..a0919f63ff 100644 --- a/src/ol/colorlike.js +++ b/src/ol/colorlike.js @@ -1,19 +1,8 @@ -goog.provide('ol.ColorLike'); goog.provide('ol.colorlike'); goog.require('ol.color'); -/** - * A type accepted by CanvasRenderingContext2D.fillStyle. - * Represents a color, pattern, or gradient. - * - * @typedef {string|CanvasPattern|CanvasGradient} - * @api - */ -ol.ColorLike; - - /** * @param {ol.Color|ol.ColorLike} color Color. * @return {ol.ColorLike} The color as an ol.ColorLike diff --git a/src/ol/control/mousepositioncontrol.js b/src/ol/control/mousepositioncontrol.js index a2bfc89249..286f6372af 100644 --- a/src/ol/control/mousepositioncontrol.js +++ b/src/ol/control/mousepositioncontrol.js @@ -5,7 +5,6 @@ goog.provide('ol.control.MousePosition'); goog.require('ol.events'); goog.require('ol.events.EventType'); goog.require('ol.Object'); -goog.require('ol.TransformFunction'); goog.require('ol.control.Control'); goog.require('ol.proj'); goog.require('ol.proj.Projection'); diff --git a/src/ol/coordinate.js b/src/ol/coordinate.js index e93fc9d45f..0ea63e2ce6 100644 --- a/src/ol/coordinate.js +++ b/src/ol/coordinate.js @@ -1,29 +1,9 @@ -goog.provide('ol.Coordinate'); -goog.provide('ol.CoordinateFormatType'); goog.provide('ol.coordinate'); goog.require('ol.math'); goog.require('ol.string'); -/** - * A function that takes a {@link ol.Coordinate} and transforms it into a - * `{string}`. - * - * @typedef {function((ol.Coordinate|undefined)): string} - * @api stable - */ -ol.CoordinateFormatType; - - -/** - * An array of numbers representing an xy coordinate. Example: `[16, 48]`. - * @typedef {Array.} ol.Coordinate - * @api stable - */ -ol.Coordinate; - - /** * Add `delta` to `coordinate`. `coordinate` is modified in place and returned * by the function. diff --git a/src/ol/extent.js b/src/ol/extent.js index d1d9b33a61..aaba2c1210 100644 --- a/src/ol/extent.js +++ b/src/ol/extent.js @@ -1,4 +1,3 @@ -goog.provide('ol.Extent'); goog.provide('ol.extent'); goog.provide('ol.extent.Corner'); goog.provide('ol.extent.Relationship'); @@ -6,14 +5,6 @@ goog.provide('ol.extent.Relationship'); goog.require('goog.asserts'); -/** - * An array of numbers representing an extent: `[minx, miny, maxx, maxy]`. - * @typedef {Array.} - * @api stable - */ -ol.Extent; - - /** * Extent corner. * @enum {string} diff --git a/src/ol/feature.js b/src/ol/feature.js index 9d07bd8c82..690391f76f 100644 --- a/src/ol/feature.js +++ b/src/ol/feature.js @@ -1,5 +1,4 @@ goog.provide('ol.Feature'); -goog.provide('ol.FeatureStyleFunction'); goog.require('goog.asserts'); goog.require('ol.events'); @@ -284,18 +283,6 @@ ol.Feature.prototype.setGeometryName = function(name) { }; -/** - * A function that returns an array of {@link ol.style.Style styles} given a - * resolution. The `this` keyword inside the function references the - * {@link ol.Feature} to be styled. - * - * @typedef {function(this: ol.Feature, number): - * (ol.style.Style|Array.)} - * @api stable - */ -ol.FeatureStyleFunction; - - /** * Convert the provided object into a feature style function. Functions passed * through unchanged. Arrays of ol.style.Style or single style objects wrapped diff --git a/src/ol/featureloader.js b/src/ol/featureloader.js index 09c484031b..66cc5c7b5e 100644 --- a/src/ol/featureloader.js +++ b/src/ol/featureloader.js @@ -1,5 +1,3 @@ -goog.provide('ol.FeatureLoader'); -goog.provide('ol.FeatureUrlFunction'); goog.provide('ol.featureloader'); goog.require('goog.asserts'); @@ -11,38 +9,6 @@ goog.require('ol.proj.Projection'); goog.require('ol.xml'); -/** - * {@link ol.source.Vector} sources use a function of this type to load - * features. - * - * This function takes an {@link ol.Extent} representing the area to be loaded, - * a `{number}` representing the resolution (map units per pixel) and an - * {@link ol.proj.Projection} for the projection as arguments. `this` within - * the function is bound to the {@link ol.source.Vector} it's called from. - * - * The function is responsible for loading the features and adding them to the - * source. - * @api - * @typedef {function(this:ol.source.Vector, ol.Extent, number, - * ol.proj.Projection)} - */ -ol.FeatureLoader; - - -/** - * {@link ol.source.Vector} sources use a function of this type to get the url - * to load features from. - * - * This function takes an {@link ol.Extent} representing the area to be loaded, - * a `{number}` representing the resolution (map units per pixel) and an - * {@link ol.proj.Projection} for the projection as arguments and returns a - * `{string}` representing the URL. - * @api - * @typedef {function(ol.Extent, number, ol.proj.Projection) : string} - */ -ol.FeatureUrlFunction; - - /** * @param {string|ol.FeatureUrlFunction} url Feature URL service. * @param {ol.format.Feature} format Feature format. diff --git a/src/ol/framestate.js b/src/ol/framestate.js deleted file mode 100644 index 65847d1bea..0000000000 --- a/src/ol/framestate.js +++ /dev/null @@ -1,19 +0,0 @@ -goog.provide('ol.PostRenderFunction'); -goog.provide('ol.PreRenderFunction'); - - -/** - * @typedef {function(ol.Map, ?olx.FrameState): boolean} - */ -ol.PostRenderFunction; - - -/** - * Function to perform manipulations before rendering. This function is called - * with the {@link ol.Map} as first and an optional {@link olx.FrameState} as - * second argument. Return `true` to keep this function for the next frame, - * `false` to remove it. - * @typedef {function(ol.Map, ?olx.FrameState): boolean} - * @api - */ -ol.PreRenderFunction; diff --git a/src/ol/geolocation.js b/src/ol/geolocation.js index 7dd0617ba7..9b5772fc35 100644 --- a/src/ol/geolocation.js +++ b/src/ol/geolocation.js @@ -6,7 +6,6 @@ goog.provide('ol.GeolocationProperty'); goog.require('ol.events'); goog.require('ol.events.EventType'); goog.require('ol.Object'); -goog.require('ol.TransformFunction'); goog.require('ol.geom.Geometry'); goog.require('ol.geom.Polygon'); goog.require('ol.has'); diff --git a/src/ol/imagecanvas.js b/src/ol/imagecanvas.js index a61695e08d..9bd290d93c 100644 --- a/src/ol/imagecanvas.js +++ b/src/ol/imagecanvas.js @@ -91,14 +91,3 @@ ol.ImageCanvas.prototype.load = function() { ol.ImageCanvas.prototype.getImage = function(opt_context) { return this.canvas_; }; - - -/** - * A function that is called to trigger asynchronous canvas drawing. It is - * called with a "done" callback that should be called when drawing is done. - * If any error occurs during drawing, the "done" callback should be called with - * that error. - * - * @typedef {function(function(Error))} - */ -ol.ImageCanvasLoader; diff --git a/src/ol/imageloadfunction.js b/src/ol/imageloadfunction.js deleted file mode 100644 index 0d4b74cda2..0000000000 --- a/src/ol/imageloadfunction.js +++ /dev/null @@ -1,21 +0,0 @@ -goog.provide('ol.ImageLoadFunctionType'); - - -/** - * A function that takes an {@link ol.Image} for the image and a `{string}` for - * the src as arguments. It is supposed to make it so the underlying image - * {@link ol.Image#getImage} is assigned the content specified by the src. If - * not specified, the default is - * - * function(image, src) { - * image.getImage().src = src; - * } - * - * Providing a custom `imageLoadFunction` can be useful to load images with - * post requests or - in general - through XHR requests, where the src of the - * image element would be set to a data URI when the content is loaded. - * - * @typedef {function(ol.Image, string)} - * @api - */ -ol.ImageLoadFunctionType; diff --git a/src/ol/interaction/dragpaninteraction.js b/src/ol/interaction/dragpaninteraction.js index b6f2a64f2b..6dcfc068d3 100644 --- a/src/ol/interaction/dragpaninteraction.js +++ b/src/ol/interaction/dragpaninteraction.js @@ -2,7 +2,7 @@ goog.provide('ol.interaction.DragPan'); goog.require('goog.asserts'); goog.require('ol.Kinetic'); -goog.require('ol.Pixel'); + goog.require('ol.ViewHint'); goog.require('ol.coordinate'); goog.require('ol.functions'); diff --git a/src/ol/interaction/modifyinteraction.js b/src/ol/interaction/modifyinteraction.js index 1d931f9849..705983893a 100644 --- a/src/ol/interaction/modifyinteraction.js +++ b/src/ol/interaction/modifyinteraction.js @@ -11,7 +11,6 @@ goog.require('ol.CollectionEventType'); goog.require('ol.Feature'); goog.require('ol.MapBrowserEvent.EventType'); goog.require('ol.MapBrowserPointerEvent'); -goog.require('ol.Pixel'); goog.require('ol.ViewHint'); goog.require('ol.array'); goog.require('ol.coordinate'); diff --git a/src/ol/interaction/pointerinteraction.js b/src/ol/interaction/pointerinteraction.js index f5fb0a00a2..6450ea3bf2 100644 --- a/src/ol/interaction/pointerinteraction.js +++ b/src/ol/interaction/pointerinteraction.js @@ -3,7 +3,6 @@ goog.provide('ol.interaction.Pointer'); goog.require('ol'); goog.require('ol.MapBrowserEvent.EventType'); goog.require('ol.MapBrowserPointerEvent'); -goog.require('ol.Pixel'); goog.require('ol.interaction.Interaction'); goog.require('ol.object'); diff --git a/src/ol/interaction/snapinteraction.js b/src/ol/interaction/snapinteraction.js index 2f58b1f897..d5a3dbbec3 100644 --- a/src/ol/interaction/snapinteraction.js +++ b/src/ol/interaction/snapinteraction.js @@ -9,7 +9,6 @@ goog.require('ol.CollectionEventType'); goog.require('ol.Feature'); goog.require('ol.Object'); goog.require('ol.Observable'); -goog.require('ol.Pixel'); goog.require('ol.coordinate'); goog.require('ol.events'); goog.require('ol.events.EventType'); diff --git a/src/ol/loadingstrategy.js b/src/ol/loadingstrategy.js index 77d8400cfd..cdd5f4fde9 100644 --- a/src/ol/loadingstrategy.js +++ b/src/ol/loadingstrategy.js @@ -1,16 +1,6 @@ -goog.provide('ol.LoadingStrategy'); goog.provide('ol.loadingstrategy'); -/** - * One of `all`, `bbox`, `tile`. - * - * @typedef {function(ol.Extent, number): Array.} - * @api - */ -ol.LoadingStrategy; - - /** * Strategy function for loading all features with a single request. * @param {ol.Extent} extent Extent. diff --git a/src/ol/map.js b/src/ol/map.js index b23aa3a50a..b41dd653c2 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -20,7 +20,6 @@ goog.require('ol.MapEventType'); goog.require('ol.Object'); goog.require('ol.ObjectEvent'); goog.require('ol.ObjectEventType'); -goog.require('ol.Pixel'); goog.require('ol.RendererType'); goog.require('ol.TileQueue'); goog.require('ol.View'); @@ -1443,19 +1442,6 @@ ol.Map.prototype.unskipFeature = function(feature) { }; -/** - * @typedef {{controls: ol.Collection., - * interactions: ol.Collection., - * keyboardEventTarget: (Element|Document), - * logos: (Object.), - * overlays: ol.Collection., - * rendererConstructor: - * function(new: ol.renderer.Map, Element, ol.Map), - * values: Object.}} - */ -ol.MapOptionsInternal; - - /** * @param {olx.MapOptions} options Map options. * @return {ol.MapOptionsInternal} Internal map options. diff --git a/src/ol/overlay.js b/src/ol/overlay.js index b595631ca2..03375430f6 100644 --- a/src/ol/overlay.js +++ b/src/ol/overlay.js @@ -8,7 +8,6 @@ goog.require('ol.events'); goog.require('goog.style'); goog.require('ol.Map'); goog.require('ol.MapEventType'); -goog.require('ol.Pixel'); goog.require('ol.Object'); goog.require('ol.animation'); goog.require('ol.dom'); diff --git a/src/ol/pixel.js b/src/ol/pixel.js deleted file mode 100644 index dbf1d451da..0000000000 --- a/src/ol/pixel.js +++ /dev/null @@ -1,10 +0,0 @@ -goog.provide('ol.Pixel'); - - -/** - * An array with two elements, representing a pixel. The first element is the - * x-coordinate, the second the y-coordinate of the pixel. - * @typedef {Array.} - * @api stable - */ -ol.Pixel; diff --git a/src/ol/proj/proj.js b/src/ol/proj/proj.js index 7edf8cfcfd..0e739092d4 100644 --- a/src/ol/proj/proj.js +++ b/src/ol/proj/proj.js @@ -5,7 +5,6 @@ goog.provide('ol.proj.Units'); goog.require('goog.asserts'); goog.require('ol'); -goog.require('ol.TransformFunction'); goog.require('ol.extent'); goog.require('ol.object'); goog.require('ol.sphere.NORMAL'); diff --git a/src/ol/raster/operation.js b/src/ol/raster/operation.js index 4dca308908..ec95350d46 100644 --- a/src/ol/raster/operation.js +++ b/src/ol/raster/operation.js @@ -1,4 +1,3 @@ -goog.provide('ol.raster.Operation'); goog.provide('ol.raster.OperationType'); diff --git a/src/ol/renderer/canvas/canvaslayerrenderer.js b/src/ol/renderer/canvas/canvaslayerrenderer.js index 1db8de09fd..9e6a02a8ce 100644 --- a/src/ol/renderer/canvas/canvaslayerrenderer.js +++ b/src/ol/renderer/canvas/canvaslayerrenderer.js @@ -2,7 +2,6 @@ goog.provide('ol.renderer.canvas.Layer'); goog.require('goog.asserts'); goog.require('goog.vec.Mat4'); -goog.require('ol.Pixel'); goog.require('ol.extent'); goog.require('ol.layer.Layer'); goog.require('ol.render.Event'); diff --git a/src/ol/resolutionconstraint.js b/src/ol/resolutionconstraint.js index df385090cf..98b1fd8b61 100644 --- a/src/ol/resolutionconstraint.js +++ b/src/ol/resolutionconstraint.js @@ -1,16 +1,9 @@ goog.provide('ol.ResolutionConstraint'); -goog.provide('ol.ResolutionConstraintType'); goog.require('ol.array'); goog.require('ol.math'); -/** - * @typedef {function((number|undefined), number, number): (number|undefined)} - */ -ol.ResolutionConstraintType; - - /** * @param {Array.} resolutions Resolutions. * @return {ol.ResolutionConstraintType} Zoom function. diff --git a/src/ol/rotationconstraint.js b/src/ol/rotationconstraint.js index b660a36444..961b9346b5 100644 --- a/src/ol/rotationconstraint.js +++ b/src/ol/rotationconstraint.js @@ -1,15 +1,8 @@ goog.provide('ol.RotationConstraint'); -goog.provide('ol.RotationConstraintType'); goog.require('ol.math'); -/** - * @typedef {function((number|undefined), number): (number|undefined)} - */ -ol.RotationConstraintType; - - /** * @param {number|undefined} rotation Rotation. * @param {number} delta Delta. diff --git a/src/ol/size.js b/src/ol/size.js index 5e73a5b7ac..9e911684c4 100644 --- a/src/ol/size.js +++ b/src/ol/size.js @@ -1,18 +1,9 @@ -goog.provide('ol.Size'); goog.provide('ol.size'); goog.require('goog.asserts'); -/** - * An array of numbers representing a size: `[width, height]`. - * @typedef {Array.} - * @api stable - */ -ol.Size; - - /** * Returns a buffered size. * @param {ol.Size} size Size. diff --git a/src/ol/source/imagearcgisrestsource.js b/src/ol/source/imagearcgisrestsource.js index 0d4f0f70fb..79ec5f2289 100644 --- a/src/ol/source/imagearcgisrestsource.js +++ b/src/ol/source/imagearcgisrestsource.js @@ -4,7 +4,6 @@ goog.require('goog.asserts'); goog.require('goog.uri.utils'); goog.require('ol'); goog.require('ol.Image'); -goog.require('ol.ImageLoadFunctionType'); goog.require('ol.events'); goog.require('ol.events.EventType'); goog.require('ol.extent'); diff --git a/src/ol/source/imagecanvassource.js b/src/ol/source/imagecanvassource.js index ea4de67dc1..1248a74b94 100644 --- a/src/ol/source/imagecanvassource.js +++ b/src/ol/source/imagecanvassource.js @@ -1,6 +1,5 @@ goog.provide('ol.source.ImageCanvas'); -goog.require('ol.CanvasFunctionType'); goog.require('ol.ImageCanvas'); goog.require('ol.extent'); goog.require('ol.source.Image'); diff --git a/src/ol/source/imagemapguidesource.js b/src/ol/source/imagemapguidesource.js index 628550a4d5..90aeec83bc 100644 --- a/src/ol/source/imagemapguidesource.js +++ b/src/ol/source/imagemapguidesource.js @@ -4,7 +4,6 @@ goog.require('ol.events'); goog.require('ol.events.EventType'); goog.require('goog.uri.utils'); goog.require('ol.Image'); -goog.require('ol.ImageLoadFunctionType'); goog.require('ol.extent'); goog.require('ol.object'); goog.require('ol.source.Image'); diff --git a/src/ol/source/imagestaticsource.js b/src/ol/source/imagestaticsource.js index d9844f1501..bcff1b7992 100644 --- a/src/ol/source/imagestaticsource.js +++ b/src/ol/source/imagestaticsource.js @@ -3,7 +3,6 @@ goog.provide('ol.source.ImageStatic'); goog.require('ol.events'); goog.require('ol.events.EventType'); goog.require('ol.Image'); -goog.require('ol.ImageLoadFunctionType'); goog.require('ol.ImageState'); goog.require('ol.dom'); goog.require('ol.extent'); diff --git a/src/ol/source/tileimagesource.js b/src/ol/source/tileimagesource.js index 19338eb869..5f623d67f4 100644 --- a/src/ol/source/tileimagesource.js +++ b/src/ol/source/tileimagesource.js @@ -3,7 +3,6 @@ goog.provide('ol.source.TileImage'); goog.require('goog.asserts'); goog.require('ol.ImageTile'); goog.require('ol.TileCache'); -goog.require('ol.TileLoadFunctionType'); goog.require('ol.TileState'); goog.require('ol.events'); goog.require('ol.events.EventType'); diff --git a/src/ol/source/vectortilesource.js b/src/ol/source/vectortilesource.js index ffe6fac59b..8b7a57adba 100644 --- a/src/ol/source/vectortilesource.js +++ b/src/ol/source/vectortilesource.js @@ -1,6 +1,5 @@ goog.provide('ol.source.VectorTile'); -goog.require('ol.TileLoadFunctionType'); goog.require('ol.TileState'); goog.require('ol.VectorTile'); goog.require('ol.events'); diff --git a/src/ol/tilecoord.js b/src/ol/tilecoord.js index a463a95b7a..c493d6587a 100644 --- a/src/ol/tilecoord.js +++ b/src/ol/tilecoord.js @@ -1,19 +1,9 @@ -goog.provide('ol.TileCoord'); goog.provide('ol.tilecoord'); goog.require('goog.asserts'); goog.require('ol.extent'); -/** - * An array of three numbers representing the location of a tile in a tile - * grid. The order is `z`, `x`, and `y`. `z` is the zoom level. - * @typedef {Array.} ol.TileCoord - * @api - */ -ol.TileCoord; - - /** * @enum {number} */ diff --git a/src/ol/tileloadfunction.js b/src/ol/tileloadfunction.js deleted file mode 100644 index 0a476ae6b3..0000000000 --- a/src/ol/tileloadfunction.js +++ /dev/null @@ -1,11 +0,0 @@ -goog.provide('ol.TileLoadFunctionType'); - - -/** - * A function that takes an {@link ol.Tile} for the tile and a `{string}` for - * the url as arguments. - * - * @typedef {function(ol.Tile, string)} - * @api - */ -ol.TileLoadFunctionType; diff --git a/src/ol/tilequeue.js b/src/ol/tilequeue.js index c2f86781ae..3d81da31e2 100644 --- a/src/ol/tilequeue.js +++ b/src/ol/tilequeue.js @@ -1,4 +1,3 @@ -goog.provide('ol.TilePriorityFunction'); goog.provide('ol.TileQueue'); goog.require('goog.asserts'); @@ -8,12 +7,6 @@ goog.require('ol.TileState'); goog.require('ol.structs.PriorityQueue'); -/** - * @typedef {function(ol.Tile, string, ol.Coordinate, number): number} - */ -ol.TilePriorityFunction; - - /** * @constructor * @extends {ol.structs.PriorityQueue.} diff --git a/src/ol/tileurlfunction.js b/src/ol/tileurlfunction.js index b4ba50dc71..7ff9bf65e9 100644 --- a/src/ol/tileurlfunction.js +++ b/src/ol/tileurlfunction.js @@ -1,28 +1,10 @@ goog.provide('ol.TileUrlFunction'); -goog.provide('ol.TileUrlFunctionType'); goog.require('goog.asserts'); goog.require('ol.math'); goog.require('ol.tilecoord'); -/** - * {@link ol.source.Tile} sources use a function of this type to get the url - * that provides a tile for a given tile coordinate. - * - * This function takes an {@link ol.TileCoord} for the tile coordinate, a - * `{number}` representing the pixel ratio and an {@link ol.proj.Projection} for - * the projection as arguments and returns a `{string}` representing the tile - * URL, or undefined if no tile should be requested for the passed tile - * coordinate. - * - * @typedef {function(ol.TileCoord, number, - * ol.proj.Projection): (string|undefined)} - * @api - */ -ol.TileUrlFunctionType; - - /** * @param {string} template Template. * @param {ol.tilegrid.TileGrid} tileGrid Tile grid. diff --git a/src/ol/transformfunction.js b/src/ol/transformfunction.js deleted file mode 100644 index d734d241fd..0000000000 --- a/src/ol/transformfunction.js +++ /dev/null @@ -1,13 +0,0 @@ -goog.provide('ol.TransformFunction'); - - -/** - * A transform function accepts an array of input coordinate values, an optional - * output array, and an optional dimension (default should be 2). The function - * transforms the input coordinate values, populates the output array, and - * returns the output array. - * - * @typedef {function(Array., Array.=, number=): Array.} - * @api stable - */ -ol.TransformFunction; diff --git a/src/ol/typedefs.js b/src/ol/typedefs.js new file mode 100644 index 0000000000..50d2e24bf5 --- /dev/null +++ b/src/ol/typedefs.js @@ -0,0 +1,289 @@ +/** + * File for all top-level (in the `ol` namespace) typedefs used by the compiler, + * and referenced by JSDoc. + */ + + +/** + * @typedef {string|Array.|ol.Attribution|Array.} + * @api + */ +ol.AttributionLike; + + +/** + * A function returning the canvas element (`{HTMLCanvasElement}`) + * used by the source as an image. The arguments passed to the function are: + * {@link ol.Extent} the image extent, `{number}` the image resolution, + * `{number}` the device pixel ratio, {@link ol.Size} the image size, and + * {@link ol.proj.Projection} the image projection. The canvas returned by + * this function is cached by the source. The this keyword inside the function + * references the {@link ol.source.ImageCanvas}. + * + * @typedef {function(this:ol.source.ImageCanvas, ol.Extent, number, + * number, ol.Size, ol.proj.Projection): HTMLCanvasElement} + * @api + */ +ol.CanvasFunctionType; + + +/** + * @typedef {function((ol.Coordinate|undefined)): (ol.Coordinate|undefined)} + */ +ol.CenterConstraintType; + + +/** + * A color represented as a short array [red, green, blue, alpha]. + * red, green, and blue should be integers in the range 0..255 inclusive. + * alpha should be a float in the range 0..1 inclusive. If no alpha value is + * given then `1` will be used. + * @typedef {Array.} + * @api + */ +ol.Color; + + +/** + * A type accepted by CanvasRenderingContext2D.fillStyle. + * Represents a color, pattern, or gradient. + * + * @typedef {string|CanvasPattern|CanvasGradient} + * @api + */ +ol.ColorLike; + + +/** + * An array of numbers representing an xy coordinate. Example: `[16, 48]`. + * @typedef {Array.} ol.Coordinate + * @api stable + */ +ol.Coordinate; + + +/** + * A function that takes a {@link ol.Coordinate} and transforms it into a + * `{string}`. + * + * @typedef {function((ol.Coordinate|undefined)): string} + * @api stable + */ +ol.CoordinateFormatType; + + +/** + * An array of numbers representing an extent: `[minx, miny, maxx, maxy]`. + * @typedef {Array.} + * @api stable + */ +ol.Extent; + + +/** + * {@link ol.source.Vector} sources use a function of this type to load + * features. + * + * This function takes an {@link ol.Extent} representing the area to be loaded, + * a `{number}` representing the resolution (map units per pixel) and an + * {@link ol.proj.Projection} for the projection as arguments. `this` within + * the function is bound to the {@link ol.source.Vector} it's called from. + * + * The function is responsible for loading the features and adding them to the + * source. + * @api + * @typedef {function(this:ol.source.Vector, ol.Extent, number, + * ol.proj.Projection)} + */ +ol.FeatureLoader; + + +/** + * A function that returns an array of {@link ol.style.Style styles} given a + * resolution. The `this` keyword inside the function references the + * {@link ol.Feature} to be styled. + * + * @typedef {function(this: ol.Feature, number): + * (ol.style.Style|Array.)} + * @api stable + */ +ol.FeatureStyleFunction; + + +/** + * {@link ol.source.Vector} sources use a function of this type to get the url + * to load features from. + * + * This function takes an {@link ol.Extent} representing the area to be loaded, + * a `{number}` representing the resolution (map units per pixel) and an + * {@link ol.proj.Projection} for the projection as arguments and returns a + * `{string}` representing the URL. + * @api + * @typedef {function(ol.Extent, number, ol.proj.Projection) : string} + */ +ol.FeatureUrlFunction; + + +/** + * A function that is called to trigger asynchronous canvas drawing. It is + * called with a "done" callback that should be called when drawing is done. + * If any error occurs during drawing, the "done" callback should be called with + * that error. + * + * @typedef {function(function(Error))} + */ +ol.ImageCanvasLoader; + + +/** + * A function that takes an {@link ol.Image} for the image and a `{string}` for + * the src as arguments. It is supposed to make it so the underlying image + * {@link ol.Image#getImage} is assigned the content specified by the src. If + * not specified, the default is + * + * function(image, src) { + * image.getImage().src = src; + * } + * + * Providing a custom `imageLoadFunction` can be useful to load images with + * post requests or - in general - through XHR requests, where the src of the + * image element would be set to a data URI when the content is loaded. + * + * @typedef {function(ol.Image, string)} + * @api + */ +ol.ImageLoadFunctionType; + + +/** + * One of `all`, `bbox`, `tile`. + * + * @typedef {function(ol.Extent, number): Array.} + * @api + */ +ol.LoadingStrategy; + + +/** + * @typedef {{controls: ol.Collection., + * interactions: ol.Collection., + * keyboardEventTarget: (Element|Document), + * logos: (Object.), + * overlays: ol.Collection., + * rendererConstructor: + * function(new: ol.renderer.Map, Element, ol.Map), + * values: Object.}} + */ +ol.MapOptionsInternal; + + +/** + * An array with two elements, representing a pixel. The first element is the + * x-coordinate, the second the y-coordinate of the pixel. + * @typedef {Array.} + * @api stable + */ +ol.Pixel; + + +/** + * @typedef {function(ol.Map, ?olx.FrameState): boolean} + */ +ol.PostRenderFunction; + + +/** + * Function to perform manipulations before rendering. This function is called + * with the {@link ol.Map} as first and an optional {@link olx.FrameState} as + * second argument. Return `true` to keep this function for the next frame, + * `false` to remove it. + * @typedef {function(ol.Map, ?olx.FrameState): boolean} + * @api + */ +ol.PreRenderFunction; + + +/** + * @typedef {function((number|undefined), number, number): (number|undefined)} + */ +ol.ResolutionConstraintType; + + +/** + * @typedef {function((number|undefined), number): (number|undefined)} + */ +ol.RotationConstraintType; + + +/** + * An array of numbers representing a size: `[width, height]`. + * @typedef {Array.} + * @api stable + */ +ol.Size; + + +/** + * An array of three numbers representing the location of a tile in a tile + * grid. The order is `z`, `x`, and `y`. `z` is the zoom level. + * @typedef {Array.} ol.TileCoord + * @api + */ +ol.TileCoord; + + +/** + * A function that takes an {@link ol.Tile} for the tile and a `{string}` for + * the url as arguments. + * + * @typedef {function(ol.Tile, string)} + * @api + */ +ol.TileLoadFunctionType; + + +/** + * @typedef {function(ol.Tile, string, ol.Coordinate, number): number} + */ +ol.TilePriorityFunction; + + +/** + * @typedef {{ + * dirty: boolean, + * renderedRenderOrder: (null|function(ol.Feature, ol.Feature):number), + * renderedTileRevision: number, + * renderedRevision: number, + * replayGroup: ol.render.IReplayGroup, + * skippedFeatures: Array.}} + */ +ol.TileReplayState; + + +/** + * {@link ol.source.Tile} sources use a function of this type to get the url + * that provides a tile for a given tile coordinate. + * + * This function takes an {@link ol.TileCoord} for the tile coordinate, a + * `{number}` representing the pixel ratio and an {@link ol.proj.Projection} for + * the projection as arguments and returns a `{string}` representing the tile + * URL, or undefined if no tile should be requested for the passed tile + * coordinate. + * + * @typedef {function(ol.TileCoord, number, + * ol.proj.Projection): (string|undefined)} + * @api + */ +ol.TileUrlFunctionType; + + +/** + * A transform function accepts an array of input coordinate values, an optional + * output array, and an optional dimension (default should be 2). The function + * transforms the input coordinate values, populates the output array, and + * returns the output array. + * + * @typedef {function(Array., Array.=, number=): Array.} + * @api stable + */ +ol.TransformFunction; diff --git a/src/ol/vectortile.js b/src/ol/vectortile.js index 0d6946d570..1ed6b49341 100644 --- a/src/ol/vectortile.js +++ b/src/ol/vectortile.js @@ -6,18 +6,6 @@ goog.require('ol.dom'); goog.require('ol.proj.Projection'); -/** - * @typedef {{ - * dirty: boolean, - * renderedRenderOrder: (null|function(ol.Feature, ol.Feature):number), - * renderedTileRevision: number, - * renderedRevision: number, - * replayGroup: ol.render.IReplayGroup, - * skippedFeatures: Array.}} - */ -ol.TileReplayState; - - /** * @constructor * @extends {ol.Tile} diff --git a/tasks/build.js b/tasks/build.js index 445d780589..8573ac5b30 100644 --- a/tasks/build.js +++ b/tasks/build.js @@ -207,6 +207,9 @@ function build(config, paths, callback) { } else { log.info('ol', 'Compiling ' + paths.length + ' sources'); options.compile.js = paths.concat(options.compile.js || []); + // typedefs file has no `goog.provide`s, so is ignored by closure-util + // when calculating dependencies. So it's added here as a compiler option. + options.compile.js.push('src/ol/typedefs.js'); closure.compile(options, callback); } }