From bd82e1aa1a762efb725848d0c62f8f56b7b7ee30 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Wed, 6 Nov 2013 16:41:23 +0100 Subject: [PATCH] Remove vector code from files --- src/objectliterals.jsdoc | 281 -------------------- src/ol/map.exports | 2 - src/ol/map.js | 28 -- src/ol/renderer/canvas/canvasmaprenderer.js | 4 - src/ol/renderer/layerrenderer.js | 20 -- src/ol/renderer/maprenderer.js | 73 ----- src/ol/source/imagewmssource.js | 26 -- src/ol/source/tilewmssource.js | 33 --- src/ol/source/wmssource.js | 80 ------ test/spec/ol/source/imagewmssource.test.js | 92 ------- test/spec/ol/source/wmssource.test.js | 22 -- 11 files changed, 661 deletions(-) diff --git a/src/objectliterals.jsdoc b/src/objectliterals.jsdoc index 2d012d4677..87a96162e5 100644 --- a/src/objectliterals.jsdoc +++ b/src/objectliterals.jsdoc @@ -20,38 +20,6 @@ * @todo stability experimental */ -/** - * @typedef {Object} ol.GetFeatureInfoOptions - * @property {ol.Pixel} pixel Pixel coordinate relative to the map viewport. - * @property {Array.|undefined} layers Layers to restrict the - * query to. All map layers will be queried if not provided. - * @property {function(Array.>)} success Callback for - * successful queries. The passed argument is the resulting feature - * information for each layer, with array indices being the same as in the - * passed `layers` array or in the layer collection as returned from - * `ol.Map#getLayers()` if no `layers` were provided. - * @property {function()|undefined} error Callback for unsuccessful queries. - * Note that queries with no matching features trigger the success callback, - * not the error callback. - * @todo stability experimental - */ - -/** - * @typedef {Object} ol.GetFeaturesOptions - * @property {ol.Pixel} pixel Pixel coordinate relative to the map viewport. - * @property {Array.|undefined} layers Layers to restrict the - * query to. All layers will be queried if not provided. - * @property {function(Array.>)} success Callback - * for successful queries. The passed argument is the resulting features for - * each layer, with array indices being the same as in the passed `layers` - * array or in the layer collection as returned from `ol.Map#getLayers()` if - * no layers were provided. - * @property {function()|undefined} error Callback for unsuccessful queries. - * Note that queries with no matching features trigger the success callback, - * not the error callback. - * @todo stability experimental - */ - /** * Object literal with config options for the map. * @typedef {Object} ol.MapOptions @@ -341,16 +309,6 @@ * @todo stability experimental */ -/** - * @typedef {Object} ol.interaction.DrawOptions - * @property {ol.layer.Vector} layer Destination layer for the features. - * @property {number|undefined} snapTolerance Pixel distance for snapping to the - * drawing finish (default is 12). - * @property {ol.geom.GeometryType} type Drawing type ('point', 'linestring', - * 'polygon', 'multipoint', 'multilinestring', or 'multipolygon'). - * @todo stability experimental - */ - /** * @typedef {Object} ol.interaction.KeyboardPanOptions * @property {ol.events.ConditionType|undefined} condition A conditional @@ -377,29 +335,6 @@ * @todo stability experimental */ -/** - * @typedef {Object} ol.interaction.ModifyOptions - * @property {undefined|Array.|function(ol.layer.Layer):boolean} layers - * Layers or filter function to restrict modification to a subset of layers. - * @property {number|undefined} pixelTolerance Pixel tolerance for considering - * the pointer close enough to a vertex for editing. Default is 20 pixels. - */ - -/** - * @typedef {Object} ol.interaction.SelectOptions - * @property {ol.events.ConditionType|undefined} addCondition A conditional - * modifier (e.g. shift key) that determines if the selection is added to - * the current selection. By default, a shift-click adds to the current - * selection. - * @property {ol.events.ConditionType|undefined} condition A conditional - * modifier (e.g. shift key) that determines if the interaction is active - * (i.e. selection occurs) or not. By default, a click with no modifier keys - * toggles the selection. - * @property {undefined|Array.|function(ol.layer.Layer):boolean} layers - * Layers or filter function to restrict selection to a subset of layers. - * @todo stability experimental - */ - /** * @typedef {Object} ol.interaction.TouchPanOptions * @property {ol.Kinetic|undefined} kinetic Kinetic inertia to apply to the @@ -483,108 +418,6 @@ * @todo stability experimental */ -/** - * @typedef {Object} ol.layer.VectorLayerOptions - * @property {function(Array.):string|undefined} transformFeatureInfo - * Function to render an array of - * features into feature info markup. If not provided, a comma separated - * list of the unique ids of the resulting features will be returned. - * @property {number|undefined} opacity Opacity. 0-1. Default is `1`. - * @property {ol.source.Source} source Source for this layer. - * @property {ol.style.Style|undefined} style Style. - * @property {boolean|undefined} visible Visibility. Default is `true` (visible). - * @property {number|undefined} minResolution The minimum resolution - * (inclusive) at which this layer will be visible. - * @property {number|undefined} maxResolution The maximum resolution - * (exclusive) below which this layer will be visible. - * @todo stability experimental - */ - -/** - * @typedef {Object} ol.parser.KMLOptions - * @property {boolean|undefined} extractAttributes Should we extract attributes - * from the KML? Default is `true`. - * @property {boolean|undefined} extractStyles Should we extract styles from the - * KML? Default is `false`. - * @property {number|undefined} maxDepth Maximum depth to follow network links. - * Default is `0`, which means we don't follow network links at all. - * @property {Array.|undefined} trackAttributes Track attributes to - * parse. - * @todo stability experimental - */ - -/** - * @typedef {Object} ol.parser.GMLReadOptions - * @property {string|undefined} axisOrientation The axis orientation. - * @todo stability experimental - */ - -/** - * @typedef {Object} ol.parser.GMLWriteOptions - * @property {ol.proj.ProjectionLike} srsName The srsName to use when writing. - * @property {string|undefined} axisOrientation The axis orientation. - * @todo stability experimental - */ - -/** - * @typedef {Object} ol.parser.GMLOptions - * @property {boolean|undefined} curve Write gml:Curve instead of - * gml:LineString elements. This also affects the elements in multi-part - * geometries. Default is `false`. This only applies to GML version 3. - * @property {boolean|undefined} extractAttributes Should we extract attributes - * from the GML? Default is `true`. - * @property {string|undefined} featureNS The feature namespace. If not set it - * will be automatically configured from the GML. - * @property {Array.|string|undefined} featureType The local - * (without prefix) feature typeName(s). - * @property {string|undefined} geometryName Name of geometry element. - * Defaults to `geometry`. If null, it will be set on when the - * first geometry is parsed. - * @property {boolean|undefined} multiCurve Write gml:MultiCurve instead of - * gml:MultiLineString. Since the latter is deprecated in GML 3, the - * default is `true`. This only applies to GML version 3. - * @property {boolean|undefined} multiSurface Write gml:multiSurface instead - * of gml:MultiPolygon. Since the latter is deprecated in GML 3, the - * default is `true`. This only applies to GML version 3. - * @property {string|undefined} schemaLocation Optional schemaLocation to use - * when writing out the GML, this will override the default provided. - * @property {boolean|undefined} surface Write gml:Surface instead of - * gml:Polygon elements. This also affects the elements in multi-part - * geometries. Default is `false`. This only applies to GML version 3. - * @property {ol.parser.GMLReadOptions|undefined} readOptions readOptions to - * use for this instance. - * @property {ol.parser.GMLWriteOptions|undefined} writeOptions writeOptions - * to use for this instance. - * @todo stability experimental - */ - -/** - * @typedef {Object} ol.parser.GPXOptions - * @property {string|undefined} creator The creator attribute to be added to - * the written GPX files. Defaults to `OpenLayers`. - * @property {string|undefined} defaultDesc Default description for the - * waypoints/tracks in the case where the feature has no `description` - * attribute. Default is `No description available`. - * @property {boolean|undefined} extractAttributes Should we extract attributes - * from the GPX? Default is `true`. - * @property {boolean|undefined} extractWaypoints Extract waypoints from GPX. - * Default is `true`. - * @property {boolean|undefined} extractTracks Extract tracks from GPX. - * Default is `true`. - * @property {boolean|undefined} extractRoutes Extract routes from GPX. - * Default is `true`. - * @todo stability experimental - */ - -/** - * @typedef {Object} ol.parser.GPXWriteOptions - * @property {Array.|ol.Feature} features The features to write - * out. - * @property {Object|undefined} metadata Metadata key/value pair with keys: - * name, desc and author. - * @todo stability experimental - */ - /** * @typedef {Object} ol.source.BingMapsOptions * @property {string|undefined} culture Culture. @@ -627,8 +460,6 @@ * @property {null|string|undefined} crossOrigin crossOrigin setting for image * requests. * @property {ol.Extent|undefined} extent Extent. - * @property {ol.source.WMSGetFeatureInfoOptions|undefined} - * getFeatureInfoOptions Options for GetFeatureInfo. * @property {Object.} params WMS request parameters. At least a * `LAYERS` param is required. `STYLES` is `` by default. `VERSION` is * `1.3.0` by default. `WIDTH`, `HEIGHT`, `BBOX` and `CRS` (`SRS` for WMS @@ -688,8 +519,6 @@ * @property {null|string|undefined} crossOrigin crossOrigin setting for image * requests. * @property {ol.Extent|undefined} extent Extent. - * @property {ol.source.WMSGetFeatureInfoOptions|undefined} - * getFeatureInfoOptions Options for GetFeatureInfo. * @property {string|undefined} logo Logo. * @property {ol.tilegrid.TileGrid|undefined} tileGrid Tile grid. * @property {number|undefined} maxZoom Maximum zoom. @@ -702,33 +531,6 @@ * @todo stability experimental */ -/** - * @typedef {Object} ol.source.VectorOptions - * @property {Array.|undefined} attributions Attributions. - * @property {Object|string|undefined} data Data to parse. - * @property {ol.Extent|undefined} extent Extent. - * @property {string|undefined} logo Logo. - * @property {ol.parser.Parser} parser Parser instance to parse data - * provided as `data` or fetched from `url`. - * @property {ol.proj.ProjectionLike|undefined} projection Projection. Usually the - * projection is provided by the parser, so this only needs to be set if - * the parser does not know the SRS (e.g. in some GML flavors), or if the - * projection determined by the parser needs to be overridden. - * @property {string|undefined} url Server url providing the vector data. - * @todo stability experimental - */ - - -/** - * @typedef {Object} ol.source.WMSGetFeatureInfoOptions - * @property {ol.source.WMSGetFeatureInfoMethod} method Method for requesting - * GetFeatureInfo. Default is `ol.source.WMSGetFeatureInfoMethod.IFRAME`. - * @property {Object} params Params for the GetFeatureInfo request. Default is - * `{'INFO_FORMAT': 'text/html'}`. - * @todo stability experimental - */ - - /** * @typedef {Object} ol.source.WMTSOptions * @property {Array.|undefined} attributions Attributions. @@ -775,89 +577,6 @@ * @todo stability experimental */ -/** - * @typedef {Object} ol.style.IconOptions - * @property {string|ol.expr.Expression} url Icon image URL. - * @property {number|ol.expr.Expression|undefined} width Width of the icon - * in pixels. Default is the width of the icon image. - * @property {number|ol.expr.Expression|undefined} height Height of the - * icon in pixels. Default is the height of the icon image. - * @property {number|ol.expr.Expression|undefined} opacity Icon opacity - * (0-1). - * @property {number|ol.expr.Expression|undefined} rotation Rotation in - * radians (positive rotation clockwise). - * @property {number|ol.expr.Expression|undefined} xOffset Pixel offset from the - * point to the center of the icon (positive values shift image left). - * @property {number|ol.expr.Expression|undefined} yOffset Pixel offset from the - * point to the center of the icon (positive values shift image down). - * @property {number|ol.expr.Expression|undefined} zIndex Stack order. - * @todo stability experimental - */ - -/** - * @typedef {Object} ol.style.FillOptions - * @property {string|ol.expr.Expression|undefined} color Fill color as hex color - * code. - * @property {number|ol.expr.Expression|undefined} opacity Opacity (0-1). - * @property {number|ol.expr.Expression|undefined} zIndex Stack order. - * @todo stability experimental - */ - -/** - * @typedef {Object} ol.style.RuleOptions - * @property {ol.expr.Expression|string|undefined} filter Filter. - * @property {number|undefined} maxResolution Optional maximum resolution. If - * a value is provided, the rule will apply at resolutions less than - * this value. - * @property {number|undefined} minResolution Optional minimum resolution. If - * a value is provided, the rule will apply at resolutions greater than or - * equal to this value. - * @property {Array.|undefined} symbolizers Symbolizers. - * @todo stability experimental - */ - -/** - * @typedef {Object} ol.style.ShapeOptions - * @property {ol.style.ShapeType|undefined} type Type. - * @property {number|ol.expr.Expression|undefined} size Size in pixels. - * @property {ol.style.Fill|undefined} fill Fill symbolizer for shape. - * @property {ol.style.Stroke|undefined} stroke Stroke symbolizer for shape. - * @property {number|ol.expr.Expression|undefined} zIndex Stack order. - * @todo stability experimental - */ - -/** - * @typedef {Object} ol.style.StrokeOptions - * @property {string|ol.expr.Expression|undefined} color Stroke color as hex - * color code. - * @property {number|ol.expr.Expression|undefined} opacity Stroke opacity (0-1). - * @property {number|ol.expr.Expression|undefined} width Stroke width in pixels. - * @property {number|ol.expr.Expression|undefined} zIndex Stack order. - * @todo stability experimental - */ - -/** - * @typedef {Object} ol.style.StyleOptions - * @property {Array.|undefined} rules Rules. - * @property {Array.|undefined} symbolizers Symbolizers - * (that apply if no rules are provided or where none of the provided rules - * apply). - * @todo stability experimental - */ - -/** - * @typedef {Object} ol.style.TextOptions - * @property {string|ol.expr.Expression|undefined} color Color. - * @property {string|ol.expr.Expression|undefined} fontFamily Font family. - * @property {number|ol.expr.Expression|undefined} fontSize Font size in pixels. - * @property {string|ol.expr.Expression|undefined} fontWeight Font weight. - * @property {string|ol.expr.Expression} text Text for the label. - * @property {number|ol.expr.Expression|undefined} opacity Opacity (0-1). - * @property {ol.style.Stroke|undefined} stroke Stroke symbolizer for text. - * @property {number|ol.expr.Expression|undefined} zIndex Stack order. - * @todo stability experimental - */ - /** * @typedef {Object} ol.tilegrid.TileGridOptions * @property {number|undefined} minZoom Minimum zoom. diff --git a/src/ol/map.exports b/src/ol/map.exports index 68ff166ae7..a4c9b4de63 100644 --- a/src/ol/map.exports +++ b/src/ol/map.exports @@ -7,8 +7,6 @@ @exportProperty ol.Map.prototype.getControls @exportProperty ol.Map.prototype.getEventCoordinate @exportProperty ol.Map.prototype.getEventPixel -@exportProperty ol.Map.prototype.getFeatureInfo -@exportProperty ol.Map.prototype.getFeatures @exportProperty ol.Map.prototype.getInteractions @exportProperty ol.Map.prototype.getLayers @exportProperty ol.Map.prototype.getOverlays diff --git a/src/ol/map.js b/src/ol/map.js index 6dabae87e5..73d70f1c97 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -563,34 +563,6 @@ ol.Map.prototype.getOverlays = function() { }; -/** - * Get feature information for a pixel on the map. - * - * @param {ol.GetFeatureInfoOptions} options Options. - * @todo stability experimental - */ -ol.Map.prototype.getFeatureInfo = function(options) { - var layers = goog.isDefAndNotNull(options.layers) ? - options.layers : this.getLayerGroup().getLayersArray(); - this.getRenderer().getFeatureInfoForPixel( - options.pixel, layers, options.success, options.error); -}; - - -/** - * Get features for a pixel on the map. - * - * @param {ol.GetFeaturesOptions} options Options. - * @todo stability experimental - */ -ol.Map.prototype.getFeatures = function(options) { - var layers = goog.isDefAndNotNull(options.layers) ? - options.layers : this.getLayerGroup().getLayersArray(); - this.getRenderer().getFeaturesForPixel( - options.pixel, layers, options.success, options.error); -}; - - /** * Gets the collection of * {@link ol.interaction|ol.interaction.Interaction} instances diff --git a/src/ol/renderer/canvas/canvasmaprenderer.js b/src/ol/renderer/canvas/canvasmaprenderer.js index b7debeb674..5526462f42 100644 --- a/src/ol/renderer/canvas/canvasmaprenderer.js +++ b/src/ol/renderer/canvas/canvasmaprenderer.js @@ -9,11 +9,9 @@ goog.require('goog.style'); goog.require('ol.css'); goog.require('ol.layer.Image'); goog.require('ol.layer.Tile'); -goog.require('ol.layer.Vector'); goog.require('ol.renderer.Map'); goog.require('ol.renderer.canvas.ImageLayer'); goog.require('ol.renderer.canvas.TileLayer'); -goog.require('ol.renderer.canvas.VectorLayer2'); goog.require('ol.source.State'); @@ -62,8 +60,6 @@ ol.renderer.canvas.Map.prototype.createLayerRenderer = function(layer) { return new ol.renderer.canvas.ImageLayer(this, layer); } else if (layer instanceof ol.layer.Tile) { return new ol.renderer.canvas.TileLayer(this, layer); - } else if (layer instanceof ol.layer.Vector) { - return new ol.renderer.canvas.VectorLayer2(this, layer); } else { goog.asserts.fail(); return null; diff --git a/src/ol/renderer/layerrenderer.js b/src/ol/renderer/layerrenderer.js index 6da52f6bfa..86c2fcfbe2 100644 --- a/src/ol/renderer/layerrenderer.js +++ b/src/ol/renderer/layerrenderer.js @@ -42,26 +42,6 @@ ol.renderer.Layer = function(mapRenderer, layer) { goog.inherits(ol.renderer.Layer, goog.Disposable); -/** - * @param {ol.Pixel} pixel Pixel coordinate relative to the map viewport. - * @param {function(string, ol.layer.Layer)} success Callback for - * successful queries. The passed arguments are the resulting feature - * information and the layer. - * @param {function()=} opt_error Callback for unsuccessful queries. - */ -ol.renderer.Layer.prototype.getFeatureInfoForPixel = - function(pixel, success, opt_error) { - var layer = this.getLayer(); - var source = layer.getSource(); - if (goog.isFunction(source.getFeatureInfoForPixel)) { - var callback = function(layerFeatureInfo) { - success(layerFeatureInfo, layer); - }; - source.getFeatureInfoForPixel(pixel, this.getMap(), callback, opt_error); - } -}; - - /** * @protected * @return {ol.layer.Layer} Layer. diff --git a/src/ol/renderer/maprenderer.js b/src/ol/renderer/maprenderer.js index a0463fc944..0023ce8b71 100644 --- a/src/ol/renderer/maprenderer.js +++ b/src/ol/renderer/maprenderer.js @@ -1,7 +1,6 @@ goog.provide('ol.renderer.Map'); goog.require('goog.Disposable'); -goog.require('goog.array'); goog.require('goog.asserts'); goog.require('goog.dispose'); goog.require('goog.functions'); @@ -98,78 +97,6 @@ ol.renderer.Map.prototype.disposeInternal = function() { ol.renderer.Map.prototype.getCanvas = goog.functions.NULL; -/** - * @param {ol.Pixel} pixel Pixel coordinate relative to the map viewport. - * @param {Array.} layers Layers to query. - * @param {function(Array.>)} success Callback for - * successful queries. The passed argument is the resulting feature - * information. Layers that are able to provide attribute data will put - * ol.Feature instances, other layers will put a string which can either - * be plain text or markup. - * @param {function()=} opt_error Callback for unsuccessful - * queries. - */ -ol.renderer.Map.prototype.getFeatureInfoForPixel = - function(pixel, layers, success, opt_error) { - var numLayers = layers.length; - var featureInfo = new Array(numLayers); - var callbackCount = 0; - var callback = function(layerFeatureInfo, layer) { - featureInfo[goog.array.indexOf(layers, layer)] = layerFeatureInfo; - --callbackCount; - if (callbackCount <= 0) { - success(featureInfo); - } - }; - - var layer, layerRenderer; - for (var i = 0; i < numLayers; ++i) { - layer = layers[i]; - layerRenderer = this.getLayerRenderer(layer); - if (goog.isFunction(layerRenderer.getFeatureInfoForPixel)) { - ++callbackCount; - layerRenderer.getFeatureInfoForPixel(pixel, callback, opt_error); - } - } -}; - - -/** - * @param {ol.Pixel} pixel Pixel coordinate relative to the map viewport. - * @param {Array.} layers Layers to query. - * @param {function(Array.>)} success Callback for - * successful queries. The passed argument is the resulting feature - * information. Layers that are able to provide attribute data will put - * ol.Feature instances, other layers will put a string which can either - * be plain text or markup. - * @param {function()=} opt_error Callback for unsuccessful - * queries. - */ -ol.renderer.Map.prototype.getFeaturesForPixel = - function(pixel, layers, success, opt_error) { - var numLayers = layers.length; - var features = new Array(numLayers); - var callbackCount = 0; - var callback = function(layerFeatures, layer) { - features[goog.array.indexOf(layers, layer)] = layerFeatures; - --callbackCount; - if (callbackCount <= 0) { - success(features); - } - }; - - var layer, layerRenderer; - for (var i = 0; i < numLayers; ++i) { - layer = layers[i]; - layerRenderer = this.getLayerRenderer(layer); - if (goog.isFunction(layerRenderer.getFeaturesForPixel)) { - ++callbackCount; - layerRenderer.getFeaturesForPixel(pixel, callback, opt_error); - } - } -}; - - /** * @param {ol.layer.Layer} layer Layer. * @protected diff --git a/src/ol/source/imagewmssource.js b/src/ol/source/imagewmssource.js index 788070fe65..af05589762 100644 --- a/src/ol/source/imagewmssource.js +++ b/src/ol/source/imagewmssource.js @@ -5,7 +5,6 @@ goog.require('goog.object'); goog.require('ol.Image'); goog.require('ol.ImageUrlFunction'); goog.require('ol.extent'); -goog.require('ol.source.FeatureInfoSource'); goog.require('ol.source.Image'); goog.require('ol.source.wms'); @@ -14,7 +13,6 @@ goog.require('ol.source.wms'); /** * @constructor * @extends {ol.source.Image} - * @implements {ol.source.FeatureInfoSource} * @param {ol.source.ImageWMSOptions} options Options. * @todo stability experimental */ @@ -40,13 +38,6 @@ ol.source.ImageWMS = function(options) { imageUrlFunction: imageUrlFunction }); - /** - * @private - * @type {ol.source.WMSGetFeatureInfoOptions} - */ - this.getFeatureInfoOptions_ = goog.isDef(options.getFeatureInfoOptions) ? - options.getFeatureInfoOptions : {}; - /** * @private * @type {ol.Image} @@ -99,23 +90,6 @@ ol.source.ImageWMS.prototype.getImage = }; -/** - * @inheritDoc - */ -ol.source.ImageWMS.prototype.getFeatureInfoForPixel = - function(pixel, map, success, opt_error) { - var view = map.getView().getView2D(); - var size = map.getSize(); - goog.asserts.assert(goog.isDefAndNotNull(size)); - var extent = view.calculateExtent(size); - var url = this.imageUrlFunction(extent, size, view.getProjection()); - goog.asserts.assert(goog.isDef(url), - 'ol.source.ImageWMS#imageUrlFunction does not return a URL'); - ol.source.wms.getFeatureInfo(url, pixel, this.getFeatureInfoOptions_, success, - opt_error); -}; - - /** * Update the user-provided params. * @param {Object} params Params. diff --git a/src/ol/source/tilewmssource.js b/src/ol/source/tilewmssource.js index 48c2d15876..aea2b21084 100644 --- a/src/ol/source/tilewmssource.js +++ b/src/ol/source/tilewmssource.js @@ -3,13 +3,11 @@ goog.provide('ol.source.TileWMS'); goog.require('goog.array'); -goog.require('goog.asserts'); goog.require('goog.math'); goog.require('goog.object'); goog.require('ol.TileCoord'); goog.require('ol.TileUrlFunction'); goog.require('ol.extent'); -goog.require('ol.source.FeatureInfoSource'); goog.require('ol.source.TileImage'); goog.require('ol.source.wms'); @@ -18,7 +16,6 @@ goog.require('ol.source.wms'); /** * @constructor * @extends {ol.source.TileImage} - * @implements {ol.source.FeatureInfoSource} * @param {ol.source.TileWMSOptions} options Tile WMS options. * @todo stability experimental */ @@ -105,13 +102,6 @@ ol.source.TileWMS = function(options) { tileCoordTransform, tileUrlFunction) }); - /** - * @private - * @type {ol.source.WMSGetFeatureInfoOptions} - */ - this.getFeatureInfoOptions_ = goog.isDef(options.getFeatureInfoOptions) ? - options.getFeatureInfoOptions : {}; - }; goog.inherits(ol.source.TileWMS, ol.source.TileImage); @@ -135,29 +125,6 @@ ol.source.TileWMS.prototype.getParams = function() { }; -/** - * @inheritDoc - */ -ol.source.TileWMS.prototype.getFeatureInfoForPixel = - function(pixel, map, success, opt_error) { - var coord = map.getCoordinateFromPixel(pixel), - view2D = map.getView().getView2D(), - projection = view2D.getProjection(), - tileGrid = goog.isNull(this.tileGrid) ? - ol.tilegrid.getForProjection(projection) : this.tileGrid, - tileCoord = tileGrid.getTileCoordForCoordAndResolution(coord, - view2D.getResolution()), - tileExtent = tileGrid.getTileCoordExtent(tileCoord), - offset = map.getPixelFromCoordinate(ol.extent.getTopLeft(tileExtent)), - url = this.tileUrlFunction(tileCoord, projection); - goog.asserts.assert(goog.isDef(url), - 'ol.source.TileWMS#tileUrlFunction does not return a URL'); - ol.source.wms.getFeatureInfo(url, - [pixel[0] - offset[0], pixel[1] - offset[1]], this.getFeatureInfoOptions_, - success, opt_error); -}; - - /** * @private */ diff --git a/src/ol/source/wmssource.js b/src/ol/source/wmssource.js index dac71c6b10..9fdd7a80ad 100644 --- a/src/ol/source/wmssource.js +++ b/src/ol/source/wmssource.js @@ -1,30 +1,9 @@ -goog.provide('ol.source.WMSGetFeatureInfoMethod'); goog.provide('ol.source.wms'); -goog.require('goog.net.XhrIo'); goog.require('goog.object'); goog.require('goog.uri.utils'); -/** - * Method to use to get WMS feature info. - * @enum {string} - * @todo stability experimental - */ -ol.source.WMSGetFeatureInfoMethod = { - /** - * Load the info in an IFRAME. Only works with `text/html` and `text/plain` as - * `INFO_FORMAT`. - */ - IFRAME: 'iframe', - /** - * Use an asynchronous GET request. Requires CORS headers or a server at the - * same origin as the application script. - */ - XHR_GET: 'xhr_get' -}; - - /** * @param {string} baseUrl WMS base URL. * @param {Object.} params Request parameters. @@ -61,62 +40,3 @@ ol.source.wms.getUrl = return goog.uri.utils.appendParamsFromMap(baseUrl, baseParams); }; - - -/** - * @param {string} url URL as provided by the url function. - * @param {ol.Pixel} pixel Pixel. - * @param {ol.source.WMSGetFeatureInfoOptions} options Options as defined in the - * source. - * @param {function(string)} success Callback function for successful queries. - * @param {function()=} opt_error Optional callback function for unsuccessful - * queries. - */ -ol.source.wms.getFeatureInfo = - function(url, pixel, options, success, opt_error) { - // TODO: This could be done in a smarter way if the url function was not a - // closure - url = url.replace('REQUEST=GetMap', 'REQUEST=GetFeatureInfo') - .replace(ol.source.wms.regExes.layers, 'LAYERS=$1&QUERY_LAYERS=$1'); - options = /** @type {ol.source.WMSGetFeatureInfoOptions} */ - (goog.isDef(options) ? goog.object.clone(options) : {}); - var localOptions = /** @type {ol.source.WMSGetFeatureInfoOptions} */ ({ - method: ol.source.WMSGetFeatureInfoMethod.IFRAME, - params: {} - }); - goog.object.extend(localOptions, options); - var params = {'INFO_FORMAT': 'text/html'}, - version = parseFloat(url.match(ol.source.wms.regExes.version)[1]), - x = Math.round(pixel[0]), - y = Math.round(pixel[1]); - if (version >= 1.3) { - goog.object.extend(params, {'I': x, 'J': y}); - } else { - goog.object.extend(params, {'X': x, 'Y': y}); - } - goog.object.extend(params, localOptions.params); - url = goog.uri.utils.appendParamsFromMap(url, params); - if (localOptions.method == ol.source.WMSGetFeatureInfoMethod.IFRAME) { - goog.global.setTimeout(function() { - success(''); - }, 0); - } else if (localOptions.method == ol.source.WMSGetFeatureInfoMethod.XHR_GET) { - goog.net.XhrIo.send(url, function(event) { - var xhr = event.target; - if (xhr.isSuccess()) { - success(xhr.getResponseText()); - } else if (goog.isDef(opt_error)) { - opt_error(); - } - }); - } -}; - - -/** - * @enum {RegExp} - */ -ol.source.wms.regExes = { - layers: (/LAYERS=([^&]+)/), - version: (/VERSION=([^&]+)/) -}; diff --git a/test/spec/ol/source/imagewmssource.test.js b/test/spec/ol/source/imagewmssource.test.js index 426a64e148..33f8f4089b 100644 --- a/test/spec/ol/source/imagewmssource.test.js +++ b/test/spec/ol/source/imagewmssource.test.js @@ -17,102 +17,10 @@ describe('ol.source.ImageWMS', function() { }); - describe('#getFeatureInfoForPixel()', function() { - - var viewport, map, view, source; - beforeEach(function() { - viewport = document.createElement('div'); - var style = viewport.style; - style.position = 'absolute'; - style.left = '-1000px'; - style.width = '360px'; - style.height = '180px'; - document.body.appendChild(viewport); - - source = new ol.source.ImageWMS({ - url: 'http://example.com/', - projection: 'EPSG:4326', - params: {'LAYERS': 'test-layer'} - }); - - view = new ol.View2D({ - projection: 'EPSG:4326', - center: [0, 0] - }); - - map = new ol.Map({ - target: viewport, - layers: [ - new ol.layer.Image({ - source: source - }) - ], - view: view - }); - - sinon.spy(ol.source.wms, 'getFeatureInfo'); - }); - - afterEach(function() { - ol.source.wms.getFeatureInfo.restore(); - document.body.removeChild(viewport); - }); - - it('calls ol.source.wms.getFeatureInfo (resolution 1)', function(done) { - // confirm things look good at resolution: 2 - map.once('postrender', function() { - source.getFeatureInfoForPixel([0, 0], map, function() { - expect(ol.source.wms.getFeatureInfo.calledOnce).to.be(true); - var args = ol.source.wms.getFeatureInfo.getCall(0).args; - - // check url arg - var url = new goog.Uri(args[0]); - var query = url.getQueryData(); - expect(query.containsKey('BBOX')).to.be(true); - expect(query.get('BBOX').split(',')).to.eql([-90, -180, 90, 180]); - - // check pixel arg - var pixel = args[1]; - expect(pixel).to.eql([0, 0]); - - done(); - }); - }); - view.setResolution(1); - }); - - it('calls ol.source.wms.getFeatureInfo (resolution 2)', function(done) { - // confirm things look good at resolution: 2 - map.once('postrender', function() { - source.getFeatureInfoForPixel([10, 20], map, function() { - expect(ol.source.wms.getFeatureInfo.calledOnce).to.be(true); - var args = ol.source.wms.getFeatureInfo.getCall(0).args; - - // check url arg - var url = new goog.Uri(args[0]); - var query = url.getQueryData(); - expect(query.containsKey('BBOX')).to.be(true); - expect(query.get('BBOX').split(',')).to.eql([-180, -360, 180, 360]); - - // check pixel arg - var pixel = args[1]; - expect(pixel).to.eql([10, 20]); - - done(); - }); - - }); - view.setResolution(2); - }); - }); - }); goog.require('goog.Uri'); goog.require('ol.Map'); -goog.require('ol.View2D'); -goog.require('ol.layer.Image'); goog.require('ol.source.ImageWMS'); goog.require('ol.source.Source'); -goog.require('ol.source.wms'); diff --git a/test/spec/ol/source/wmssource.test.js b/test/spec/ol/source/wmssource.test.js index fb23af0dbf..665c4baf2f 100644 --- a/test/spec/ol/source/wmssource.test.js +++ b/test/spec/ol/source/wmssource.test.js @@ -26,30 +26,8 @@ describe('ol.source.wms', function() { }); }); - describe('ol.source.wms.getFeatureInfo', function() { - it('calls a callback with a feature info IFRAME as result', function(done) { - ol.source.wms.getFeatureInfo('?REQUEST=GetMap&VERSION=1.3&LAYERS=foo', - [5, 10], {params: {'INFO_FORMAT': 'text/plain'}}, - function(info) { - expect(info).to.eql(''); - done(); - }); - }); - it('can do xhr to retrieve feature info', function(done) { - ol.source.wms.getFeatureInfo('?REQUEST=GetMap&VERSION=1.1.1&LAYERS=foo', - [5, 10], {method: ol.source.WMSGetFeatureInfoMethod.XHR_GET}, - function(info) { - expect(info).to.contain(''); - done(); - }); - }); - }); - }); goog.require('ol.proj'); -goog.require('ol.source.WMSGetFeatureInfoMethod'); goog.require('ol.source.wms');