Rename _ol_source_ImageWMS_ to ImageWMS
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import Map from '../src/ol/Map.js';
|
||||
import View from '../src/ol/View.js';
|
||||
import ImageLayer from '../src/ol/layer/Image.js';
|
||||
import _ol_source_ImageWMS_ from '../src/ol/source/ImageWMS.js';
|
||||
import ImageWMS from '../src/ol/source/ImageWMS.js';
|
||||
|
||||
|
||||
var wmsSource = new _ol_source_ImageWMS_({
|
||||
var wmsSource = new ImageWMS({
|
||||
url: 'https://ahocevar.com/geoserver/wms',
|
||||
params: {'LAYERS': 'ne:ne'},
|
||||
serverType: 'geoserver',
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import Map from '../src/ol/Map.js';
|
||||
import View from '../src/ol/View.js';
|
||||
import ImageLayer from '../src/ol/layer/Image.js';
|
||||
import _ol_source_ImageWMS_ from '../src/ol/source/ImageWMS.js';
|
||||
import ImageWMS from '../src/ol/source/ImageWMS.js';
|
||||
|
||||
|
||||
/**
|
||||
@@ -77,7 +77,7 @@ Progress.prototype.hide = function() {
|
||||
|
||||
var progress = new Progress(document.getElementById('progress'));
|
||||
|
||||
var source = new _ol_source_ImageWMS_({
|
||||
var source = new ImageWMS({
|
||||
url: 'https://ahocevar.com/geoserver/wms',
|
||||
params: {'LAYERS': 'topp:states'},
|
||||
serverType: 'geoserver'
|
||||
|
||||
@@ -5,7 +5,7 @@ import ScaleLine from '../src/ol/control/ScaleLine.js';
|
||||
import ImageLayer from '../src/ol/layer/Image.js';
|
||||
import {fromLonLat} from '../src/ol/proj.js';
|
||||
import _ol_proj_Projection_ from '../src/ol/proj/Projection.js';
|
||||
import _ol_source_ImageWMS_ from '../src/ol/source/ImageWMS.js';
|
||||
import ImageWMS from '../src/ol/source/ImageWMS.js';
|
||||
import {register} from '../src/ol/proj/proj4.js';
|
||||
import proj4 from 'proj4';
|
||||
|
||||
@@ -38,7 +38,7 @@ var extent = [420000, 30000, 900000, 350000];
|
||||
var layers = [
|
||||
new ImageLayer({
|
||||
extent: extent,
|
||||
source: new _ol_source_ImageWMS_({
|
||||
source: new ImageWMS({
|
||||
url: 'https://wms.geo.admin.ch/',
|
||||
crossOrigin: 'anonymous',
|
||||
attributions: '© <a href="http://www.geo.admin.ch/internet/geoportal/' +
|
||||
@@ -52,7 +52,7 @@ var layers = [
|
||||
}),
|
||||
new ImageLayer({
|
||||
extent: extent,
|
||||
source: new _ol_source_ImageWMS_({
|
||||
source: new ImageWMS({
|
||||
url: 'https://wms.geo.admin.ch/',
|
||||
crossOrigin: 'anonymous',
|
||||
attributions: '© <a href="http://www.geo.admin.ch/internet/geoportal/' +
|
||||
|
||||
@@ -2,7 +2,7 @@ import Map from '../src/ol/Map.js';
|
||||
import View from '../src/ol/View.js';
|
||||
import ImageLayer from '../src/ol/layer/Image.js';
|
||||
import TileLayer from '../src/ol/layer/Tile.js';
|
||||
import _ol_source_ImageWMS_ from '../src/ol/source/ImageWMS.js';
|
||||
import ImageWMS from '../src/ol/source/ImageWMS.js';
|
||||
import _ol_source_OSM_ from '../src/ol/source/OSM.js';
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ var layers = [
|
||||
}),
|
||||
new ImageLayer({
|
||||
extent: [-13884991, 2870341, -7455066, 6338219],
|
||||
source: new _ol_source_ImageWMS_({
|
||||
source: new ImageWMS({
|
||||
url: 'https://ahocevar.com/geoserver/wms',
|
||||
params: {'LAYERS': 'topp:states'},
|
||||
ratio: 1,
|
||||
|
||||
@@ -3,7 +3,7 @@ import View from '../src/ol/View.js';
|
||||
import ImageLayer from '../src/ol/layer/Image.js';
|
||||
import TileLayer from '../src/ol/layer/Tile.js';
|
||||
import _ol_proj_Projection_ from '../src/ol/proj/Projection.js';
|
||||
import _ol_source_ImageWMS_ from '../src/ol/source/ImageWMS.js';
|
||||
import ImageWMS from '../src/ol/source/ImageWMS.js';
|
||||
import _ol_source_TileWMS_ from '../src/ol/source/TileWMS.js';
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ var layers = [
|
||||
})
|
||||
}),
|
||||
new ImageLayer({
|
||||
source: new _ol_source_ImageWMS_({
|
||||
source: new ImageWMS({
|
||||
attributions: '© <a href="http://www.geo.admin.ch/internet/geoportal/' +
|
||||
'en/home.html">National parks / geo.admin.ch</a>',
|
||||
crossOrigin: 'anonymous',
|
||||
|
||||
@@ -27,7 +27,7 @@ import _ol_uri_ from '../uri.js';
|
||||
* @param {olx.source.ImageWMSOptions=} opt_options Options.
|
||||
* @api
|
||||
*/
|
||||
var _ol_source_ImageWMS_ = function(opt_options) {
|
||||
var ImageWMS = function(opt_options) {
|
||||
|
||||
var options = opt_options || {};
|
||||
|
||||
@@ -108,7 +108,7 @@ var _ol_source_ImageWMS_ = function(opt_options) {
|
||||
|
||||
};
|
||||
|
||||
inherits(_ol_source_ImageWMS_, ImageSource);
|
||||
inherits(ImageWMS, ImageSource);
|
||||
|
||||
|
||||
/**
|
||||
@@ -116,7 +116,7 @@ inherits(_ol_source_ImageWMS_, ImageSource);
|
||||
* @type {ol.Size}
|
||||
* @private
|
||||
*/
|
||||
_ol_source_ImageWMS_.GETFEATUREINFO_IMAGE_SIZE_ = [101, 101];
|
||||
ImageWMS.GETFEATUREINFO_IMAGE_SIZE_ = [101, 101];
|
||||
|
||||
|
||||
/**
|
||||
@@ -133,7 +133,7 @@ _ol_source_ImageWMS_.GETFEATUREINFO_IMAGE_SIZE_ = [101, 101];
|
||||
* @return {string|undefined} GetFeatureInfo URL.
|
||||
* @api
|
||||
*/
|
||||
_ol_source_ImageWMS_.prototype.getGetFeatureInfoUrl = function(coordinate, resolution, projection, params) {
|
||||
ImageWMS.prototype.getGetFeatureInfoUrl = function(coordinate, resolution, projection, params) {
|
||||
if (this.url_ === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -146,7 +146,7 @@ _ol_source_ImageWMS_.prototype.getGetFeatureInfoUrl = function(coordinate, resol
|
||||
}
|
||||
|
||||
var extent = getForViewAndSize(coordinate, resolution, 0,
|
||||
_ol_source_ImageWMS_.GETFEATUREINFO_IMAGE_SIZE_);
|
||||
ImageWMS.GETFEATUREINFO_IMAGE_SIZE_);
|
||||
|
||||
var baseParams = {
|
||||
'SERVICE': 'WMS',
|
||||
@@ -164,7 +164,7 @@ _ol_source_ImageWMS_.prototype.getGetFeatureInfoUrl = function(coordinate, resol
|
||||
baseParams[this.v13_ ? 'J' : 'Y'] = y;
|
||||
|
||||
return this.getRequestUrl_(
|
||||
extent, _ol_source_ImageWMS_.GETFEATUREINFO_IMAGE_SIZE_,
|
||||
extent, ImageWMS.GETFEATUREINFO_IMAGE_SIZE_,
|
||||
1, sourceProjectionObj || projectionObj, baseParams);
|
||||
};
|
||||
|
||||
@@ -175,7 +175,7 @@ _ol_source_ImageWMS_.prototype.getGetFeatureInfoUrl = function(coordinate, resol
|
||||
* @return {Object} Params.
|
||||
* @api
|
||||
*/
|
||||
_ol_source_ImageWMS_.prototype.getParams = function() {
|
||||
ImageWMS.prototype.getParams = function() {
|
||||
return this.params_;
|
||||
};
|
||||
|
||||
@@ -183,7 +183,7 @@ _ol_source_ImageWMS_.prototype.getParams = function() {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
_ol_source_ImageWMS_.prototype.getImageInternal = function(extent, resolution, pixelRatio, projection) {
|
||||
ImageWMS.prototype.getImageInternal = function(extent, resolution, pixelRatio, projection) {
|
||||
|
||||
if (this.url_ === undefined) {
|
||||
return null;
|
||||
@@ -249,7 +249,7 @@ _ol_source_ImageWMS_.prototype.getImageInternal = function(extent, resolution, p
|
||||
* @return {ol.ImageLoadFunctionType} The image load function.
|
||||
* @api
|
||||
*/
|
||||
_ol_source_ImageWMS_.prototype.getImageLoadFunction = function() {
|
||||
ImageWMS.prototype.getImageLoadFunction = function() {
|
||||
return this.imageLoadFunction_;
|
||||
};
|
||||
|
||||
@@ -263,7 +263,7 @@ _ol_source_ImageWMS_.prototype.getImageLoadFunction = function() {
|
||||
* @return {string} Request URL.
|
||||
* @private
|
||||
*/
|
||||
_ol_source_ImageWMS_.prototype.getRequestUrl_ = function(extent, size, pixelRatio, projection, params) {
|
||||
ImageWMS.prototype.getRequestUrl_ = function(extent, size, pixelRatio, projection, params) {
|
||||
|
||||
assert(this.url_ !== undefined, 9); // `url` must be configured or set using `#setUrl()`
|
||||
|
||||
@@ -317,7 +317,7 @@ _ol_source_ImageWMS_.prototype.getRequestUrl_ = function(extent, size, pixelRati
|
||||
* @return {string|undefined} URL.
|
||||
* @api
|
||||
*/
|
||||
_ol_source_ImageWMS_.prototype.getUrl = function() {
|
||||
ImageWMS.prototype.getUrl = function() {
|
||||
return this.url_;
|
||||
};
|
||||
|
||||
@@ -327,7 +327,7 @@ _ol_source_ImageWMS_.prototype.getUrl = function() {
|
||||
* @param {ol.ImageLoadFunctionType} imageLoadFunction Image load function.
|
||||
* @api
|
||||
*/
|
||||
_ol_source_ImageWMS_.prototype.setImageLoadFunction = function(
|
||||
ImageWMS.prototype.setImageLoadFunction = function(
|
||||
imageLoadFunction) {
|
||||
this.image_ = null;
|
||||
this.imageLoadFunction_ = imageLoadFunction;
|
||||
@@ -340,7 +340,7 @@ _ol_source_ImageWMS_.prototype.setImageLoadFunction = function(
|
||||
* @param {string|undefined} url URL.
|
||||
* @api
|
||||
*/
|
||||
_ol_source_ImageWMS_.prototype.setUrl = function(url) {
|
||||
ImageWMS.prototype.setUrl = function(url) {
|
||||
if (url != this.url_) {
|
||||
this.url_ = url;
|
||||
this.image_ = null;
|
||||
@@ -354,7 +354,7 @@ _ol_source_ImageWMS_.prototype.setUrl = function(url) {
|
||||
* @param {Object} params Params.
|
||||
* @api
|
||||
*/
|
||||
_ol_source_ImageWMS_.prototype.updateParams = function(params) {
|
||||
ImageWMS.prototype.updateParams = function(params) {
|
||||
_ol_obj_.assign(this.params_, params);
|
||||
this.updateV13_();
|
||||
this.image_ = null;
|
||||
@@ -365,8 +365,8 @@ _ol_source_ImageWMS_.prototype.updateParams = function(params) {
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_ol_source_ImageWMS_.prototype.updateV13_ = function() {
|
||||
ImageWMS.prototype.updateV13_ = function() {
|
||||
var version = this.params_['VERSION'] || DEFAULT_WMS_VERSION;
|
||||
this.v13_ = _ol_string_.compareVersions(version, '1.3') >= 0;
|
||||
};
|
||||
export default _ol_source_ImageWMS_;
|
||||
export default ImageWMS;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import _ol_source_ImageWMS_ from '../../../../src/ol/source/ImageWMS.js';
|
||||
import ImageWMS from '../../../../src/ol/source/ImageWMS.js';
|
||||
import {get as getProjection} from '../../../../src/ol/proj.js';
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ describe('ol.source.ImageWMS', function() {
|
||||
|
||||
it('returns the expected image URL', function() {
|
||||
options.ratio = 1.5;
|
||||
var source = new _ol_source_ImageWMS_(options);
|
||||
var source = new ImageWMS(options);
|
||||
var image = source.getImage([10, 20, 30.1, 39.9], resolution, pixelRatio, projection);
|
||||
var uri = new URL(image.src_);
|
||||
var queryData = uri.searchParams;
|
||||
@@ -44,7 +44,7 @@ describe('ol.source.ImageWMS', function() {
|
||||
it('uses correct WIDTH and HEIGHT for HiDPI devices', function() {
|
||||
pixelRatio = 2;
|
||||
options.serverType = 'geoserver';
|
||||
var source = new _ol_source_ImageWMS_(options);
|
||||
var source = new ImageWMS(options);
|
||||
var image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
var uri = new URL(image.src_);
|
||||
var queryData = uri.searchParams;
|
||||
@@ -56,7 +56,7 @@ describe('ol.source.ImageWMS', function() {
|
||||
|
||||
it('requests integer WIDTH and HEIGHT', function() {
|
||||
options.ratio = 1.5;
|
||||
var source = new _ol_source_ImageWMS_(options);
|
||||
var source = new ImageWMS(options);
|
||||
var image = source.getImage([10, 20, 30.1, 39.9], resolution, pixelRatio, projection);
|
||||
var uri = new URL(image.src_);
|
||||
var queryData = uri.searchParams;
|
||||
@@ -67,7 +67,7 @@ describe('ol.source.ImageWMS', function() {
|
||||
});
|
||||
|
||||
it('sets WIDTH and HEIGHT to match the aspect ratio of BBOX', function() {
|
||||
var source = new _ol_source_ImageWMS_(options);
|
||||
var source = new ImageWMS(options);
|
||||
var image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
var uri = new URL(image.src_);
|
||||
expect(uri.protocol).to.be('http:');
|
||||
@@ -91,7 +91,7 @@ describe('ol.source.ImageWMS', function() {
|
||||
|
||||
it('sets the SRS query value instead of CRS if version < 1.3', function() {
|
||||
options.params.VERSION = '1.2';
|
||||
var source = new _ol_source_ImageWMS_(options);
|
||||
var source = new ImageWMS(options);
|
||||
var image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
var uri = new URL(image.src_);
|
||||
var queryData = uri.searchParams;
|
||||
@@ -102,7 +102,7 @@ describe('ol.source.ImageWMS', function() {
|
||||
it('allows various parameters to be overridden', function() {
|
||||
options.params.FORMAT = 'image/jpeg';
|
||||
options.params.TRANSPARENT = false;
|
||||
var source = new _ol_source_ImageWMS_(options);
|
||||
var source = new ImageWMS(options);
|
||||
var image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
var uri = new URL(image.src_);
|
||||
var queryData = uri.searchParams;
|
||||
@@ -112,7 +112,7 @@ describe('ol.source.ImageWMS', function() {
|
||||
|
||||
it('does not add a STYLES= option if one is specified', function() {
|
||||
options.params.STYLES = 'foo';
|
||||
var source = new _ol_source_ImageWMS_(options);
|
||||
var source = new ImageWMS(options);
|
||||
var image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
var uri = new URL(image.src_);
|
||||
var queryData = uri.searchParams;
|
||||
@@ -120,7 +120,7 @@ describe('ol.source.ImageWMS', function() {
|
||||
});
|
||||
|
||||
it('changes the BBOX order for EN axis orientations', function() {
|
||||
var source = new _ol_source_ImageWMS_(options);
|
||||
var source = new ImageWMS(options);
|
||||
projection = getProjection('CRS:84');
|
||||
var image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
var uri = new URL(image.src_);
|
||||
@@ -130,7 +130,7 @@ describe('ol.source.ImageWMS', function() {
|
||||
|
||||
it('uses EN BBOX order if version < 1.3', function() {
|
||||
options.params.VERSION = '1.1.0';
|
||||
var source = new _ol_source_ImageWMS_(options);
|
||||
var source = new ImageWMS(options);
|
||||
var image =
|
||||
source.getImage(extent, resolution, pixelRatio, projection);
|
||||
var uri = new URL(image.src_);
|
||||
@@ -140,7 +140,7 @@ describe('ol.source.ImageWMS', function() {
|
||||
|
||||
it('sets MAP_RESOLUTION when the server is MapServer', function() {
|
||||
options.serverType = 'mapserver';
|
||||
var source = new _ol_source_ImageWMS_(options);
|
||||
var source = new ImageWMS(options);
|
||||
pixelRatio = 2;
|
||||
var image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
var uri = new URL(image.src_);
|
||||
@@ -150,7 +150,7 @@ describe('ol.source.ImageWMS', function() {
|
||||
|
||||
it('sets FORMAT_OPTIONS when the server is GeoServer', function() {
|
||||
options.serverType = 'geoserver';
|
||||
var source = new _ol_source_ImageWMS_(options);
|
||||
var source = new ImageWMS(options);
|
||||
pixelRatio = 2;
|
||||
var image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
var uri = new URL(image.src_);
|
||||
@@ -160,7 +160,7 @@ describe('ol.source.ImageWMS', function() {
|
||||
|
||||
it('extends FORMAT_OPTIONS if it is already present', function() {
|
||||
options.serverType = 'geoserver';
|
||||
var source = new _ol_source_ImageWMS_(options);
|
||||
var source = new ImageWMS(options);
|
||||
options.params.FORMAT_OPTIONS = 'param1:value1';
|
||||
pixelRatio = 2;
|
||||
var image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
@@ -172,7 +172,7 @@ describe('ol.source.ImageWMS', function() {
|
||||
it('rounds FORMAT_OPTIONS to an integer when the server is GeoServer',
|
||||
function() {
|
||||
options.serverType = 'geoserver';
|
||||
var source = new _ol_source_ImageWMS_(options);
|
||||
var source = new ImageWMS(options);
|
||||
pixelRatio = 1.325;
|
||||
var image =
|
||||
source.getImage(extent, resolution, pixelRatio, projection);
|
||||
@@ -183,7 +183,7 @@ describe('ol.source.ImageWMS', function() {
|
||||
|
||||
it('sets DPI when the server is QGIS', function() {
|
||||
options.serverType = 'qgis';
|
||||
var source = new _ol_source_ImageWMS_(options);
|
||||
var source = new ImageWMS(options);
|
||||
pixelRatio = 2;
|
||||
var image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
var uri = new URL(image.src_);
|
||||
@@ -194,7 +194,7 @@ describe('ol.source.ImageWMS', function() {
|
||||
it('creates an image with a custom imageLoadFunction', function() {
|
||||
var imageLoadFunction = sinon.spy();
|
||||
options.imageLoadFunction = imageLoadFunction;
|
||||
var source = new _ol_source_ImageWMS_(options);
|
||||
var source = new ImageWMS(options);
|
||||
var image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
image.load();
|
||||
expect(imageLoadFunction).to.be.called();
|
||||
@@ -203,7 +203,7 @@ describe('ol.source.ImageWMS', function() {
|
||||
|
||||
it('returns same image for consecutive calls with same args', function() {
|
||||
var extent = [10.01, 20, 30.01, 40];
|
||||
var source = new _ol_source_ImageWMS_(options);
|
||||
var source = new ImageWMS(options);
|
||||
var image1 = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
var image2 = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
expect(image1).to.equal(image2);
|
||||
@@ -211,7 +211,7 @@ describe('ol.source.ImageWMS', function() {
|
||||
|
||||
it('returns same image for calls with similar extents', function() {
|
||||
options.ratio = 1.5;
|
||||
var source = new _ol_source_ImageWMS_(options);
|
||||
var source = new ImageWMS(options);
|
||||
var extent = [10.01, 20, 30.01, 40];
|
||||
var image1 = source.getImage(extent, resolution, pixelRatio, projection);
|
||||
extent = [10.01, 20.1, 30.01, 40.1];
|
||||
@@ -221,7 +221,7 @@ describe('ol.source.ImageWMS', function() {
|
||||
|
||||
it('calculates correct image size with ratio', function() {
|
||||
options.ratio = 1.5;
|
||||
var source = new _ol_source_ImageWMS_(options);
|
||||
var source = new ImageWMS(options);
|
||||
var extent = [10, 5, 30, 45];
|
||||
source.getImage(extent, resolution, pixelRatio, projection);
|
||||
expect(source.imageSize_).to.eql([300, 600]);
|
||||
@@ -232,7 +232,7 @@ describe('ol.source.ImageWMS', function() {
|
||||
describe('#getGetFeatureInfoUrl', function() {
|
||||
|
||||
it('returns the expected GetFeatureInfo URL', function() {
|
||||
var source = new _ol_source_ImageWMS_(options);
|
||||
var source = new ImageWMS(options);
|
||||
var url = source.getGetFeatureInfoUrl(
|
||||
[20, 30], resolution, projection,
|
||||
{INFO_FORMAT: 'text/plain'});
|
||||
@@ -260,7 +260,7 @@ describe('ol.source.ImageWMS', function() {
|
||||
});
|
||||
|
||||
it('returns the expected GetFeatureInfo URL when source\'s projection is different from the parameter', function() {
|
||||
var source = new _ol_source_ImageWMS_(optionsReproj);
|
||||
var source = new ImageWMS(optionsReproj);
|
||||
var url = source.getGetFeatureInfoUrl(
|
||||
[20, 30], resolution, projection,
|
||||
{INFO_FORMAT: 'text/plain'});
|
||||
@@ -288,7 +288,7 @@ describe('ol.source.ImageWMS', function() {
|
||||
});
|
||||
|
||||
it('sets the QUERY_LAYERS param as expected', function() {
|
||||
var source = new _ol_source_ImageWMS_(options);
|
||||
var source = new ImageWMS(options);
|
||||
var url = source.getGetFeatureInfoUrl(
|
||||
[20, 30], resolution, projection,
|
||||
{INFO_FORMAT: 'text/plain', QUERY_LAYERS: 'foo,bar'});
|
||||
|
||||
Reference in New Issue
Block a user