Merge branch 'master' of github.com:openlayers/ol3
This commit is contained in:
9
Makefile
9
Makefile
@@ -1,9 +0,0 @@
|
|||||||
all:
|
|
||||||
java -jar plovr.jar serve main.json
|
|
||||||
build:
|
|
||||||
java -jar plovr.jar build main.json > index.js
|
|
||||||
jsdoc:
|
|
||||||
java -jar plovr.jar jsdoc main.json
|
|
||||||
|
|
||||||
.PHONY: build
|
|
||||||
.PHONY: jsdoc
|
|
||||||
5
api.json
5
api.json
@@ -3,6 +3,11 @@
|
|||||||
|
|
||||||
"output-file": "api.js",
|
"output-file": "api.js",
|
||||||
|
|
||||||
|
"output-wrapper": [
|
||||||
|
"// Copyright 2012 ...\n",
|
||||||
|
"(function(){%output%})();"
|
||||||
|
],
|
||||||
|
|
||||||
"inputs": "src/ol.export.js",
|
"inputs": "src/ol.export.js",
|
||||||
"paths": [
|
"paths": [
|
||||||
"src"
|
"src"
|
||||||
|
|||||||
10
main.html
10
main.html
@@ -1,10 +0,0 @@
|
|||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Closure Library + Plovr</title>
|
|
||||||
<script src="http://localhost:9810/compile?id=main"></script>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="output"></div>
|
|
||||||
<script>main()</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -38,6 +38,7 @@ ol.bounds = function(opt_arg){
|
|||||||
maxX = opt_arg[2];
|
maxX = opt_arg[2];
|
||||||
maxY = opt_arg[3];
|
maxY = opt_arg[3];
|
||||||
} else if (goog.isObject(opt_arg)) {
|
} else if (goog.isObject(opt_arg)) {
|
||||||
|
ol.base.checkKeys(opt_arg, ['minX', 'minY', 'maxX', 'maxY', 'projection']);
|
||||||
minX = opt_arg['minX'];
|
minX = opt_arg['minX'];
|
||||||
minY = opt_arg['minY'];
|
minY = opt_arg['minY'];
|
||||||
maxX = opt_arg['maxX'];
|
maxX = opt_arg['maxX'];
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
goog.provide('ol.feature');
|
goog.provide('ol.feature');
|
||||||
|
|
||||||
|
goog.require('ol.base');
|
||||||
goog.require('ol.Feature');
|
goog.require('ol.Feature');
|
||||||
goog.require('ol.geom.Geometry');
|
goog.require('ol.geom.Geometry');
|
||||||
|
|
||||||
@@ -29,6 +30,7 @@ ol.feature = function(opt_arg){
|
|||||||
return opt_arg;
|
return opt_arg;
|
||||||
}
|
}
|
||||||
else if (goog.isObject(opt_arg)) {
|
else if (goog.isObject(opt_arg)) {
|
||||||
|
ol.base.checkKeys(opt_arg, ['geometry', 'properties', 'type']);
|
||||||
properties = opt_arg['properties'];
|
properties = opt_arg['properties'];
|
||||||
geometry = opt_arg['geometry'];
|
geometry = opt_arg['geometry'];
|
||||||
type = opt_arg['type'];
|
type = opt_arg['type'];
|
||||||
@@ -56,6 +58,7 @@ ol.feature = function(opt_arg){
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @export
|
||||||
* @param {!string} attr The name of the attribute to be set.
|
* @param {!string} attr The name of the attribute to be set.
|
||||||
* @param {string|number|boolean} value The value of the attribute to be set.
|
* @param {string|number|boolean} value The value of the attribute to be set.
|
||||||
* @returns {ol.Feature} The feature so calls can be chained
|
* @returns {ol.Feature} The feature so calls can be chained
|
||||||
@@ -66,6 +69,7 @@ ol.Feature.prototype.set = function(attr, value) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @export
|
||||||
* @param {!string} attr The name of the attribute to be set.
|
* @param {!string} attr The name of the attribute to be set.
|
||||||
* @returns {string|number|boolean|undefined} The attribute value requested.
|
* @returns {string|number|boolean|undefined} The attribute value requested.
|
||||||
*/
|
*/
|
||||||
@@ -74,6 +78,7 @@ ol.Feature.prototype.get = function(attr) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @export
|
||||||
* @param {ol.geom.Geometry=} opt_arg
|
* @param {ol.geom.Geometry=} opt_arg
|
||||||
* @returns {ol.Feature|ol.geom.Geometry|undefined} get or set the geometry on a feature
|
* @returns {ol.Feature|ol.geom.Geometry|undefined} get or set the geometry on a feature
|
||||||
*/
|
*/
|
||||||
@@ -85,5 +90,3 @@ ol.Feature.prototype.geometry = function(opt_arg) {
|
|||||||
return this.getGeometry();
|
return this.getGeometry();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ ol.loc = function(opt_arg){
|
|||||||
z = opt_arg[2];
|
z = opt_arg[2];
|
||||||
projection = opt_arg[3];
|
projection = opt_arg[3];
|
||||||
} else if (goog.isObject(opt_arg)) {
|
} else if (goog.isObject(opt_arg)) {
|
||||||
|
ol.base.checkKeys(opt_arg, ['projection', 'x', 'y', 'z']);
|
||||||
x = opt_arg['x'];
|
x = opt_arg['x'];
|
||||||
y = opt_arg['y'];
|
y = opt_arg['y'];
|
||||||
z = opt_arg['z'];
|
z = opt_arg['z'];
|
||||||
|
|||||||
@@ -49,33 +49,18 @@ ol.map = function(opt_arg) {
|
|||||||
return opt_arg;
|
return opt_arg;
|
||||||
}
|
}
|
||||||
else if (goog.isObject(opt_arg)) {
|
else if (goog.isObject(opt_arg)) {
|
||||||
|
ol.base.checkKeys(opt_arg, ['center', 'zoom', 'numZoomLevels', 'projection', 'userProjection', 'maxExtent', 'maxRes', 'resolutions', 'renderTo', 'layers', 'controls']);
|
||||||
center = opt_arg['center'];
|
center = opt_arg['center'];
|
||||||
delete opt_arg['center'];
|
|
||||||
zoom = opt_arg['zoom'];
|
zoom = opt_arg['zoom'];
|
||||||
delete opt_arg['zoom'];
|
|
||||||
numZoomLevels = opt_arg['numZoomLevels'];
|
numZoomLevels = opt_arg['numZoomLevels'];
|
||||||
delete opt_arg['numZoomLevels'];
|
|
||||||
projection = opt_arg['projection'];
|
projection = opt_arg['projection'];
|
||||||
delete opt_arg['projection'];
|
|
||||||
userProjection = opt_arg['userProjection'];
|
userProjection = opt_arg['userProjection'];
|
||||||
delete opt_arg['userProjection'];
|
|
||||||
maxExtent = opt_arg['maxExtent'];
|
maxExtent = opt_arg['maxExtent'];
|
||||||
delete opt_arg['maxExtent'];
|
|
||||||
maxRes = opt_arg['maxRes'];
|
maxRes = opt_arg['maxRes'];
|
||||||
delete opt_arg['maxRes'];
|
|
||||||
resolutions = opt_arg['resolutions'];
|
resolutions = opt_arg['resolutions'];
|
||||||
delete opt_arg['resolutions'];
|
|
||||||
renderTo = opt_arg['renderTo'];
|
renderTo = opt_arg['renderTo'];
|
||||||
delete opt_arg['renderTo'];
|
|
||||||
layers = opt_arg['layers'];
|
layers = opt_arg['layers'];
|
||||||
delete opt_arg['layers'];
|
|
||||||
controls = opt_arg['controls'];
|
controls = opt_arg['controls'];
|
||||||
delete opt_arg['controls'];
|
|
||||||
var k = goog.object.getAnyKey(opt_arg);
|
|
||||||
if (goog.isDef(k)) {
|
|
||||||
ol.error(k + ' is not a map option');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new Error('ol.map');
|
throw new Error('ol.map');
|
||||||
@@ -236,7 +221,7 @@ ol.Map.prototype.controls = function(opt_arg) {
|
|||||||
/**
|
/**
|
||||||
* @export
|
* @export
|
||||||
* @param {Array=} opt_arg
|
* @param {Array=} opt_arg
|
||||||
* @returns {ol.Map|ol.UnreferencedBounds|undefined} Map max extent.
|
* @returns {ol.Map|ol.Bounds|undefined} Map max extent.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.maxExtent = function(opt_arg) {
|
ol.Map.prototype.maxExtent = function(opt_arg) {
|
||||||
if (arguments.length == 1 && goog.isDef(opt_arg)) {
|
if (arguments.length == 1 && goog.isDef(opt_arg)) {
|
||||||
@@ -247,28 +232,6 @@ ol.Map.prototype.maxExtent = function(opt_arg) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @export
|
|
||||||
* @param {number=} opt_arg
|
|
||||||
* @returns {ol.Map|number|undefined} Map maximum resolution
|
|
||||||
*/
|
|
||||||
ol.Map.prototype.maxRes = function(opt_arg) {
|
|
||||||
if (arguments.length == 1 && goog.isDef(opt_arg)) {
|
|
||||||
this.setMaxRes(opt_arg);
|
|
||||||
return this;
|
|
||||||
} else {
|
|
||||||
return this.getMaxRes();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {number} arg
|
|
||||||
* @returns {number} resolution for a given zoom level
|
|
||||||
*/
|
|
||||||
ol.Map.prototype.getResForZoom = function(arg) {
|
|
||||||
return this.getResolutionForZoom(arg);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string|Element} arg Render the map to a container
|
* @param {string|Element} arg Render the map to a container
|
||||||
* @returns {ol.Map}
|
* @returns {ol.Map}
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
goog.provide('ol.projection');
|
goog.provide('ol.projection');
|
||||||
|
|
||||||
|
goog.require('ol.base');
|
||||||
goog.require('ol.Projection');
|
goog.require('ol.Projection');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {ol.Projection|string}
|
* @typedef {ol.Projection|Object|string}
|
||||||
*/
|
*/
|
||||||
ol.ProjectionLike;
|
ol.ProjectionLike;
|
||||||
|
|
||||||
@@ -32,6 +33,7 @@ ol.projection = function(opt_arg){
|
|||||||
code = opt_arg;
|
code = opt_arg;
|
||||||
}
|
}
|
||||||
else if (goog.isObject(opt_arg)) {
|
else if (goog.isObject(opt_arg)) {
|
||||||
|
ol.base.checkKeys(opt_arg, ['code', 'maxExtent', 'units']);
|
||||||
if (goog.isString(opt_arg['code'])) {
|
if (goog.isString(opt_arg['code'])) {
|
||||||
code = opt_arg['code'];
|
code = opt_arg['code'];
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -45,3 +45,18 @@ goog.exportProperty( ol.Bounds.prototype, 'minX', ol.Bounds.prototype.minX );
|
|||||||
goog.exportProperty( ol.Bounds.prototype, 'minY', ol.Bounds.prototype.minY );
|
goog.exportProperty( ol.Bounds.prototype, 'minY', ol.Bounds.prototype.minY );
|
||||||
goog.exportProperty( ol.Bounds.prototype, 'maxX', ol.Bounds.prototype.maxX );
|
goog.exportProperty( ol.Bounds.prototype, 'maxX', ol.Bounds.prototype.maxX );
|
||||||
goog.exportProperty( ol.Bounds.prototype, 'maxY', ol.Bounds.prototype.maxY );
|
goog.exportProperty( ol.Bounds.prototype, 'maxY', ol.Bounds.prototype.maxY );
|
||||||
|
|
||||||
|
// ol.feature
|
||||||
|
goog.exportSymbol('ol.feature', ol.feature);
|
||||||
|
goog.exportSymbol('ol.Feature', ol.Feature);
|
||||||
|
goog.exportProperty(ol.Feature.prototype, 'set', ol.Feature.prototype.set);
|
||||||
|
goog.exportProperty(ol.Feature.prototype, 'get', ol.Feature.prototype.get);
|
||||||
|
goog.exportProperty(ol.Feature.prototype, 'geometry', ol.Feature.prototype.geometry);
|
||||||
|
|
||||||
|
// ol.geom.point
|
||||||
|
goog.exportSymbol('ol.geom.point', ol.geom.point);
|
||||||
|
goog.exportSymbol('ol.geom.Point', ol.geom.Point);
|
||||||
|
goog.exportProperty(ol.geom.Point.prototype, 'x', ol.geom.Point.prototype.x);
|
||||||
|
goog.exportProperty(ol.geom.Point.prototype, 'y', ol.geom.Point.prototype.y);
|
||||||
|
goog.exportPropertz(ol.geom.Point.prototzpe, 'z', ol.geom.Point.prototzpe.z);
|
||||||
|
goog.exportProperty(ol.geom.Point.prototype, 'projection', ol.geom.Point.prototype.projection);
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
goog.provide("ol");
|
goog.provide("ol");
|
||||||
|
|
||||||
|
goog.require('ol.base');
|
||||||
goog.require('ol.bounds');
|
goog.require('ol.bounds');
|
||||||
goog.require('ol.control.Control');
|
goog.require('ol.control.Control');
|
||||||
goog.require('ol.control.Navigation');
|
goog.require('ol.control.Navigation');
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ goog.require('ol.geom.Geometry');
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @export
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
ol.Feature = function() {
|
ol.Feature = function() {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
goog.provide('ol.Map');
|
goog.provide('ol.Map');
|
||||||
|
|
||||||
goog.require('ol.Loc');
|
goog.require('ol.Loc');
|
||||||
|
goog.require('ol.Bounds');
|
||||||
goog.require('ol.Projection');
|
goog.require('ol.Projection');
|
||||||
goog.require('ol.event');
|
goog.require('ol.event');
|
||||||
goog.require('ol.event.Events');
|
goog.require('ol.event.Events');
|
||||||
@@ -65,7 +66,7 @@ ol.Map = function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {ol.UnreferencedBounds}
|
* @type {ol.Bounds}
|
||||||
*/
|
*/
|
||||||
this.maxExtent_ = null;
|
this.maxExtent_ = null;
|
||||||
|
|
||||||
@@ -209,14 +210,19 @@ ol.Map.prototype.getControls = function() {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {ol.UnreferencedBounds} the maxExtent for the map
|
* @return {ol.Bounds} the maxExtent for the map
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.getMaxExtent = function() {
|
ol.Map.prototype.getMaxExtent = function() {
|
||||||
if (goog.isDefAndNotNull(this.maxExtent_)) {
|
if (goog.isDefAndNotNull(this.maxExtent_)) {
|
||||||
return this.maxExtent_;
|
return this.maxExtent_;
|
||||||
} else {
|
} else {
|
||||||
var extent = this.getProjection().getExtent();
|
var projection = this.getProjection();
|
||||||
|
var extent = projection.getExtent();
|
||||||
if (goog.isDefAndNotNull(extent)) {
|
if (goog.isDefAndNotNull(extent)) {
|
||||||
|
extent = new ol.Bounds(
|
||||||
|
extent.getMinX(), extent.getMinY(),
|
||||||
|
extent.getMaxX(), extent.getMaxY());
|
||||||
|
extent.setProjection(projection);
|
||||||
return extent;
|
return extent;
|
||||||
} else {
|
} else {
|
||||||
throw('maxExtent must be defined either in the map or the projection');
|
throw('maxExtent must be defined either in the map or the projection');
|
||||||
@@ -332,7 +338,7 @@ ol.Map.prototype.setControls = function(opt_controls) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.UnreferencedBounds} extent the maxExtent for the map
|
* @param {ol.Bounds} extent the maxExtent for the map
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.setMaxExtent = function(extent) {
|
ol.Map.prototype.setMaxExtent = function(extent) {
|
||||||
this.maxExtent_ = extent;
|
this.maxExtent_ = extent;
|
||||||
|
|||||||
39
src/ol/base.js
Normal file
39
src/ol/base.js
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
goog.provide('ol.base');
|
||||||
|
goog.provide('ol.error');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} message Message.
|
||||||
|
*/
|
||||||
|
ol.error = function(message) {
|
||||||
|
if (ol.error.VERBOSE_ERRORS) {
|
||||||
|
throw new Error(message);
|
||||||
|
} else {
|
||||||
|
throw null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @define {boolean}
|
||||||
|
*/
|
||||||
|
ol.error.VERBOSE_ERRORS = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @define {boolean}
|
||||||
|
*/
|
||||||
|
ol.CHECK_KEYS = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Object} obj Object.
|
||||||
|
* @param {!Array.<string>} allowedKeys Allowed keys.
|
||||||
|
*/
|
||||||
|
ol.base.checkKeys = function(obj, allowedKeys) {
|
||||||
|
if (ol.CHECK_KEYS) {
|
||||||
|
var keys = goog.object.getKeys(obj);
|
||||||
|
goog.array.forEach(allowedKeys, function(allowedKey) {
|
||||||
|
goog.array.remove(keys, allowedKey);
|
||||||
|
});
|
||||||
|
if (!goog.array.isEmpty(keys)) {
|
||||||
|
ol.error('object contains invalid keys: ' + keys.join(', '));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
goog.provide('ol.error');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} message Message.
|
|
||||||
*/
|
|
||||||
ol.error = function(message) {
|
|
||||||
if (ol.error.VERBOSE_ERRORS) {
|
|
||||||
throw new Error(message);
|
|
||||||
} else {
|
|
||||||
throw null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @define {boolean}
|
|
||||||
*/
|
|
||||||
ol.error.VERBOSE_ERRORS = true;
|
|
||||||
@@ -3,6 +3,7 @@ goog.provide('ol.geom.Collection');
|
|||||||
goog.require('goog.array');
|
goog.require('goog.array');
|
||||||
goog.require('ol.geom.Geometry');
|
goog.require('ol.geom.Geometry');
|
||||||
goog.require('ol.Projection');
|
goog.require('ol.Projection');
|
||||||
|
goog.require('ol.base');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates ol.geom.Collection objects.
|
* Creates ol.geom.Collection objects.
|
||||||
@@ -96,8 +97,9 @@ ol.geom.Collection.prototype.setComponents = function(components) {
|
|||||||
if (allValidTypes) {
|
if (allValidTypes) {
|
||||||
this.components_ = components;
|
this.components_ = components;
|
||||||
} else {
|
} else {
|
||||||
throw new Error('ol.geom.Collection: at least one component passed to '
|
var msg = 'ol.geom.Collection: at least one component passed to '
|
||||||
+ 'setComponents is not allowed.');
|
+ 'setComponents is not allowed.';
|
||||||
|
ol.error(msg);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -111,8 +113,8 @@ ol.geom.Collection.prototype.addComponent = function(component, index) {
|
|||||||
if (this.isAllowedComponent(component)) {
|
if (this.isAllowedComponent(component)) {
|
||||||
goog.array.insertAt(this.components_, component, index);
|
goog.array.insertAt(this.components_, component, index);
|
||||||
} else {
|
} else {
|
||||||
throw new Error("ol.geom.Collection: The component is not allowed "
|
var msg = 'ol.geom.Collection: component is not allowed to be added.';
|
||||||
+ "to be added.");
|
ol.error(msg);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ goog.require('ol.geom.Geometry');
|
|||||||
|
|
||||||
goog.require('ol.Projection');
|
goog.require('ol.Projection');
|
||||||
goog.require('ol.coord.AccessorInterface');
|
goog.require('ol.coord.AccessorInterface');
|
||||||
|
goog.require('ol.base');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates ol.geom.Point objects.
|
* Creates ol.geom.Point objects.
|
||||||
@@ -135,7 +136,8 @@ ol.geom.Point.prototype._transform = function(proj) {
|
|||||||
var point = {'x': this.x_, 'y': this.y_};
|
var point = {'x': this.x_, 'y': this.y_};
|
||||||
var sourceProj = this.projection_;
|
var sourceProj = this.projection_;
|
||||||
if (!goog.isDefAndNotNull(sourceProj)) {
|
if (!goog.isDefAndNotNull(sourceProj)) {
|
||||||
throw new Error("Cannot transform a point without a source projection.");
|
var msg = 'Cannot transform a point without a source projection.';
|
||||||
|
ol.error(msg);
|
||||||
}
|
}
|
||||||
ol.Projection.transform(point, sourceProj, proj);
|
ol.Projection.transform(point, sourceProj, proj);
|
||||||
|
|
||||||
|
|||||||
@@ -153,15 +153,44 @@ ol.layer.TileLayer.prototype.getTileOrigin = function() {
|
|||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get max resolution. Return undefined if the layer has no maxResolution,
|
||||||
|
* and no extent from which maxResolution could be derived.
|
||||||
|
* @return {number|undefined}
|
||||||
|
*/
|
||||||
|
ol.layer.TileLayer.prototype.getMaxResolution = function() {
|
||||||
|
if (!goog.isDef(this.maxResolution_)) {
|
||||||
|
var extent = this.getExtent();
|
||||||
|
if (!goog.isNull(extent)) {
|
||||||
|
this.maxResolution_ = Math.max(
|
||||||
|
(extent.getMaxX() - extent.getMinX()) / this.tileWidth_,
|
||||||
|
(extent.getMaxY() - extent.getMaxX()) / this.tileHeight_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this.maxResolution_;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the number of the zoom levels.
|
||||||
|
* @return {number|undefined}
|
||||||
|
*/
|
||||||
|
ol.layer.TileLayer.prototype.getNumZoomLevels = function() {
|
||||||
|
return this.numZoomLevels_;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get layer resolutions. Return null if the layer has no resolutions.
|
* Get layer resolutions. Return null if the layer has no resolutions.
|
||||||
* @return {Array.<number>}
|
* @return {Array.<number>}
|
||||||
*/
|
*/
|
||||||
ol.layer.TileLayer.prototype.getResolutions = function() {
|
ol.layer.TileLayer.prototype.getResolutions = function() {
|
||||||
if (goog.isNull(this.resolutions_) && goog.isDef(this.maxResolution_)) {
|
if (goog.isNull(this.resolutions_)) {
|
||||||
|
var maxResolution = this.getMaxResolution(),
|
||||||
|
numZoomLevels = this.getNumZoomLevels();
|
||||||
|
if (goog.isDef(maxResolution) && goog.isDef(numZoomLevels)) {
|
||||||
this.resolutions_ = [];
|
this.resolutions_ = [];
|
||||||
for (var i = 0; i < this.numZoomLevels_; i++) {
|
for (var i = 0; i < numZoomLevels; i++) {
|
||||||
this.resolutions_[i] = this.maxResolution_ / Math.pow(2, i);
|
this.resolutions_[i] = maxResolution / Math.pow(2, i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.resolutions_;
|
return this.resolutions_;
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ ol.layer.XYZ = function(url) {
|
|||||||
goog.base(this);
|
goog.base(this);
|
||||||
|
|
||||||
this.setUrl(url);
|
this.setUrl(url);
|
||||||
this.setMaxResolution(156543.03390625);
|
this.setProjection(new ol.Projection("EPSG:3857"));
|
||||||
|
this.setNumZoomLevels(22);
|
||||||
};
|
};
|
||||||
|
|
||||||
goog.inherits(ol.layer.XYZ, ol.layer.TileLayer);
|
goog.inherits(ol.layer.XYZ, ol.layer.TileLayer);
|
||||||
|
|||||||
@@ -58,21 +58,6 @@
|
|||||||
<script type="text/javascript" src="spec/api/layer/xyz.test.js"></script>
|
<script type="text/javascript" src="spec/api/layer/xyz.test.js"></script>
|
||||||
<script type="text/javascript" src="spec/api/layer/osm.test.js"></script>
|
<script type="text/javascript" src="spec/api/layer/osm.test.js"></script>
|
||||||
<script type="text/javascript" src="spec/api/feature.test.js"></script>
|
<script type="text/javascript" src="spec/api/feature.test.js"></script>
|
||||||
<script type="text/javascript" src="spec/ol/Events.test.js"></script>
|
|
||||||
<script type="text/javascript" src="spec/ol/UnreferencedBounds.test.js"></script>
|
|
||||||
<script type="text/javascript" src="spec/ol/Projection.test.js"></script>
|
|
||||||
<script type="text/javascript" src="spec/ol/Bounds.test.js"></script>
|
|
||||||
<script type="text/javascript" src="spec/ol/Tile.test.js"></script>
|
|
||||||
<script type="text/javascript" src="spec/ol/TileSet.test.js"></script>
|
|
||||||
<script type="text/javascript" src="spec/ol/TileCache.test.js"></script>
|
|
||||||
<script type="text/javascript" src="spec/ol/geom/Point.test.js"></script>
|
|
||||||
<script type="text/javascript" src="spec/ol/geom/MultiPoint.test.js"></script>
|
|
||||||
<script type="text/javascript" src="spec/ol/geom/LineString.test.js"></script>
|
|
||||||
<script type="text/javascript" src="spec/ol/geom/Collection.test.js"></script>
|
|
||||||
<script type="text/javascript" src="spec/ol/layer/TileLayer.test.js"></script>
|
|
||||||
<script type="text/javascript" src="spec/ol/layer/XYZ.test.js"></script>
|
|
||||||
<script type="text/javascript" src="spec/ol/Feature.test.js"></script>
|
|
||||||
<script type="text/javascript" src="spec/ol/renderer/WebGL.test.js"></script>
|
|
||||||
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
127
test/ol.html
Normal file
127
test/ol.html
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>OL Spec Runner</title>
|
||||||
|
|
||||||
|
<link rel="shortcut icon" type="image/png" href="jasmine-1.2.0/jasmine_favicon.png">
|
||||||
|
<link rel="stylesheet" type="text/css" href="jasmine-1.2.0/jasmine.css">
|
||||||
|
<script type="text/javascript" src="jasmine-1.2.0/jasmine.js"></script>
|
||||||
|
<script type="text/javascript" src="jasmine-1.2.0/jasmine-html.js"></script>
|
||||||
|
|
||||||
|
<!-- include source files here... -->
|
||||||
|
<script type="text/javascript">
|
||||||
|
// the following code includes the source-files of OpenLayers as they are
|
||||||
|
// defined in ol.js.
|
||||||
|
//
|
||||||
|
// You can control in which form the source will be loaded by passing
|
||||||
|
// URL-parameters:
|
||||||
|
//
|
||||||
|
// - host
|
||||||
|
// where the plovr compiler is running, if not passed this defaults to the
|
||||||
|
// current host on port 9810
|
||||||
|
//
|
||||||
|
// - mode
|
||||||
|
// which mode of compilation should be applied. Common values for this are
|
||||||
|
// RAW, SIMPLE or ADVANCED. If not provided, SIMPLE is used.
|
||||||
|
(function(doc, l){
|
||||||
|
var hostRegex = /[\\?&]host=([^&#]*)/,
|
||||||
|
modeRegex = /[\\?&]mode=([^&#]*)/,
|
||||||
|
hostResult = hostRegex.exec(l.href),
|
||||||
|
modeResult = modeRegex.exec(l.href),
|
||||||
|
host = (hostResult && hostResult[1])
|
||||||
|
? hostResult[1]
|
||||||
|
: (l.host)
|
||||||
|
? l.host + ':9810'
|
||||||
|
: 'localhost:9810',
|
||||||
|
mode = (modeResult && modeResult[1])
|
||||||
|
? modeResult[1]
|
||||||
|
: 'SIMPLE',
|
||||||
|
|
||||||
|
// Create the script tag which includes the derived variables from above
|
||||||
|
script = '<sc' + 'ript type="text/javascript" '
|
||||||
|
+ 'src="http://' + host + '/compile?id=ol&mode=' + mode + '">'
|
||||||
|
+ '</scr' + 'ipt>',
|
||||||
|
|
||||||
|
// this function will fix the links of the result to also include
|
||||||
|
// the once defined URL Parametrs passed to the testsuite.
|
||||||
|
fixLinks = function() {
|
||||||
|
if (doc.getElementsByTagName) {
|
||||||
|
var candidates = doc.getElementsByTagName('a'),
|
||||||
|
link,
|
||||||
|
hrefExpression = /\?spec/,
|
||||||
|
i = 0, len = candidates.length;
|
||||||
|
for(; i < len; i++){
|
||||||
|
link = candidates[i];
|
||||||
|
if (hrefExpression.test(link.href)) {
|
||||||
|
link.href += '&host=' + encodeURIComponent(host)
|
||||||
|
+ '&mode=' + encodeURIComponent(mode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// write out the script-tag to load the compiled result
|
||||||
|
doc.write(script);
|
||||||
|
|
||||||
|
// overwrite jasmines finishCallback to run the fixLinks method afterwards
|
||||||
|
jasmine.Runner.prototype.finishCallback = function() {
|
||||||
|
jasmine.getEnv().reporter.reportRunnerResults(this);
|
||||||
|
fixLinks();
|
||||||
|
};
|
||||||
|
})(document, location);
|
||||||
|
</script>
|
||||||
|
<!-- common jasmine extensions -->
|
||||||
|
<script type="text/javascript" src="jasmine-extensions.js"></script>
|
||||||
|
|
||||||
|
<!-- include spec files here... -->
|
||||||
|
<script type="text/javascript" src="spec/ol/Events.test.js"></script>
|
||||||
|
<script type="text/javascript" src="spec/ol/UnreferencedBounds.test.js"></script>
|
||||||
|
<script type="text/javascript" src="spec/ol/Projection.test.js"></script>
|
||||||
|
<script type="text/javascript" src="spec/ol/Bounds.test.js"></script>
|
||||||
|
<script type="text/javascript" src="spec/ol/Tile.test.js"></script>
|
||||||
|
<script type="text/javascript" src="spec/ol/TileSet.test.js"></script>
|
||||||
|
<script type="text/javascript" src="spec/ol/TileCache.test.js"></script>
|
||||||
|
<script type="text/javascript" src="spec/ol/geom/Point.test.js"></script>
|
||||||
|
<script type="text/javascript" src="spec/ol/geom/MultiPoint.test.js"></script>
|
||||||
|
<script type="text/javascript" src="spec/ol/geom/LineString.test.js"></script>
|
||||||
|
<script type="text/javascript" src="spec/ol/geom/Collection.test.js"></script>
|
||||||
|
<script type="text/javascript" src="spec/ol/layer/TileLayer.test.js"></script>
|
||||||
|
<script type="text/javascript" src="spec/ol/layer/XYZ.test.js"></script>
|
||||||
|
<script type="text/javascript" src="spec/ol/Feature.test.js"></script>
|
||||||
|
<script type="text/javascript" src="spec/ol/renderer/WebGL.test.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
(function() {
|
||||||
|
var jasmineEnv = jasmine.getEnv();
|
||||||
|
jasmineEnv.updateInterval = 1000;
|
||||||
|
|
||||||
|
var htmlReporter = new jasmine.HtmlReporter();
|
||||||
|
|
||||||
|
jasmineEnv.addReporter(htmlReporter);
|
||||||
|
|
||||||
|
jasmineEnv.specFilter = function(spec) {
|
||||||
|
return htmlReporter.specFilter(spec);
|
||||||
|
};
|
||||||
|
|
||||||
|
var currentWindowOnload = window.onload;
|
||||||
|
|
||||||
|
window.onload = function() {
|
||||||
|
if (currentWindowOnload) {
|
||||||
|
currentWindowOnload();
|
||||||
|
}
|
||||||
|
execJasmine();
|
||||||
|
};
|
||||||
|
|
||||||
|
function execJasmine() {
|
||||||
|
jasmineEnv.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -27,5 +27,16 @@ describe("ol.bounds", function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("raises an error on invalid keys", function() {
|
||||||
|
expect(function() {
|
||||||
|
ol.bounds({
|
||||||
|
minX: 9,
|
||||||
|
minY: 10,
|
||||||
|
maxX: 11,
|
||||||
|
maxWhy: 12
|
||||||
|
});
|
||||||
|
}).toThrow();
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ describe("ol.feature", function() {
|
|||||||
|
|
||||||
var geom = feat.geometry();
|
var geom = feat.geometry();
|
||||||
expect(feat).toBeA(ol.Feature);
|
expect(feat).toBeA(ol.Feature);
|
||||||
expect(geom.getX()).toBe(21);
|
expect(geom.x()).toBe(21);
|
||||||
expect(geom.getY()).toBe(4);
|
expect(geom.y()).toBe(4);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be easy to create a feature from object literals", function() {
|
it("should be easy to create a feature from object literals", function() {
|
||||||
@@ -49,8 +49,8 @@ describe("ol.feature", function() {
|
|||||||
|
|
||||||
var geom = feat.geometry();
|
var geom = feat.geometry();
|
||||||
expect(feat).toBeA(ol.Feature);
|
expect(feat).toBeA(ol.Feature);
|
||||||
expect(geom.getX()).toBe(56);
|
expect(geom.x()).toBe(56);
|
||||||
expect(geom.getY()).toBe(22);
|
expect(geom.y()).toBe(22);
|
||||||
expect(feat.get('foo')).toBe('bar');
|
expect(feat.get('foo')).toBe('bar');
|
||||||
expect(feat.get('two')).toBe('deux');
|
expect(feat.get('two')).toBe('deux');
|
||||||
expect(feat.get('size')).toBe(3);
|
expect(feat.get('size')).toBe(3);
|
||||||
@@ -69,8 +69,8 @@ describe("ol.feature", function() {
|
|||||||
|
|
||||||
var geom = feat.geometry();
|
var geom = feat.geometry();
|
||||||
expect(feat).toBeA(ol.Feature);
|
expect(feat).toBeA(ol.Feature);
|
||||||
expect(geom.getX()).toBe(102.0);
|
expect(geom.x()).toBe(102.0);
|
||||||
expect(geom.getY()).toBe(0.5);
|
expect(geom.y()).toBe(0.5);
|
||||||
expect(feat.get('prop0')).toBe('value0');
|
expect(feat.get('prop0')).toBe('value0');
|
||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -193,11 +193,11 @@ describe("ol.map", function() {
|
|||||||
var map = ol.map();
|
var map = ol.map();
|
||||||
|
|
||||||
var extent = map.maxExtent();
|
var extent = map.maxExtent();
|
||||||
expect(extent).toBeA(ol.UnreferencedBounds);
|
expect(extent).toBeA(ol.Bounds);
|
||||||
expect(extent.getMinX()).toBe(-20037508.34);
|
expect(extent.minX()).toBe(-20037508.34);
|
||||||
expect(extent.getMaxX()).toBe(20037508.34);
|
expect(extent.maxX()).toBe(20037508.34);
|
||||||
expect(extent.getMinY()).toBe(-20037508.34);
|
expect(extent.minY()).toBe(-20037508.34);
|
||||||
expect(extent.getMaxY()).toBe(20037508.34);
|
expect(extent.maxY()).toBe(20037508.34);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -206,11 +206,11 @@ describe("ol.map", function() {
|
|||||||
map.maxExtent([-5,-4,7,9]);
|
map.maxExtent([-5,-4,7,9]);
|
||||||
|
|
||||||
var extent = map.maxExtent();
|
var extent = map.maxExtent();
|
||||||
expect(extent).toBeA(ol.UnreferencedBounds);
|
expect(extent).toBeA(ol.Bounds);
|
||||||
expect(extent.getMinX()).toBe(-5);
|
expect(extent.minX()).toBe(-5);
|
||||||
expect(extent.getMaxX()).toBe(7);
|
expect(extent.maxX()).toBe(7);
|
||||||
expect(extent.getMinY()).toBe(-4);
|
expect(extent.minY()).toBe(-4);
|
||||||
expect(extent.getMaxY()).toBe(9);
|
expect(extent.maxY()).toBe(9);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -219,11 +219,11 @@ describe("ol.map", function() {
|
|||||||
map.projection("CRS:84");
|
map.projection("CRS:84");
|
||||||
|
|
||||||
var extent = map.maxExtent();
|
var extent = map.maxExtent();
|
||||||
expect(extent).toBeA(ol.UnreferencedBounds);
|
expect(extent).toBeA(ol.Bounds);
|
||||||
expect(extent.getMinX()).toBe(-180);
|
expect(extent.minX()).toBe(-180);
|
||||||
expect(extent.getMaxX()).toBe(180);
|
expect(extent.maxX()).toBe(180);
|
||||||
expect(extent.getMinY()).toBe(-90);
|
expect(extent.minY()).toBe(-90);
|
||||||
expect(extent.getMaxY()).toBe(90);
|
expect(extent.maxY()).toBe(90);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -234,59 +234,6 @@ describe("ol.map", function() {
|
|||||||
}).toThrow();
|
}).toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("getMaxRes returns correct defaults", function() {
|
|
||||||
var map = ol.map();
|
|
||||||
|
|
||||||
var res = map.maxRes();
|
|
||||||
expect(res.toFixed(5)).toBe("156543.03391");
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
it("allows setting of maxRes", function() {
|
|
||||||
var map = ol.map({
|
|
||||||
maxRes: 67
|
|
||||||
});
|
|
||||||
|
|
||||||
var res = map.maxRes();
|
|
||||||
expect(res).toBe(67);
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
it("getMaxRes returns correct for custom maxExtent", function() {
|
|
||||||
var map = ol.map({
|
|
||||||
projection: ol.projection({
|
|
||||||
code: 'foo',
|
|
||||||
maxExtent: [0,0,90,90]
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
var res = map.maxRes();
|
|
||||||
expect(res.toFixed(7)).toBe("0.3515625");
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
it("returns correct getResForZoom for default map", function() {
|
|
||||||
var map = ol.map();
|
|
||||||
|
|
||||||
var res = map.getResForZoom(0);
|
|
||||||
expect(res.toFixed(5)).toBe("156543.03391");
|
|
||||||
res = map.getResForZoom(5);
|
|
||||||
expect(res.toFixed(5)).toBe("4891.96981");
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
it("returns correct getResForZoom when resolution array is set",function() {
|
|
||||||
var map = ol.map({
|
|
||||||
resolutions: [1,4,7,9,12]
|
|
||||||
});
|
|
||||||
|
|
||||||
var res = map.getResForZoom(0);
|
|
||||||
expect(res).toBe(1);
|
|
||||||
res = map.getResForZoom(3);
|
|
||||||
expect(res).toBe(9);
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
it("has no layers by default", function() {
|
it("has no layers by default", function() {
|
||||||
var map = ol.map();
|
var map = ol.map();
|
||||||
|
|
||||||
|
|||||||
@@ -134,6 +134,38 @@ describe('ol.layer.TileLayer', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('get max resolution', function() {
|
||||||
|
var layer;
|
||||||
|
|
||||||
|
beforeEach(function() {
|
||||||
|
layer = new ol.layer.TileLayer();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('with max resolution', function() {
|
||||||
|
|
||||||
|
beforeEach(function() {
|
||||||
|
layer.setMaxResolution(156543.03390625);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns the expected maxResolution', function() {
|
||||||
|
var maxResolution = layer.getMaxResolution();
|
||||||
|
expect(maxResolution).toEqual(156543.03390625);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('with projection', function() {
|
||||||
|
|
||||||
|
beforeEach(function() {
|
||||||
|
layer.setProjection(new ol.Projection("EPSG:3857"));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns the expected maxResolution', function() {
|
||||||
|
var maxResolution = layer.getMaxResolution();
|
||||||
|
expect(maxResolution).toEqual(156543.03390625);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('get data from the layer', function() {
|
describe('get data from the layer', function() {
|
||||||
var layer;
|
var layer;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user