Merge pull request #5702 from tschaub/no-missing-requires

Add rule to identify missing requires
This commit is contained in:
Tim Schaub
2016-08-13 10:32:41 -06:00
committed by GitHub
189 changed files with 2233 additions and 1913 deletions

View File

@@ -86,7 +86,7 @@ check-deps:
done ;\
.PHONY: ci
ci: lint build test test-rendering test-node compile-examples check-examples apidoc
ci: lint build test test-rendering compile-examples check-examples apidoc
.PHONY: compile-examples
compile-examples: build/compiled-examples/all.combined.js
@@ -135,10 +135,6 @@ serve: build/test_requires.js build/test_rendering_requires.js
test: build/timestamps/node-modules-timestamp build/test_requires.js
node tasks/test.js
.PHONY: test-node
test-node: build/timestamps/node-modules-timestamp
./node_modules/.bin/mocha test/node --fgrep 'has a path that maps to the provide'
.PHONY: test-coverage
test-coverage: build/timestamps/node-modules-timestamp
node tasks/test-coverage.js
@@ -256,7 +252,7 @@ build/timestamps/eslint-timestamp: $(SRC_JS) $(SPEC_JS) $(SPEC_RENDERING_JS) \
build/timestamps/node-modules-timestamp
@mkdir -p $(@D)
@echo "Running eslint..."
@./node_modules/.bin/eslint tasks test test_rendering src examples
@./node_modules/.bin/eslint --quiet tasks test test_rendering src examples
@touch $@
build/timestamps/node-modules-timestamp: package.json

View File

@@ -18,6 +18,8 @@ A number of internal types have been renamed. This will not affect those who us
* rename `ol.CollectionEventType` to `ol.Collection.EventType`
* rename `ol.CollectionEvent` to `ol.Collection.Event`
* rename `ol.ViewHint` to `ol.View.Hint`
* rename `ol.ViewProperty` to `ol.View.Property`
* rename `ol.render.webgl.imagereplay.shader.Default.Locations` to `ol.render.webgl.imagereplay.defaultshader.Locations`
* rename `ol.render.webgl.imagereplay.shader.DefaultFragment` to `ol.render.webgl.imagereplay.defaultshader.Fragment`
* rename `ol.render.webgl.imagereplay.shader.DefaultVertex` to `ol.render.webgl.imagereplay.defaultshader.Vertex`
@@ -28,6 +30,7 @@ A number of internal types have been renamed. This will not affect those who us
* rename `ol.renderer.webgl.tilelayer.shader.Fragment` to `ol.renderer.webgl.tilelayershader.Fragment`
* rename `ol.renderer.webgl.tilelayer.shader.Locations` to `ol.renderer.webgl.tilelayershader.Locations`
* rename `ol.renderer.webgl.tilelayer.shader.Vertex` to `ol.renderer.webgl.tilelayershader.Vertex`
* rename `ol.webgl.WebGLContextEventType` to `ol.webgl.ContextEventType`
* rename `ol.webgl.shader.Fragment` to `ol.webgl.Fragment`
* rename `ol.webgl.shader.Vertex` to `ol.webgl.Vertex`

View File

@@ -1,3 +1,4 @@
goog.require('ol');
goog.require('ol.Feature');
goog.require('ol.Map');
goog.require('ol.View');

View File

@@ -40,16 +40,15 @@ var map = new ol.Map({
});
// generate a GetFeature request
var f = ol.format.ogc.filter;
var featureRequest = new ol.format.WFS().writeGetFeature({
srsName: 'EPSG:3857',
featureNS: 'http://openstreemap.org',
featurePrefix: 'osm',
featureTypes: ['water_areas'],
outputFormat: 'application/json',
filter: f.and(
f.like('name', 'Mississippi*'),
f.equalTo('waterway', 'riverbank')
filter: ol.format.ogc.filter.and(
ol.format.ogc.filter.like('name', 'Mississippi*'),
ol.format.ogc.filter.equalTo('waterway', 'riverbank')
)
});

View File

@@ -1260,7 +1260,7 @@ olx.control.OverviewMapOptions.prototype.view;
* minWidth: (number|undefined),
* render: (function(ol.MapEvent)|undefined),
* target: (Element|undefined),
* units: (ol.control.ScaleLineUnits|string|undefined)}}
* units: (ol.control.ScaleLine.Units|string|undefined)}}
*/
olx.control.ScaleLineOptions;
@@ -1300,7 +1300,7 @@ olx.control.ScaleLineOptions.prototype.target;
/**
* Units. Default is `metric`.
* @type {ol.control.ScaleLineUnits|string|undefined}
* @type {ol.control.ScaleLine.Units|string|undefined}
* @api stable
*/
olx.control.ScaleLineOptions.prototype.units;
@@ -4190,7 +4190,7 @@ olx.source.TileUTFGridOptions.prototype.url;
* reprojectionErrorThreshold: (number|undefined),
* state: (ol.source.State|undefined),
* tileClass: (function(new: ol.ImageTile, ol.TileCoord,
* ol.TileState, string, ?string,
* ol.Tile.State, string, ?string,
* ol.TileLoadFunctionType)|undefined),
* tileGrid: (ol.tilegrid.TileGrid|undefined),
* tileLoadFunction: (ol.TileLoadFunctionType|undefined),
@@ -4275,7 +4275,7 @@ olx.source.TileImageOptions.prototype.state;
/**
* Class used to instantiate image tiles. Default is {@link ol.ImageTile}.
* @type {function(new: ol.ImageTile, ol.TileCoord,
* ol.TileState, string, ?string,
* ol.Tile.State, string, ?string,
* ol.TileLoadFunctionType)|undefined}
* @api
*/
@@ -4359,7 +4359,7 @@ olx.source.TileImageOptions.prototype.wrapX;
* projection: ol.ProjectionLike,
* state: (ol.source.State|undefined),
* tileClass: (function(new: ol.VectorTile, ol.TileCoord,
* ol.TileState, string, ol.format.Feature,
* ol.Tile.State, string, ol.format.Feature,
* ol.TileLoadFunctionType)|undefined),
* tileGrid: (ol.tilegrid.TileGrid|undefined),
* tileLoadFunction: (ol.TileLoadFunctionType|undefined),
@@ -4424,7 +4424,7 @@ olx.source.VectorTileOptions.prototype.state;
/**
* Class used to instantiate image tiles. Default is {@link ol.VectorTile}.
* @type {function(new: ol.VectorTile, ol.TileCoord,
* ol.TileState, string, ol.format.Feature,
* ol.Tile.State, string, ol.format.Feature,
* ol.TileLoadFunctionType)|undefined}
* @api
*/
@@ -5922,7 +5922,7 @@ olx.source.VectorOptions.prototype.wrapX;
* tileLoadFunction: (ol.TileLoadFunctionType|undefined),
* urls: (Array.<string>|undefined),
* tileClass: (function(new: ol.ImageTile, ol.TileCoord,
* ol.TileState, string, ?string,
* ol.Tile.State, string, ?string,
* ol.TileLoadFunctionType)|undefined),
* wrapX: (boolean|undefined)}}
*/
@@ -6017,7 +6017,7 @@ olx.source.WMTSOptions.prototype.style;
/**
* Class used to instantiate image tiles. Default is {@link ol.ImageTile}.
* @type {function(new: ol.ImageTile, ol.TileCoord,
* ol.TileState, string, ?string,
* ol.Tile.State, string, ?string,
* ol.TileLoadFunctionType)|undefined}
* @api
*/

View File

@@ -13,7 +13,6 @@
"postinstall": "closure-util update",
"start": "node tasks/serve.js",
"pretest": "eslint tasks test test_rendering src examples",
"test-node": "mocha test/node",
"test": "node tasks/test.js",
"debug-server": "node tasks/serve-lib.js"
},
@@ -35,7 +34,6 @@
"browserify": "13.1.0",
"closure-util": "1.15.0",
"derequire": "2.0.3",
"eslint-plugin-openlayers-internal": "file:rules",
"fs-extra": "0.30.0",
"glob": "7.0.5",
"handlebars": "4.0.5",
@@ -57,6 +55,7 @@
"debounce": "^1.0.0",
"eslint": "3.2.2",
"eslint-config-openlayers": "5.0.0",
"eslint-plugin-openlayers-internal": "2.1.0",
"expect.js": "0.3.1",
"gaze": "^1.0.0",
"istanbul": "0.4.4",
@@ -98,8 +97,11 @@
],
"no-constant-condition": 0,
"openlayers-internal/no-duplicate-requires": 2,
"openlayers-internal/no-missing-requires": 1,
"openlayers-internal/no-unused-requires": 2,
"openlayers-internal/one-provide": 1,
"openlayers-internal/requires-first": 2,
"openlayers-internal/valid-provide": 2,
"openlayers-internal/valid-requires": 2
}
},

View File

@@ -3,8 +3,11 @@
module.exports = {
rules: {
'no-duplicate-requires': require('./no-duplicate-requires').rule,
'no-missing-requires': require('./no-missing-requires').rule,
'no-unused-requires': require('./no-unused-requires').rule,
'one-provide': require('./one-provide').rule,
'requires-first': require('./requires-first').rule,
'valid-provide': require('./valid-provide').rule,
'valid-requires': require('./valid-requires').rule
}
};

View File

@@ -0,0 +1,90 @@
'use strict';
const util = require('./util');
/**
* Unfortunately fragile RegExp to follow. Here is the logic:
*
* 1. check if a name looks like a const (ol.foo.BOO_HOO must have a "_")
* if so, require the "namespace" (ol.foo)
* 2. check if a name looks like a class (ol.foo.Bar or ol.foo.XYZ)
* if so, require the class (ol.foo.Bar)
* 3. otherwise, lop off the last part of a name and require the rest
* (e.g. ol.foo.bar would require ol.foo)
*/
const CONST_RE = /^(ol(\.[a-z]\w*)*)\.[A-Z]+_([_A-Z])+$/;
const CLASS_RE = /^(ol(\.[a-z]\w*)*\.[A-Z]\w*)(\.\w+)*$/;
exports.rule = {
meta: {
docs: {
description: 'ensure there are goog.require() calls for all used symbols'
},
fixable: 'code'
},
create: function(context) {
const defined = {};
return {
ExpressionStatement: function(statement) {
if (util.isRequireStatement(statement) || util.isProvideStatement(statement)) {
const expression = statement.expression;
const arg = expression.arguments[0];
if (!arg || !arg.value) {
return;
}
defined[arg.value] = true;
}
},
MemberExpression: function(expression) {
const parent = expression.parent;
if (parent.type !== 'MemberExpression') {
const name = util.getName(expression);
if (name && name.startsWith('ol.')) {
// check if the name looks like a const
let match = name.match(CONST_RE);
if (match) {
if (!defined[match[1]]) {
context.report(expression, `Missing goog.require('${match[1]}')`);
}
return;
}
// check if the name looks like a class
match = name.match(CLASS_RE);
if (match) {
const className = match[1];
const parts = className.split('.');
const lastPart = parts[parts.length - 1];
if (lastPart.toUpperCase() === lastPart) {
// unfortunately ambiguous:
// ol.has.WEBGL -> require('ol.has')
// ol.source.XYZ -> require('ol.source.XYZ')
const objectName = parts.slice(0, -1).join('.');
if (!defined[className] && !defined[objectName]) {
context.report(expression, `Missing goog.require('${className}') or goog.require('${objectName}')`);
}
return;
}
if (!defined[className]) {
context.report(expression, `Missing goog.require('${className}')`);
}
return;
}
// otherwise, assume the object should be required
const parts = name.split('.');
parts.pop();
const objectName = parts.join('.');
if (!defined[objectName]) {
context.report(expression, `Missing goog.require('${objectName}')`);
}
}
}
}
};
}
};

View File

@@ -2,25 +2,6 @@
const util = require('./util');
function getName(node) {
if (node.type !== 'MemberExpression') {
return;
}
if (node.property.type !== 'Identifier' || node.property.computed) {
return;
}
let objectName;
if (node.object.type === 'Identifier' && !node.object.computed) {
objectName = node.object.name;
} else if (node.object.type === 'MemberExpression' && !node.object.computed) {
objectName = getName(node.object);
}
if (!objectName) {
return;
}
return `${objectName}.${node.property.name}`;
}
exports.rule = {
meta: {
docs: {
@@ -48,20 +29,15 @@ exports.rule = {
}
const name = arg.value;
const ancestors = context.getAncestors();
const parent = ancestors[ancestors.length - 1];
if (!parent) {
return;
}
requireStatements[name] = statement;
}
},
MemberExpression: function(node) {
const name = getName(node);
const name = util.getName(node);
if (name in requireStatements) {
const requiredAncestor = context.getAncestors().some(ancestorNode => !!requireStatements[getName(ancestorNode)]);
const requiredAncestor = context.getAncestors().some(
ancestorNode => !!requireStatements[util.getName(ancestorNode)]);
if (!requiredAncestor) {
usedNames[name] = true;
}
@@ -73,7 +49,8 @@ exports.rule = {
if (name in requireStatements) {
const ancestors = context.getAncestors();
if (ancestors.length && ancestors[0].type === 'MemberExpression') {
const requiredAncestor = context.getAncestors().some(ancestorNode => !!requireStatements[getName(ancestorNode)]);
const requiredAncestor = ancestors.some(
ancestorNode => !!requireStatements[util.getName(ancestorNode)]);
if (!requiredAncestor) {
usedNames[name] = true;
}

28
rules/one-provide.js Normal file
View File

@@ -0,0 +1,28 @@
'use strict';
const util = require('./util');
exports.rule = {
meta: {
docs: {
description: 'disallow multiple goog.provide() calls'
}
},
create: function(context) {
let hasProvide = false;
return {
ExpressionStatement: function(statement) {
if (util.isProvideStatement(statement)) {
if (hasProvide) {
const name = statement.expression.arguments[0].value;
context.report(statement, `Extra goog.provide('${name}')`);
} else {
hasProvide = true;
}
}
}
};
}
};

View File

@@ -1,6 +1,11 @@
{
"name": "eslint-plugin-openlayers-internal",
"version": "1.0.0",
"version": "2.1.0",
"description": "Custom ESLint rules for the OpenLayers project",
"main": "index.js"
"main": "index.js",
"repository": {
"type": "git",
"url": "git://github.com/openlayers/ol3.git"
},
"license": "BSD-2-Clause"
}

View File

@@ -28,3 +28,22 @@ exports.isRequireExpression = function(node) {
exports.isRequireStatement = function(node) {
return isGoogStatement(node, 'require');
};
var getName = exports.getName = function(node) {
if (node.type !== 'MemberExpression') {
return;
}
if (node.property.type !== 'Identifier' || node.property.computed) {
return;
}
let objectName;
if (node.object.type === 'Identifier' && !node.object.computed) {
objectName = node.object.name;
} else if (node.object.type === 'MemberExpression' && !node.object.computed) {
objectName = getName(node.object);
}
if (!objectName) {
return;
}
return `${objectName}.${node.property.name}`;
};

72
rules/valid-provide.js Normal file
View File

@@ -0,0 +1,72 @@
'use strict';
const path = require('path');
const util = require('./util');
function longestCommonPrefix(path1, path2) {
const parts1 = path.resolve(path1).split(path.sep);
const parts2 = path.resolve(path2).split(path.sep);
const common = [];
for (let i = 0, ii = parts1.length; i < ii; ++i) {
if (parts1[i] === parts2[i]) {
common.push(parts1[i]);
} else {
break;
}
}
return common.join(path.sep);
}
exports.rule = {
meta: {
docs: {
description: 'require the first goog.provide() has an arg named like the file path'
}
},
create: function(context) {
let gotFirst = false;
return {
CallExpression: function(expression) {
if (gotFirst) {
return;
}
if (util.isProvideExpression(expression)) {
gotFirst = true;
const parent = expression.parent;
if (parent.type !== 'ExpressionStatement') {
return context.report(expression, 'Expected goog.provide() to in an expression statement');
}
if (parent.parent.type !== 'Program') {
return context.report(expression, 'Expected goog.provide() to be at the top level');
}
if (expression.arguments.length !== 1) {
return context.report(expression, 'Expected one argument for goog.require()');
}
const arg = expression.arguments[0];
if (arg.type !== 'Literal' || !arg.value || typeof arg.value !== 'string') {
return context.report(expression, 'Expected goog.require() to be called with a string');
}
const filePath = context.getFilename();
const sourceRoot = path.join(longestCommonPrefix(__dirname, filePath), 'src');
const requirePath = path.relative(sourceRoot, filePath);
let ext;
if (path.basename(requirePath) === 'index.js') {
ext = path.sep + 'index.js';
} else {
ext = '.js';
}
const name = arg.value;
const expectedPath = name.split('.').join(path.sep) + ext;
if (expectedPath.toLowerCase() !== requirePath.toLowerCase()) {
return context.report(expression, `Expected goog.provide('${name}') to be like ${requirePath}`);
}
}
}
};
}
};

View File

@@ -13,13 +13,12 @@ exports.rule = {
return {
CallExpression: function(expression) {
if (util.isRequireExpression(expression)) {
const ancestors = context.getAncestors();
const parent = ancestors[ancestors.length - 1];
const parent = expression.parent;
if (parent.type !== 'ExpressionStatement') {
return context.report(expression, 'Expected goog.require() to in an expression statement');
}
if (ancestors.length !== 2) {
if (parent.parent.type !== 'Program') {
return context.report(expression, 'Expected goog.require() to be at the top level');
}

View File

@@ -1,7 +1,7 @@
goog.provide('ol.animation');
goog.require('ol');
goog.require('ol.ViewHint');
goog.require('ol.View');
goog.require('ol.coordinate');
goog.require('ol.easing');
@@ -28,14 +28,14 @@ ol.animation.bounce = function(options) {
function(map, frameState) {
if (frameState.time < start) {
frameState.animate = true;
frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
frameState.viewHints[ol.View.Hint.ANIMATING] += 1;
return true;
} else if (frameState.time < start + duration) {
var delta = easing((frameState.time - start) / duration);
var deltaResolution = resolution - frameState.viewState.resolution;
frameState.animate = true;
frameState.viewState.resolution += delta * deltaResolution;
frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
frameState.viewHints[ol.View.Hint.ANIMATING] += 1;
return true;
} else {
return false;
@@ -67,7 +67,7 @@ ol.animation.pan = function(options) {
function(map, frameState) {
if (frameState.time < start) {
frameState.animate = true;
frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
frameState.viewHints[ol.View.Hint.ANIMATING] += 1;
return true;
} else if (frameState.time < start + duration) {
var delta = 1 - easing((frameState.time - start) / duration);
@@ -76,7 +76,7 @@ ol.animation.pan = function(options) {
frameState.animate = true;
frameState.viewState.center[0] += delta * deltaX;
frameState.viewState.center[1] += delta * deltaY;
frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
frameState.viewHints[ol.View.Hint.ANIMATING] += 1;
return true;
} else {
return false;
@@ -109,7 +109,7 @@ ol.animation.rotate = function(options) {
function(map, frameState) {
if (frameState.time < start) {
frameState.animate = true;
frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
frameState.viewHints[ol.View.Hint.ANIMATING] += 1;
return true;
} else if (frameState.time < start + duration) {
var delta = 1 - easing((frameState.time - start) / duration);
@@ -123,7 +123,7 @@ ol.animation.rotate = function(options) {
ol.coordinate.rotate(center, deltaRotation);
ol.coordinate.add(center, anchor);
}
frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
frameState.viewHints[ol.View.Hint.ANIMATING] += 1;
return true;
} else {
return false;
@@ -153,7 +153,7 @@ ol.animation.zoom = function(options) {
function(map, frameState) {
if (frameState.time < start) {
frameState.animate = true;
frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
frameState.viewHints[ol.View.Hint.ANIMATING] += 1;
return true;
} else if (frameState.time < start + duration) {
var delta = 1 - easing((frameState.time - start) / duration);
@@ -161,7 +161,7 @@ ol.animation.zoom = function(options) {
sourceResolution - frameState.viewState.resolution;
frameState.animate = true;
frameState.viewState.resolution += delta * deltaResolution;
frameState.viewHints[ol.ViewHint.ANIMATING] += 1;
frameState.viewHints[ol.View.Hint.ANIMATING] += 1;
return true;
} else {
return false;

36
src/ol/assertionerror.js Normal file
View File

@@ -0,0 +1,36 @@
goog.provide('ol.AssertionError');
goog.require('ol');
/**
* Error object thrown when an assertion failed. This is an ECMA-262 Error,
* extended with a `code` property.
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error}
* @constructor
* @extends {Error}
* @implements {oli.AssertionError}
* @param {number} code Error code.
*/
ol.AssertionError = function(code) {
/**
* @type {string}
*/
this.message = 'Assertion failed. See ' +
(ol.VERSION ? 'http://openlayers.org/en/' + ol.VERSION.split('-')[0] : '') +
'/doc/errors/#' + code + ' for details.';
/**
* Error code. The meaning of the code can be found on
* {@link http://openlayers.org/en/latest/errors.html} (replace `latest` with
* the version found in the OpenLayers script's header comment if a version
* other than the latest is used).
* @type {number}
* @api
*/
this.code = code;
this.name = 'AssertionError';
};
ol.inherits(ol.AssertionError, Error);

15
src/ol/asserts.js Normal file
View File

@@ -0,0 +1,15 @@
goog.provide('ol.asserts');
goog.require('ol');
goog.require('ol.AssertionError');
/**
* @param {*} assertion Assertion we expected to be truthy.
* @param {number} errorCode Error code.
*/
ol.asserts.assert = function(assertion, errorCode) {
if (!assertion) {
throw new ol.AssertionError(errorCode);
}
};

View File

@@ -159,7 +159,7 @@ ol.color.fromStringInternal_ = function(s) {
if (ol.color.hexColorRe_.exec(s)) { // hex
var n = s.length - 1; // number of hex digits
ol.assert(n == 3 || n == 6, 54); // Hex color should have 3 or 6 digits
ol.asserts.assert(n == 3 || n == 6, 54); // Hex color should have 3 or 6 digits
var d = n == 3 ? 1 : 2; // number of digits per channel
r = parseInt(s.substr(1 + 0 * d, d), 16);
g = parseInt(s.substr(1 + 1 * d, d), 16);
@@ -183,7 +183,7 @@ ol.color.fromStringInternal_ = function(s) {
b = Number(match[3]);
color = ol.color.normalize([r, g, b, 1]);
} else {
ol.assert(false, 14); // Invalid color
ol.asserts.assert(false, 14); // Invalid color
}
return /** @type {ol.Color} */ (color);
};

View File

@@ -1,7 +1,5 @@
goog.provide('ol.control.OverviewMap');
goog.require('ol.events');
goog.require('ol.events.EventType');
goog.require('ol');
goog.require('ol.Collection');
goog.require('ol.Map');
@@ -10,11 +8,13 @@ goog.require('ol.Object');
goog.require('ol.ObjectEventType');
goog.require('ol.Overlay');
goog.require('ol.OverlayPositioning');
goog.require('ol.ViewProperty');
goog.require('ol.View');
goog.require('ol.control.Control');
goog.require('ol.coordinate');
goog.require('ol.css');
goog.require('ol.dom');
goog.require('ol.events');
goog.require('ol.events.EventType');
goog.require('ol.extent');
@@ -211,7 +211,7 @@ ol.control.OverviewMap.prototype.handleMapPropertyChange_ = function(event) {
*/
ol.control.OverviewMap.prototype.bindView_ = function(view) {
ol.events.listen(view,
ol.Object.getChangeEventType(ol.ViewProperty.ROTATION),
ol.Object.getChangeEventType(ol.View.Property.ROTATION),
this.handleRotationChanged_, this);
};
@@ -223,7 +223,7 @@ ol.control.OverviewMap.prototype.bindView_ = function(view) {
*/
ol.control.OverviewMap.prototype.unbindView_ = function(view) {
ol.events.unlisten(view,
ol.Object.getChangeEventType(ol.ViewProperty.ROTATION),
ol.Object.getChangeEventType(ol.View.Property.ROTATION),
this.handleRotationChanged_, this);
};

View File

@@ -1,37 +1,15 @@
goog.provide('ol.control.ScaleLine');
goog.provide('ol.control.ScaleLineUnits');
goog.require('ol.events');
goog.require('ol');
goog.require('ol.Object');
goog.require('ol.asserts');
goog.require('ol.control.Control');
goog.require('ol.css');
goog.require('ol.events');
goog.require('ol.proj.METERS_PER_UNIT');
goog.require('ol.proj.Units');
/**
* @enum {string}
*/
ol.control.ScaleLineProperty = {
UNITS: 'units'
};
/**
* Units for the scale line. Supported values are `'degrees'`, `'imperial'`,
* `'nautical'`, `'metric'`, `'us'`.
* @enum {string}
*/
ol.control.ScaleLineUnits = {
DEGREES: 'degrees',
IMPERIAL: 'imperial',
NAUTICAL: 'nautical',
METRIC: 'metric',
US: 'us'
};
/**
* @classdesc
* A control displaying rough y-axis distances, calculated for the center of the
@@ -107,11 +85,11 @@ ol.control.ScaleLine = function(opt_options) {
});
ol.events.listen(
this, ol.Object.getChangeEventType(ol.control.ScaleLineProperty.UNITS),
this, ol.Object.getChangeEventType(ol.control.ScaleLine.Property.UNITS),
this.handleUnitsChanged_, this);
this.setUnits(/** @type {ol.control.ScaleLineUnits} */ (options.units) ||
ol.control.ScaleLineUnits.METRIC);
this.setUnits(/** @type {ol.control.ScaleLine.Units} */ (options.units) ||
ol.control.ScaleLine.Units.METRIC);
};
ol.inherits(ol.control.ScaleLine, ol.control.Control);
@@ -126,14 +104,14 @@ ol.control.ScaleLine.LEADING_DIGITS = [1, 2, 5];
/**
* Return the units to use in the scale line.
* @return {ol.control.ScaleLineUnits|undefined} The units to use in the scale
* @return {ol.control.ScaleLine.Units|undefined} The units to use in the scale
* line.
* @observable
* @api stable
*/
ol.control.ScaleLine.prototype.getUnits = function() {
return /** @type {ol.control.ScaleLineUnits|undefined} */ (
this.get(ol.control.ScaleLineProperty.UNITS));
return /** @type {ol.control.ScaleLine.Units|undefined} */ (
this.get(ol.control.ScaleLine.Property.UNITS));
};
@@ -164,12 +142,12 @@ ol.control.ScaleLine.prototype.handleUnitsChanged_ = function() {
/**
* Set the units to use in the scale line.
* @param {ol.control.ScaleLineUnits} units The units to use in the scale line.
* @param {ol.control.ScaleLine.Units} units The units to use in the scale line.
* @observable
* @api stable
*/
ol.control.ScaleLine.prototype.setUnits = function(units) {
this.set(ol.control.ScaleLineProperty.UNITS, units);
this.set(ol.control.ScaleLine.Property.UNITS, units);
};
@@ -197,7 +175,7 @@ ol.control.ScaleLine.prototype.updateElement_ = function() {
var nominalCount = this.minWidth_ * pointResolution;
var suffix = '';
var units = this.getUnits();
if (units == ol.control.ScaleLineUnits.DEGREES) {
if (units == ol.control.ScaleLine.Units.DEGREES) {
var metersPerDegree = ol.proj.METERS_PER_UNIT[ol.proj.Units.DEGREES];
pointResolution /= metersPerDegree;
if (nominalCount < metersPerDegree / 60) {
@@ -209,7 +187,7 @@ ol.control.ScaleLine.prototype.updateElement_ = function() {
} else {
suffix = '\u00b0'; // degrees
}
} else if (units == ol.control.ScaleLineUnits.IMPERIAL) {
} else if (units == ol.control.ScaleLine.Units.IMPERIAL) {
if (nominalCount < 0.9144) {
suffix = 'in';
pointResolution /= 0.0254;
@@ -220,10 +198,10 @@ ol.control.ScaleLine.prototype.updateElement_ = function() {
suffix = 'mi';
pointResolution /= 1609.344;
}
} else if (units == ol.control.ScaleLineUnits.NAUTICAL) {
} else if (units == ol.control.ScaleLine.Units.NAUTICAL) {
pointResolution /= 1852;
suffix = 'nm';
} else if (units == ol.control.ScaleLineUnits.METRIC) {
} else if (units == ol.control.ScaleLine.Units.METRIC) {
if (nominalCount < 1) {
suffix = 'mm';
pointResolution *= 1000;
@@ -233,7 +211,7 @@ ol.control.ScaleLine.prototype.updateElement_ = function() {
suffix = 'km';
pointResolution /= 1000;
}
} else if (units == ol.control.ScaleLineUnits.US) {
} else if (units == ol.control.ScaleLine.Units.US) {
if (nominalCount < 0.9144) {
suffix = 'in';
pointResolution *= 39.37;
@@ -245,7 +223,7 @@ ol.control.ScaleLine.prototype.updateElement_ = function() {
pointResolution /= 1609.3472;
}
} else {
ol.assert(false, 33); // Invalid units
ol.asserts.assert(false, 33); // Invalid units
}
var i = 3 * Math.floor(
@@ -282,3 +260,26 @@ ol.control.ScaleLine.prototype.updateElement_ = function() {
}
};
/**
* @enum {string}
* @api
*/
ol.control.ScaleLine.Property = {
UNITS: 'units'
};
/**
* Units for the scale line. Supported values are `'degrees'`, `'imperial'`,
* `'nautical'`, `'metric'`, `'us'`.
* @enum {string}
*/
ol.control.ScaleLine.Units = {
DEGREES: 'degrees',
IMPERIAL: 'imperial',
NAUTICAL: 'nautical',
METRIC: 'metric',
US: 'us'
};

View File

@@ -2,16 +2,16 @@
goog.provide('ol.control.ZoomSlider');
goog.require('ol.events');
goog.require('ol.events.Event');
goog.require('ol.events.EventType');
goog.require('ol.pointer.PointerEventHandler');
goog.require('ol.ViewHint');
goog.require('ol.View');
goog.require('ol.animation');
goog.require('ol.control.Control');
goog.require('ol.css');
goog.require('ol.easing');
goog.require('ol.events');
goog.require('ol.events.Event');
goog.require('ol.events.EventType');
goog.require('ol.math');
goog.require('ol.pointer.PointerEventHandler');
/**
@@ -255,7 +255,7 @@ ol.control.ZoomSlider.prototype.handleContainerClick_ = function(event) {
ol.control.ZoomSlider.prototype.handleDraggerStart_ = function(event) {
if (!this.dragging_ &&
event.originalEvent.target === this.element.firstElementChild) {
this.getMap().getView().setHint(ol.ViewHint.INTERACTING, 1);
this.getMap().getView().setHint(ol.View.Hint.INTERACTING, 1);
this.previousX_ = event.clientX;
this.previousY_ = event.clientY;
this.dragging_ = true;
@@ -306,7 +306,7 @@ ol.control.ZoomSlider.prototype.handleDraggerEnd_ = function(event) {
if (this.dragging_) {
var map = this.getMap();
var view = map.getView();
view.setHint(ol.ViewHint.INTERACTING, -1);
view.setHint(ol.View.Hint.INTERACTING, -1);
map.beforeRender(ol.animation.zoom({
resolution: /** @type {number} */ (this.currentResolution_),
duration: this.duration_,

View File

@@ -0,0 +1,35 @@
goog.provide('ol.events.EventType');
/**
* @enum {string}
* @const
*/
ol.events.EventType = {
/**
* Generic change event. Triggered when the revision counter is increased.
* @event ol.events.Event#change
* @api
*/
CHANGE: 'change',
CLICK: 'click',
DBLCLICK: 'dblclick',
DRAGENTER: 'dragenter',
DRAGOVER: 'dragover',
DROP: 'drop',
ERROR: 'error',
KEYDOWN: 'keydown',
KEYPRESS: 'keypress',
LOAD: 'load',
MOUSEDOWN: 'mousedown',
MOUSEMOVE: 'mousemove',
MOUSEOUT: 'mouseout',
MOUSEUP: 'mouseup',
MOUSEWHEEL: 'mousewheel',
MSPOINTERDOWN: 'mspointerdown',
RESIZE: 'resize',
TOUCHSTART: 'touchstart',
TOUCHMOVE: 'touchmove',
TOUCHEND: 'touchend',
WHEEL: 'wheel'
};

View File

@@ -1,57 +1,8 @@
goog.provide('ol.events');
goog.provide('ol.events.EventType');
goog.provide('ol.events.KeyCode');
goog.require('ol.obj');
/**
* @enum {string}
* @const
*/
ol.events.EventType = {
/**
* Generic change event. Triggered when the revision counter is increased.
* @event ol.events.Event#change
* @api
*/
CHANGE: 'change',
CLICK: 'click',
DBLCLICK: 'dblclick',
DRAGENTER: 'dragenter',
DRAGOVER: 'dragover',
DROP: 'drop',
ERROR: 'error',
KEYDOWN: 'keydown',
KEYPRESS: 'keypress',
LOAD: 'load',
MOUSEDOWN: 'mousedown',
MOUSEMOVE: 'mousemove',
MOUSEOUT: 'mouseout',
MOUSEUP: 'mouseup',
MOUSEWHEEL: 'mousewheel',
MSPOINTERDOWN: 'mspointerdown',
RESIZE: 'resize',
TOUCHSTART: 'touchstart',
TOUCHMOVE: 'touchmove',
TOUCHEND: 'touchend',
WHEEL: 'wheel'
};
/**
* @enum {number}
* @const
*/
ol.events.KeyCode = {
LEFT: 37,
UP: 38,
RIGHT: 39,
DOWN: 40
};
/**
* @param {ol.EventsKey} listenerObj Listener object.
* @return {ol.EventsListenerFunctionType} Bound listener.

12
src/ol/events/keycode.js Normal file
View File

@@ -0,0 +1,12 @@
goog.provide('ol.events.KeyCode');
/**
* @enum {number}
* @const
*/
ol.events.KeyCode = {
LEFT: 37,
UP: 38,
RIGHT: 39,
DOWN: 40
};

View File

@@ -526,7 +526,7 @@ ol.extent.getCorner = function(extent, corner) {
} else if (corner === ol.extent.Corner.TOP_RIGHT) {
coordinate = ol.extent.getTopRight(extent);
} else {
ol.assert(false, 13); // Invalid corner
ol.asserts.assert(false, 13); // Invalid corner
}
return /** @type {!ol.Coordinate} */ (coordinate);
};

View File

@@ -301,7 +301,7 @@ ol.Feature.createStyleFunction = function(obj) {
if (Array.isArray(obj)) {
styles = obj;
} else {
ol.assert(obj instanceof ol.style.Style,
ol.asserts.assert(obj instanceof ol.style.Style,
41); // Expected an `ol.style.Style` or an array of `ol.style.Style`
styles = [obj];
}

View File

@@ -1,6 +1,6 @@
goog.provide('ol.featureloader');
goog.require('ol.TileState');
goog.require('ol.Tile');
goog.require('ol.format.FormatType');
goog.require('ol.xml');
@@ -93,7 +93,7 @@ ol.featureloader.tile = function(url, format) {
* @this {ol.VectorTile}
*/
function() {
this.setState(ol.TileState.ERROR);
this.setState(ol.Tile.State.ERROR);
});
};

View File

@@ -282,7 +282,7 @@ ol.format.EsriJSON.writePointGeometry_ = function(geometry, opt_options) {
y: coordinates[1]
});
} else {
ol.assert(false, 34); // Invalid geometry layout
ol.asserts.assert(false, 34); // Invalid geometry layout
}
return /** @type {EsriJSONGeometry} */ (esriJSON);
};

View File

@@ -422,7 +422,7 @@ ol.format.GeoJSON.prototype.readFeaturesFromObject = function(
opt_options));
}
} else {
ol.assert(false, 35); // Unknown GeoJSON object type
ol.asserts.assert(false, 35); // Unknown GeoJSON object type
}
return /** Array.<ol.Feature> */ (features);
};
@@ -478,7 +478,7 @@ ol.format.GeoJSON.prototype.readProjectionFromObject = function(object) {
// is fixed and widely deployed.
projection = ol.proj.get('EPSG:' + crs.properties.code);
} else {
ol.assert(false, 36); // Unknown SRS type
ol.asserts.assert(false, 36); // Unknown SRS type
}
} else {
projection = this.defaultDataProjection;

View File

@@ -981,7 +981,7 @@ ol.format.KML.readMultiGeometry_ = function(node, objectStack) {
} else if (type == ol.geom.GeometryType.GEOMETRY_COLLECTION) {
multiGeometry = new ol.geom.GeometryCollection(geometries);
} else {
ol.assert(false, 37); // Unknown geometry type found
ol.asserts.assert(false, 37); // Unknown geometry type found
}
} else {
multiGeometry = new ol.geom.GeometryCollection(geometries);
@@ -1217,7 +1217,7 @@ ol.format.KML.PlacemarkStyleMapParser_ = function(node, objectStack) {
} else if (typeof styleMapValue === 'string') {
placemarkObject['styleUrl'] = styleMapValue;
} else {
ol.assert(false, 38); // `styleMapValue` has an unknown type
ol.asserts.assert(false, 38); // `styleMapValue` has an unknown type
}
};
@@ -2067,7 +2067,7 @@ ol.format.KML.writeCoordinatesTextNode_ = function(node, coordinates, objectStac
layout == ol.geom.GeometryLayout.XYZM) {
dimension = 3;
} else {
ol.assert(false, 34); // Invalid geometry layout
ol.asserts.assert(false, 34); // Invalid geometry layout
}
var d, i;
@@ -2259,7 +2259,7 @@ ol.format.KML.writeMultiGeometry_ = function(node, geometry, objectStack) {
(/** @type {ol.geom.MultiPolygon} */ (geometry)).getPolygons();
factory = ol.format.KML.POLYGON_NODE_FACTORY_;
} else {
ol.assert(false, 39); // Unknown geometry type
ol.asserts.assert(false, 39); // Unknown geometry type
}
ol.xml.pushSerializeAndPop(context,
ol.format.KML.MULTI_GEOMETRY_SERIALIZERS_, factory,

View File

@@ -1,745 +0,0 @@
goog.provide('ol.format.ogc.filter');
goog.provide('ol.format.ogc.filter.Filter');
goog.provide('ol.format.ogc.filter.Logical');
goog.provide('ol.format.ogc.filter.LogicalBinary');
goog.provide('ol.format.ogc.filter.And');
goog.provide('ol.format.ogc.filter.Or');
goog.provide('ol.format.ogc.filter.Not');
goog.provide('ol.format.ogc.filter.Bbox');
goog.provide('ol.format.ogc.filter.Intersects');
goog.provide('ol.format.ogc.filter.Within');
goog.provide('ol.format.ogc.filter.Comparison');
goog.provide('ol.format.ogc.filter.ComparisonBinary');
goog.provide('ol.format.ogc.filter.EqualTo');
goog.provide('ol.format.ogc.filter.NotEqualTo');
goog.provide('ol.format.ogc.filter.LessThan');
goog.provide('ol.format.ogc.filter.LessThanOrEqualTo');
goog.provide('ol.format.ogc.filter.GreaterThan');
goog.provide('ol.format.ogc.filter.GreaterThanOrEqualTo');
goog.provide('ol.format.ogc.filter.IsNull');
goog.provide('ol.format.ogc.filter.IsBetween');
goog.provide('ol.format.ogc.filter.IsLike');
/**
* Create a logical `<And>` operator between two filter conditions.
*
* @param {!ol.format.ogc.filter.Filter} conditionA First filter condition.
* @param {!ol.format.ogc.filter.Filter} conditionB Second filter condition.
* @returns {!ol.format.ogc.filter.And} `<And>` operator.
* @api
*/
ol.format.ogc.filter.and = function(conditionA, conditionB) {
return new ol.format.ogc.filter.And(conditionA, conditionB);
};
/**
* Create a logical `<Or>` operator between two filter conditions.
*
* @param {!ol.format.ogc.filter.Filter} conditionA First filter condition.
* @param {!ol.format.ogc.filter.Filter} conditionB Second filter condition.
* @returns {!ol.format.ogc.filter.Or} `<Or>` operator.
* @api
*/
ol.format.ogc.filter.or = function(conditionA, conditionB) {
return new ol.format.ogc.filter.Or(conditionA, conditionB);
};
/**
* Represents a logical `<Not>` operator for a filter condition.
*
* @param {!ol.format.ogc.filter.Filter} condition Filter condition.
* @returns {!ol.format.ogc.filter.Not} `<Not>` operator.
* @api
*/
ol.format.ogc.filter.not = function(condition) {
return new ol.format.ogc.filter.Not(condition);
};
/**
* Create a `<BBOX>` operator to test whether a geometry-valued property
* intersects a fixed bounding box
*
* @param {!string} geometryName Geometry name to use.
* @param {!ol.Extent} extent Extent.
* @param {string=} opt_srsName SRS name. No srsName attribute will be
* set on geometries when this is not provided.
* @returns {!ol.format.ogc.filter.Bbox} `<BBOX>` operator.
* @api
*/
ol.format.ogc.filter.bbox = function(geometryName, extent, opt_srsName) {
return new ol.format.ogc.filter.Bbox(geometryName, extent, opt_srsName);
};
/**
* Create a `<Intersects>` operator to test whether a geometry-valued property
* intersects a given geometry.
*
* @param {!string} geometryName Geometry name to use.
* @param {!ol.geom.Geometry} geometry Geometry.
* @param {string=} opt_srsName SRS name. No srsName attribute will be
* set on geometries when this is not provided.
* @returns {!ol.format.ogc.filter.Intersects} `<Intersects>` operator.
* @api
*/
ol.format.ogc.filter.intersects = function(geometryName, geometry, opt_srsName) {
return new ol.format.ogc.filter.Intersects(geometryName, geometry, opt_srsName);
};
/**
* Create a `<Within>` operator to test whether a geometry-valued property
* is within a given geometry.
*
* @param {!string} geometryName Geometry name to use.
* @param {!ol.geom.Geometry} geometry Geometry.
* @param {string=} opt_srsName SRS name. No srsName attribute will be
* set on geometries when this is not provided.
* @returns {!ol.format.ogc.filter.Within} `<Within>` operator.
* @api
*/
ol.format.ogc.filter.within = function(geometryName, geometry, opt_srsName) {
return new ol.format.ogc.filter.Within(geometryName, geometry, opt_srsName);
};
/**
* Creates a `<PropertyIsEqualTo>` comparison operator.
*
* @param {!string} propertyName Name of the context property to compare.
* @param {!(string|number)} expression The value to compare.
* @param {boolean=} opt_matchCase Case-sensitive?
* @returns {!ol.format.ogc.filter.EqualTo} `<PropertyIsEqualTo>` operator.
* @api
*/
ol.format.ogc.filter.equalTo = function(propertyName, expression, opt_matchCase) {
return new ol.format.ogc.filter.EqualTo(propertyName, expression, opt_matchCase);
};
/**
* Creates a `<PropertyIsNotEqualTo>` comparison operator.
*
* @param {!string} propertyName Name of the context property to compare.
* @param {!(string|number)} expression The value to compare.
* @param {boolean=} opt_matchCase Case-sensitive?
* @returns {!ol.format.ogc.filter.NotEqualTo} `<PropertyIsNotEqualTo>` operator.
* @api
*/
ol.format.ogc.filter.notEqualTo = function(propertyName, expression, opt_matchCase) {
return new ol.format.ogc.filter.NotEqualTo(propertyName, expression, opt_matchCase);
};
/**
* Creates a `<PropertyIsLessThan>` comparison operator.
*
* @param {!string} propertyName Name of the context property to compare.
* @param {!number} expression The value to compare.
* @returns {!ol.format.ogc.filter.LessThan} `<PropertyIsLessThan>` operator.
* @api
*/
ol.format.ogc.filter.lessThan = function(propertyName, expression) {
return new ol.format.ogc.filter.LessThan(propertyName, expression);
};
/**
* Creates a `<PropertyIsLessThanOrEqualTo>` comparison operator.
*
* @param {!string} propertyName Name of the context property to compare.
* @param {!number} expression The value to compare.
* @returns {!ol.format.ogc.filter.LessThanOrEqualTo} `<PropertyIsLessThanOrEqualTo>` operator.
* @api
*/
ol.format.ogc.filter.lessThanOrEqualTo = function(propertyName, expression) {
return new ol.format.ogc.filter.LessThanOrEqualTo(propertyName, expression);
};
/**
* Creates a `<PropertyIsGreaterThan>` comparison operator.
*
* @param {!string} propertyName Name of the context property to compare.
* @param {!number} expression The value to compare.
* @returns {!ol.format.ogc.filter.GreaterThan} `<PropertyIsGreaterThan>` operator.
* @api
*/
ol.format.ogc.filter.greaterThan = function(propertyName, expression) {
return new ol.format.ogc.filter.GreaterThan(propertyName, expression);
};
/**
* Creates a `<PropertyIsGreaterThanOrEqualTo>` comparison operator.
*
* @param {!string} propertyName Name of the context property to compare.
* @param {!number} expression The value to compare.
* @returns {!ol.format.ogc.filter.GreaterThanOrEqualTo} `<PropertyIsGreaterThanOrEqualTo>` operator.
* @api
*/
ol.format.ogc.filter.greaterThanOrEqualTo = function(propertyName, expression) {
return new ol.format.ogc.filter.GreaterThanOrEqualTo(propertyName, expression);
};
/**
* Creates a `<PropertyIsNull>` comparison operator to test whether a property value
* is null.
*
* @param {!string} propertyName Name of the context property to compare.
* @returns {!ol.format.ogc.filter.IsNull} `<PropertyIsNull>` operator.
* @api
*/
ol.format.ogc.filter.isNull = function(propertyName) {
return new ol.format.ogc.filter.IsNull(propertyName);
};
/**
* Creates a `<PropertyIsBetween>` comparison operator to test whether an expression
* value lies within a range given by a lower and upper bound (inclusive).
*
* @param {!string} propertyName Name of the context property to compare.
* @param {!number} lowerBoundary The lower bound of the range.
* @param {!number} upperBoundary The upper bound of the range.
* @returns {!ol.format.ogc.filter.IsBetween} `<PropertyIsBetween>` operator.
* @api
*/
ol.format.ogc.filter.between = function(propertyName, lowerBoundary, upperBoundary) {
return new ol.format.ogc.filter.IsBetween(propertyName, lowerBoundary, upperBoundary);
};
/**
* Represents a `<PropertyIsLike>` comparison operator that matches a string property
* value against a text pattern.
*
* @param {!string} propertyName Name of the context property to compare.
* @param {!string} pattern Text pattern.
* @param {string=} opt_wildCard Pattern character which matches any sequence of
* zero or more string characters. Default is '*'.
* @param {string=} opt_singleChar pattern character which matches any single
* string character. Default is '.'.
* @param {string=} opt_escapeChar Escape character which can be used to escape
* the pattern characters. Default is '!'.
* @param {boolean=} opt_matchCase Case-sensitive?
* @returns {!ol.format.ogc.filter.IsLike} `<PropertyIsLike>` operator.
* @api
*/
ol.format.ogc.filter.like = function(propertyName, pattern,
opt_wildCard, opt_singleChar, opt_escapeChar, opt_matchCase) {
return new ol.format.ogc.filter.IsLike(propertyName, pattern,
opt_wildCard, opt_singleChar, opt_escapeChar, opt_matchCase);
};
/**
* @classdesc
* Abstract class; normally only used for creating subclasses and not instantiated in apps.
* Base class for WFS GetFeature filters.
*
* @constructor
* @param {!string} tagName The XML tag name for this filter.
* @struct
* @api
*/
ol.format.ogc.filter.Filter = function(tagName) {
/**
* @private
* @type {!string}
*/
this.tagName_ = tagName;
};
/**
* The XML tag name for a filter.
* @returns {!string} Name.
*/
ol.format.ogc.filter.Filter.prototype.getTagName = function() {
return this.tagName_;
};
// Logical filters
/**
* @classdesc
* Abstract class; normally only used for creating subclasses and not instantiated in apps.
* Base class for WFS GetFeature logical filters.
*
* @constructor
* @param {!string} tagName The XML tag name for this filter.
* @extends {ol.format.ogc.filter.Filter}
*/
ol.format.ogc.filter.Logical = function(tagName) {
ol.format.ogc.filter.Filter.call(this, tagName);
};
ol.inherits(ol.format.ogc.filter.Logical, ol.format.ogc.filter.Filter);
/**
* @classdesc
* Abstract class; normally only used for creating subclasses and not instantiated in apps.
* Base class for WFS GetFeature binary logical filters.
*
* @constructor
* @param {!string} tagName The XML tag name for this filter.
* @param {!ol.format.ogc.filter.Filter} conditionA First filter condition.
* @param {!ol.format.ogc.filter.Filter} conditionB Second filter condition.
* @extends {ol.format.ogc.filter.Logical}
*/
ol.format.ogc.filter.LogicalBinary = function(tagName, conditionA, conditionB) {
ol.format.ogc.filter.Logical.call(this, tagName);
/**
* @public
* @type {!ol.format.ogc.filter.Filter}
*/
this.conditionA = conditionA;
/**
* @public
* @type {!ol.format.ogc.filter.Filter}
*/
this.conditionB = conditionB;
};
ol.inherits(ol.format.ogc.filter.LogicalBinary, ol.format.ogc.filter.Logical);
/**
* @classdesc
* Represents a logical `<And>` operator between two filter conditions.
*
* @constructor
* @param {!ol.format.ogc.filter.Filter} conditionA First filter condition.
* @param {!ol.format.ogc.filter.Filter} conditionB Second filter condition.
* @extends {ol.format.ogc.filter.LogicalBinary}
* @api
*/
ol.format.ogc.filter.And = function(conditionA, conditionB) {
ol.format.ogc.filter.LogicalBinary.call(this, 'And', conditionA, conditionB);
};
ol.inherits(ol.format.ogc.filter.And, ol.format.ogc.filter.LogicalBinary);
/**
* @classdesc
* Represents a logical `<Or>` operator between two filter conditions.
*
* @constructor
* @param {!ol.format.ogc.filter.Filter} conditionA First filter condition.
* @param {!ol.format.ogc.filter.Filter} conditionB Second filter condition.
* @extends {ol.format.ogc.filter.LogicalBinary}
* @api
*/
ol.format.ogc.filter.Or = function(conditionA, conditionB) {
ol.format.ogc.filter.LogicalBinary.call(this, 'Or', conditionA, conditionB);
};
ol.inherits(ol.format.ogc.filter.Or, ol.format.ogc.filter.LogicalBinary);
/**
* @classdesc
* Represents a logical `<Not>` operator for a filter condition.
*
* @constructor
* @param {!ol.format.ogc.filter.Filter} condition Filter condition.
* @extends {ol.format.ogc.filter.Logical}
* @api
*/
ol.format.ogc.filter.Not = function(condition) {
ol.format.ogc.filter.Logical.call(this, 'Not');
/**
* @public
* @type {!ol.format.ogc.filter.Filter}
*/
this.condition = condition;
};
ol.inherits(ol.format.ogc.filter.Not, ol.format.ogc.filter.Logical);
// Spatial filters
/**
* @classdesc
* Represents a `<BBOX>` operator to test whether a geometry-valued property
* intersects a fixed bounding box
*
* @constructor
* @param {!string} geometryName Geometry name to use.
* @param {!ol.Extent} extent Extent.
* @param {string=} opt_srsName SRS name. No srsName attribute will be
* set on geometries when this is not provided.
* @extends {ol.format.ogc.filter.Filter}
* @api
*/
ol.format.ogc.filter.Bbox = function(geometryName, extent, opt_srsName) {
ol.format.ogc.filter.Filter.call(this, 'BBOX');
/**
* @public
* @type {!string}
*/
this.geometryName = geometryName;
/**
* @public
* @type {ol.Extent}
*/
this.extent = extent;
/**
* @public
* @type {string|undefined}
*/
this.srsName = opt_srsName;
};
ol.inherits(ol.format.ogc.filter.Bbox, ol.format.ogc.filter.Filter);
/**
* @classdesc
* Represents a spatial operator to test whether a geometry-valued property
* relates to a given geometry.
*
* @constructor
* @param {!string} tagName The XML tag name for this filter.
* @param {!string} geometryName Geometry name to use.
* @param {!ol.geom.Geometry} geometry Geometry.
* @param {string=} opt_srsName SRS name. No srsName attribute will be
* set on geometries when this is not provided.
* @extends {ol.format.ogc.filter.Filter}
* @api
*/
ol.format.ogc.filter.Spatial = function(tagName, geometryName, geometry, opt_srsName) {
ol.format.ogc.filter.Filter.call(this, tagName);
/**
* @public
* @type {!string}
*/
this.geometryName = geometryName || 'the_geom';
/**
* @public
* @type {ol.geom.Geometry}
*/
this.geometry = geometry;
/**
* @public
* @type {string|undefined}
*/
this.srsName = opt_srsName;
};
ol.inherits(ol.format.ogc.filter.Spatial, ol.format.ogc.filter.Filter);
/**
* @classdesc
* Represents a `<Intersects>` operator to test whether a geometry-valued property
* intersects a given geometry.
*
* @constructor
* @param {!string} geometryName Geometry name to use.
* @param {!ol.geom.Geometry} geometry Geometry.
* @param {string=} opt_srsName SRS name. No srsName attribute will be
* set on geometries when this is not provided.
* @extends {ol.format.ogc.filter.Spatial}
* @api
*/
ol.format.ogc.filter.Intersects = function(geometryName, geometry, opt_srsName) {
ol.format.ogc.filter.Spatial.call(this, 'Intersects', geometryName, geometry, opt_srsName);
};
ol.inherits(ol.format.ogc.filter.Intersects, ol.format.ogc.filter.Spatial);
/**
* @classdesc
* Represents a `<Within>` operator to test whether a geometry-valued property
* is within a given geometry.
*
* @constructor
* @param {!string} geometryName Geometry name to use.
* @param {!ol.geom.Geometry} geometry Geometry.
* @param {string=} opt_srsName SRS name. No srsName attribute will be
* set on geometries when this is not provided.
* @extends {ol.format.ogc.filter.Spatial}
* @api
*/
ol.format.ogc.filter.Within = function(geometryName, geometry, opt_srsName) {
ol.format.ogc.filter.Spatial.call(this, 'Within', geometryName, geometry, opt_srsName);
};
ol.inherits(ol.format.ogc.filter.Within, ol.format.ogc.filter.Spatial);
// Property comparison filters
/**
* @classdesc
* Abstract class; normally only used for creating subclasses and not instantiated in apps.
* Base class for WFS GetFeature property comparison filters.
*
* @constructor
* @param {!string} tagName The XML tag name for this filter.
* @param {!string} propertyName Name of the context property to compare.
* @extends {ol.format.ogc.filter.Filter}
* @api
*/
ol.format.ogc.filter.Comparison = function(tagName, propertyName) {
ol.format.ogc.filter.Filter.call(this, tagName);
/**
* @public
* @type {!string}
*/
this.propertyName = propertyName;
};
ol.inherits(ol.format.ogc.filter.Comparison, ol.format.ogc.filter.Filter);
/**
* @classdesc
* Abstract class; normally only used for creating subclasses and not instantiated in apps.
* Base class for WFS GetFeature property binary comparison filters.
*
* @constructor
* @param {!string} tagName The XML tag name for this filter.
* @param {!string} propertyName Name of the context property to compare.
* @param {!(string|number)} expression The value to compare.
* @param {boolean=} opt_matchCase Case-sensitive?
* @extends {ol.format.ogc.filter.Comparison}
* @api
*/
ol.format.ogc.filter.ComparisonBinary = function(
tagName, propertyName, expression, opt_matchCase) {
ol.format.ogc.filter.Comparison.call(this, tagName, propertyName);
/**
* @public
* @type {!(string|number)}
*/
this.expression = expression;
/**
* @public
* @type {boolean|undefined}
*/
this.matchCase = opt_matchCase;
};
ol.inherits(ol.format.ogc.filter.ComparisonBinary, ol.format.ogc.filter.Comparison);
/**
* @classdesc
* Represents a `<PropertyIsEqualTo>` comparison operator.
*
* @constructor
* @param {!string} propertyName Name of the context property to compare.
* @param {!(string|number)} expression The value to compare.
* @param {boolean=} opt_matchCase Case-sensitive?
* @extends {ol.format.ogc.filter.ComparisonBinary}
* @api
*/
ol.format.ogc.filter.EqualTo = function(propertyName, expression, opt_matchCase) {
ol.format.ogc.filter.ComparisonBinary.call(this, 'PropertyIsEqualTo', propertyName, expression, opt_matchCase);
};
ol.inherits(ol.format.ogc.filter.EqualTo, ol.format.ogc.filter.ComparisonBinary);
/**
* @classdesc
* Represents a `<PropertyIsNotEqualTo>` comparison operator.
*
* @constructor
* @param {!string} propertyName Name of the context property to compare.
* @param {!(string|number)} expression The value to compare.
* @param {boolean=} opt_matchCase Case-sensitive?
* @extends {ol.format.ogc.filter.ComparisonBinary}
* @api
*/
ol.format.ogc.filter.NotEqualTo = function(propertyName, expression, opt_matchCase) {
ol.format.ogc.filter.ComparisonBinary.call(this, 'PropertyIsNotEqualTo', propertyName, expression, opt_matchCase);
};
ol.inherits(ol.format.ogc.filter.NotEqualTo, ol.format.ogc.filter.ComparisonBinary);
/**
* @classdesc
* Represents a `<PropertyIsLessThan>` comparison operator.
*
* @constructor
* @param {!string} propertyName Name of the context property to compare.
* @param {!number} expression The value to compare.
* @extends {ol.format.ogc.filter.ComparisonBinary}
* @api
*/
ol.format.ogc.filter.LessThan = function(propertyName, expression) {
ol.format.ogc.filter.ComparisonBinary.call(this, 'PropertyIsLessThan', propertyName, expression);
};
ol.inherits(ol.format.ogc.filter.LessThan, ol.format.ogc.filter.ComparisonBinary);
/**
* @classdesc
* Represents a `<PropertyIsLessThanOrEqualTo>` comparison operator.
*
* @constructor
* @param {!string} propertyName Name of the context property to compare.
* @param {!number} expression The value to compare.
* @extends {ol.format.ogc.filter.ComparisonBinary}
* @api
*/
ol.format.ogc.filter.LessThanOrEqualTo = function(propertyName, expression) {
ol.format.ogc.filter.ComparisonBinary.call(this, 'PropertyIsLessThanOrEqualTo', propertyName, expression);
};
ol.inherits(ol.format.ogc.filter.LessThanOrEqualTo, ol.format.ogc.filter.ComparisonBinary);
/**
* @classdesc
* Represents a `<PropertyIsGreaterThan>` comparison operator.
*
* @constructor
* @param {!string} propertyName Name of the context property to compare.
* @param {!number} expression The value to compare.
* @extends {ol.format.ogc.filter.ComparisonBinary}
* @api
*/
ol.format.ogc.filter.GreaterThan = function(propertyName, expression) {
ol.format.ogc.filter.ComparisonBinary.call(this, 'PropertyIsGreaterThan', propertyName, expression);
};
ol.inherits(ol.format.ogc.filter.GreaterThan, ol.format.ogc.filter.ComparisonBinary);
/**
* @classdesc
* Represents a `<PropertyIsGreaterThanOrEqualTo>` comparison operator.
*
* @constructor
* @param {!string} propertyName Name of the context property to compare.
* @param {!number} expression The value to compare.
* @extends {ol.format.ogc.filter.ComparisonBinary}
* @api
*/
ol.format.ogc.filter.GreaterThanOrEqualTo = function(propertyName, expression) {
ol.format.ogc.filter.ComparisonBinary.call(this, 'PropertyIsGreaterThanOrEqualTo', propertyName, expression);
};
ol.inherits(ol.format.ogc.filter.GreaterThanOrEqualTo, ol.format.ogc.filter.ComparisonBinary);
/**
* @classdesc
* Represents a `<PropertyIsNull>` comparison operator.
*
* @constructor
* @param {!string} propertyName Name of the context property to compare.
* @extends {ol.format.ogc.filter.Comparison}
* @api
*/
ol.format.ogc.filter.IsNull = function(propertyName) {
ol.format.ogc.filter.Comparison.call(this, 'PropertyIsNull', propertyName);
};
ol.inherits(ol.format.ogc.filter.IsNull, ol.format.ogc.filter.Comparison);
/**
* @classdesc
* Represents a `<PropertyIsBetween>` comparison operator.
*
* @constructor
* @param {!string} propertyName Name of the context property to compare.
* @param {!number} lowerBoundary The lower bound of the range.
* @param {!number} upperBoundary The upper bound of the range.
* @extends {ol.format.ogc.filter.Comparison}
* @api
*/
ol.format.ogc.filter.IsBetween = function(propertyName, lowerBoundary, upperBoundary) {
ol.format.ogc.filter.Comparison.call(this, 'PropertyIsBetween', propertyName);
/**
* @public
* @type {!number}
*/
this.lowerBoundary = lowerBoundary;
/**
* @public
* @type {!number}
*/
this.upperBoundary = upperBoundary;
};
ol.inherits(ol.format.ogc.filter.IsBetween, ol.format.ogc.filter.Comparison);
/**
* @classdesc
* Represents a `<PropertyIsLike>` comparison operator.
*
* @constructor
* @param {!string} propertyName Name of the context property to compare.
* @param {!string} pattern Text pattern.
* @param {string=} opt_wildCard Pattern character which matches any sequence of
* zero or more string characters. Default is '*'.
* @param {string=} opt_singleChar pattern character which matches any single
* string character. Default is '.'.
* @param {string=} opt_escapeChar Escape character which can be used to escape
* the pattern characters. Default is '!'.
* @param {boolean=} opt_matchCase Case-sensitive?
* @extends {ol.format.ogc.filter.Comparison}
* @api
*/
ol.format.ogc.filter.IsLike = function(propertyName, pattern,
opt_wildCard, opt_singleChar, opt_escapeChar, opt_matchCase) {
ol.format.ogc.filter.Comparison.call(this, 'PropertyIsLike', propertyName);
/**
* @public
* @type {!string}
*/
this.pattern = pattern;
/**
* @public
* @type {!string}
*/
this.wildCard = (opt_wildCard !== undefined) ? opt_wildCard : '*';
/**
* @public
* @type {!string}
*/
this.singleChar = (opt_singleChar !== undefined) ? opt_singleChar : '.';
/**
* @public
* @type {!string}
*/
this.escapeChar = (opt_escapeChar !== undefined) ? opt_escapeChar : '!';
/**
* @public
* @type {boolean|undefined}
*/
this.matchCase = opt_matchCase;
};
ol.inherits(ol.format.ogc.filter.IsLike, ol.format.ogc.filter.Comparison);

View File

@@ -0,0 +1,19 @@
goog.provide('ol.format.ogc.filter.And');
goog.require('ol');
goog.require('ol.format.ogc.filter.LogicalBinary');
/**
* @classdesc
* Represents a logical `<And>` operator between two filter conditions.
*
* @constructor
* @param {!ol.format.ogc.filter.Filter} conditionA First filter condition.
* @param {!ol.format.ogc.filter.Filter} conditionB Second filter condition.
* @extends {ol.format.ogc.filter.LogicalBinary}
* @api
*/
ol.format.ogc.filter.And = function(conditionA, conditionB) {
ol.format.ogc.filter.LogicalBinary.call(this, 'And', conditionA, conditionB);
};
ol.inherits(ol.format.ogc.filter.And, ol.format.ogc.filter.LogicalBinary);

View File

@@ -0,0 +1,42 @@
goog.provide('ol.format.ogc.filter.Bbox');
goog.require('ol');
goog.require('ol.format.ogc.filter.Filter');
/**
* @classdesc
* Represents a `<BBOX>` operator to test whether a geometry-valued property
* intersects a fixed bounding box
*
* @constructor
* @param {!string} geometryName Geometry name to use.
* @param {!ol.Extent} extent Extent.
* @param {string=} opt_srsName SRS name. No srsName attribute will be
* set on geometries when this is not provided.
* @extends {ol.format.ogc.filter.Filter}
* @api
*/
ol.format.ogc.filter.Bbox = function(geometryName, extent, opt_srsName) {
ol.format.ogc.filter.Filter.call(this, 'BBOX');
/**
* @public
* @type {!string}
*/
this.geometryName = geometryName;
/**
* @public
* @type {ol.Extent}
*/
this.extent = extent;
/**
* @public
* @type {string|undefined}
*/
this.srsName = opt_srsName;
};
ol.inherits(ol.format.ogc.filter.Bbox, ol.format.ogc.filter.Filter);

View File

@@ -0,0 +1,28 @@
goog.provide('ol.format.ogc.filter.Comparison');
goog.require('ol');
goog.require('ol.format.ogc.filter.Filter');
/**
* @classdesc
* Abstract class; normally only used for creating subclasses and not instantiated in apps.
* Base class for WFS GetFeature property comparison filters.
*
* @constructor
* @param {!string} tagName The XML tag name for this filter.
* @param {!string} propertyName Name of the context property to compare.
* @extends {ol.format.ogc.filter.Filter}
* @api
*/
ol.format.ogc.filter.Comparison = function(tagName, propertyName) {
ol.format.ogc.filter.Filter.call(this, tagName);
/**
* @public
* @type {!string}
*/
this.propertyName = propertyName;
};
ol.inherits(ol.format.ogc.filter.Comparison, ol.format.ogc.filter.Filter);

View File

@@ -0,0 +1,37 @@
goog.provide('ol.format.ogc.filter.ComparisonBinary');
goog.require('ol');
goog.require('ol.format.ogc.filter.Comparison');
/**
* @classdesc
* Abstract class; normally only used for creating subclasses and not instantiated in apps.
* Base class for WFS GetFeature property binary comparison filters.
*
* @constructor
* @param {!string} tagName The XML tag name for this filter.
* @param {!string} propertyName Name of the context property to compare.
* @param {!(string|number)} expression The value to compare.
* @param {boolean=} opt_matchCase Case-sensitive?
* @extends {ol.format.ogc.filter.Comparison}
* @api
*/
ol.format.ogc.filter.ComparisonBinary = function(
tagName, propertyName, expression, opt_matchCase) {
ol.format.ogc.filter.Comparison.call(this, tagName, propertyName);
/**
* @public
* @type {!(string|number)}
*/
this.expression = expression;
/**
* @public
* @type {boolean|undefined}
*/
this.matchCase = opt_matchCase;
};
ol.inherits(ol.format.ogc.filter.ComparisonBinary, ol.format.ogc.filter.Comparison);

View File

@@ -0,0 +1,21 @@
goog.provide('ol.format.ogc.filter.EqualTo');
goog.require('ol');
goog.require('ol.format.ogc.filter.ComparisonBinary');
/**
* @classdesc
* Represents a `<PropertyIsEqualTo>` comparison operator.
*
* @constructor
* @param {!string} propertyName Name of the context property to compare.
* @param {!(string|number)} expression The value to compare.
* @param {boolean=} opt_matchCase Case-sensitive?
* @extends {ol.format.ogc.filter.ComparisonBinary}
* @api
*/
ol.format.ogc.filter.EqualTo = function(propertyName, expression, opt_matchCase) {
ol.format.ogc.filter.ComparisonBinary.call(this, 'PropertyIsEqualTo', propertyName, expression, opt_matchCase);
};
ol.inherits(ol.format.ogc.filter.EqualTo, ol.format.ogc.filter.ComparisonBinary);

View File

@@ -0,0 +1,31 @@
goog.provide('ol.format.ogc.filter.Filter');
goog.require('ol');
/**
* @classdesc
* Abstract class; normally only used for creating subclasses and not instantiated in apps.
* Base class for WFS GetFeature filters.
*
* @constructor
* @param {!string} tagName The XML tag name for this filter.
* @struct
* @api
*/
ol.format.ogc.filter.Filter = function(tagName) {
/**
* @private
* @type {!string}
*/
this.tagName_ = tagName;
};
/**
* The XML tag name for a filter.
* @returns {!string} Name.
*/
ol.format.ogc.filter.Filter.prototype.getTagName = function() {
return this.tagName_;
};

View File

@@ -0,0 +1,20 @@
goog.provide('ol.format.ogc.filter.GreaterThan');
goog.require('ol');
goog.require('ol.format.ogc.filter.ComparisonBinary');
/**
* @classdesc
* Represents a `<PropertyIsGreaterThan>` comparison operator.
*
* @constructor
* @param {!string} propertyName Name of the context property to compare.
* @param {!number} expression The value to compare.
* @extends {ol.format.ogc.filter.ComparisonBinary}
* @api
*/
ol.format.ogc.filter.GreaterThan = function(propertyName, expression) {
ol.format.ogc.filter.ComparisonBinary.call(this, 'PropertyIsGreaterThan', propertyName, expression);
};
ol.inherits(ol.format.ogc.filter.GreaterThan, ol.format.ogc.filter.ComparisonBinary);

View File

@@ -0,0 +1,20 @@
goog.provide('ol.format.ogc.filter.GreaterThanOrEqualTo');
goog.require('ol');
goog.require('ol.format.ogc.filter.ComparisonBinary');
/**
* @classdesc
* Represents a `<PropertyIsGreaterThanOrEqualTo>` comparison operator.
*
* @constructor
* @param {!string} propertyName Name of the context property to compare.
* @param {!number} expression The value to compare.
* @extends {ol.format.ogc.filter.ComparisonBinary}
* @api
*/
ol.format.ogc.filter.GreaterThanOrEqualTo = function(propertyName, expression) {
ol.format.ogc.filter.ComparisonBinary.call(this, 'PropertyIsGreaterThanOrEqualTo', propertyName, expression);
};
ol.inherits(ol.format.ogc.filter.GreaterThanOrEqualTo, ol.format.ogc.filter.ComparisonBinary);

View File

@@ -0,0 +1,233 @@
goog.provide('ol.format.ogc.filter');
goog.require('ol');
goog.require('ol.format.ogc.filter.And');
goog.require('ol.format.ogc.filter.Bbox');
goog.require('ol.format.ogc.filter.EqualTo');
goog.require('ol.format.ogc.filter.GreaterThan');
goog.require('ol.format.ogc.filter.GreaterThanOrEqualTo');
goog.require('ol.format.ogc.filter.Intersects');
goog.require('ol.format.ogc.filter.IsBetween');
goog.require('ol.format.ogc.filter.IsLike');
goog.require('ol.format.ogc.filter.IsNull');
goog.require('ol.format.ogc.filter.LessThan');
goog.require('ol.format.ogc.filter.LessThanOrEqualTo');
goog.require('ol.format.ogc.filter.Not');
goog.require('ol.format.ogc.filter.NotEqualTo');
goog.require('ol.format.ogc.filter.Or');
goog.require('ol.format.ogc.filter.Within');
/**
* Create a logical `<And>` operator between two filter conditions.
*
* @param {!ol.format.ogc.filter.Filter} conditionA First filter condition.
* @param {!ol.format.ogc.filter.Filter} conditionB Second filter condition.
* @returns {!ol.format.ogc.filter.And} `<And>` operator.
* @api
*/
ol.format.ogc.filter.and = function(conditionA, conditionB) {
return new ol.format.ogc.filter.And(conditionA, conditionB);
};
/**
* Create a logical `<Or>` operator between two filter conditions.
*
* @param {!ol.format.ogc.filter.Filter} conditionA First filter condition.
* @param {!ol.format.ogc.filter.Filter} conditionB Second filter condition.
* @returns {!ol.format.ogc.filter.Or} `<Or>` operator.
* @api
*/
ol.format.ogc.filter.or = function(conditionA, conditionB) {
return new ol.format.ogc.filter.Or(conditionA, conditionB);
};
/**
* Represents a logical `<Not>` operator for a filter condition.
*
* @param {!ol.format.ogc.filter.Filter} condition Filter condition.
* @returns {!ol.format.ogc.filter.Not} `<Not>` operator.
* @api
*/
ol.format.ogc.filter.not = function(condition) {
return new ol.format.ogc.filter.Not(condition);
};
/**
* Create a `<BBOX>` operator to test whether a geometry-valued property
* intersects a fixed bounding box
*
* @param {!string} geometryName Geometry name to use.
* @param {!ol.Extent} extent Extent.
* @param {string=} opt_srsName SRS name. No srsName attribute will be
* set on geometries when this is not provided.
* @returns {!ol.format.ogc.filter.Bbox} `<BBOX>` operator.
* @api
*/
ol.format.ogc.filter.bbox = function(geometryName, extent, opt_srsName) {
return new ol.format.ogc.filter.Bbox(geometryName, extent, opt_srsName);
};
/**
* Create a `<Intersects>` operator to test whether a geometry-valued property
* intersects a given geometry.
*
* @param {!string} geometryName Geometry name to use.
* @param {!ol.geom.Geometry} geometry Geometry.
* @param {string=} opt_srsName SRS name. No srsName attribute will be
* set on geometries when this is not provided.
* @returns {!ol.format.ogc.filter.Intersects} `<Intersects>` operator.
* @api
*/
ol.format.ogc.filter.intersects = function(geometryName, geometry, opt_srsName) {
return new ol.format.ogc.filter.Intersects(geometryName, geometry, opt_srsName);
};
/**
* Create a `<Within>` operator to test whether a geometry-valued property
* is within a given geometry.
*
* @param {!string} geometryName Geometry name to use.
* @param {!ol.geom.Geometry} geometry Geometry.
* @param {string=} opt_srsName SRS name. No srsName attribute will be
* set on geometries when this is not provided.
* @returns {!ol.format.ogc.filter.Within} `<Within>` operator.
* @api
*/
ol.format.ogc.filter.within = function(geometryName, geometry, opt_srsName) {
return new ol.format.ogc.filter.Within(geometryName, geometry, opt_srsName);
};
/**
* Creates a `<PropertyIsEqualTo>` comparison operator.
*
* @param {!string} propertyName Name of the context property to compare.
* @param {!(string|number)} expression The value to compare.
* @param {boolean=} opt_matchCase Case-sensitive?
* @returns {!ol.format.ogc.filter.EqualTo} `<PropertyIsEqualTo>` operator.
* @api
*/
ol.format.ogc.filter.equalTo = function(propertyName, expression, opt_matchCase) {
return new ol.format.ogc.filter.EqualTo(propertyName, expression, opt_matchCase);
};
/**
* Creates a `<PropertyIsNotEqualTo>` comparison operator.
*
* @param {!string} propertyName Name of the context property to compare.
* @param {!(string|number)} expression The value to compare.
* @param {boolean=} opt_matchCase Case-sensitive?
* @returns {!ol.format.ogc.filter.NotEqualTo} `<PropertyIsNotEqualTo>` operator.
* @api
*/
ol.format.ogc.filter.notEqualTo = function(propertyName, expression, opt_matchCase) {
return new ol.format.ogc.filter.NotEqualTo(propertyName, expression, opt_matchCase);
};
/**
* Creates a `<PropertyIsLessThan>` comparison operator.
*
* @param {!string} propertyName Name of the context property to compare.
* @param {!number} expression The value to compare.
* @returns {!ol.format.ogc.filter.LessThan} `<PropertyIsLessThan>` operator.
* @api
*/
ol.format.ogc.filter.lessThan = function(propertyName, expression) {
return new ol.format.ogc.filter.LessThan(propertyName, expression);
};
/**
* Creates a `<PropertyIsLessThanOrEqualTo>` comparison operator.
*
* @param {!string} propertyName Name of the context property to compare.
* @param {!number} expression The value to compare.
* @returns {!ol.format.ogc.filter.LessThanOrEqualTo} `<PropertyIsLessThanOrEqualTo>` operator.
* @api
*/
ol.format.ogc.filter.lessThanOrEqualTo = function(propertyName, expression) {
return new ol.format.ogc.filter.LessThanOrEqualTo(propertyName, expression);
};
/**
* Creates a `<PropertyIsGreaterThan>` comparison operator.
*
* @param {!string} propertyName Name of the context property to compare.
* @param {!number} expression The value to compare.
* @returns {!ol.format.ogc.filter.GreaterThan} `<PropertyIsGreaterThan>` operator.
* @api
*/
ol.format.ogc.filter.greaterThan = function(propertyName, expression) {
return new ol.format.ogc.filter.GreaterThan(propertyName, expression);
};
/**
* Creates a `<PropertyIsGreaterThanOrEqualTo>` comparison operator.
*
* @param {!string} propertyName Name of the context property to compare.
* @param {!number} expression The value to compare.
* @returns {!ol.format.ogc.filter.GreaterThanOrEqualTo} `<PropertyIsGreaterThanOrEqualTo>` operator.
* @api
*/
ol.format.ogc.filter.greaterThanOrEqualTo = function(propertyName, expression) {
return new ol.format.ogc.filter.GreaterThanOrEqualTo(propertyName, expression);
};
/**
* Creates a `<PropertyIsNull>` comparison operator to test whether a property value
* is null.
*
* @param {!string} propertyName Name of the context property to compare.
* @returns {!ol.format.ogc.filter.IsNull} `<PropertyIsNull>` operator.
* @api
*/
ol.format.ogc.filter.isNull = function(propertyName) {
return new ol.format.ogc.filter.IsNull(propertyName);
};
/**
* Creates a `<PropertyIsBetween>` comparison operator to test whether an expression
* value lies within a range given by a lower and upper bound (inclusive).
*
* @param {!string} propertyName Name of the context property to compare.
* @param {!number} lowerBoundary The lower bound of the range.
* @param {!number} upperBoundary The upper bound of the range.
* @returns {!ol.format.ogc.filter.IsBetween} `<PropertyIsBetween>` operator.
* @api
*/
ol.format.ogc.filter.between = function(propertyName, lowerBoundary, upperBoundary) {
return new ol.format.ogc.filter.IsBetween(propertyName, lowerBoundary, upperBoundary);
};
/**
* Represents a `<PropertyIsLike>` comparison operator that matches a string property
* value against a text pattern.
*
* @param {!string} propertyName Name of the context property to compare.
* @param {!string} pattern Text pattern.
* @param {string=} opt_wildCard Pattern character which matches any sequence of
* zero or more string characters. Default is '*'.
* @param {string=} opt_singleChar pattern character which matches any single
* string character. Default is '.'.
* @param {string=} opt_escapeChar Escape character which can be used to escape
* the pattern characters. Default is '!'.
* @param {boolean=} opt_matchCase Case-sensitive?
* @returns {!ol.format.ogc.filter.IsLike} `<PropertyIsLike>` operator.
* @api
*/
ol.format.ogc.filter.like = function(propertyName, pattern,
opt_wildCard, opt_singleChar, opt_escapeChar, opt_matchCase) {
return new ol.format.ogc.filter.IsLike(propertyName, pattern,
opt_wildCard, opt_singleChar, opt_escapeChar, opt_matchCase);
};

View File

@@ -0,0 +1,25 @@
goog.provide('ol.format.ogc.filter.Intersects');
goog.require('ol');
goog.require('ol.format.ogc.filter.Spatial');
/**
* @classdesc
* Represents a `<Intersects>` operator to test whether a geometry-valued property
* intersects a given geometry.
*
* @constructor
* @param {!string} geometryName Geometry name to use.
* @param {!ol.geom.Geometry} geometry Geometry.
* @param {string=} opt_srsName SRS name. No srsName attribute will be
* set on geometries when this is not provided.
* @extends {ol.format.ogc.filter.Spatial}
* @api
*/
ol.format.ogc.filter.Intersects = function(geometryName, geometry, opt_srsName) {
ol.format.ogc.filter.Spatial.call(this, 'Intersects', geometryName, geometry, opt_srsName);
};
ol.inherits(ol.format.ogc.filter.Intersects, ol.format.ogc.filter.Spatial);

View File

@@ -0,0 +1,33 @@
goog.provide('ol.format.ogc.filter.IsBetween');
goog.require('ol');
goog.require('ol.format.ogc.filter.Comparison');
/**
* @classdesc
* Represents a `<PropertyIsBetween>` comparison operator.
*
* @constructor
* @param {!string} propertyName Name of the context property to compare.
* @param {!number} lowerBoundary The lower bound of the range.
* @param {!number} upperBoundary The upper bound of the range.
* @extends {ol.format.ogc.filter.Comparison}
* @api
*/
ol.format.ogc.filter.IsBetween = function(propertyName, lowerBoundary, upperBoundary) {
ol.format.ogc.filter.Comparison.call(this, 'PropertyIsBetween', propertyName);
/**
* @public
* @type {!number}
*/
this.lowerBoundary = lowerBoundary;
/**
* @public
* @type {!number}
*/
this.upperBoundary = upperBoundary;
};
ol.inherits(ol.format.ogc.filter.IsBetween, ol.format.ogc.filter.Comparison);

View File

@@ -0,0 +1,58 @@
goog.provide('ol.format.ogc.filter.IsLike');
goog.require('ol');
goog.require('ol.format.ogc.filter.Comparison');
/**
* @classdesc
* Represents a `<PropertyIsLike>` comparison operator.
*
* @constructor
* @param {!string} propertyName Name of the context property to compare.
* @param {!string} pattern Text pattern.
* @param {string=} opt_wildCard Pattern character which matches any sequence of
* zero or more string characters. Default is '*'.
* @param {string=} opt_singleChar pattern character which matches any single
* string character. Default is '.'.
* @param {string=} opt_escapeChar Escape character which can be used to escape
* the pattern characters. Default is '!'.
* @param {boolean=} opt_matchCase Case-sensitive?
* @extends {ol.format.ogc.filter.Comparison}
* @api
*/
ol.format.ogc.filter.IsLike = function(propertyName, pattern,
opt_wildCard, opt_singleChar, opt_escapeChar, opt_matchCase) {
ol.format.ogc.filter.Comparison.call(this, 'PropertyIsLike', propertyName);
/**
* @public
* @type {!string}
*/
this.pattern = pattern;
/**
* @public
* @type {!string}
*/
this.wildCard = (opt_wildCard !== undefined) ? opt_wildCard : '*';
/**
* @public
* @type {!string}
*/
this.singleChar = (opt_singleChar !== undefined) ? opt_singleChar : '.';
/**
* @public
* @type {!string}
*/
this.escapeChar = (opt_escapeChar !== undefined) ? opt_escapeChar : '!';
/**
* @public
* @type {boolean|undefined}
*/
this.matchCase = opt_matchCase;
};
ol.inherits(ol.format.ogc.filter.IsLike, ol.format.ogc.filter.Comparison);

View File

@@ -0,0 +1,19 @@
goog.provide('ol.format.ogc.filter.IsNull');
goog.require('ol');
goog.require('ol.format.ogc.filter.Comparison');
/**
* @classdesc
* Represents a `<PropertyIsNull>` comparison operator.
*
* @constructor
* @param {!string} propertyName Name of the context property to compare.
* @extends {ol.format.ogc.filter.Comparison}
* @api
*/
ol.format.ogc.filter.IsNull = function(propertyName) {
ol.format.ogc.filter.Comparison.call(this, 'PropertyIsNull', propertyName);
};
ol.inherits(ol.format.ogc.filter.IsNull, ol.format.ogc.filter.Comparison);

View File

@@ -0,0 +1,20 @@
goog.provide('ol.format.ogc.filter.LessThan');
goog.require('ol');
goog.require('ol.format.ogc.filter.ComparisonBinary');
/**
* @classdesc
* Represents a `<PropertyIsLessThan>` comparison operator.
*
* @constructor
* @param {!string} propertyName Name of the context property to compare.
* @param {!number} expression The value to compare.
* @extends {ol.format.ogc.filter.ComparisonBinary}
* @api
*/
ol.format.ogc.filter.LessThan = function(propertyName, expression) {
ol.format.ogc.filter.ComparisonBinary.call(this, 'PropertyIsLessThan', propertyName, expression);
};
ol.inherits(ol.format.ogc.filter.LessThan, ol.format.ogc.filter.ComparisonBinary);

View File

@@ -0,0 +1,20 @@
goog.provide('ol.format.ogc.filter.LessThanOrEqualTo');
goog.require('ol');
goog.require('ol.format.ogc.filter.ComparisonBinary');
/**
* @classdesc
* Represents a `<PropertyIsLessThanOrEqualTo>` comparison operator.
*
* @constructor
* @param {!string} propertyName Name of the context property to compare.
* @param {!number} expression The value to compare.
* @extends {ol.format.ogc.filter.ComparisonBinary}
* @api
*/
ol.format.ogc.filter.LessThanOrEqualTo = function(propertyName, expression) {
ol.format.ogc.filter.ComparisonBinary.call(this, 'PropertyIsLessThanOrEqualTo', propertyName, expression);
};
ol.inherits(ol.format.ogc.filter.LessThanOrEqualTo, ol.format.ogc.filter.ComparisonBinary);

View File

@@ -0,0 +1,19 @@
goog.provide('ol.format.ogc.filter.Logical');
goog.require('ol');
goog.require('ol.format.ogc.filter.Filter');
/**
* @classdesc
* Abstract class; normally only used for creating subclasses and not instantiated in apps.
* Base class for WFS GetFeature logical filters.
*
* @constructor
* @param {!string} tagName The XML tag name for this filter.
* @extends {ol.format.ogc.filter.Filter}
*/
ol.format.ogc.filter.Logical = function(tagName) {
ol.format.ogc.filter.Filter.call(this, tagName);
};
ol.inherits(ol.format.ogc.filter.Logical, ol.format.ogc.filter.Filter);

View File

@@ -0,0 +1,35 @@
goog.provide('ol.format.ogc.filter.LogicalBinary');
goog.require('ol');
goog.require('ol.format.ogc.filter.Logical');
/**
* @classdesc
* Abstract class; normally only used for creating subclasses and not instantiated in apps.
* Base class for WFS GetFeature binary logical filters.
*
* @constructor
* @param {!string} tagName The XML tag name for this filter.
* @param {!ol.format.ogc.filter.Filter} conditionA First filter condition.
* @param {!ol.format.ogc.filter.Filter} conditionB Second filter condition.
* @extends {ol.format.ogc.filter.Logical}
*/
ol.format.ogc.filter.LogicalBinary = function(tagName, conditionA, conditionB) {
ol.format.ogc.filter.Logical.call(this, tagName);
/**
* @public
* @type {!ol.format.ogc.filter.Filter}
*/
this.conditionA = conditionA;
/**
* @public
* @type {!ol.format.ogc.filter.Filter}
*/
this.conditionB = conditionB;
};
ol.inherits(ol.format.ogc.filter.LogicalBinary, ol.format.ogc.filter.Logical);

View File

@@ -0,0 +1,26 @@
goog.provide('ol.format.ogc.filter.Not');
goog.require('ol');
goog.require('ol.format.ogc.filter.Logical');
/**
* @classdesc
* Represents a logical `<Not>` operator for a filter condition.
*
* @constructor
* @param {!ol.format.ogc.filter.Filter} condition Filter condition.
* @extends {ol.format.ogc.filter.Logical}
* @api
*/
ol.format.ogc.filter.Not = function(condition) {
ol.format.ogc.filter.Logical.call(this, 'Not');
/**
* @public
* @type {!ol.format.ogc.filter.Filter}
*/
this.condition = condition;
};
ol.inherits(ol.format.ogc.filter.Not, ol.format.ogc.filter.Logical);

View File

@@ -0,0 +1,21 @@
goog.provide('ol.format.ogc.filter.NotEqualTo');
goog.require('ol');
goog.require('ol.format.ogc.filter.ComparisonBinary');
/**
* @classdesc
* Represents a `<PropertyIsNotEqualTo>` comparison operator.
*
* @constructor
* @param {!string} propertyName Name of the context property to compare.
* @param {!(string|number)} expression The value to compare.
* @param {boolean=} opt_matchCase Case-sensitive?
* @extends {ol.format.ogc.filter.ComparisonBinary}
* @api
*/
ol.format.ogc.filter.NotEqualTo = function(propertyName, expression, opt_matchCase) {
ol.format.ogc.filter.ComparisonBinary.call(this, 'PropertyIsNotEqualTo', propertyName, expression, opt_matchCase);
};
ol.inherits(ol.format.ogc.filter.NotEqualTo, ol.format.ogc.filter.ComparisonBinary);

View File

@@ -0,0 +1,20 @@
goog.provide('ol.format.ogc.filter.Or');
goog.require('ol');
goog.require('ol.format.ogc.filter.LogicalBinary');
/**
* @classdesc
* Represents a logical `<Or>` operator between two filter conditions.
*
* @constructor
* @param {!ol.format.ogc.filter.Filter} conditionA First filter condition.
* @param {!ol.format.ogc.filter.Filter} conditionB Second filter condition.
* @extends {ol.format.ogc.filter.LogicalBinary}
* @api
*/
ol.format.ogc.filter.Or = function(conditionA, conditionB) {
ol.format.ogc.filter.LogicalBinary.call(this, 'Or', conditionA, conditionB);
};
ol.inherits(ol.format.ogc.filter.Or, ol.format.ogc.filter.LogicalBinary);

View File

@@ -0,0 +1,43 @@
goog.provide('ol.format.ogc.filter.Spatial');
goog.require('ol');
goog.require('ol.format.ogc.filter.Filter');
/**
* @classdesc
* Represents a spatial operator to test whether a geometry-valued property
* relates to a given geometry.
*
* @constructor
* @param {!string} tagName The XML tag name for this filter.
* @param {!string} geometryName Geometry name to use.
* @param {!ol.geom.Geometry} geometry Geometry.
* @param {string=} opt_srsName SRS name. No srsName attribute will be
* set on geometries when this is not provided.
* @extends {ol.format.ogc.filter.Filter}
* @api
*/
ol.format.ogc.filter.Spatial = function(tagName, geometryName, geometry, opt_srsName) {
ol.format.ogc.filter.Filter.call(this, tagName);
/**
* @public
* @type {!string}
*/
this.geometryName = geometryName || 'the_geom';
/**
* @public
* @type {ol.geom.Geometry}
*/
this.geometry = geometry;
/**
* @public
* @type {string|undefined}
*/
this.srsName = opt_srsName;
};
ol.inherits(ol.format.ogc.filter.Spatial, ol.format.ogc.filter.Filter);

View File

@@ -0,0 +1,25 @@
goog.provide('ol.format.ogc.filter.Within');
goog.require('ol');
goog.require('ol.format.ogc.filter.Spatial');
/**
* @classdesc
* Represents a `<Within>` operator to test whether a geometry-valued property
* is within a given geometry.
*
* @constructor
* @param {!string} geometryName Geometry name to use.
* @param {!ol.geom.Geometry} geometry Geometry.
* @param {string=} opt_srsName SRS name. No srsName attribute will be
* set on geometries when this is not provided.
* @extends {ol.format.ogc.filter.Spatial}
* @api
*/
ol.format.ogc.filter.Within = function(geometryName, geometry, opt_srsName) {
ol.format.ogc.filter.Spatial.call(this, 'Within', geometryName, geometry, opt_srsName);
};
ol.inherits(ol.format.ogc.filter.Within, ol.format.ogc.filter.Spatial);

View File

@@ -355,7 +355,7 @@ ol.format.Polyline.prototype.writeFeatureText = function(feature, opt_options) {
if (geometry) {
return this.writeGeometryText(geometry, opt_options);
} else {
ol.assert(false, 40); // Expected `feature` to have a geometry
ol.asserts.assert(false, 40); // Expected `feature` to have a geometry
return '';
}
};

View File

@@ -386,7 +386,7 @@ ol.format.WFS.writeOgcFidFilter_ = function(node, fid, objectStack) {
*/
ol.format.WFS.writeDelete_ = function(node, feature, objectStack) {
var context = objectStack[objectStack.length - 1];
ol.assert(feature.getId() !== undefined, 26); // Features must have an id set
ol.asserts.assert(feature.getId() !== undefined, 26); // Features must have an id set
var featureType = context['featureType'];
var featurePrefix = context['featurePrefix'];
featurePrefix = featurePrefix ? featurePrefix :
@@ -410,7 +410,7 @@ ol.format.WFS.writeDelete_ = function(node, feature, objectStack) {
*/
ol.format.WFS.writeUpdate_ = function(node, feature, objectStack) {
var context = objectStack[objectStack.length - 1];
ol.assert(feature.getId() !== undefined, 27); // Features must have an id set
ol.asserts.assert(feature.getId() !== undefined, 27); // Features must have an id set
var featureType = context['featureType'];
var featurePrefix = context['featurePrefix'];
featurePrefix = featurePrefix ? featurePrefix :
@@ -802,7 +802,7 @@ ol.format.WFS.prototype.writeGetFeature = function(options) {
}
filter = options.filter;
if (options.bbox) {
ol.assert(options.geometryName,
ol.asserts.assert(options.geometryName,
12); // `options.geometryName` must also be provided when `options.bbox` is set
var bbox = ol.format.ogc.filter.bbox(
/** @type {string} */ (options.geometryName), options.bbox, options.srsName);
@@ -826,7 +826,7 @@ ol.format.WFS.prototype.writeGetFeature = function(options) {
'filter': filter,
'propertyNames': options.propertyNames ? options.propertyNames : []
};
ol.assert(Array.isArray(options.featureTypes),
ol.asserts.assert(Array.isArray(options.featureTypes),
11); // `options.featureTypes` should be an Array
ol.format.WFS.writeGetFeature_(node, /** @type {!Array.<string>} */ (options.featureTypes), [context]);
return node;

View File

@@ -323,7 +323,7 @@ ol.geom.SimpleGeometry.prototype.translate = function(deltaX, deltaY) {
* @param {Array.<number>=} opt_dest Destination.
* @return {Array.<number>} Transformed flat coordinates.
*/
ol.geom.transformSimpleGeometry2D = function(simpleGeometry, transform, opt_dest) {
ol.geom.SimpleGeometry.transform2D = function(simpleGeometry, transform, opt_dest) {
var flatCoordinates = simpleGeometry.getFlatCoordinates();
if (!flatCoordinates) {
return null;

View File

@@ -1,5 +1,6 @@
goog.provide('ol.ImageCanvas');
goog.require('ol');
goog.require('ol.ImageBase');
goog.require('ol.ImageState');

View File

@@ -1,7 +1,6 @@
goog.provide('ol.ImageTile');
goog.require('ol.Tile');
goog.require('ol.TileState');
goog.require('ol.events');
goog.require('ol.events.EventType');
goog.require('ol.obj');
@@ -11,7 +10,7 @@ goog.require('ol.obj');
* @constructor
* @extends {ol.Tile}
* @param {ol.TileCoord} tileCoord Tile coordinate.
* @param {ol.TileState} state State.
* @param {ol.Tile.State} state State.
* @param {string} src Image source URI.
* @param {?string} crossOrigin Cross origin.
* @param {ol.TileLoadFunctionType} tileLoadFunction Tile load function.
@@ -63,13 +62,13 @@ ol.inherits(ol.ImageTile, ol.Tile);
* @inheritDoc
*/
ol.ImageTile.prototype.disposeInternal = function() {
if (this.state == ol.TileState.LOADING) {
if (this.state == ol.Tile.State.LOADING) {
this.unlistenImage_();
}
if (this.interimTile) {
this.interimTile.dispose();
}
this.state = ol.TileState.ABORT;
this.state = ol.Tile.State.ABORT;
this.changed();
ol.Tile.prototype.disposeInternal.call(this);
};
@@ -113,7 +112,7 @@ ol.ImageTile.prototype.getKey = function() {
* @private
*/
ol.ImageTile.prototype.handleImageError_ = function() {
this.state = ol.TileState.ERROR;
this.state = ol.Tile.State.ERROR;
this.unlistenImage_();
this.changed();
};
@@ -126,9 +125,9 @@ ol.ImageTile.prototype.handleImageError_ = function() {
*/
ol.ImageTile.prototype.handleImageLoad_ = function() {
if (this.image_.naturalWidth && this.image_.naturalHeight) {
this.state = ol.TileState.LOADED;
this.state = ol.Tile.State.LOADED;
} else {
this.state = ol.TileState.EMPTY;
this.state = ol.Tile.State.EMPTY;
}
this.unlistenImage_();
this.changed();
@@ -142,8 +141,8 @@ ol.ImageTile.prototype.handleImageLoad_ = function() {
* @api
*/
ol.ImageTile.prototype.load = function() {
if (this.state == ol.TileState.IDLE || this.state == ol.TileState.ERROR) {
this.state = ol.TileState.LOADING;
if (this.state == ol.Tile.State.IDLE || this.state == ol.Tile.State.ERROR) {
this.state = ol.Tile.State.LOADING;
this.changed();
goog.DEBUG && console.assert(!this.imageListenerKeys_,
'this.imageListenerKeys_ should be null');

View File

@@ -173,7 +173,7 @@ ol.OVERVIEWMAP_MIN_RATIO = 0.1;
* This can happen if the developer defines projections improperly and/or
* with unlimited extents.
* If too many tiles are required, no tiles are loaded and
* `ol.TileState.ERROR` state is set. Default is `100`.
* `ol.Tile.State.ERROR` state is set. Default is `100`.
*/
ol.RASTER_REPROJECTION_MAX_SOURCE_TILES = 100;
@@ -303,48 +303,3 @@ if (typeof window !== 'undefined') {
} else if (typeof self !== 'undefined') {
ol.global = self;
}
/**
* Error object thrown when an assertion failed. This is an ECMA-262 Error,
* extended with a `code` property.
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error}
* @constructor
* @extends {Error}
* @implements {oli.AssertionError}
* @param {number} code Error code.
*/
ol.AssertionError = function(code) {
/**
* @type {string}
*/
this.message = 'Assertion failed. See ' +
(ol.VERSION ? 'http://openlayers.org/en/' + ol.VERSION.split('-')[0] : '') +
'/doc/errors/#' + code + ' for details.';
/**
* Error code. The meaning of the code can be found on
* {@link http://openlayers.org/en/latest/errors.html} (replace `latest` with
* the version found in the OpenLayers script's header comment if a version
* other than the latest is used).
* @type {number}
* @api
*/
this.code = code;
this.name = 'AssertionError';
};
ol.inherits(ol.AssertionError, Error);
/**
* @param {*} assertion Assertion we expected to be truthy.
* @param {number} errorCode Error code.
*/
ol.assert = function(assertion, errorCode) {
if (!assertion) {
throw new ol.AssertionError(errorCode);
}
};

View File

@@ -1,9 +1,9 @@
goog.provide('ol.interaction.DragPan');
goog.require('ol.ViewHint');
goog.require('ol.View');
goog.require('ol.coordinate');
goog.require('ol.functions');
goog.require('ol.events.condition');
goog.require('ol.functions');
goog.require('ol.interaction.Pointer');
@@ -115,7 +115,7 @@ ol.interaction.DragPan.handleUpEvent_ = function(mapBrowserEvent) {
dest = view.constrainCenter(dest);
view.setCenter(dest);
}
view.setHint(ol.ViewHint.INTERACTING, -1);
view.setHint(ol.View.Hint.INTERACTING, -1);
map.render();
return false;
} else {
@@ -137,7 +137,7 @@ ol.interaction.DragPan.handleDownEvent_ = function(mapBrowserEvent) {
var view = map.getView();
this.lastCentroid = null;
if (!this.handlingDownUpSequence) {
view.setHint(ol.ViewHint.INTERACTING, 1);
view.setHint(ol.View.Hint.INTERACTING, 1);
}
map.render();
if (this.kineticPreRenderFn_ &&

View File

@@ -1,9 +1,9 @@
goog.provide('ol.interaction.DragRotate');
goog.require('ol');
goog.require('ol.ViewHint');
goog.require('ol.functions');
goog.require('ol.View');
goog.require('ol.events.condition');
goog.require('ol.functions');
goog.require('ol.interaction.Interaction');
goog.require('ol.interaction.Pointer');
@@ -93,7 +93,7 @@ ol.interaction.DragRotate.handleUpEvent_ = function(mapBrowserEvent) {
var map = mapBrowserEvent.map;
var view = map.getView();
view.setHint(ol.ViewHint.INTERACTING, -1);
view.setHint(ol.View.Hint.INTERACTING, -1);
var rotation = view.getRotation();
ol.interaction.Interaction.rotate(map, view, rotation,
undefined, this.duration_);
@@ -115,7 +115,7 @@ ol.interaction.DragRotate.handleDownEvent_ = function(mapBrowserEvent) {
if (ol.events.condition.mouseActionButton(mapBrowserEvent) &&
this.condition_(mapBrowserEvent)) {
var map = mapBrowserEvent.map;
map.getView().setHint(ol.ViewHint.INTERACTING, 1);
map.getView().setHint(ol.View.Hint.INTERACTING, 1);
map.render();
this.lastAngle_ = undefined;
return true;

View File

@@ -1,7 +1,7 @@
goog.provide('ol.interaction.DragRotateAndZoom');
goog.require('ol');
goog.require('ol.ViewHint');
goog.require('ol.View');
goog.require('ol.events.condition');
goog.require('ol.interaction.Interaction');
goog.require('ol.interaction.Pointer');
@@ -116,7 +116,7 @@ ol.interaction.DragRotateAndZoom.handleUpEvent_ = function(mapBrowserEvent) {
var map = mapBrowserEvent.map;
var view = map.getView();
view.setHint(ol.ViewHint.INTERACTING, -1);
view.setHint(ol.View.Hint.INTERACTING, -1);
var direction = this.lastScaleDelta_ - 1;
ol.interaction.Interaction.rotate(map, view, view.getRotation());
ol.interaction.Interaction.zoom(map, view, view.getResolution(),
@@ -138,7 +138,7 @@ ol.interaction.DragRotateAndZoom.handleDownEvent_ = function(mapBrowserEvent) {
}
if (this.condition_(mapBrowserEvent)) {
mapBrowserEvent.map.getView().setHint(ol.ViewHint.INTERACTING, 1);
mapBrowserEvent.map.getView().setHint(ol.View.Hint.INTERACTING, 1);
this.lastAngle_ = undefined;
this.lastMagnitude_ = undefined;
return true;

View File

@@ -312,7 +312,7 @@ ol.inherits(ol.interaction.Draw, ol.interaction.Pointer);
* @return {ol.StyleFunction} Styles.
*/
ol.interaction.Draw.getDefaultStyleFunction = function() {
var styles = ol.style.createDefaultEditingStyles();
var styles = ol.style.Style.createDefaultEditing();
return function(feature, resolution) {
return styles[feature.getGeometry().getType()];
};

View File

@@ -1,17 +1,17 @@
goog.provide('ol.interaction.Modify');
goog.provide('ol.interaction.ModifyEvent');
goog.require('ol.events');
goog.require('ol.events.Event');
goog.require('ol.events.EventType');
goog.require('ol');
goog.require('ol.Collection');
goog.require('ol.Feature');
goog.require('ol.MapBrowserEvent.EventType');
goog.require('ol.MapBrowserPointerEvent');
goog.require('ol.ViewHint');
goog.require('ol.View');
goog.require('ol.array');
goog.require('ol.coordinate');
goog.require('ol.events');
goog.require('ol.events.Event');
goog.require('ol.events.EventType');
goog.require('ol.events.condition');
goog.require('ol.extent');
goog.require('ol.geom.GeometryType');
@@ -696,7 +696,7 @@ ol.interaction.Modify.handleEvent = function(mapBrowserEvent) {
this.lastPointerEvent_ = mapBrowserEvent;
var handled;
if (!mapBrowserEvent.map.getView().getHints()[ol.ViewHint.INTERACTING] &&
if (!mapBrowserEvent.map.getView().getHints()[ol.View.Hint.INTERACTING] &&
mapBrowserEvent.type == ol.MapBrowserEvent.EventType.POINTERMOVE &&
!this.handlingDownUpSequence) {
this.handlePointerMove_(mapBrowserEvent);
@@ -1034,7 +1034,7 @@ ol.interaction.Modify.prototype.updateSegmentIndices_ = function(
* @return {ol.StyleFunction} Styles.
*/
ol.interaction.Modify.getDefaultStyleFunction = function() {
var style = ol.style.createDefaultEditingStyles();
var style = ol.style.Style.createDefaultEditing();
return function(feature, resolution) {
return style[ol.geom.GeometryType.POINT];
};

View File

@@ -1,8 +1,8 @@
goog.provide('ol.interaction.PinchRotate');
goog.require('ol');
goog.require('ol.View');
goog.require('ol.functions');
goog.require('ol.ViewHint');
goog.require('ol.interaction.Interaction');
goog.require('ol.interaction.Pointer');
@@ -128,7 +128,7 @@ ol.interaction.PinchRotate.handleUpEvent_ = function(mapBrowserEvent) {
if (this.targetPointers.length < 2) {
var map = mapBrowserEvent.map;
var view = map.getView();
view.setHint(ol.ViewHint.INTERACTING, -1);
view.setHint(ol.View.Hint.INTERACTING, -1);
if (this.rotating_) {
var rotation = view.getRotation();
ol.interaction.Interaction.rotate(
@@ -155,7 +155,7 @@ ol.interaction.PinchRotate.handleDownEvent_ = function(mapBrowserEvent) {
this.rotating_ = false;
this.rotationDelta_ = 0.0;
if (!this.handlingDownUpSequence) {
map.getView().setHint(ol.ViewHint.INTERACTING, 1);
map.getView().setHint(ol.View.Hint.INTERACTING, 1);
}
map.render();
return true;

View File

@@ -1,8 +1,8 @@
goog.provide('ol.interaction.PinchZoom');
goog.require('ol');
goog.require('ol.View');
goog.require('ol.functions');
goog.require('ol.ViewHint');
goog.require('ol.interaction.Interaction');
goog.require('ol.interaction.Pointer');
@@ -110,7 +110,7 @@ ol.interaction.PinchZoom.handleUpEvent_ = function(mapBrowserEvent) {
if (this.targetPointers.length < 2) {
var map = mapBrowserEvent.map;
var view = map.getView();
view.setHint(ol.ViewHint.INTERACTING, -1);
view.setHint(ol.View.Hint.INTERACTING, -1);
var resolution = view.getResolution();
// Zoom to final resolution, with an animation, and provide a
// direction not to zoom out/in if user was pinching in/out.
@@ -138,7 +138,7 @@ ol.interaction.PinchZoom.handleDownEvent_ = function(mapBrowserEvent) {
this.lastDistance_ = undefined;
this.lastScaleDelta_ = 1;
if (!this.handlingDownUpSequence) {
map.getView().setHint(ol.ViewHint.INTERACTING, 1);
map.getView().setHint(ol.View.Hint.INTERACTING, 1);
}
map.render();
return true;

View File

@@ -225,7 +225,7 @@ ol.interaction.Select.prototype.getFeatures = function() {
* @api
*/
ol.interaction.Select.prototype.getLayer = function(feature) {
ol.assert(feature instanceof ol.Feature,
ol.asserts.assert(feature instanceof ol.Feature,
42); // Expected an `ol.Feature`, but got an `ol.RenderFeature`
var key = ol.getUid(feature);
return /** @type {ol.layer.Vector} */ (this.featureLayerAssociation_[key]);
@@ -342,7 +342,7 @@ ol.interaction.Select.prototype.setMap = function(map) {
* @return {ol.StyleFunction} Styles.
*/
ol.interaction.Select.getDefaultStyleFunction = function() {
var styles = ol.style.createDefaultEditingStyles();
var styles = ol.style.Style.createDefaultEditing();
ol.array.extend(styles[ol.geom.GeometryType.POLYGON],
styles[ol.geom.GeometryType.LINE_STRING]);
ol.array.extend(styles[ol.geom.GeometryType.GEOMETRY_COLLECTION],

View File

@@ -61,7 +61,7 @@ ol.layer.Group = function(opt_options) {
if (Array.isArray(layers)) {
layers = new ol.Collection(layers.slice());
} else {
ol.assert(layers instanceof ol.Collection,
ol.asserts.assert(layers instanceof ol.Collection,
43); // Expected `layers` to be an array or an `ol.Collection`
layers = layers;
}

View File

@@ -177,8 +177,8 @@ ol.layer.Vector.prototype.setRenderOrder = function(renderOrder) {
* @api stable
*/
ol.layer.Vector.prototype.setStyle = function(style) {
this.style_ = style !== undefined ? style : ol.style.defaultStyleFunction;
this.style_ = style !== undefined ? style : ol.style.Style.defaultFunction;
this.styleFunction_ = style === null ?
undefined : ol.style.createStyleFunction(this.style_);
undefined : ol.style.Style.createFunction(this.style_);
this.changed();
};

View File

@@ -58,7 +58,7 @@ ol.layer.VectorTile = function(opt_options) {
this.setUseInterimTilesOnError(options.useInterimTilesOnError ?
options.useInterimTilesOnError : true);
ol.assert(options.renderMode == undefined ||
ol.asserts.assert(options.renderMode == undefined ||
options.renderMode == ol.layer.VectorTileRenderType.IMAGE ||
options.renderMode == ol.layer.VectorTileRenderType.HYBRID ||
options.renderMode == ol.layer.VectorTileRenderType.VECTOR,

View File

@@ -17,7 +17,6 @@ goog.require('ol.ObjectEventType');
goog.require('ol.RendererType');
goog.require('ol.TileQueue');
goog.require('ol.View');
goog.require('ol.ViewHint');
goog.require('ol.array');
goog.require('ol.control');
goog.require('ol.dom');
@@ -29,7 +28,6 @@ goog.require('ol.functions');
goog.require('ol.has');
goog.require('ol.interaction');
goog.require('ol.layer.Group');
goog.require('ol.transform');
goog.require('ol.obj');
goog.require('ol.proj.common');
goog.require('ol.renderer.Map');
@@ -38,6 +36,7 @@ goog.require('ol.renderer.dom.Map');
goog.require('ol.renderer.webgl.Map');
goog.require('ol.size');
goog.require('ol.structs.PriorityQueue');
goog.require('ol.transform');
/**
@@ -1003,11 +1002,11 @@ ol.Map.prototype.handlePostRender = function() {
var maxNewLoads = maxTotalLoading;
if (frameState) {
var hints = frameState.viewHints;
if (hints[ol.ViewHint.ANIMATING]) {
if (hints[ol.View.Hint.ANIMATING]) {
maxTotalLoading = this.loadTilesWhileAnimating_ ? 8 : 0;
maxNewLoads = 2;
}
if (hints[ol.ViewHint.INTERACTING]) {
if (hints[ol.View.Hint.INTERACTING]) {
maxTotalLoading = this.loadTilesWhileInteracting_ ? 8 : 0;
maxNewLoads = 2;
}
@@ -1299,8 +1298,8 @@ ol.Map.prototype.renderFrame_ = function(time) {
this.postRenderFunctions_, frameState.postRenderFunctions);
var idle = this.preRenderFunctions_.length === 0 &&
!frameState.viewHints[ol.ViewHint.ANIMATING] &&
!frameState.viewHints[ol.ViewHint.INTERACTING] &&
!frameState.viewHints[ol.View.Hint.ANIMATING] &&
!frameState.viewHints[ol.View.Hint.INTERACTING] &&
!ol.extent.equals(frameState.extent, this.previousExtent_);
if (idle) {
@@ -1444,8 +1443,8 @@ ol.Map.createOptionsInternal = function(options) {
} else if (logo instanceof HTMLElement) {
logos[ol.getUid(logo).toString()] = logo;
} else if (logo) {
ol.assert(typeof logo.href == 'string', 44); // `logo.href` should be a string.
ol.assert(typeof logo.src == 'string', 45); // `logo.src` should be a string.
ol.asserts.assert(typeof logo.href == 'string', 44); // `logo.href` should be a string.
ol.asserts.assert(typeof logo.src == 'string', 45); // `logo.src` should be a string.
logos[logo.src] = logo.href;
}
}
@@ -1474,7 +1473,7 @@ ol.Map.createOptionsInternal = function(options) {
} else if (typeof options.renderer === 'string') {
rendererTypes = [options.renderer];
} else {
ol.assert(false, 46); // Incorrect format for `renderer` option
ol.asserts.assert(false, 46); // Incorrect format for `renderer` option
}
} else {
rendererTypes = ol.DEFAULT_RENDERER_TYPES;
@@ -1507,7 +1506,7 @@ ol.Map.createOptionsInternal = function(options) {
if (Array.isArray(options.controls)) {
controls = new ol.Collection(options.controls.slice());
} else {
ol.assert(options.controls instanceof ol.Collection,
ol.asserts.assert(options.controls instanceof ol.Collection,
47); // Expected `controls` to be an array or an `ol.Collection`
controls = options.controls;
}
@@ -1520,7 +1519,7 @@ ol.Map.createOptionsInternal = function(options) {
if (Array.isArray(options.interactions)) {
interactions = new ol.Collection(options.interactions.slice());
} else {
ol.assert(options.interactions instanceof ol.Collection,
ol.asserts.assert(options.interactions instanceof ol.Collection,
48); // Expected `interactions` to be an array or an `ol.Collection`
interactions = options.interactions;
}
@@ -1533,7 +1532,7 @@ ol.Map.createOptionsInternal = function(options) {
if (Array.isArray(options.overlays)) {
overlays = new ol.Collection(options.overlays.slice());
} else {
ol.assert(options.overlays instanceof ol.Collection,
ol.asserts.assert(options.overlays instanceof ol.Collection,
49); // Expected `overlays` to be an array or an `ol.Collection`
overlays = options.overlays;
}

View File

@@ -46,7 +46,7 @@ ol.math.cosh = (function() {
* @return {number} The smallest power of two greater than or equal to x.
*/
ol.math.roundUpToPowerOfTwo = function(x) {
ol.assert(0 < x, 29); // `x` must be greater than `0`
ol.asserts.assert(0 < x, 29); // `x` must be greater than `0`
return Math.pow(2, Math.ceil(Math.log(x) / Math.LN2));
};

View File

@@ -148,7 +148,8 @@ ol.pointer.TouchSource.prototype.removePrimaryPointer_ = function(inPointer) {
* @private
*/
ol.pointer.TouchSource.prototype.resetClickCount_ = function() {
this.resetId_ = ol.global.setTimeout(
var global = ol.global;
this.resetId_ = global.setTimeout(
this.resetClickCountHandler_.bind(this),
ol.pointer.TouchSource.CLICK_COUNT_TIMEOUT);
};
@@ -167,8 +168,9 @@ ol.pointer.TouchSource.prototype.resetClickCountHandler_ = function() {
* @private
*/
ol.pointer.TouchSource.prototype.cancelResetClickCount_ = function() {
var global = ol.global;
if (this.resetId_ !== undefined) {
ol.global.clearTimeout(this.resetId_);
global.clearTimeout(this.resetId_);
}
};
@@ -440,7 +442,8 @@ ol.pointer.TouchSource.prototype.dedupSynthMouse_ = function(inEvent) {
var lt = [t.clientX, t.clientY];
lts.push(lt);
ol.global.setTimeout(function() {
var global = ol.global;
global.setTimeout(function() {
// remove touch after timeout
ol.array.remove(lts, lt);
}, ol.pointer.TouchSource.DEDUP_TIMEOUT);

View File

@@ -1,5 +1,6 @@
goog.provide('ol.proj.EPSG3857');
goog.require('ol');
goog.require('ol.math');
goog.require('ol.proj');
goog.require('ol.proj.Projection');

View File

@@ -1,5 +1,6 @@
goog.provide('ol.proj.EPSG4326');
goog.require('ol');
goog.require('ol.proj');
goog.require('ol.proj.Projection');
goog.require('ol.proj.Units');

View File

@@ -1,5 +1,6 @@
goog.provide('ol.render');
goog.require('ol.has');
goog.require('ol.transform');
goog.require('ol.render.canvas.Immediate');

View File

@@ -2,6 +2,7 @@
goog.provide('ol.render.Box');
goog.require('ol');
goog.require('ol.Disposable');
goog.require('ol.geom.Polygon');

View File

@@ -4,16 +4,18 @@
goog.provide('ol.render.canvas.Immediate');
goog.require('ol.transform');
goog.require('ol');
goog.require('ol.array');
goog.require('ol.color');
goog.require('ol.colorlike');
goog.require('ol.extent');
goog.require('ol.geom.GeometryType');
goog.require('ol.geom.SimpleGeometry');
goog.require('ol.geom.flat.transform');
goog.require('ol.has');
goog.require('ol.render.VectorContext');
goog.require('ol.render.canvas');
goog.require('ol.transform');
/**
@@ -405,7 +407,7 @@ ol.render.canvas.Immediate.prototype.drawCircle = function(geometry) {
if (this.strokeState_) {
this.setContextStrokeState_(this.strokeState_);
}
var pixelCoordinates = ol.geom.transformSimpleGeometry2D(
var pixelCoordinates = ol.geom.SimpleGeometry.transform2D(
geometry, this.transform_, this.pixelCoordinates_);
var dx = pixelCoordinates[2] - pixelCoordinates[0];
var dy = pixelCoordinates[3] - pixelCoordinates[1];

View File

@@ -1,6 +1,7 @@
goog.provide('ol.render.Event');
goog.provide('ol.render.EventType');
goog.require('ol');
goog.require('ol.events.Event');

View File

@@ -1,6 +1,6 @@
goog.provide('ol.render.Feature');
goog.require('ol');
goog.require('ol.extent');
goog.require('ol.geom.GeometryType');

View File

@@ -1,6 +1,7 @@
goog.provide('ol.render.webgl.ImageReplay');
goog.provide('ol.render.webgl.ReplayGroup');
goog.require('ol');
goog.require('ol.extent');
goog.require('ol.obj');
goog.require('ol.render.ReplayGroup');

View File

@@ -1,5 +1,6 @@
goog.provide('ol.render.webgl.Immediate');
goog.require('ol');
goog.require('ol.extent');
goog.require('ol.geom.GeometryType');
goog.require('ol.render.ReplayType');

View File

@@ -1,13 +1,14 @@
goog.provide('ol.renderer.canvas.ImageLayer');
goog.require('ol.transform');
goog.require('ol.functions');
goog.require('ol.ViewHint');
goog.require('ol');
goog.require('ol.View');
goog.require('ol.dom');
goog.require('ol.extent');
goog.require('ol.functions');
goog.require('ol.proj');
goog.require('ol.renderer.canvas.Layer');
goog.require('ol.source.ImageVector');
goog.require('ol.transform');
/**
@@ -160,7 +161,7 @@ ol.renderer.canvas.ImageLayer.prototype.prepareFrame = function(frameState, laye
renderedExtent, layerState.extent);
}
if (!hints[ol.ViewHint.ANIMATING] && !hints[ol.ViewHint.INTERACTING] &&
if (!hints[ol.View.Hint.ANIMATING] && !hints[ol.View.Hint.INTERACTING] &&
!ol.extent.isEmpty(renderedExtent)) {
var projection = viewState.projection;
if (!ol.ENABLE_RASTER_REPROJECTION) {

View File

@@ -1,12 +1,13 @@
goog.provide('ol.renderer.canvas.Layer');
goog.require('ol.transform');
goog.require('ol');
goog.require('ol.extent');
goog.require('ol.render.Event');
goog.require('ol.render.EventType');
goog.require('ol.render.canvas');
goog.require('ol.render.canvas.Immediate');
goog.require('ol.renderer.Layer');
goog.require('ol.transform');
/**

View File

@@ -4,7 +4,7 @@ goog.provide('ol.renderer.canvas.TileLayer');
goog.require('ol.transform');
goog.require('ol.TileRange');
goog.require('ol.TileState');
goog.require('ol.Tile');
goog.require('ol.array');
goog.require('ol.dom');
goog.require('ol.extent');
@@ -131,9 +131,9 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame = function(
*/
function(tile) {
var tileState = tile.getState();
return tileState == ol.TileState.LOADED ||
tileState == ol.TileState.EMPTY ||
tileState == ol.TileState.ERROR && !useInterimTilesOnError;
return tileState == ol.Tile.State.LOADED ||
tileState == ol.Tile.State.EMPTY ||
tileState == ol.Tile.State.ERROR && !useInterimTilesOnError;
});
for (x = tileRange.minX; x <= tileRange.maxX; ++x) {
for (y = tileRange.minY; y <= tileRange.maxY; ++y) {
@@ -168,7 +168,7 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame = function(
tilesToDraw = tilesToDrawByZ[currentZ];
for (tileCoordKey in tilesToDraw) {
tile = tilesToDraw[tileCoordKey];
if (tile.getState() == ol.TileState.LOADED) {
if (tile.getState() == ol.Tile.State.LOADED) {
renderables.push(tile);
}
}

View File

@@ -1,6 +1,7 @@
goog.provide('ol.renderer.canvas.VectorLayer');
goog.require('ol.ViewHint');
goog.require('ol');
goog.require('ol.View');
goog.require('ol.dom');
goog.require('ol.extent');
goog.require('ol.render.EventType');
@@ -201,8 +202,8 @@ ol.renderer.canvas.VectorLayer.prototype.prepareFrame = function(frameState, lay
frameState.attributions, vectorSource.getAttributions());
this.updateLogos(frameState, vectorSource);
var animating = frameState.viewHints[ol.ViewHint.ANIMATING];
var interacting = frameState.viewHints[ol.ViewHint.INTERACTING];
var animating = frameState.viewHints[ol.View.Hint.ANIMATING];
var interacting = frameState.viewHints[ol.View.Hint.INTERACTING];
var updateWhileAnimating = vectorLayer.getUpdateWhileAnimating();
var updateWhileInteracting = vectorLayer.getUpdateWhileInteracting();

View File

@@ -1,5 +1,6 @@
goog.provide('ol.renderer.canvas.VectorTileLayer');
goog.require('ol');
goog.require('ol.array');
goog.require('ol.extent');
goog.require('ol.proj');

View File

@@ -1,11 +1,13 @@
goog.provide('ol.renderer.dom.ImageLayer');
goog.require('ol.transform');
goog.require('ol.ViewHint');
goog.require('ol');
goog.require('ol.View');
goog.require('ol.array');
goog.require('ol.dom');
goog.require('ol.extent');
goog.require('ol.proj');
goog.require('ol.renderer.dom.Layer');
goog.require('ol.transform');
/**
@@ -88,7 +90,7 @@ ol.renderer.dom.ImageLayer.prototype.prepareFrame = function(frameState, layerSt
renderedExtent, layerState.extent);
}
if (!hints[ol.ViewHint.ANIMATING] && !hints[ol.ViewHint.INTERACTING] &&
if (!hints[ol.View.Hint.ANIMATING] && !hints[ol.View.Hint.INTERACTING] &&
!ol.extent.isEmpty(renderedExtent)) {
var projection = viewState.projection;
if (!ol.ENABLE_RASTER_REPROJECTION) {

View File

@@ -3,16 +3,16 @@
goog.provide('ol.renderer.dom.TileLayer');
goog.require('ol.transform');
goog.require('ol');
goog.require('ol.Tile');
goog.require('ol.TileRange');
goog.require('ol.TileState');
goog.require('ol.ViewHint');
goog.require('ol.View');
goog.require('ol.array');
goog.require('ol.dom');
goog.require('ol.extent');
goog.require('ol.renderer.dom.Layer');
goog.require('ol.size');
goog.require('ol.transform');
/**
@@ -120,18 +120,18 @@ ol.renderer.dom.TileLayer.prototype.prepareFrame = function(frameState, layerSta
for (y = tileRange.minY; y <= tileRange.maxY; ++y) {
tile = tileSource.getTile(z, x, y, pixelRatio, projection);
tileState = tile.getState();
drawable = tileState == ol.TileState.LOADED ||
tileState == ol.TileState.EMPTY ||
tileState == ol.TileState.ERROR && !useInterimTilesOnError;
drawable = tileState == ol.Tile.State.LOADED ||
tileState == ol.Tile.State.EMPTY ||
tileState == ol.Tile.State.ERROR && !useInterimTilesOnError;
if (!drawable && tile.interimTile) {
tile = tile.interimTile;
}
tileState = tile.getState();
if (tileState == ol.TileState.LOADED) {
if (tileState == ol.Tile.State.LOADED) {
tilesToDrawByZ[z][tile.tileCoord.toString()] = tile;
continue;
} else if (tileState == ol.TileState.EMPTY ||
(tileState == ol.TileState.ERROR &&
} else if (tileState == ol.Tile.State.EMPTY ||
(tileState == ol.Tile.State.ERROR &&
!useInterimTilesOnError)) {
continue;
}
@@ -225,8 +225,8 @@ ol.renderer.dom.TileLayer.prototype.prepareFrame = function(frameState, layerSta
this.target.insertBefore(tileLayerZ.target, this.target.childNodes[0] || null);
}
} else {
if (!frameState.viewHints[ol.ViewHint.ANIMATING] &&
!frameState.viewHints[ol.ViewHint.INTERACTING]) {
if (!frameState.viewHints[ol.View.Hint.ANIMATING] &&
!frameState.viewHints[ol.View.Hint.INTERACTING]) {
tileLayerZ.removeTilesOutsideExtent(extent, tmpTileRange);
}
}

View File

@@ -1,7 +1,7 @@
goog.provide('ol.renderer.dom.VectorLayer');
goog.require('ol.transform');
goog.require('ol.ViewHint');
goog.require('ol');
goog.require('ol.View');
goog.require('ol.dom');
goog.require('ol.extent');
goog.require('ol.render.Event');
@@ -10,6 +10,7 @@ goog.require('ol.render.canvas.Immediate');
goog.require('ol.render.canvas.ReplayGroup');
goog.require('ol.renderer.dom.Layer');
goog.require('ol.renderer.vector');
goog.require('ol.transform');
/**
@@ -217,8 +218,8 @@ ol.renderer.dom.VectorLayer.prototype.prepareFrame = function(frameState, layerS
frameState.attributions, vectorSource.getAttributions());
this.updateLogos(frameState, vectorSource);
var animating = frameState.viewHints[ol.ViewHint.ANIMATING];
var interacting = frameState.viewHints[ol.ViewHint.INTERACTING];
var animating = frameState.viewHints[ol.View.Hint.ANIMATING];
var interacting = frameState.viewHints[ol.View.Hint.INTERACTING];
var updateWhileAnimating = vectorLayer.getUpdateWhileAnimating();
var updateWhileInteracting = vectorLayer.getUpdateWhileInteracting();

View File

@@ -1,14 +1,15 @@
goog.provide('ol.renderer.Layer');
goog.require('ol.events');
goog.require('ol.events.EventType');
goog.require('ol');
goog.require('ol.functions');
goog.require('ol.ImageState');
goog.require('ol.Observable');
goog.require('ol.TileState');
goog.require('ol.transform');
goog.require('ol.Tile');
goog.require('ol.asserts');
goog.require('ol.events');
goog.require('ol.events.EventType');
goog.require('ol.functions');
goog.require('ol.source.State');
goog.require('ol.transform');
/**
@@ -221,8 +222,8 @@ ol.renderer.Layer.prototype.updateLogos = function(frameState, source) {
if (typeof logo === 'string') {
frameState.logos[logo] = '';
} else if (logo) {
ol.assert(typeof logo.href == 'string', 44); // `logo.href` should be a string.
ol.assert(typeof logo.src == 'string', 45); // `logo.src` should be a string.
ol.asserts.assert(typeof logo.href == 'string', 44); // `logo.href` should be a string.
ol.asserts.assert(typeof logo.src == 'string', 45); // `logo.src` should be a string.
frameState.logos[logo.src] = logo.href;
}
}
@@ -306,7 +307,7 @@ ol.renderer.Layer.prototype.manageTilePyramid = function(
for (y = tileRange.minY; y <= tileRange.maxY; ++y) {
if (currentZ - z <= preload) {
tile = tileSource.getTile(z, x, y, pixelRatio, projection);
if (tile.getState() == ol.TileState.IDLE) {
if (tile.getState() == ol.Tile.State.IDLE) {
wantedTiles[tile.getKey()] = true;
if (!tileQueue.isKeyQueued(tile.getKey())) {
tileQueue.enqueue([tile, tileSourceKey,

View File

@@ -1,7 +1,6 @@
goog.provide('ol.renderer.Map');
goog.provide('ol.RendererType');
goog.require('ol.transform');
goog.require('ol');
goog.require('ol.Disposable');
goog.require('ol.events');
@@ -9,7 +8,8 @@ goog.require('ol.events.EventType');
goog.require('ol.extent');
goog.require('ol.functions');
goog.require('ol.layer.Layer');
goog.require('ol.style.iconImageCache');
goog.require('ol.style');
goog.require('ol.transform');
/**
@@ -104,7 +104,8 @@ ol.renderer.Map.prototype.disposeInternal = function() {
* @private
*/
ol.renderer.Map.expireIconCache_ = function(map, frameState) {
ol.style.iconImageCache.expire();
var cache = ol.style.iconImageCache;
cache.expire();
};

View File

@@ -1,5 +1,6 @@
goog.provide('ol.renderer.vector');
goog.require('ol');
goog.require('ol.render.ReplayType');
goog.require('ol.style.ImageState');

View File

@@ -1,13 +1,14 @@
goog.provide('ol.renderer.webgl.ImageLayer');
goog.require('ol.transform');
goog.require('ol.ViewHint');
goog.require('ol');
goog.require('ol.View');
goog.require('ol.dom');
goog.require('ol.extent');
goog.require('ol.functions');
goog.require('ol.proj');
goog.require('ol.renderer.webgl.Layer');
goog.require('ol.source.ImageVector');
goog.require('ol.transform');
goog.require('ol.webgl');
goog.require('ol.webgl.Context');
@@ -111,7 +112,7 @@ ol.renderer.webgl.ImageLayer.prototype.prepareFrame = function(frameState, layer
renderedExtent = ol.extent.getIntersection(
renderedExtent, layerState.extent);
}
if (!hints[ol.ViewHint.ANIMATING] && !hints[ol.ViewHint.INTERACTING] &&
if (!hints[ol.View.Hint.ANIMATING] && !hints[ol.View.Hint.INTERACTING] &&
!ol.extent.isEmpty(renderedExtent)) {
var projection = viewState.projection;
if (!ol.ENABLE_RASTER_REPROJECTION) {

View File

@@ -1,11 +1,12 @@
goog.provide('ol.renderer.webgl.Layer');
goog.require('ol.transform');
goog.require('ol');
goog.require('ol.render.Event');
goog.require('ol.render.EventType');
goog.require('ol.render.webgl.Immediate');
goog.require('ol.renderer.Layer');
goog.require('ol.renderer.webgl.defaultmapshader');
goog.require('ol.transform');
goog.require('ol.vec.Mat4');
goog.require('ol.webgl');
goog.require('ol.webgl.Buffer');

View File

@@ -24,7 +24,7 @@ goog.require('ol.structs.LRUCache');
goog.require('ol.structs.PriorityQueue');
goog.require('ol.webgl');
goog.require('ol.webgl.Context');
goog.require('ol.webgl.WebGLContextEventType');
goog.require('ol.webgl.ContextEventType');
/**
@@ -91,9 +91,9 @@ ol.renderer.webgl.Map = function(container, map) {
*/
this.context_ = new ol.webgl.Context(this.canvas_, this.gl_);
ol.events.listen(this.canvas_, ol.webgl.WebGLContextEventType.LOST,
ol.events.listen(this.canvas_, ol.webgl.ContextEventType.LOST,
this.handleWebGLContextLost, this);
ol.events.listen(this.canvas_, ol.webgl.WebGLContextEventType.RESTORED,
ol.events.listen(this.canvas_, ol.webgl.ContextEventType.RESTORED,
this.handleWebGLContextRestored, this);
/**

View File

@@ -3,15 +3,16 @@
goog.provide('ol.renderer.webgl.TileLayer');
goog.require('ol.transform');
goog.require('ol');
goog.require('ol.Tile');
goog.require('ol.TileRange');
goog.require('ol.TileState');
goog.require('ol.array');
goog.require('ol.extent');
goog.require('ol.math');
goog.require('ol.renderer.webgl.Layer');
goog.require('ol.renderer.webgl.tilelayershader');
goog.require('ol.size');
goog.require('ol.transform');
goog.require('ol.webgl');
goog.require('ol.webgl.Buffer');
@@ -248,20 +249,20 @@ ol.renderer.webgl.TileLayer.prototype.prepareFrame = function(frameState, layerS
}
}
tileState = tile.getState();
drawable = tileState == ol.TileState.LOADED ||
tileState == ol.TileState.EMPTY ||
tileState == ol.TileState.ERROR && !useInterimTilesOnError;
drawable = tileState == ol.Tile.State.LOADED ||
tileState == ol.Tile.State.EMPTY ||
tileState == ol.Tile.State.ERROR && !useInterimTilesOnError;
if (!drawable && tile.interimTile) {
tile = tile.interimTile;
}
tileState = tile.getState();
if (tileState == ol.TileState.LOADED) {
if (tileState == ol.Tile.State.LOADED) {
if (mapRenderer.isTileTextureLoaded(tile)) {
tilesToDrawByZ[z][tile.tileCoord.toString()] = tile;
continue;
}
} else if (tileState == ol.TileState.EMPTY ||
(tileState == ol.TileState.ERROR &&
} else if (tileState == ol.Tile.State.EMPTY ||
(tileState == ol.Tile.State.ERROR &&
!useInterimTilesOnError)) {
continue;
}
@@ -328,7 +329,7 @@ ol.renderer.webgl.TileLayer.prototype.prepareFrame = function(frameState, layerS
* @param {ol.Tile} tile Tile.
*/
function(tile) {
if (tile.getState() == ol.TileState.LOADED &&
if (tile.getState() == ol.Tile.State.LOADED &&
!mapRenderer.isTileTextureLoaded(tile) &&
!tileTextureQueue.isKeyQueued(tile.getKey())) {
tileTextureQueue.enqueue([

View File

@@ -1,11 +1,12 @@
goog.provide('ol.renderer.webgl.VectorLayer');
goog.require('ol.ViewHint');
goog.require('ol');
goog.require('ol.View');
goog.require('ol.extent');
goog.require('ol.transform');
goog.require('ol.render.webgl.ReplayGroup');
goog.require('ol.renderer.vector');
goog.require('ol.renderer.webgl.Layer');
goog.require('ol.transform');
/**
@@ -190,8 +191,8 @@ ol.renderer.webgl.VectorLayer.prototype.prepareFrame = function(frameState, laye
frameState.attributions, vectorSource.getAttributions());
this.updateLogos(frameState, vectorSource);
var animating = frameState.viewHints[ol.ViewHint.ANIMATING];
var interacting = frameState.viewHints[ol.ViewHint.INTERACTING];
var animating = frameState.viewHints[ol.View.Hint.ANIMATING];
var interacting = frameState.viewHints[ol.View.Hint.INTERACTING];
var updateWhileAnimating = vectorLayer.getUpdateWhileAnimating();
var updateWhileInteracting = vectorLayer.getUpdateWhileInteracting();

View File

@@ -1,9 +1,10 @@
goog.provide('ol.reproj.Image');
goog.require('ol.events');
goog.require('ol.events.EventType');
goog.require('ol');
goog.require('ol.ImageBase');
goog.require('ol.ImageState');
goog.require('ol.events');
goog.require('ol.events.EventType');
goog.require('ol.extent');
goog.require('ol.reproj');
goog.require('ol.reproj.Triangulation');

Some files were not shown because too many files have changed in this diff Show More