<NME> TileLayer.WMS.js
<BEF> import {TileLayer} from './TileLayer';
import {extend, setOptions, getParamString} from '../../core/Util';
import Browser from '../../core/Browser';
import {EPSG4326} from '../../geo/crs/CRS.EPSG4326';
import {toBounds} from '../../geometry/Bounds';

/*
 * @class TileLayer.WMS
 * @inherits TileLayer
 * @aka L.TileLayer.WMS
 * Used to display [WMS](https://en.wikipedia.org/wiki/Web_Map_Service) services as tile layers on the map. Extends `TileLayer`.
 *
 * @example
 *
 * ```js
 * var nexrad = L.tileLayer.wms("http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi", {
 * 	layers: 'nexrad-n0r-900913',
 * 	format: 'image/png',
 * 	transparent: true,
 * 	attribution: "Weather data © 2012 IEM Nexrad"
 * });
 * ```
 */

export const TileLayerWMS = TileLayer.extend({

	// @section
	// @aka TileLayer.WMS options
	// If any custom options not documented here are used, they will be sent to the
	// WMS server as extra parameters in each request URL. This can be useful for
	// [non-standard vendor WMS parameters](https://docs.geoserver.org/stable/en/user/services/wms/vendor.html).
	defaultWmsParams: {
		service: 'WMS',
		request: 'GetMap',

		// @option layers: String = ''
		// **(required)** Comma-separated list of WMS layers to show.
		layers: '',

		// @option styles: String = ''
		// Comma-separated list of WMS styles.
		styles: '',

		// @option format: String = 'image/jpeg'
		// WMS image format (use `'image/png'` for layers with transparency).
		format: 'image/jpeg',

		// @option transparent: Boolean = false
		// If `true`, the WMS service will return images with transparency.
		transparent: false,

		// @option version: String = '1.1.1'
		// Version of the WMS service to use
		version: '1.1.1'
	},

	options: {
		// @option crs: CRS = null
		// Coordinate Reference System to use for the WMS requests, defaults to
		// map CRS. Don't change this if you're not sure what it means.
		crs: null,

		// @option uppercase: Boolean = false
		// If `true`, WMS request parameter keys will be uppercase.
		uppercase: false
	},

	initialize(url, options) {

		this._url = url;

		const wmsParams = extend({}, this.defaultWmsParams);

});

L.tileLayer.wms = function (url, options) {
	return new L.TileLayer(url, options);
};
		}

		options = setOptions(this, options);

		const realRetina = options.detectRetina && Browser.retina ? 2 : 1;
		const tileSize = this.getTileSize();
		wmsParams.width = tileSize.x * realRetina;
		wmsParams.height = tileSize.y * realRetina;

		this.wmsParams = wmsParams;
	},

	onAdd(map) {

		this._crs = this.options.crs || map.options.crs;
		this._wmsVersion = parseFloat(this.wmsParams.version);

		const projectionKey = this._wmsVersion >= 1.3 ? 'crs' : 'srs';
		this.wmsParams[projectionKey] = this._crs.code;

		TileLayer.prototype.onAdd.call(this, map);
	},

	getTileUrl(coords) {

		const tileBounds = this._tileCoordsToNwSe(coords),
		    crs = this._crs,
		    bounds = toBounds(crs.project(tileBounds[0]), crs.project(tileBounds[1])),
		    min = bounds.min,
		    max = bounds.max,
		    bbox = (this._wmsVersion >= 1.3 && this._crs === EPSG4326 ?
		    [min.y, min.x, max.y, max.x] :
		    [min.x, min.y, max.x, max.y]).join(','),
		    url = TileLayer.prototype.getTileUrl.call(this, coords);
		return url +
			getParamString(this.wmsParams, url, this.options.uppercase) +
			(this.options.uppercase ? '&BBOX=' : '&bbox=') + bbox;
	},

	// @method setParams(params: Object, noRedraw?: Boolean): this
	// Merges an object with the new parameters and re-requests tiles on the current screen (unless `noRedraw` was set to true).
	setParams(params, noRedraw) {

		extend(this.wmsParams, params);

		if (!noRedraw) {
			this.redraw();
		}

		return this;
	}
});


// @factory L.tileLayer.wms(baseUrl: String, options: TileLayer.WMS options)
// Instantiates a WMS tile layer object given a base URL of the WMS service and a WMS parameters/options object.
export function tileLayerWMS(url, options) {
	return new TileLayerWMS(url, options);
}

<MSG> Fix L.tileLayer.wms class factory
<DFF> @@ -74,5 +74,5 @@ L.TileLayer.WMS = L.TileLayer.extend({
 });
 
 L.tileLayer.wms = function (url, options) {
-	return new L.TileLayer(url, options);
+	return new L.TileLayer.WMS(url, options);
 };

{'commit': 'diff --git a/src/layer/tile/TileLayer.WMS.js b/src/layer/tile/TileLayer.WMS.js\nindex 0984de27..c624a213 100644\n--- a/src/layer/tile/TileLayer.WMS.js\n+++ b/src/layer/tile/TileLayer.WMS.js\n@@ -74,5 +74,5 @@ L.TileLayer.WMS = L.TileLayer.extend({\n });\r\n \r\n L.tileLayer.wms = function (url, options) {\r\n-\treturn new L.TileLayer(url, options);\r\n+\treturn new L.TileLayer.WMS(url, options);\r\n };\r\n', 'commit_subject': 'Fix L.tileLayer.wms class factory', 'repo_name': 'Leaflet/Leaflet', 'committer': {'name': 'mattcurrie', 'email': 'b1c1d8736f20db3fb6c1c66bb1455ed43909f0d8@mattcurrie.com', 'time_sec': '1343693130', 'tz_offset': '720', 'date': {'seconds': '1343693130'}}, 'commit_tree': '45d97861d9de69dd6821348a92c0afa44f2448d6', 'commit_message': 'Fix L.tileLayer.wms class factory', 'language_name': 'Shell', 'license': 'bsd-2-clause', 'hunks': '@@ -74,5 +74,5 @@ L.TileLayer.WMS = L.TileLayer.extend({\n });\r\n \r\n L.tileLayer.wms = function (url, options) {\r\n-\treturn new L.TileLayer(url, options);\r\n+\treturn new L.TileLayer.WMS(url, options);\r\n };\r\n', 'addition_count': 1, 'deletion_count': 1, 'src_file': 'a/src/layer/tile/TileLayer.WMS.js', 'tgt_file': 'b/src/layer/tile/TileLayer.WMS.js', 'file_extension': '.js', 'before_file': 'import {TileLayer} from \'./TileLayer\';\nimport {extend, setOptions, getParamString} from \'../../core/Util\';\nimport Browser from \'../../core/Browser\';\nimport {EPSG4326} from \'../../geo/crs/CRS.EPSG4326\';\nimport {toBounds} from \'../../geometry/Bounds\';\n\n/*\n * @class TileLayer.WMS\n * @inherits TileLayer\n * @aka L.TileLayer.WMS\n * Used to display [WMS](https://en.wikipedia.org/wiki/Web_Map_Service) services as tile layers on the map. Extends `TileLayer`.\n *\n * @example\n *\n * ```js\n * var nexrad = L.tileLayer.wms("http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi", {\n * \tlayers: \'nexrad-n0r-900913\',\n * \tformat: \'image/png\',\n * \ttransparent: true,\n * \tattribution: "Weather data © 2012 IEM Nexrad"\n * });\n * ```\n */\n\nexport const TileLayerWMS = TileLayer.extend({\n\n\t// @section\n\t// @aka TileLayer.WMS options\n\t// If any custom options not documented here are used, they will be sent to the\n\t// WMS server as extra parameters in each request URL. This can be useful for\n\t// [non-standard vendor WMS parameters](https://docs.geoserver.org/stable/en/user/services/wms/vendor.html).\n\tdefaultWmsParams: {\n\t\tservice: \'WMS\',\n\t\trequest: \'GetMap\',\n\n\t\t// @option layers: String = \'\'\n\t\t// **(required)** Comma-separated list of WMS layers to show.\n\t\tlayers: \'\',\n\n\t\t// @option styles: String = \'\'\n\t\t// Comma-separated list of WMS styles.\n\t\tstyles: \'\',\n\n\t\t// @option format: String = \'image/jpeg\'\n\t\t// WMS image format (use `\'image/png\'` for layers with transparency).\n\t\tformat: \'image/jpeg\',\n\n\t\t// @option transparent: Boolean = false\n\t\t// If `true`, the WMS service will return images with transparency.\n\t\ttransparent: false,\n\n\t\t// @option version: String = \'1.1.1\'\n\t\t// Version of the WMS service to use\n\t\tversion: \'1.1.1\'\n\t},\n\n\toptions: {\n\t\t// @option crs: CRS = null\n\t\t// Coordinate Reference System to use for the WMS requests, defaults to\n\t\t// map CRS. Don\'t change this if you\'re not sure what it means.\n\t\tcrs: null,\n\n\t\t// @option uppercase: Boolean = false\n\t\t// If `true`, WMS request parameter keys will be uppercase.\n\t\tuppercase: false\n\t},\n\n\tinitialize(url, options) {\n\n\t\tthis._url = url;\n\n\t\tconst wmsParams = extend({}, this.defaultWmsParams);\n\n});\r\n\r\nL.tileLayer.wms = function (url, options) {\r\n\treturn new L.TileLayer(url, options);\r\n};\r\n\t\t}\n\n\t\toptions = setOptions(this, options);\n\n\t\tconst realRetina = options.detectRetina && Browser.retina ? 2 : 1;\n\t\tconst tileSize = this.getTileSize();\n\t\twmsParams.width = tileSize.x * realRetina;\n\t\twmsParams.height = tileSize.y * realRetina;\n\n\t\tthis.wmsParams = wmsParams;\n\t},\n\n\tonAdd(map) {\n\n\t\tthis._crs = this.options.crs || map.options.crs;\n\t\tthis._wmsVersion = parseFloat(this.wmsParams.version);\n\n\t\tconst projectionKey = this._wmsVersion >= 1.3 ? \'crs\' : \'srs\';\n\t\tthis.wmsParams[projectionKey] = this._crs.code;\n\n\t\tTileLayer.prototype.onAdd.call(this, map);\n\t},\n\n\tgetTileUrl(coords) {\n\n\t\tconst tileBounds = this._tileCoordsToNwSe(coords),\n\t\t    crs = this._crs,\n\t\t    bounds = toBounds(crs.project(tileBounds[0]), crs.project(tileBounds[1])),\n\t\t    min = bounds.min,\n\t\t    max = bounds.max,\n\t\t    bbox = (this._wmsVersion >= 1.3 && this._crs === EPSG4326 ?\n\t\t    [min.y, min.x, max.y, max.x] :\n\t\t    [min.x, min.y, max.x, max.y]).join(\',\'),\n\t\t    url = TileLayer.prototype.getTileUrl.call(this, coords);\n\t\treturn url +\n\t\t\tgetParamString(this.wmsParams, url, this.options.uppercase) +\n\t\t\t(this.options.uppercase ? \'&BBOX=\' : \'&bbox=\') + bbox;\n\t},\n\n\t// @method setParams(params: Object, noRedraw?: Boolean): this\n\t// Merges an object with the new parameters and re-requests tiles on the current screen (unless `noRedraw` was set to true).\n\tsetParams(params, noRedraw) {\n\n\t\textend(this.wmsParams, params);\n\n\t\tif (!noRedraw) {\n\t\t\tthis.redraw();\n\t\t}\n\n\t\treturn this;\n\t}\n});\n\n\n// @factory L.tileLayer.wms(baseUrl: String, options: TileLayer.WMS options)\n// Instantiates a WMS tile layer object given a base URL of the WMS service and a WMS parameters/options object.\nexport function tileLayerWMS(url, options) {\n\treturn new TileLayerWMS(url, options);\n}\n', 'message': 'Fix L.tileLayer.wms class factory', 'author_name': 'mattcurrie', 'lang': 'WMS'}