Remove vector code from files

This commit is contained in:
Tom Payne
2013-11-06 16:41:23 +01:00
parent 4e65fefc00
commit bd82e1aa1a
11 changed files with 0 additions and 661 deletions

View File

@@ -20,38 +20,6 @@
* @todo stability experimental * @todo stability experimental
*/ */
/**
* @typedef {Object} ol.GetFeatureInfoOptions
* @property {ol.Pixel} pixel Pixel coordinate relative to the map viewport.
* @property {Array.<ol.layer.Layer>|undefined} layers Layers to restrict the
* query to. All map layers will be queried if not provided.
* @property {function(Array.<Array.<string|undefined>>)} 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.<ol.layer.Layer>|undefined} layers Layers to restrict the
* query to. All layers will be queried if not provided.
* @property {function(Array.<Array.<ol.Feature|undefined>>)} 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. * Object literal with config options for the map.
* @typedef {Object} ol.MapOptions * @typedef {Object} ol.MapOptions
@@ -341,16 +309,6 @@
* @todo stability experimental * @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 * @typedef {Object} ol.interaction.KeyboardPanOptions
* @property {ol.events.ConditionType|undefined} condition A conditional * @property {ol.events.ConditionType|undefined} condition A conditional
@@ -377,29 +335,6 @@
* @todo stability experimental * @todo stability experimental
*/ */
/**
* @typedef {Object} ol.interaction.ModifyOptions
* @property {undefined|Array.<ol.layer.Layer>|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.<ol.layer.Layer>|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 * @typedef {Object} ol.interaction.TouchPanOptions
* @property {ol.Kinetic|undefined} kinetic Kinetic inertia to apply to the * @property {ol.Kinetic|undefined} kinetic Kinetic inertia to apply to the
@@ -483,108 +418,6 @@
* @todo stability experimental * @todo stability experimental
*/ */
/**
* @typedef {Object} ol.layer.VectorLayerOptions
* @property {function(Array.<ol.Feature>):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.<string>|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>|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 <read> 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>|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 * @typedef {Object} ol.source.BingMapsOptions
* @property {string|undefined} culture Culture. * @property {string|undefined} culture Culture.
@@ -627,8 +460,6 @@
* @property {null|string|undefined} crossOrigin crossOrigin setting for image * @property {null|string|undefined} crossOrigin crossOrigin setting for image
* requests. * requests.
* @property {ol.Extent|undefined} extent Extent. * @property {ol.Extent|undefined} extent Extent.
* @property {ol.source.WMSGetFeatureInfoOptions|undefined}
* getFeatureInfoOptions Options for GetFeatureInfo.
* @property {Object.<string,*>} params WMS request parameters. At least a * @property {Object.<string,*>} params WMS request parameters. At least a
* `LAYERS` param is required. `STYLES` is `` by default. `VERSION` is * `LAYERS` param is required. `STYLES` is `` by default. `VERSION` is
* `1.3.0` by default. `WIDTH`, `HEIGHT`, `BBOX` and `CRS` (`SRS` for WMS * `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 * @property {null|string|undefined} crossOrigin crossOrigin setting for image
* requests. * requests.
* @property {ol.Extent|undefined} extent Extent. * @property {ol.Extent|undefined} extent Extent.
* @property {ol.source.WMSGetFeatureInfoOptions|undefined}
* getFeatureInfoOptions Options for GetFeatureInfo.
* @property {string|undefined} logo Logo. * @property {string|undefined} logo Logo.
* @property {ol.tilegrid.TileGrid|undefined} tileGrid Tile grid. * @property {ol.tilegrid.TileGrid|undefined} tileGrid Tile grid.
* @property {number|undefined} maxZoom Maximum zoom. * @property {number|undefined} maxZoom Maximum zoom.
@@ -702,33 +531,6 @@
* @todo stability experimental * @todo stability experimental
*/ */
/**
* @typedef {Object} ol.source.VectorOptions
* @property {Array.<ol.Attribution>|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 * @typedef {Object} ol.source.WMTSOptions
* @property {Array.<ol.Attribution>|undefined} attributions Attributions. * @property {Array.<ol.Attribution>|undefined} attributions Attributions.
@@ -775,89 +577,6 @@
* @todo stability experimental * @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.<ol.style.Symbolizer>|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.<ol.style.Rule>|undefined} rules Rules.
* @property {Array.<ol.style.Symbolizer>|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 * @typedef {Object} ol.tilegrid.TileGridOptions
* @property {number|undefined} minZoom Minimum zoom. * @property {number|undefined} minZoom Minimum zoom.

View File

@@ -7,8 +7,6 @@
@exportProperty ol.Map.prototype.getControls @exportProperty ol.Map.prototype.getControls
@exportProperty ol.Map.prototype.getEventCoordinate @exportProperty ol.Map.prototype.getEventCoordinate
@exportProperty ol.Map.prototype.getEventPixel @exportProperty ol.Map.prototype.getEventPixel
@exportProperty ol.Map.prototype.getFeatureInfo
@exportProperty ol.Map.prototype.getFeatures
@exportProperty ol.Map.prototype.getInteractions @exportProperty ol.Map.prototype.getInteractions
@exportProperty ol.Map.prototype.getLayers @exportProperty ol.Map.prototype.getLayers
@exportProperty ol.Map.prototype.getOverlays @exportProperty ol.Map.prototype.getOverlays

View File

@@ -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 * Gets the collection of
* {@link ol.interaction|ol.interaction.Interaction} instances * {@link ol.interaction|ol.interaction.Interaction} instances

View File

@@ -9,11 +9,9 @@ goog.require('goog.style');
goog.require('ol.css'); goog.require('ol.css');
goog.require('ol.layer.Image'); goog.require('ol.layer.Image');
goog.require('ol.layer.Tile'); goog.require('ol.layer.Tile');
goog.require('ol.layer.Vector');
goog.require('ol.renderer.Map'); goog.require('ol.renderer.Map');
goog.require('ol.renderer.canvas.ImageLayer'); goog.require('ol.renderer.canvas.ImageLayer');
goog.require('ol.renderer.canvas.TileLayer'); goog.require('ol.renderer.canvas.TileLayer');
goog.require('ol.renderer.canvas.VectorLayer2');
goog.require('ol.source.State'); 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); return new ol.renderer.canvas.ImageLayer(this, layer);
} else if (layer instanceof ol.layer.Tile) { } else if (layer instanceof ol.layer.Tile) {
return new ol.renderer.canvas.TileLayer(this, layer); return new ol.renderer.canvas.TileLayer(this, layer);
} else if (layer instanceof ol.layer.Vector) {
return new ol.renderer.canvas.VectorLayer2(this, layer);
} else { } else {
goog.asserts.fail(); goog.asserts.fail();
return null; return null;

View File

@@ -42,26 +42,6 @@ ol.renderer.Layer = function(mapRenderer, layer) {
goog.inherits(ol.renderer.Layer, goog.Disposable); 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 * @protected
* @return {ol.layer.Layer} Layer. * @return {ol.layer.Layer} Layer.

View File

@@ -1,7 +1,6 @@
goog.provide('ol.renderer.Map'); goog.provide('ol.renderer.Map');
goog.require('goog.Disposable'); goog.require('goog.Disposable');
goog.require('goog.array');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('goog.dispose'); goog.require('goog.dispose');
goog.require('goog.functions'); goog.require('goog.functions');
@@ -98,78 +97,6 @@ ol.renderer.Map.prototype.disposeInternal = function() {
ol.renderer.Map.prototype.getCanvas = goog.functions.NULL; ol.renderer.Map.prototype.getCanvas = goog.functions.NULL;
/**
* @param {ol.Pixel} pixel Pixel coordinate relative to the map viewport.
* @param {Array.<ol.layer.Layer>} layers Layers to query.
* @param {function(Array.<Array.<string|undefined>>)} 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.<ol.layer.Layer>} layers Layers to query.
* @param {function(Array.<Array.<ol.Feature|undefined>>)} 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. * @param {ol.layer.Layer} layer Layer.
* @protected * @protected

View File

@@ -5,7 +5,6 @@ goog.require('goog.object');
goog.require('ol.Image'); goog.require('ol.Image');
goog.require('ol.ImageUrlFunction'); goog.require('ol.ImageUrlFunction');
goog.require('ol.extent'); goog.require('ol.extent');
goog.require('ol.source.FeatureInfoSource');
goog.require('ol.source.Image'); goog.require('ol.source.Image');
goog.require('ol.source.wms'); goog.require('ol.source.wms');
@@ -14,7 +13,6 @@ goog.require('ol.source.wms');
/** /**
* @constructor * @constructor
* @extends {ol.source.Image} * @extends {ol.source.Image}
* @implements {ol.source.FeatureInfoSource}
* @param {ol.source.ImageWMSOptions} options Options. * @param {ol.source.ImageWMSOptions} options Options.
* @todo stability experimental * @todo stability experimental
*/ */
@@ -40,13 +38,6 @@ ol.source.ImageWMS = function(options) {
imageUrlFunction: imageUrlFunction imageUrlFunction: imageUrlFunction
}); });
/**
* @private
* @type {ol.source.WMSGetFeatureInfoOptions}
*/
this.getFeatureInfoOptions_ = goog.isDef(options.getFeatureInfoOptions) ?
options.getFeatureInfoOptions : {};
/** /**
* @private * @private
* @type {ol.Image} * @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. * Update the user-provided params.
* @param {Object} params Params. * @param {Object} params Params.

View File

@@ -3,13 +3,11 @@
goog.provide('ol.source.TileWMS'); goog.provide('ol.source.TileWMS');
goog.require('goog.array'); goog.require('goog.array');
goog.require('goog.asserts');
goog.require('goog.math'); goog.require('goog.math');
goog.require('goog.object'); goog.require('goog.object');
goog.require('ol.TileCoord'); goog.require('ol.TileCoord');
goog.require('ol.TileUrlFunction'); goog.require('ol.TileUrlFunction');
goog.require('ol.extent'); goog.require('ol.extent');
goog.require('ol.source.FeatureInfoSource');
goog.require('ol.source.TileImage'); goog.require('ol.source.TileImage');
goog.require('ol.source.wms'); goog.require('ol.source.wms');
@@ -18,7 +16,6 @@ goog.require('ol.source.wms');
/** /**
* @constructor * @constructor
* @extends {ol.source.TileImage} * @extends {ol.source.TileImage}
* @implements {ol.source.FeatureInfoSource}
* @param {ol.source.TileWMSOptions} options Tile WMS options. * @param {ol.source.TileWMSOptions} options Tile WMS options.
* @todo stability experimental * @todo stability experimental
*/ */
@@ -105,13 +102,6 @@ ol.source.TileWMS = function(options) {
tileCoordTransform, tileUrlFunction) tileCoordTransform, tileUrlFunction)
}); });
/**
* @private
* @type {ol.source.WMSGetFeatureInfoOptions}
*/
this.getFeatureInfoOptions_ = goog.isDef(options.getFeatureInfoOptions) ?
options.getFeatureInfoOptions : {};
}; };
goog.inherits(ol.source.TileWMS, ol.source.TileImage); 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 * @private
*/ */

View File

@@ -1,30 +1,9 @@
goog.provide('ol.source.WMSGetFeatureInfoMethod');
goog.provide('ol.source.wms'); goog.provide('ol.source.wms');
goog.require('goog.net.XhrIo');
goog.require('goog.object'); goog.require('goog.object');
goog.require('goog.uri.utils'); 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 {string} baseUrl WMS base URL.
* @param {Object.<string, string|number>} params Request parameters. * @param {Object.<string, string|number>} params Request parameters.
@@ -61,62 +40,3 @@ ol.source.wms.getUrl =
return goog.uri.utils.appendParamsFromMap(baseUrl, baseParams); 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('<iframe seamless src="' + url + '"></iframe>');
}, 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=([^&]+)/)
};

View File

@@ -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('goog.Uri');
goog.require('ol.Map'); goog.require('ol.Map');
goog.require('ol.View2D');
goog.require('ol.layer.Image');
goog.require('ol.source.ImageWMS'); goog.require('ol.source.ImageWMS');
goog.require('ol.source.Source'); goog.require('ol.source.Source');
goog.require('ol.source.wms');

View File

@@ -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('<iframe seamless src="' +
'?REQUEST=GetFeatureInfo&VERSION=1.3&LAYERS=foo&QUERY_LAYERS=' +
'foo&INFO_FORMAT=text%2Fplain&I=5&J=10"></iframe>');
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('<html>');
done();
});
});
});
}); });
goog.require('ol.proj'); goog.require('ol.proj');
goog.require('ol.source.WMSGetFeatureInfoMethod');
goog.require('ol.source.wms'); goog.require('ol.source.wms');