From 535e8f5e35e4f935cfd297acd9bd6da5e5d29558 Mon Sep 17 00:00:00 2001 From: Peter Robins Date: Wed, 4 May 2016 12:05:41 +0000 Subject: [PATCH 1/8] 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); } } From ed34caa25aa1f84873aa98a53885a332d6a4127e Mon Sep 17 00:00:00 2001 From: Peter Robins Date: Sat, 7 May 2016 19:03:02 +0000 Subject: [PATCH 2/8] Fix ogc/filter This only compiles if there is goog.provide('ol.Extent') in the typedefs file, and goog.require('ol.Extent') in this file. An alternative is to add an assert statement, but this means an extra dependency. With this change there is no longer a need for the change to tasks/build.js --- src/ol/format/ogc/filter.js | 1 + src/ol/typedefs.js | 1 + tasks/build.js | 3 --- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ol/format/ogc/filter.js b/src/ol/format/ogc/filter.js index 0af819fc19..c4c5422f13 100644 --- a/src/ol/format/ogc/filter.js +++ b/src/ol/format/ogc/filter.js @@ -18,6 +18,7 @@ goog.provide('ol.format.ogc.filter.IsNull'); goog.provide('ol.format.ogc.filter.IsBetween'); goog.provide('ol.format.ogc.filter.IsLike'); +goog.require('ol.Extent'); goog.require('ol.Object'); diff --git a/src/ol/typedefs.js b/src/ol/typedefs.js index 50d2e24bf5..38863528d9 100644 --- a/src/ol/typedefs.js +++ b/src/ol/typedefs.js @@ -2,6 +2,7 @@ * File for all top-level (in the `ol` namespace) typedefs used by the compiler, * and referenced by JSDoc. */ +goog.provide('ol.Extent'); /** diff --git a/tasks/build.js b/tasks/build.js index 8573ac5b30..445d780589 100644 --- a/tasks/build.js +++ b/tasks/build.js @@ -207,9 +207,6 @@ 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); } } From 4f0b4dacbda66912b7b2be0491c3cd6d2bcd5d31 Mon Sep 17 00:00:00 2001 From: Peter Robins Date: Sat, 7 May 2016 21:11:40 +0000 Subject: [PATCH 3/8] Move sub-namespace typedefs to typedefs.js Here too there is one problem case. --- src/ol/events.js | 34 -- src/ol/events/condition.js | 10 - src/ol/format/kmlformat.js | 14 - src/ol/format/wfsformat.js | 20 -- src/ol/interaction/dragboxinteraction.js | 10 - src/ol/interaction/drawinteraction.js | 13 - src/ol/interaction/modifyinteraction.js | 10 - src/ol/interaction/selectinteraction.js | 11 - src/ol/interaction/snapinteraction.js | 19 -- src/ol/layer/layerbase.js | 14 - src/ol/proj/proj.js | 9 - src/ol/raster/operation.js | 19 -- src/ol/raster/pixel.js | 10 - src/ol/render/canvas/canvas.js | 25 -- src/ol/renderer/webgl/webglmaprenderer.js | 6 - src/ol/reproj/image.js | 6 - src/ol/reproj/tile.js | 6 - src/ol/reproj/triangulation.js | 9 - src/ol/source/imagesource.js | 11 - src/ol/source/source.js | 10 - src/ol/source/tilesource.js | 15 - src/ol/source/urltilesource.js | 19 -- src/ol/structs/lrucache.js | 9 - src/ol/style/imagestyle.js | 10 - src/ol/style/style.js | 23 -- src/ol/typedefs.js | 368 ++++++++++++++++++++++ src/ol/webgl/context.js | 7 - src/ol/xml.js | 21 -- 28 files changed, 368 insertions(+), 370 deletions(-) delete mode 100644 src/ol/raster/pixel.js diff --git a/src/ol/events.js b/src/ol/events.js index 6bd280a1ea..718372adf1 100644 --- a/src/ol/events.js +++ b/src/ol/events.js @@ -61,40 +61,6 @@ ol.events.KeyCode = { ol.events.LISTENER_MAP_PROP_ = 'olm_' + ((Math.random() * 1e4) | 0); -/** - * @typedef {EventTarget|ol.events.EventTarget| - * {addEventListener: function(string, Function, boolean=), - * removeEventListener: function(string, Function, boolean=), - * dispatchEvent: function(string)}} - */ -ol.events.EventTargetLike; - - -/** - * Key to use with {@link ol.Observable#unByKey}. - * - * @typedef {{bindTo: (Object|undefined), - * boundListener: (ol.events.ListenerFunctionType|undefined), - * callOnce: boolean, - * deleteIndex: (number|undefined), - * listener: ol.events.ListenerFunctionType, - * target: (EventTarget|ol.events.EventTarget), - * type: string}} - * @api - */ -ol.events.Key; - - -/** - * Listener function. This function is called with an event object as argument. - * When the function returns `false`, event propagation will stop. - * - * @typedef {function(ol.events.Event)|function(ol.events.Event): boolean} - * @api - */ -ol.events.ListenerFunctionType; - - /** * @param {ol.events.Key} listenerObj Listener object. * @return {ol.events.ListenerFunctionType} Bound listener. diff --git a/src/ol/events/condition.js b/src/ol/events/condition.js index 1d0662b40c..144aa1464e 100644 --- a/src/ol/events/condition.js +++ b/src/ol/events/condition.js @@ -6,16 +6,6 @@ goog.require('ol.MapBrowserEvent.EventType'); goog.require('ol.MapBrowserPointerEvent'); -/** - * A function that takes an {@link ol.MapBrowserEvent} and returns a - * `{boolean}`. If the condition is met, true should be returned. - * - * @typedef {function(ol.MapBrowserEvent): boolean} - * @api stable - */ -ol.events.ConditionType; - - /** * Return `true` if only the alt-key is pressed, `false` otherwise (e.g. when * additionally the shift-key is pressed). diff --git a/src/ol/format/kmlformat.js b/src/ol/format/kmlformat.js index 9f77f216d7..8919459b14 100644 --- a/src/ol/format/kmlformat.js +++ b/src/ol/format/kmlformat.js @@ -41,20 +41,6 @@ goog.require('ol.style.Text'); goog.require('ol.xml'); -/** - * @typedef {{x: number, xunits: (ol.style.IconAnchorUnits|undefined), - * y: number, yunits: (ol.style.IconAnchorUnits|undefined)}} - */ -ol.format.KMLVec2_; - - -/** - * @typedef {{flatCoordinates: Array., - * whens: Array.}} - */ -ol.format.KMLGxTrackObject_; - - /** * @classdesc * Feature format for reading and writing data in the KML format. diff --git a/src/ol/format/wfsformat.js b/src/ol/format/wfsformat.js index fa9e660566..25b2a441d5 100644 --- a/src/ol/format/wfsformat.js +++ b/src/ol/format/wfsformat.js @@ -82,26 +82,6 @@ ol.format.WFS.FEATURE_PREFIX = 'feature'; ol.format.WFS.XMLNS = 'http://www.w3.org/2000/xmlns/'; -/** - * Number of features; bounds/extent. - * @typedef {{numberOfFeatures: number, - * bounds: ol.Extent}} - * @api stable - */ -ol.format.WFS.FeatureCollectionMetadata; - - -/** - * Total deleted; total inserted; total updated; array of insert ids. - * @typedef {{totalDeleted: number, - * totalInserted: number, - * totalUpdated: number, - * insertIds: Array.}} - * @api stable - */ -ol.format.WFS.TransactionResponse; - - /** * @const * @type {string} diff --git a/src/ol/interaction/dragboxinteraction.js b/src/ol/interaction/dragboxinteraction.js index 22a1feabdd..05f2db8d79 100644 --- a/src/ol/interaction/dragboxinteraction.js +++ b/src/ol/interaction/dragboxinteraction.js @@ -79,16 +79,6 @@ ol.DragBoxEvent = function(type, coordinate, mapBrowserEvent) { goog.inherits(ol.DragBoxEvent, ol.events.Event); -/** - * A function that takes a {@link ol.MapBrowserEvent} and two - * {@link ol.Pixel}s and returns a `{boolean}`. If the condition is met, - * true should be returned. - * @typedef {function(ol.MapBrowserEvent, ol.Pixel, ol.Pixel):boolean} - * @api - */ -ol.interaction.DragBoxEndConditionType; - - /** * @classdesc * Allows the user to draw a vector box by clicking and dragging on the map, diff --git a/src/ol/interaction/drawinteraction.js b/src/ol/interaction/drawinteraction.js index d085c883dc..6746eb08ed 100644 --- a/src/ol/interaction/drawinteraction.js +++ b/src/ol/interaction/drawinteraction.js @@ -850,19 +850,6 @@ ol.interaction.Draw.getMode_ = function(type) { }; -/** - * Function that takes coordinates and an optional existing geometry as - * arguments, and returns a geometry. The optional existing geometry is the - * geometry that is returned when the function is called without a second - * argument. - * @typedef {function(!(ol.Coordinate|Array.| - * Array.>), ol.geom.SimpleGeometry=): - * ol.geom.SimpleGeometry} - * @api - */ -ol.interaction.DrawGeometryFunctionType; - - /** * Draw mode. This collapses multi-part geometry types with their single-part * cousins. diff --git a/src/ol/interaction/modifyinteraction.js b/src/ol/interaction/modifyinteraction.js index 705983893a..a2557e6248 100644 --- a/src/ol/interaction/modifyinteraction.js +++ b/src/ol/interaction/modifyinteraction.js @@ -82,16 +82,6 @@ ol.interaction.ModifyEvent = function(type, features, mapBrowserPointerEvent) { goog.inherits(ol.interaction.ModifyEvent, ol.events.Event); -/** - * @typedef {{depth: (Array.|undefined), - * feature: ol.Feature, - * geometry: ol.geom.SimpleGeometry, - * index: (number|undefined), - * segment: Array.}} - */ -ol.interaction.SegmentDataType; - - /** * @classdesc * Interaction for modifying feature geometries. diff --git a/src/ol/interaction/selectinteraction.js b/src/ol/interaction/selectinteraction.js index 516a432b75..8316e88be8 100644 --- a/src/ol/interaction/selectinteraction.js +++ b/src/ol/interaction/selectinteraction.js @@ -30,17 +30,6 @@ ol.interaction.SelectEventType = { }; -/** - * A function that takes an {@link ol.Feature} or {@link ol.render.Feature} and - * an {@link ol.layer.Layer} and returns `true` if the feature may be selected - * or `false` otherwise. - * @typedef {function((ol.Feature|ol.render.Feature), ol.layer.Layer): - * boolean} - * @api - */ -ol.interaction.SelectFilterFunction; - - /** * @classdesc * Events emitted by {@link ol.interaction.Select} instances are instances of diff --git a/src/ol/interaction/snapinteraction.js b/src/ol/interaction/snapinteraction.js index d5a3dbbec3..2aa222c5e0 100644 --- a/src/ol/interaction/snapinteraction.js +++ b/src/ol/interaction/snapinteraction.js @@ -591,25 +591,6 @@ ol.interaction.Snap.prototype.writePolygonGeometry_ = function(feature, geometry }; -/** - * @typedef {{ - * snapped: {boolean}, - * vertex: (ol.Coordinate|null), - * vertexPixel: (ol.Pixel|null) - * }} - */ -ol.interaction.Snap.ResultType; - - -/** - * @typedef {{ - * feature: ol.Feature, - * segment: Array. - * }} - */ -ol.interaction.Snap.SegmentDataType; - - /** * Handle all pointer events events. * @param {ol.MapBrowserEvent} evt A move event. diff --git a/src/ol/layer/layerbase.js b/src/ol/layer/layerbase.js index 30951a0449..e594f6d54c 100644 --- a/src/ol/layer/layerbase.js +++ b/src/ol/layer/layerbase.js @@ -22,20 +22,6 @@ ol.layer.LayerProperty = { }; -/** - * @typedef {{layer: ol.layer.Layer, - * opacity: number, - * sourceState: ol.source.State, - * visible: boolean, - * managed: boolean, - * extent: (ol.Extent|undefined), - * zIndex: number, - * maxResolution: number, - * minResolution: number}} - */ -ol.layer.LayerState; - - /** * @classdesc * Abstract base class; normally only used for creating subclasses and not diff --git a/src/ol/proj/proj.js b/src/ol/proj/proj.js index 0e739092d4..ef927199fc 100644 --- a/src/ol/proj/proj.js +++ b/src/ol/proj/proj.js @@ -10,15 +10,6 @@ goog.require('ol.object'); goog.require('ol.sphere.NORMAL'); -/** - * A projection as {@link ol.proj.Projection}, SRS identifier string or - * undefined. - * @typedef {ol.proj.Projection|string|undefined} ol.proj.ProjectionLike - * @api stable - */ -ol.proj.ProjectionLike; - - /** * Projection units: `'degrees'`, `'ft'`, `'m'`, `'pixels'`, `'tile-pixels'` or * `'us-ft'`. diff --git a/src/ol/raster/operation.js b/src/ol/raster/operation.js index ec95350d46..0c2547d8b4 100644 --- a/src/ol/raster/operation.js +++ b/src/ol/raster/operation.js @@ -10,22 +10,3 @@ ol.raster.OperationType = { PIXEL: 'pixel', IMAGE: 'image' }; - - -/** - * A function that takes an array of input data, performs some operation, and - * returns an array of ouput data. For `'pixel'` type operations, functions - * will be called with an array of {@link ol.raster.Pixel} data and should - * return an array of the same. For `'image'` type operations, functions will - * be called with an array of {@link ImageData - * https://developer.mozilla.org/en-US/docs/Web/API/ImageData} and should return - * an array of the same. The operations are called with a second "data" - * argument, which can be used for storage. The data object is accessible - * from raster events, where it can be initialized in "beforeoperations" and - * accessed again in "afteroperations". - * - * @typedef {function((Array.|Array.), Object): - * (Array.|Array.)} - * @api - */ -ol.raster.Operation; diff --git a/src/ol/raster/pixel.js b/src/ol/raster/pixel.js deleted file mode 100644 index 58947f0523..0000000000 --- a/src/ol/raster/pixel.js +++ /dev/null @@ -1,10 +0,0 @@ -// goog.provide can't be removed from files which only contain a typedef -goog.provide('ol.raster.Pixel'); - - -/** - * An array of numbers representing pixel values. - * @typedef {Array.} ol.raster.Pixel - * @api - */ -ol.raster.Pixel; diff --git a/src/ol/render/canvas/canvas.js b/src/ol/render/canvas/canvas.js index 28644bc9da..8b8d5fcf5d 100644 --- a/src/ol/render/canvas/canvas.js +++ b/src/ol/render/canvas/canvas.js @@ -1,31 +1,6 @@ goog.provide('ol.render.canvas'); -/** - * @typedef {{fillStyle: ol.ColorLike}} - */ -ol.render.canvas.FillState; - - -/** - * @typedef {{lineCap: string, - * lineDash: Array., - * lineJoin: string, - * lineWidth: number, - * miterLimit: number, - * strokeStyle: string}} - */ -ol.render.canvas.StrokeState; - - -/** - * @typedef {{font: string, - * textAlign: string, - * textBaseline: string}} - */ -ol.render.canvas.TextState; - - /** * @const * @type {string} diff --git a/src/ol/renderer/webgl/webglmaprenderer.js b/src/ol/renderer/webgl/webglmaprenderer.js index 99d8b49d21..8a6b6dcc1b 100644 --- a/src/ol/renderer/webgl/webglmaprenderer.js +++ b/src/ol/renderer/webgl/webglmaprenderer.js @@ -33,12 +33,6 @@ goog.require('ol.webgl.Context'); goog.require('ol.webgl.WebGLContextEventType'); -/** - * @typedef {{magFilter: number, minFilter: number, texture: WebGLTexture}} - */ -ol.renderer.webgl.TextureCacheEntry; - - /** * @constructor * @extends {ol.renderer.Map} diff --git a/src/ol/reproj/image.js b/src/ol/reproj/image.js index 6d8c29f94e..087ec42c95 100644 --- a/src/ol/reproj/image.js +++ b/src/ol/reproj/image.js @@ -11,12 +11,6 @@ goog.require('ol.reproj'); goog.require('ol.reproj.Triangulation'); -/** - * @typedef {function(ol.Extent, number, number) : ol.ImageBase} - */ -ol.reproj.ImageFunctionType; - - /** * @classdesc * Class encapsulating single reprojected image. diff --git a/src/ol/reproj/tile.js b/src/ol/reproj/tile.js index 5c9566da57..28a2d69688 100644 --- a/src/ol/reproj/tile.js +++ b/src/ol/reproj/tile.js @@ -13,12 +13,6 @@ goog.require('ol.reproj'); goog.require('ol.reproj.Triangulation'); -/** - * @typedef {function(number, number, number, number) : ol.Tile} - */ -ol.reproj.TileFunctionType; - - /** * @classdesc * Class encapsulating single reprojected tile. diff --git a/src/ol/reproj/triangulation.js b/src/ol/reproj/triangulation.js index e893c134da..c4e9051824 100644 --- a/src/ol/reproj/triangulation.js +++ b/src/ol/reproj/triangulation.js @@ -6,15 +6,6 @@ goog.require('ol.math'); goog.require('ol.proj'); -/** - * Single triangle; consists of 3 source points and 3 target points. - * - * @typedef {{source: Array., - * target: Array.}} - */ -ol.reproj.Triangle; - - /** * @classdesc * Class containing triangulation of the given target extent. diff --git a/src/ol/source/imagesource.js b/src/ol/source/imagesource.js index 3881bc7184..0d1c24f5f3 100644 --- a/src/ol/source/imagesource.js +++ b/src/ol/source/imagesource.js @@ -11,17 +11,6 @@ goog.require('ol.reproj.Image'); goog.require('ol.source.Source'); -/** - * @typedef {{attributions: (ol.AttributionLike|undefined), - * extent: (null|ol.Extent|undefined), - * logo: (string|olx.LogoOptions|undefined), - * projection: ol.proj.ProjectionLike, - * resolutions: (Array.|undefined), - * state: (ol.source.State|undefined)}} - */ -ol.source.ImageOptions; - - /** * @classdesc * Abstract base class; normally only used for creating subclasses and not diff --git a/src/ol/source/source.js b/src/ol/source/source.js index 9a4db1b021..4bb1e82ca7 100644 --- a/src/ol/source/source.js +++ b/src/ol/source/source.js @@ -20,16 +20,6 @@ ol.source.State = { }; -/** - * @typedef {{attributions: (ol.AttributionLike|undefined), - * logo: (string|olx.LogoOptions|undefined), - * projection: ol.proj.ProjectionLike, - * state: (ol.source.State|undefined), - * wrapX: (boolean|undefined)}} - */ -ol.source.SourceOptions; - - /** * @classdesc * Abstract base class; normally only used for creating subclasses and not diff --git a/src/ol/source/tilesource.js b/src/ol/source/tilesource.js index a509eaebb7..dbd41fa803 100644 --- a/src/ol/source/tilesource.js +++ b/src/ol/source/tilesource.js @@ -14,21 +14,6 @@ goog.require('ol.tilecoord'); goog.require('ol.tilegrid.TileGrid'); -/** - * @typedef {{attributions: (ol.AttributionLike|undefined), - * cacheSize: (number|undefined), - * extent: (ol.Extent|undefined), - * logo: (string|olx.LogoOptions|undefined), - * opaque: (boolean|undefined), - * tilePixelRatio: (number|undefined), - * projection: ol.proj.ProjectionLike, - * state: (ol.source.State|undefined), - * tileGrid: (ol.tilegrid.TileGrid|undefined), - * wrapX: (boolean|undefined)}} - */ -ol.source.TileOptions; - - /** * @classdesc * Abstract base class; normally only used for creating subclasses and not diff --git a/src/ol/source/urltilesource.js b/src/ol/source/urltilesource.js index f1dff5a971..6b87c687d5 100644 --- a/src/ol/source/urltilesource.js +++ b/src/ol/source/urltilesource.js @@ -7,25 +7,6 @@ goog.require('ol.source.Tile'); goog.require('ol.source.TileEvent'); -/** - * @typedef {{attributions: (ol.AttributionLike|undefined), - * cacheSize: (number|undefined), - * extent: (ol.Extent|undefined), - * logo: (string|olx.LogoOptions|undefined), - * opaque: (boolean|undefined), - * projection: ol.proj.ProjectionLike, - * state: (ol.source.State|undefined), - * tileGrid: (ol.tilegrid.TileGrid|undefined), - * tileLoadFunction: ol.TileLoadFunctionType, - * tilePixelRatio: (number|undefined), - * tileUrlFunction: (ol.TileUrlFunctionType|undefined), - * url: (string|undefined), - * urls: (Array.|undefined), - * wrapX: (boolean|undefined)}} - */ -ol.source.UrlTileOptions; - - /** * @classdesc * Base class for sources providing tiles divided into a tile grid over http. diff --git a/src/ol/structs/lrucache.js b/src/ol/structs/lrucache.js index 9cdcf49bda..458ddd544e 100644 --- a/src/ol/structs/lrucache.js +++ b/src/ol/structs/lrucache.js @@ -259,12 +259,3 @@ ol.structs.LRUCache.prototype.set = function(key, value) { this.entries_[key] = entry; ++this.count_; }; - - -/** - * @typedef {{key_: string, - * newer: ol.structs.LRUCacheEntry, - * older: ol.structs.LRUCacheEntry, - * value_: *}} - */ -ol.structs.LRUCacheEntry; diff --git a/src/ol/style/imagestyle.js b/src/ol/style/imagestyle.js index 7de23bfc00..4858061a8a 100644 --- a/src/ol/style/imagestyle.js +++ b/src/ol/style/imagestyle.js @@ -13,16 +13,6 @@ ol.style.ImageState = { }; -/** - * @typedef {{opacity: number, - * rotateWithView: boolean, - * rotation: number, - * scale: number, - * snapToPixel: boolean}} - */ -ol.style.ImageOptions; - - /** * @classdesc * A base class used for creating subclasses and not instantiated in diff --git a/src/ol/style/style.js b/src/ol/style/style.js index d7f6c515fc..b9835060a1 100644 --- a/src/ol/style/style.js +++ b/src/ol/style/style.js @@ -191,18 +191,6 @@ ol.style.Style.prototype.setZIndex = function(zIndex) { }; -/** - * A function that takes an {@link ol.Feature} and a `{number}` representing - * the view's resolution. The function should return a {@link ol.style.Style} - * or an array of them. This way e.g. a vector layer can be styled. - * - * @typedef {function((ol.Feature|ol.render.Feature), number): - * (ol.style.Style|Array.)} - * @api - */ -ol.style.StyleFunction; - - /** * Convert the provided object into a style function. Functions passed through * unchanged. Arrays of ol.style.Style or single style objects wrapped in a @@ -349,17 +337,6 @@ ol.style.createDefaultEditingStyles = function() { }; -/** - * A function that takes an {@link ol.Feature} as argument and returns an - * {@link ol.geom.Geometry} that will be rendered and styled for the feature. - * - * @typedef {function((ol.Feature|ol.render.Feature)): - * (ol.geom.Geometry|ol.render.Feature|undefined)} - * @api - */ -ol.style.GeometryFunction; - - /** * Function that is called with a feature and returns its default geometry. * @param {ol.Feature|ol.render.Feature} feature Feature to get the geometry diff --git a/src/ol/typedefs.js b/src/ol/typedefs.js index 38863528d9..006c0b4a8e 100644 --- a/src/ol/typedefs.js +++ b/src/ol/typedefs.js @@ -288,3 +288,371 @@ ol.TileUrlFunctionType; * @api stable */ ol.TransformFunction; + + +/** + * A function that takes an {@link ol.MapBrowserEvent} and returns a + * `{boolean}`. If the condition is met, true should be returned. + * + * @typedef {function(ol.MapBrowserEvent): boolean} + * @api stable + */ +ol.events.ConditionType; + + +/** + * @typedef {EventTarget|ol.events.EventTarget| + * {addEventListener: function(string, Function, boolean=), + * removeEventListener: function(string, Function, boolean=), + * dispatchEvent: function(string)}} + */ +ol.events.EventTargetLike; + + +/** + * Key to use with {@link ol.Observable#unByKey}. + * + * @typedef {{bindTo: (Object|undefined), + * boundListener: (ol.events.ListenerFunctionType|undefined), + * callOnce: boolean, + * deleteIndex: (number|undefined), + * listener: ol.events.ListenerFunctionType, + * target: (EventTarget|ol.events.EventTarget), + * type: string}} + * @api + */ +ol.events.Key; + + +/** + * Listener function. This function is called with an event object as argument. + * When the function returns `false`, event propagation will stop. + * + * @typedef {function(ol.events.Event)|function(ol.events.Event): boolean} + * @api + */ +ol.events.ListenerFunctionType; + + +/** + * @typedef {{x: number, xunits: (ol.style.IconAnchorUnits|undefined), + * y: number, yunits: (ol.style.IconAnchorUnits|undefined)}} + */ +ol.format.KMLVec2_; + + +/** + * @typedef {{flatCoordinates: Array., + * whens: Array.}} + */ +ol.format.KMLGxTrackObject_; + + +/** + * Number of features; bounds/extent. + * @typedef {{numberOfFeatures: number, + * bounds: ol.Extent}} + * @api stable + */ +ol.format.WFS.FeatureCollectionMetadata; + + +/** + * Total deleted; total inserted; total updated; array of insert ids. + * @typedef {{totalDeleted: number, + * totalInserted: number, + * totalUpdated: number, + * insertIds: Array.}} + * @api stable + */ +ol.format.WFS.TransactionResponse; + + +/** + * A function that takes a {@link ol.MapBrowserEvent} and two + * {@link ol.Pixel}s and returns a `{boolean}`. If the condition is met, + * true should be returned. + * @typedef {function(ol.MapBrowserEvent, ol.Pixel, ol.Pixel):boolean} + * @api + */ +ol.interaction.DragBoxEndConditionType; + + +/** + * Function that takes coordinates and an optional existing geometry as + * arguments, and returns a geometry. The optional existing geometry is the + * geometry that is returned when the function is called without a second + * argument. + * @typedef {function(!(ol.Coordinate|Array.| + * Array.>), ol.geom.SimpleGeometry=): + * ol.geom.SimpleGeometry} + * @api + */ +ol.interaction.DrawGeometryFunctionType; + + +/** + * @typedef {{depth: (Array.|undefined), + * feature: ol.Feature, + * geometry: ol.geom.SimpleGeometry, + * index: (number|undefined), + * segment: Array.}} + */ +ol.interaction.SegmentDataType; + + +/** + * A function that takes an {@link ol.Feature} or {@link ol.render.Feature} and + * an {@link ol.layer.Layer} and returns `true` if the feature may be selected + * or `false` otherwise. + * @typedef {function((ol.Feature|ol.render.Feature), ol.layer.Layer): + * boolean} + * @api + */ +ol.interaction.SelectFilterFunction; + + +/** + * @typedef {{ + * snapped: {boolean}, + * vertex: (ol.Coordinate|null), + * vertexPixel: (ol.Pixel|null) + * }} + */ +ol.interaction.Snap.ResultType; + + +/** + * @typedef {{ + * feature: ol.Feature, + * segment: Array. + * }} + */ +ol.interaction.Snap.SegmentDataType; + + +/** + * @typedef {{layer: ol.layer.Layer, + * opacity: number, + * sourceState: ol.source.State, + * visible: boolean, + * managed: boolean, + * extent: (ol.Extent|undefined), + * zIndex: number, + * maxResolution: number, + * minResolution: number}} + */ +ol.layer.LayerState; + + +/** + * A projection as {@link ol.proj.Projection}, SRS identifier string or + * undefined. + * @typedef {ol.proj.Projection|string|undefined} ol.proj.ProjectionLike + * @api stable + */ +ol.proj.ProjectionLike; + + +/** + * A function that takes an array of input data, performs some operation, and + * returns an array of ouput data. For `'pixel'` type operations, functions + * will be called with an array of {@link ol.raster.Pixel} data and should + * return an array of the same. For `'image'` type operations, functions will + * be called with an array of {@link ImageData + * https://developer.mozilla.org/en-US/docs/Web/API/ImageData} and should return + * an array of the same. The operations are called with a second "data" + * argument, which can be used for storage. The data object is accessible + * from raster events, where it can be initialized in "beforeoperations" and + * accessed again in "afteroperations". + * + * @typedef {function((Array.|Array.), Object): + * (Array.|Array.)} + * @api + */ +ol.raster.Operation; + + +/** + * An array of numbers representing pixel values. + * @typedef {Array.} ol.raster.Pixel + * @api + */ +ol.raster.Pixel; + + +/** + * @typedef {{fillStyle: ol.ColorLike}} + */ +ol.render.canvas.FillState; + + +/** + * @typedef {{lineCap: string, + * lineDash: Array., + * lineJoin: string, + * lineWidth: number, + * miterLimit: number, + * strokeStyle: string}} + */ +ol.render.canvas.StrokeState; + + +/** + * @typedef {{font: string, + * textAlign: string, + * textBaseline: string}} + */ +ol.render.canvas.TextState; + + +/** + * @typedef {{magFilter: number, minFilter: number, texture: WebGLTexture}} + */ +ol.renderer.webgl.TextureCacheEntry; + + +/** + * @typedef {function(ol.Extent, number, number) : ol.ImageBase} + */ +ol.reproj.ImageFunctionType; + + +/** + * @typedef {function(number, number, number, number) : ol.Tile} + */ +ol.reproj.TileFunctionType; + + +/** + * Single triangle; consists of 3 source points and 3 target points. + * + * @typedef {{source: Array., + * target: Array.}} + */ +ol.reproj.Triangle; + + +/** + * @typedef {{attributions: (ol.AttributionLike|undefined), + * extent: (null|ol.Extent|undefined), + * logo: (string|olx.LogoOptions|undefined), + * projection: ol.proj.ProjectionLike, + * resolutions: (Array.|undefined), + * state: (ol.source.State|undefined)}} + */ +ol.source.ImageOptions; + + +/** + * @typedef {{attributions: (ol.AttributionLike|undefined), + * logo: (string|olx.LogoOptions|undefined), + * projection: ol.proj.ProjectionLike, + * state: (ol.source.State|undefined), + * wrapX: (boolean|undefined)}} + */ +ol.source.SourceOptions; + + +/** + * @typedef {{attributions: (ol.AttributionLike|undefined), + * cacheSize: (number|undefined), + * extent: (ol.Extent|undefined), + * logo: (string|olx.LogoOptions|undefined), + * opaque: (boolean|undefined), + * tilePixelRatio: (number|undefined), + * projection: ol.proj.ProjectionLike, + * state: (ol.source.State|undefined), + * tileGrid: (ol.tilegrid.TileGrid|undefined), + * wrapX: (boolean|undefined)}} + */ +ol.source.TileOptions; + + +/** + * @typedef {{attributions: (ol.AttributionLike|undefined), + * cacheSize: (number|undefined), + * extent: (ol.Extent|undefined), + * logo: (string|olx.LogoOptions|undefined), + * opaque: (boolean|undefined), + * projection: ol.proj.ProjectionLike, + * state: (ol.source.State|undefined), + * tileGrid: (ol.tilegrid.TileGrid|undefined), + * tileLoadFunction: ol.TileLoadFunctionType, + * tilePixelRatio: (number|undefined), + * tileUrlFunction: (ol.TileUrlFunctionType|undefined), + * url: (string|undefined), + * urls: (Array.|undefined), + * wrapX: (boolean|undefined)}} + */ +ol.source.UrlTileOptions; + + +/** + * @typedef {{key_: string, + * newer: ol.structs.LRUCacheEntry, + * older: ol.structs.LRUCacheEntry, + * value_: *}} + */ +ol.structs.LRUCacheEntry; + + +/** + * @typedef {{opacity: number, + * rotateWithView: boolean, + * rotation: number, + * scale: number, + * snapToPixel: boolean}} + */ +ol.style.ImageOptions; + + +/** + * A function that takes an {@link ol.Feature} as argument and returns an + * {@link ol.geom.Geometry} that will be rendered and styled for the feature. + * + * @typedef {function((ol.Feature|ol.render.Feature)): + * (ol.geom.Geometry|ol.render.Feature|undefined)} + * @api + */ +ol.style.GeometryFunction; + + +/** + * A function that takes an {@link ol.Feature} and a `{number}` representing + * the view's resolution. The function should return a {@link ol.style.Style} + * or an array of them. This way e.g. a vector layer can be styled. + * + * @typedef {function((ol.Feature|ol.render.Feature), number): + * (ol.style.Style|Array.)} + * @api + */ +ol.style.StyleFunction; + + +/** + * @typedef {{buf: ol.webgl.Buffer, + * buffer: WebGLBuffer}} + */ +ol.webgl.BufferCacheEntry; + + +/** + * When using {@link ol.xml.makeChildAppender} or + * {@link ol.xml.makeSimpleNodeFactory}, the top `objectStack` item needs to + * have this structure. + * @typedef {{node:Node}} + */ +ol.xml.NodeStackItem; + + +/** + * @typedef {function(Node, Array.<*>)} + */ +ol.xml.Parser; + + +/** + * @typedef {function(Node, *, Array.<*>)} + */ +ol.xml.Serializer; diff --git a/src/ol/webgl/context.js b/src/ol/webgl/context.js index b506251c3d..059175f3c1 100644 --- a/src/ol/webgl/context.js +++ b/src/ol/webgl/context.js @@ -10,13 +10,6 @@ goog.require('ol.webgl.Buffer'); goog.require('ol.webgl.WebGLContextEventType'); -/** - * @typedef {{buf: ol.webgl.Buffer, - * buffer: WebGLBuffer}} - */ -ol.webgl.BufferCacheEntry; - - /** * @classdesc * A WebGL context for accessing low-level WebGL capabilities. diff --git a/src/ol/xml.js b/src/ol/xml.js index 9d16765c52..119ad799a5 100644 --- a/src/ol/xml.js +++ b/src/ol/xml.js @@ -5,27 +5,6 @@ goog.require('goog.dom.NodeType'); goog.require('ol.array'); -/** - * When using {@link ol.xml.makeChildAppender} or - * {@link ol.xml.makeSimpleNodeFactory}, the top `objectStack` item needs to - * have this structure. - * @typedef {{node:Node}} - */ -ol.xml.NodeStackItem; - - -/** - * @typedef {function(Node, Array.<*>)} - */ -ol.xml.Parser; - - -/** - * @typedef {function(Node, *, Array.<*>)} - */ -ol.xml.Serializer; - - /** * This document should be used when creating nodes for XML serializations. This * document is also used by {@link ol.xml.createElementNS} and From a1c86ed56010375cc4cb4ec0513db75d723852f8 Mon Sep 17 00:00:00 2001 From: Peter Robins Date: Wed, 11 May 2016 14:52:53 +0000 Subject: [PATCH 4/8] Fix eventTargetLike This needs a goog.provide and a goog.require in events.js to compile. --- src/ol/events.js | 1 + src/ol/typedefs.js | 1 + 2 files changed, 2 insertions(+) diff --git a/src/ol/events.js b/src/ol/events.js index 718372adf1..ad572dc42a 100644 --- a/src/ol/events.js +++ b/src/ol/events.js @@ -3,6 +3,7 @@ goog.provide('ol.events.EventType'); goog.provide('ol.events.KeyCode'); goog.require('ol.object'); +goog.require('ol.events.EventTargetLike'); /** diff --git a/src/ol/typedefs.js b/src/ol/typedefs.js index 006c0b4a8e..d99285a52e 100644 --- a/src/ol/typedefs.js +++ b/src/ol/typedefs.js @@ -3,6 +3,7 @@ * and referenced by JSDoc. */ goog.provide('ol.Extent'); +goog.provide('ol.events.EventTargetLike'); /** From c7aeebed8cd04123c8b2138a91f96531d427864f Mon Sep 17 00:00:00 2001 From: Peter Robins Date: Sat, 7 May 2016 21:09:48 +0000 Subject: [PATCH 5/8] Rename sub-sub-namespace typedefs to sub-namespace These sub-sub-namespace typedefs are only used internally; some of them cause problems by creating a form of circular dependency. For example, ol.style.Atlas is created in style/atlasmanager.js; if ol.style.Atlas.Block is in a separate file, ol.style.Atlas is dependent on it, so the new file must precede ol.style.Atlas. However if it precedes it then it has to create the ol.style.Atlas namespace which should be created by atlasmanager.js. To get round this, these typedefs are renamed to remove the sub-sub-namespace. Fortunately they are all non-api, so the rename should not affect anything. --- src/ol/format/wktformat.js | 10 +--- src/ol/interaction/snapinteraction.js | 24 ++++---- src/ol/render/canvas/canvasimmediate.js | 22 +++---- src/ol/render/canvas/canvasreplay.js | 18 +++--- src/ol/renderer/webgl/webglmaprenderer.js | 4 +- src/ol/source/rastersource.js | 10 +--- src/ol/style/atlasmanager.js | 37 ++---------- src/ol/style/circlestyle.js | 15 ++--- src/ol/style/regularshapestyle.js | 22 ++----- src/ol/typedefs.js | 73 +++++++++++++++++++++-- 10 files changed, 118 insertions(+), 117 deletions(-) diff --git a/src/ol/format/wktformat.js b/src/ol/format/wktformat.js index 486666eb32..7532560d30 100644 --- a/src/ol/format/wktformat.js +++ b/src/ol/format/wktformat.js @@ -366,12 +366,6 @@ ol.format.WKT.prototype.writeGeometryText = function(geometry, opt_options) { }; -/** - * @typedef {{type: number, value: (number|string|undefined), position: number}} - */ -ol.format.WKT.Token; - - /** * @const * @enum {number} @@ -451,7 +445,7 @@ ol.format.WKT.Lexer.prototype.nextChar_ = function() { /** * Fetch and return the next token. - * @return {!ol.format.WKT.Token} Next string token. + * @return {!ol.format.WKTToken} Next string token. */ ol.format.WKT.Lexer.prototype.nextToken = function() { var c = this.nextChar_(); @@ -537,7 +531,7 @@ ol.format.WKT.Parser = function(lexer) { this.lexer_ = lexer; /** - * @type {ol.format.WKT.Token} + * @type {ol.format.WKTToken} * @private */ this.token_; diff --git a/src/ol/interaction/snapinteraction.js b/src/ol/interaction/snapinteraction.js index 2aa222c5e0..dc5bf6570f 100644 --- a/src/ol/interaction/snapinteraction.js +++ b/src/ol/interaction/snapinteraction.js @@ -129,7 +129,7 @@ ol.interaction.Snap = function(opt_options) { options.pixelTolerance : 10; /** - * @type {function(ol.interaction.Snap.SegmentDataType, ol.interaction.Snap.SegmentDataType): number} + * @type {function(ol.interaction.SnapSegmentDataType, ol.interaction.SnapSegmentDataType): number} * @private */ this.sortByDistance_ = ol.interaction.Snap.sortByDistance.bind(this); @@ -137,7 +137,7 @@ ol.interaction.Snap = function(opt_options) { /** * Segment RTree for each layer - * @type {ol.structs.RBush.} + * @type {ol.structs.RBush.} * @private */ this.rBush_ = new ol.structs.RBush(); @@ -378,7 +378,7 @@ ol.interaction.Snap.prototype.shouldStopEvent = ol.functions.FALSE; * @param {ol.Pixel} pixel Pixel * @param {ol.Coordinate} pixelCoordinate Coordinate * @param {ol.Map} map Map. - * @return {ol.interaction.Snap.ResultType} Snap result + * @return {ol.interaction.SnapResultType} Snap result */ ol.interaction.Snap.prototype.snapTo = function(pixel, pixelCoordinate, map) { @@ -437,7 +437,7 @@ ol.interaction.Snap.prototype.snapTo = function(pixel, pixelCoordinate, map) { vertexPixel = [Math.round(vertexPixel[0]), Math.round(vertexPixel[1])]; } } - return /** @type {ol.interaction.Snap.ResultType} */ ({ + return /** @type {ol.interaction.SnapResultType} */ ({ snapped: snapped, vertex: vertex, vertexPixel: vertexPixel @@ -479,7 +479,7 @@ ol.interaction.Snap.prototype.writeLineStringGeometry_ = function(feature, geome var i, ii, segment, segmentData; for (i = 0, ii = coordinates.length - 1; i < ii; ++i) { segment = coordinates.slice(i, i + 2); - segmentData = /** @type {ol.interaction.Snap.SegmentDataType} */ ({ + segmentData = /** @type {ol.interaction.SnapSegmentDataType} */ ({ feature: feature, segment: segment }); @@ -500,7 +500,7 @@ ol.interaction.Snap.prototype.writeMultiLineStringGeometry_ = function(feature, coordinates = lines[j]; for (i = 0, ii = coordinates.length - 1; i < ii; ++i) { segment = coordinates.slice(i, i + 2); - segmentData = /** @type {ol.interaction.Snap.SegmentDataType} */ ({ + segmentData = /** @type {ol.interaction.SnapSegmentDataType} */ ({ feature: feature, segment: segment }); @@ -520,7 +520,7 @@ ol.interaction.Snap.prototype.writeMultiPointGeometry_ = function(feature, geome var coordinates, i, ii, segmentData; for (i = 0, ii = points.length; i < ii; ++i) { coordinates = points[i]; - segmentData = /** @type {ol.interaction.Snap.SegmentDataType} */ ({ + segmentData = /** @type {ol.interaction.SnapSegmentDataType} */ ({ feature: feature, segment: [coordinates, coordinates] }); @@ -543,7 +543,7 @@ ol.interaction.Snap.prototype.writeMultiPolygonGeometry_ = function(feature, geo coordinates = rings[j]; for (i = 0, ii = coordinates.length - 1; i < ii; ++i) { segment = coordinates.slice(i, i + 2); - segmentData = /** @type {ol.interaction.Snap.SegmentDataType} */ ({ + segmentData = /** @type {ol.interaction.SnapSegmentDataType} */ ({ feature: feature, segment: segment }); @@ -561,7 +561,7 @@ ol.interaction.Snap.prototype.writeMultiPolygonGeometry_ = function(feature, geo */ ol.interaction.Snap.prototype.writePointGeometry_ = function(feature, geometry) { var coordinates = geometry.getCoordinates(); - var segmentData = /** @type {ol.interaction.Snap.SegmentDataType} */ ({ + var segmentData = /** @type {ol.interaction.SnapSegmentDataType} */ ({ feature: feature, segment: [coordinates, coordinates] }); @@ -581,7 +581,7 @@ ol.interaction.Snap.prototype.writePolygonGeometry_ = function(feature, geometry coordinates = rings[j]; for (i = 0, ii = coordinates.length - 1; i < ii; ++i) { segment = coordinates.slice(i, i + 2); - segmentData = /** @type {ol.interaction.Snap.SegmentDataType} */ ({ + segmentData = /** @type {ol.interaction.SnapSegmentDataType} */ ({ feature: feature, segment: segment }); @@ -626,8 +626,8 @@ ol.interaction.Snap.handleUpEvent_ = function(evt) { /** * Sort segments by distance, helper function - * @param {ol.interaction.Snap.SegmentDataType} a The first segment data. - * @param {ol.interaction.Snap.SegmentDataType} b The second segment data. + * @param {ol.interaction.SnapSegmentDataType} a The first segment data. + * @param {ol.interaction.SnapSegmentDataType} b The second segment data. * @return {number} The difference in distance. * @this {ol.interaction.Snap} */ diff --git a/src/ol/render/canvas/canvasimmediate.js b/src/ol/render/canvas/canvasimmediate.js index 68f2dad395..c2d8ba8899 100644 --- a/src/ol/render/canvas/canvasimmediate.js +++ b/src/ol/render/canvas/canvasimmediate.js @@ -71,31 +71,31 @@ ol.render.canvas.Immediate = function(context, pixelRatio, extent, transform, vi /** * @private - * @type {?ol.render.canvas.FillState} + * @type {?ol.render.canvasFillState} */ this.contextFillState_ = null; /** * @private - * @type {?ol.render.canvas.StrokeState} + * @type {?ol.render.canvasStrokeState} */ this.contextStrokeState_ = null; /** * @private - * @type {?ol.render.canvas.TextState} + * @type {?ol.render.canvasTextState} */ this.contextTextState_ = null; /** * @private - * @type {?ol.render.canvas.FillState} + * @type {?ol.render.canvasFillState} */ this.fillState_ = null; /** * @private - * @type {?ol.render.canvas.StrokeState} + * @type {?ol.render.canvasStrokeState} */ this.strokeState_ = null; @@ -203,19 +203,19 @@ ol.render.canvas.Immediate = function(context, pixelRatio, extent, transform, vi /** * @private - * @type {?ol.render.canvas.FillState} + * @type {?ol.render.canvasFillState} */ this.textFillState_ = null; /** * @private - * @type {?ol.render.canvas.StrokeState} + * @type {?ol.render.canvasStrokeState} */ this.textStrokeState_ = null; /** * @private - * @type {?ol.render.canvas.TextState} + * @type {?ol.render.canvasTextState} */ this.textState_ = null; @@ -700,7 +700,7 @@ ol.render.canvas.Immediate.prototype.drawMultiPolygon = function(geometry) { /** - * @param {ol.render.canvas.FillState} fillState Fill state. + * @param {ol.render.canvasFillState} fillState Fill state. * @private */ ol.render.canvas.Immediate.prototype.setContextFillState_ = function(fillState) { @@ -720,7 +720,7 @@ ol.render.canvas.Immediate.prototype.setContextFillState_ = function(fillState) /** - * @param {ol.render.canvas.StrokeState} strokeState Stroke state. + * @param {ol.render.canvasStrokeState} strokeState Stroke state. * @private */ ol.render.canvas.Immediate.prototype.setContextStrokeState_ = function(strokeState) { @@ -772,7 +772,7 @@ ol.render.canvas.Immediate.prototype.setContextStrokeState_ = function(strokeSta /** - * @param {ol.render.canvas.TextState} textState Text state. + * @param {ol.render.canvasTextState} textState Text state. * @private */ ol.render.canvas.Immediate.prototype.setContextTextState_ = function(textState) { diff --git a/src/ol/render/canvas/canvasreplay.js b/src/ol/render/canvas/canvasreplay.js index 976839a403..4ad1e193b5 100644 --- a/src/ol/render/canvas/canvasreplay.js +++ b/src/ol/render/canvas/canvasreplay.js @@ -1538,19 +1538,19 @@ ol.render.canvas.TextReplay = function(tolerance, maxExtent, resolution) { /** * @private - * @type {?ol.render.canvas.FillState} + * @type {?ol.render.canvasFillState} */ this.replayFillState_ = null; /** * @private - * @type {?ol.render.canvas.StrokeState} + * @type {?ol.render.canvasStrokeState} */ this.replayStrokeState_ = null; /** * @private - * @type {?ol.render.canvas.TextState} + * @type {?ol.render.canvasTextState} */ this.replayTextState_ = null; @@ -1586,19 +1586,19 @@ ol.render.canvas.TextReplay = function(tolerance, maxExtent, resolution) { /** * @private - * @type {?ol.render.canvas.FillState} + * @type {?ol.render.canvasFillState} */ this.textFillState_ = null; /** * @private - * @type {?ol.render.canvas.StrokeState} + * @type {?ol.render.canvasStrokeState} */ this.textStrokeState_ = null; /** * @private - * @type {?ol.render.canvas.TextState} + * @type {?ol.render.canvasTextState} */ this.textState_ = null; @@ -1638,7 +1638,7 @@ ol.render.canvas.TextReplay.prototype.drawText = function(flatCoordinates, offse /** - * @param {ol.render.canvas.FillState} fillState Fill state. + * @param {ol.render.canvasFillState} fillState Fill state. * @private */ ol.render.canvas.TextReplay.prototype.setReplayFillState_ = function(fillState) { @@ -1662,7 +1662,7 @@ ol.render.canvas.TextReplay.prototype.setReplayFillState_ = function(fillState) /** - * @param {ol.render.canvas.StrokeState} strokeState Stroke state. + * @param {ol.render.canvasStrokeState} strokeState Stroke state. * @private */ ol.render.canvas.TextReplay.prototype.setReplayStrokeState_ = function(strokeState) { @@ -1704,7 +1704,7 @@ ol.render.canvas.TextReplay.prototype.setReplayStrokeState_ = function(strokeSta /** - * @param {ol.render.canvas.TextState} textState Text state. + * @param {ol.render.canvasTextState} textState Text state. * @private */ ol.render.canvas.TextReplay.prototype.setReplayTextState_ = function(textState) { diff --git a/src/ol/renderer/webgl/webglmaprenderer.js b/src/ol/renderer/webgl/webglmaprenderer.js index 8a6b6dcc1b..550b8fb491 100644 --- a/src/ol/renderer/webgl/webglmaprenderer.js +++ b/src/ol/renderer/webgl/webglmaprenderer.js @@ -104,7 +104,7 @@ ol.renderer.webgl.Map = function(container, map) { /** * @private - * @type {ol.structs.LRUCache.} + * @type {ol.structs.LRUCache.} */ this.textureCache_ = new ol.structs.LRUCache(); @@ -294,7 +294,7 @@ ol.renderer.webgl.Map.prototype.disposeInternal = function() { if (!gl.isContextLost()) { this.textureCache_.forEach( /** - * @param {?ol.renderer.webgl.TextureCacheEntry} textureCacheEntry + * @param {?ol.renderer.webglTextureCacheEntry} textureCacheEntry * Texture cache entry. */ function(textureCacheEntry) { diff --git a/src/ol/source/rastersource.js b/src/ol/source/rastersource.js index bbae4bc9d1..5c9f0ac993 100644 --- a/src/ol/source/rastersource.js +++ b/src/ol/source/rastersource.js @@ -91,7 +91,7 @@ ol.source.Raster = function(options) { /** * The most recently rendered state. - * @type {?ol.source.Raster.RenderedState} + * @type {?ol.source.RasterRenderedState} * @private */ this.renderedState_ = null; @@ -445,14 +445,6 @@ ol.source.Raster.createTileRenderer_ = function(source) { }; -/** - * @typedef {{revision: number, - * resolution: number, - * extent: ol.Extent}} - */ -ol.source.Raster.RenderedState; - - /** * @classdesc * Events emitted by {@link ol.source.Raster} instances are instances of this diff --git a/src/ol/style/atlasmanager.js b/src/ol/style/atlasmanager.js index 35526bc6dc..0ca4bd08e8 100644 --- a/src/ol/style/atlasmanager.js +++ b/src/ol/style/atlasmanager.js @@ -5,16 +5,6 @@ goog.require('goog.asserts'); goog.require('ol'); goog.require('ol.dom'); -/** - * Provides information for an image inside an atlas manager. - * `offsetX` and `offsetY` is the position of the image inside - * the atlas image `image` and the position of the hit-detection image - * inside the hit-detection atlas image `hitImage`. - * @typedef {{offsetX: number, offsetY: number, image: HTMLCanvasElement, - * hitImage: HTMLCanvasElement}} - */ -ol.style.AtlasManagerInfo; - /** * Manages the creation of image atlases. @@ -239,15 +229,6 @@ ol.style.AtlasManager.prototype.add_ = function(isHitAtlas, id, width, height, }; -/** - * Provides information for an image inside an atlas. - * `offsetX` and `offsetY` are the position of the image inside - * the atlas image `image`. - * @typedef {{offsetX: number, offsetY: number, image: HTMLCanvasElement}} - */ -ol.style.AtlasInfo; - - /** * This class facilitates the creation of image atlases. * @@ -275,7 +256,7 @@ ol.style.Atlas = function(size, space) { /** * @private - * @type {Array.} + * @type {Array.} */ this.emptyBlocks_ = [{x: 0, y: 0, width: size, height: size}]; @@ -351,7 +332,7 @@ ol.style.Atlas.prototype.add = function(id, width, height, renderCallback, opt_t /** * @private * @param {number} index The index of the block. - * @param {ol.style.Atlas.Block} block The block to split. + * @param {ol.style.AtlasBlock} block The block to split. * @param {number} width The width of the entry to insert. * @param {number} height The height of the entry to insert. */ @@ -359,9 +340,9 @@ ol.style.Atlas.prototype.split_ = function(index, block, width, height) { var deltaWidth = block.width - width; var deltaHeight = block.height - height; - /** @type {ol.style.Atlas.Block} */ + /** @type {ol.style.AtlasBlock} */ var newBlock1; - /** @type {ol.style.Atlas.Block} */ + /** @type {ol.style.AtlasBlock} */ var newBlock2; if (deltaWidth > deltaHeight) { @@ -410,8 +391,8 @@ ol.style.Atlas.prototype.split_ = function(index, block, width, height) { * blocks (that are potentially smaller) are filled first. * @private * @param {number} index The index of the block to remove. - * @param {ol.style.Atlas.Block} newBlock1 The 1st block to add. - * @param {ol.style.Atlas.Block} newBlock2 The 2nd block to add. + * @param {ol.style.AtlasBlock} newBlock1 The 1st block to add. + * @param {ol.style.AtlasBlock} newBlock2 The 2nd block to add. */ ol.style.Atlas.prototype.updateBlocks_ = function(index, newBlock1, newBlock2) { var args = [index, 1]; @@ -423,9 +404,3 @@ ol.style.Atlas.prototype.updateBlocks_ = function(index, newBlock1, newBlock2) { } this.emptyBlocks_.splice.apply(this.emptyBlocks_, args); }; - - -/** - * @typedef {{x: number, y: number, width: number, height: number}} - */ -ol.style.Atlas.Block; diff --git a/src/ol/style/circlestyle.js b/src/ol/style/circlestyle.js index a073ee8c1b..9d8c689c23 100644 --- a/src/ol/style/circlestyle.js +++ b/src/ol/style/circlestyle.js @@ -227,13 +227,6 @@ ol.style.Circle.prototype.load = ol.nullFunction; ol.style.Circle.prototype.unlistenImageChange = ol.nullFunction; -/** - * @typedef {{strokeStyle: (string|undefined), strokeWidth: number, - * size: number, lineDash: Array.}} - */ -ol.style.Circle.RenderOptions; - - /** * @private * @param {ol.style.AtlasManager|undefined} atlasManager An atlas manager. @@ -259,7 +252,7 @@ ol.style.Circle.prototype.render_ = function(atlasManager) { var size = 2 * (this.radius_ + strokeWidth) + 1; - /** @type {ol.style.Circle.RenderOptions} */ + /** @type {ol.style.CircleRenderOptions} */ var renderOptions = { strokeStyle: strokeStyle, strokeWidth: strokeWidth, @@ -320,7 +313,7 @@ ol.style.Circle.prototype.render_ = function(atlasManager) { /** * @private - * @param {ol.style.Circle.RenderOptions} renderOptions Render options. + * @param {ol.style.CircleRenderOptions} renderOptions Render options. * @param {CanvasRenderingContext2D} context The rendering context. * @param {number} x The origin for the symbol (x). * @param {number} y The origin for the symbol (y). @@ -355,7 +348,7 @@ ol.style.Circle.prototype.draw_ = function(renderOptions, context, x, y) { /** * @private - * @param {ol.style.Circle.RenderOptions} renderOptions Render options. + * @param {ol.style.CircleRenderOptions} renderOptions Render options. */ ol.style.Circle.prototype.createHitDetectionCanvas_ = function(renderOptions) { this.hitDetectionImageSize_ = [renderOptions.size, renderOptions.size]; @@ -375,7 +368,7 @@ ol.style.Circle.prototype.createHitDetectionCanvas_ = function(renderOptions) { /** * @private - * @param {ol.style.Circle.RenderOptions} renderOptions Render options. + * @param {ol.style.CircleRenderOptions} renderOptions Render options. * @param {CanvasRenderingContext2D} context The context. * @param {number} x The origin for the symbol (x). * @param {number} y The origin for the symbol (y). diff --git a/src/ol/style/regularshapestyle.js b/src/ol/style/regularshapestyle.js index 32c9217f9c..2a6242ac35 100644 --- a/src/ol/style/regularshapestyle.js +++ b/src/ol/style/regularshapestyle.js @@ -289,20 +289,6 @@ ol.style.RegularShape.prototype.load = ol.nullFunction; ol.style.RegularShape.prototype.unlistenImageChange = ol.nullFunction; -/** - * @typedef {{ - * strokeStyle: (string|undefined), - * strokeWidth: number, - * size: number, - * lineCap: string, - * lineDash: Array., - * lineJoin: string, - * miterLimit: number - * }} - */ -ol.style.RegularShape.RenderOptions; - - /** * @private * @param {ol.style.AtlasManager|undefined} atlasManager An atlas manager. @@ -342,7 +328,7 @@ ol.style.RegularShape.prototype.render_ = function(atlasManager) { var size = 2 * (this.radius_ + strokeWidth) + 1; - /** @type {ol.style.RegularShape.RenderOptions} */ + /** @type {ol.style.RegularShapeRenderOptions} */ var renderOptions = { strokeStyle: strokeStyle, strokeWidth: strokeWidth, @@ -405,7 +391,7 @@ ol.style.RegularShape.prototype.render_ = function(atlasManager) { /** * @private - * @param {ol.style.RegularShape.RenderOptions} renderOptions Render options. + * @param {ol.style.RegularShapeRenderOptions} renderOptions Render options. * @param {CanvasRenderingContext2D} context The rendering context. * @param {number} x The origin for the symbol (x). * @param {number} y The origin for the symbol (y). @@ -450,7 +436,7 @@ ol.style.RegularShape.prototype.draw_ = function(renderOptions, context, x, y) { /** * @private - * @param {ol.style.RegularShape.RenderOptions} renderOptions Render options. + * @param {ol.style.RegularShapeRenderOptions} renderOptions Render options. */ ol.style.RegularShape.prototype.createHitDetectionCanvas_ = function(renderOptions) { this.hitDetectionImageSize_ = [renderOptions.size, renderOptions.size]; @@ -470,7 +456,7 @@ ol.style.RegularShape.prototype.createHitDetectionCanvas_ = function(renderOptio /** * @private - * @param {ol.style.RegularShape.RenderOptions} renderOptions Render options. + * @param {ol.style.RegularShapeRenderOptions} renderOptions Render options. * @param {CanvasRenderingContext2D} context The context. * @param {number} x The origin for the symbol (x). * @param {number} y The origin for the symbol (y). diff --git a/src/ol/typedefs.js b/src/ol/typedefs.js index d99285a52e..9091233f26 100644 --- a/src/ol/typedefs.js +++ b/src/ol/typedefs.js @@ -369,6 +369,12 @@ ol.format.WFS.FeatureCollectionMetadata; ol.format.WFS.TransactionResponse; +/** + * @typedef {{type: number, value: (number|string|undefined), position: number}} + */ +ol.format.WKTToken; + + /** * A function that takes a {@link ol.MapBrowserEvent} and two * {@link ol.Pixel}s and returns a `{boolean}`. If the condition is met, @@ -420,7 +426,7 @@ ol.interaction.SelectFilterFunction; * vertexPixel: (ol.Pixel|null) * }} */ -ol.interaction.Snap.ResultType; +ol.interaction.SnapResultType; /** @@ -429,7 +435,7 @@ ol.interaction.Snap.ResultType; * segment: Array. * }} */ -ol.interaction.Snap.SegmentDataType; +ol.interaction.SnapSegmentDataType; /** @@ -485,7 +491,7 @@ ol.raster.Pixel; /** * @typedef {{fillStyle: ol.ColorLike}} */ -ol.render.canvas.FillState; +ol.render.canvasFillState; /** @@ -496,7 +502,7 @@ ol.render.canvas.FillState; * miterLimit: number, * strokeStyle: string}} */ -ol.render.canvas.StrokeState; +ol.render.canvasStrokeState; /** @@ -504,13 +510,13 @@ ol.render.canvas.StrokeState; * textAlign: string, * textBaseline: string}} */ -ol.render.canvas.TextState; +ol.render.canvasTextState; /** * @typedef {{magFilter: number, minFilter: number, texture: WebGLTexture}} */ -ol.renderer.webgl.TextureCacheEntry; +ol.renderer.webglTextureCacheEntry; /** @@ -545,6 +551,14 @@ ol.reproj.Triangle; ol.source.ImageOptions; +/** + * @typedef {{revision: number, + * resolution: number, + * extent: ol.Extent}} + */ +ol.source.RasterRenderedState; + + /** * @typedef {{attributions: (ol.AttributionLike|undefined), * logo: (string|olx.LogoOptions|undefined), @@ -598,6 +612,39 @@ ol.source.UrlTileOptions; ol.structs.LRUCacheEntry; +/** + * @typedef {{x: number, y: number, width: number, height: number}} + */ +ol.style.AtlasBlock; + + +/** + * Provides information for an image inside an atlas. + * `offsetX` and `offsetY` are the position of the image inside + * the atlas image `image`. + * @typedef {{offsetX: number, offsetY: number, image: HTMLCanvasElement}} + */ +ol.style.AtlasInfo; + + +/** + * Provides information for an image inside an atlas manager. + * `offsetX` and `offsetY` is the position of the image inside + * the atlas image `image` and the position of the hit-detection image + * inside the hit-detection atlas image `hitImage`. + * @typedef {{offsetX: number, offsetY: number, image: HTMLCanvasElement, + * hitImage: HTMLCanvasElement}} + */ +ol.style.AtlasManagerInfo; + + +/** + * @typedef {{strokeStyle: (string|undefined), strokeWidth: number, + * size: number, lineDash: Array.}} + */ +ol.style.CircleRenderOptions; + + /** * @typedef {{opacity: number, * rotateWithView: boolean, @@ -619,6 +666,20 @@ ol.style.ImageOptions; ol.style.GeometryFunction; +/** + * @typedef {{ + * strokeStyle: (string|undefined), + * strokeWidth: number, + * size: number, + * lineCap: string, + * lineDash: Array., + * lineJoin: string, + * miterLimit: number + * }} + */ +ol.style.RegularShapeRenderOptions; + + /** * A function that takes an {@link ol.Feature} and a `{number}` representing * the view's resolution. The function should return a {@link ol.style.Style} From ab9ff536f55bd93f6f6ac214e79c9d366a395536 Mon Sep 17 00:00:00 2001 From: Peter Robins Date: Wed, 11 May 2016 16:55:34 +0000 Subject: [PATCH 6/8] Add goog.provides to typedefs.js to prevent compiler warnings Without this there are 'defined before its owner' warnings, and issues of missing namespaces when compiling code with the library. --- src/ol/typedefs.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/ol/typedefs.js b/src/ol/typedefs.js index 9091233f26..3b04f103b5 100644 --- a/src/ol/typedefs.js +++ b/src/ol/typedefs.js @@ -1,10 +1,28 @@ /** * File for all top-level (in the `ol` namespace) typedefs used by the compiler, * and referenced by JSDoc. + * + * goog.provides are needed for 2 cases: + * - the 1st two are to prevent compiler errors + * - the others are to prevent 'defined before its owner' warnings */ goog.provide('ol.Extent'); goog.provide('ol.events.EventTargetLike'); +goog.provide('ol.format.KMLVec2_'); +goog.provide('ol.interaction.DragBoxEndConditionType'); +goog.provide('ol.layer.LayerState'); +goog.provide('ol.proj.ProjectionLike'); +goog.provide('ol.raster.Operation'); +goog.provide('ol.render.canvas.FillState'); +goog.provide('ol.renderer.webgl.TextureCacheEntry'); +goog.provide('ol.reproj.ImageFunctionType'); +goog.provide('ol.source.ImageOptions'); +goog.provide('ol.structs.LRUCacheEntry'); +goog.provide('ol.style.AtlasBlock'); +goog.provide('ol.webgl.BufferCacheEntry'); +goog.provide('ol.xml.NodeStackItem'); + /** * @typedef {string|Array.|ol.Attribution|Array.} From dd358af0f2841c24fc231b1cf16c950233be1ad2 Mon Sep 17 00:00:00 2001 From: Peter Robins Date: Wed, 11 May 2016 17:39:15 +0000 Subject: [PATCH 7/8] Fix WFS errors by moving typedefs to own file The WFS typedefs are the only sub-sub-namespace ones which are marked 'api', so cannot be renamed. Moving them to their own file resolves the errors. --- src/ol/typedefs-wfs.js | 26 ++++++++++++++++++++++++++ src/ol/typedefs.js | 20 -------------------- 2 files changed, 26 insertions(+), 20 deletions(-) create mode 100644 src/ol/typedefs-wfs.js diff --git a/src/ol/typedefs-wfs.js b/src/ol/typedefs-wfs.js new file mode 100644 index 0000000000..6fc0bde945 --- /dev/null +++ b/src/ol/typedefs-wfs.js @@ -0,0 +1,26 @@ +/** + * typedefs for the WFS sub-sub-namespace + * See typedefs.js for more details + */ +goog.provide('ol.format.WFS.FeatureCollectionMetadata'); +goog.provide('ol.format.WFS.TransactionResponse'); + + +/** + * Number of features; bounds/extent. + * @typedef {{numberOfFeatures: number, + * bounds: ol.Extent}} + * @api stable + */ +ol.format.WFS.FeatureCollectionMetadata; + + +/** + * Total deleted; total inserted; total updated; array of insert ids. + * @typedef {{totalDeleted: number, + * totalInserted: number, + * totalUpdated: number, + * insertIds: Array.}} + * @api stable + */ +ol.format.WFS.TransactionResponse; diff --git a/src/ol/typedefs.js b/src/ol/typedefs.js index 3b04f103b5..98cec9740c 100644 --- a/src/ol/typedefs.js +++ b/src/ol/typedefs.js @@ -367,26 +367,6 @@ ol.format.KMLVec2_; ol.format.KMLGxTrackObject_; -/** - * Number of features; bounds/extent. - * @typedef {{numberOfFeatures: number, - * bounds: ol.Extent}} - * @api stable - */ -ol.format.WFS.FeatureCollectionMetadata; - - -/** - * Total deleted; total inserted; total updated; array of insert ids. - * @typedef {{totalDeleted: number, - * totalInserted: number, - * totalUpdated: number, - * insertIds: Array.}} - * @api stable - */ -ol.format.WFS.TransactionResponse; - - /** * @typedef {{type: number, value: (number|string|undefined), position: number}} */ From 0daa2cf574e71bd3cac7efe5dfa1beaa77cac004 Mon Sep 17 00:00:00 2001 From: Peter Robins Date: Sun, 8 May 2016 09:50:22 +0000 Subject: [PATCH 8/8] Document typedef move --- changelog/v3.16.0.md | 12 ++++++++++++ src/ol/typedefs.js | 28 +++++++++++++++++++++++----- 2 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 changelog/v3.16.0.md diff --git a/changelog/v3.16.0.md b/changelog/v3.16.0.md new file mode 100644 index 0000000000..49e785b15f --- /dev/null +++ b/changelog/v3.16.0.md @@ -0,0 +1,12 @@ +# v3.16.0 + +## Summary + + +## Upgrade notes + +### v3.16.0 + +#### Move of typedefs out of code and into separate file + +This change should not affect the great majority of application developers, but it's possible there are edge cases when compiling application code together with the library which cause compiler errors or warnings. In this case, please raise a GitHub issue. `goog.require`s for typedefs should not be necessary. diff --git a/src/ol/typedefs.js b/src/ol/typedefs.js index 98cec9740c..8a966e6891 100644 --- a/src/ol/typedefs.js +++ b/src/ol/typedefs.js @@ -1,10 +1,28 @@ /** - * File for all top-level (in the `ol` namespace) typedefs used by the compiler, - * and referenced by JSDoc. + * File for all typedefs used by the compiler, and referenced by JSDoc. * - * goog.provides are needed for 2 cases: - * - the 1st two are to prevent compiler errors - * - the others are to prevent 'defined before its owner' warnings + * These look like vars (or var properties), but in fact are simply identifiers + * for the Closure compiler. Originally they were included in the appropriate + * namespace file, but with the move away from Closure namespaces and towards + * self-contained standard modules are now all in this file, with two exceptions. + * Unlike the other type definitions - enums and constructor functions - they + * are not code and so are not imported or exported. They are only referred to + * in type-defining comments used by the Closure compiler, and so should not + * appear in module code. + * + * The 2 exceptions are the WFS typedefs which are in a sub-sub-namespace and + * are API. These have been put in their own separate file. + * + * When the code is converted to ES6 modules, the namespace structure will + * disappear, and these typedefs will have to be renamed accordingly, but the + * namespace structure is maintained for the present for backwards compatibility. + * + * In principle, typedefs should not have a `goog.provide` nor should files which + * refer to a typedef in comments need a `goog.require`. However, goog.provides + * are needed for 2 cases, both to prevent compiler errors/warnings: + * - the 1st two for specific errors + * - each sub-namespace needs at least one so the namespace is created when not + * used in the code, as when application code is compiled with the library. */ goog.provide('ol.Extent'); goog.provide('ol.events.EventTargetLike');