Merge branch 'master' of https://github.com/openlayers/ol3
This commit is contained in:
@@ -47,4 +47,67 @@ ol.geom.point = function(opt_arg){
|
|||||||
var p = new ol.geom.Point(x,y,z,projection);
|
var p = new ol.geom.Point(x,y,z,projection);
|
||||||
return p;
|
return p;
|
||||||
};
|
};
|
||||||
goog.inherits(ol.geom.point, ol.geom.geometry);
|
goog.inherits(ol.geom.point, ol.geom.geometry);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @export
|
||||||
|
* @param {number=} opt_arg X.
|
||||||
|
* @return {ol.geom.Point|number} Result.
|
||||||
|
*/
|
||||||
|
ol.geom.Point.prototype.x = function(opt_arg){
|
||||||
|
if (arguments.length == 1 && goog.isDef(opt_arg)) {
|
||||||
|
this.setX(opt_arg);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return this.getX();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @export
|
||||||
|
* @param {number=} opt_arg Y.
|
||||||
|
* @return {ol.geom.Point|number} Result.
|
||||||
|
*/
|
||||||
|
ol.geom.Point.prototype.y = function(opt_arg){
|
||||||
|
if (arguments.length == 1 && goog.isDef(opt_arg)) {
|
||||||
|
this.setY(opt_arg);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return this.getY();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @export
|
||||||
|
* @param {number=} opt_arg Z.
|
||||||
|
* @return {ol.geom.Point|number|undefined} Result.
|
||||||
|
*/
|
||||||
|
ol.geom.Point.prototype.z = function(opt_arg){
|
||||||
|
if (arguments.length == 1 && goog.isDef(opt_arg)) {
|
||||||
|
this.setZ(opt_arg);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return this.getZ();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @export
|
||||||
|
* @param {ol.Projection=} opt_arg Projection.
|
||||||
|
* @return {ol.geom.Point|ol.Projection|undefined} Result.
|
||||||
|
*/
|
||||||
|
ol.geom.Point.prototype.projection = function(opt_arg){
|
||||||
|
if (arguments.length == 1 && goog.isDef(opt_arg)) {
|
||||||
|
this.setProjection(ol.projection(opt_arg));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return this.getProjection();
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -22,11 +22,20 @@ ol.loc = function(opt_arg){
|
|||||||
return opt_arg;
|
return opt_arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
var x = 0;
|
/** @type {number|undefined} */
|
||||||
var y = 0;
|
var x;
|
||||||
|
|
||||||
|
/** @type {number|undefined} */
|
||||||
|
var y;
|
||||||
|
|
||||||
|
/** @type {number|undefined} */
|
||||||
var z;
|
var z;
|
||||||
|
|
||||||
|
/** @type {Object|undefined} */
|
||||||
var projection;
|
var projection;
|
||||||
|
|
||||||
|
var usage = 'ol.loc accepts a coordinate array or an object with x, y, and (optional) z properties';
|
||||||
|
|
||||||
if (arguments.length == 1 && goog.isDef(opt_arg)) {
|
if (arguments.length == 1 && goog.isDef(opt_arg)) {
|
||||||
if (goog.isArray(opt_arg)) {
|
if (goog.isArray(opt_arg)) {
|
||||||
x = opt_arg[0];
|
x = opt_arg[0];
|
||||||
@@ -39,9 +48,13 @@ ol.loc = function(opt_arg){
|
|||||||
z = opt_arg['z'];
|
z = opt_arg['z'];
|
||||||
projection = opt_arg['projection'];
|
projection = opt_arg['projection'];
|
||||||
} else {
|
} else {
|
||||||
throw new Error('ol.loc');
|
throw new Error(usage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!goog.isNumber(x) || !goog.isNumber(y)) {
|
||||||
|
throw new Error(usage);
|
||||||
|
}
|
||||||
|
|
||||||
if (goog.isDef(projection)) {
|
if (goog.isDef(projection)) {
|
||||||
projection = ol.projection(projection);
|
projection = ol.projection(projection);
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ ol.map = function(opt_arg){
|
|||||||
var userProjection;
|
var userProjection;
|
||||||
/** @type {ol.Bounds|undefined} */
|
/** @type {ol.Bounds|undefined} */
|
||||||
var maxExtent;
|
var maxExtent;
|
||||||
|
/** @type {ol.Bounds|undefined} */
|
||||||
|
var maxRes;
|
||||||
/** @type {Array.<number>|undefined} */
|
/** @type {Array.<number>|undefined} */
|
||||||
var resolutions;
|
var resolutions;
|
||||||
/** @type {Array|undefined} */
|
/** @type {Array|undefined} */
|
||||||
@@ -47,6 +49,7 @@ ol.map = function(opt_arg){
|
|||||||
projection = opt_arg['projection'];
|
projection = opt_arg['projection'];
|
||||||
userProjection = opt_arg['userProjection'];
|
userProjection = opt_arg['userProjection'];
|
||||||
maxExtent = opt_arg['maxExtent'];
|
maxExtent = opt_arg['maxExtent'];
|
||||||
|
maxRes = opt_arg['maxRes'];
|
||||||
resolutions = opt_arg['resolutions'];
|
resolutions = opt_arg['resolutions'];
|
||||||
layers = opt_arg['layers'];
|
layers = opt_arg['layers'];
|
||||||
}
|
}
|
||||||
@@ -74,6 +77,9 @@ ol.map = function(opt_arg){
|
|||||||
if (goog.isDef(maxExtent)) {
|
if (goog.isDef(maxExtent)) {
|
||||||
map.setMaxExtent(ol.bounds(maxExtent));
|
map.setMaxExtent(ol.bounds(maxExtent));
|
||||||
}
|
}
|
||||||
|
if (goog.isDef(maxRes)) {
|
||||||
|
map.setMaxRes(maxRes);
|
||||||
|
}
|
||||||
if (goog.isDef(resolutions)) {
|
if (goog.isDef(resolutions)) {
|
||||||
map.setResolutions(resolutions);
|
map.setResolutions(resolutions);
|
||||||
}
|
}
|
||||||
@@ -187,3 +193,24 @@ ol.Map.prototype.maxExtent = function(opt_arg) {
|
|||||||
return this.getMaxExtent();
|
return this.getMaxExtent();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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);
|
||||||
|
};
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ ol.projection = function(opt_arg){
|
|||||||
/** @type {undefined|number} */
|
/** @type {undefined|number} */
|
||||||
var units;
|
var units;
|
||||||
|
|
||||||
|
/** @type {undefined|Array|ol.UnreferencedBounds} */
|
||||||
|
var extent;
|
||||||
|
|
||||||
if (arguments.length == 1 && goog.isDefAndNotNull(opt_arg)) {
|
if (arguments.length == 1 && goog.isDefAndNotNull(opt_arg)) {
|
||||||
if (opt_arg instanceof ol.Projection) {
|
if (opt_arg instanceof ol.Projection) {
|
||||||
return opt_arg;
|
return opt_arg;
|
||||||
@@ -35,13 +38,21 @@ ol.projection = function(opt_arg){
|
|||||||
throw new Error('Projection requires a string code.');
|
throw new Error('Projection requires a string code.');
|
||||||
}
|
}
|
||||||
units = opt_arg['units'];
|
units = opt_arg['units'];
|
||||||
|
extent = opt_arg['maxExtent'];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new Error('ol.projection');
|
throw new Error('ol.projection');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var proj = new ol.Projection(code);
|
var proj = new ol.Projection(code);
|
||||||
proj.setUnits(units);
|
if (goog.isDef(units)) {
|
||||||
|
proj.setUnits(units);
|
||||||
|
}
|
||||||
|
if (goog.isDef(extent)) {
|
||||||
|
proj.setExtent(
|
||||||
|
new ol.UnreferencedBounds(extent[0],extent[1],extent[2],extent[3])
|
||||||
|
);
|
||||||
|
}
|
||||||
return proj;
|
return proj;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -33,9 +33,9 @@ ol.Loc = function(x, y, opt_z, opt_projection) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {ol.Projection|undefined}
|
* @type {ol.Projection}
|
||||||
*/
|
*/
|
||||||
this.projection_ = opt_projection;
|
this.projection_ = goog.isDef(opt_projection) ? opt_projection : null;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ ol.Loc.prototype.getZ = function() {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Projection|undefined} projection Projection.
|
* @param {ol.Projection} projection Projection.
|
||||||
*/
|
*/
|
||||||
ol.Loc.prototype.setProjection = function(projection) {
|
ol.Loc.prototype.setProjection = function(projection) {
|
||||||
this.projection_ = projection;
|
this.projection_ = projection;
|
||||||
@@ -118,7 +118,7 @@ ol.Loc.prototype.transform = function(proj) {
|
|||||||
if (goog.isString(proj)) {
|
if (goog.isString(proj)) {
|
||||||
proj = new ol.Projection(proj);
|
proj = new ol.Projection(proj);
|
||||||
}
|
}
|
||||||
return this.transform_(proj);
|
return this._transform(proj);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -127,8 +127,8 @@ ol.Loc.prototype.transform = function(proj) {
|
|||||||
* @param {!ol.Projection} proj The destination projection.
|
* @param {!ol.Projection} proj The destination projection.
|
||||||
* @returns {!ol.Loc}
|
* @returns {!ol.Loc}
|
||||||
*/
|
*/
|
||||||
ol.Loc.prototype.transform_ = function(proj) {
|
ol.Loc.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 location without a source projection.");
|
throw new Error("Cannot transform a location without a source projection.");
|
||||||
|
|||||||
@@ -42,16 +42,28 @@ ol.Map = function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {Array|undefined}
|
* @type {Array}
|
||||||
*/
|
*/
|
||||||
this.resolutions_ = null;
|
this.resolutions_ = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {Array|undefined}
|
* @type {Array}
|
||||||
*/
|
*/
|
||||||
this.layers_ = null;
|
this.layers_ = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {ol.UnreferencedBounds}
|
||||||
|
*/
|
||||||
|
this.maxExtent_ = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {number|undefined}
|
||||||
|
*/
|
||||||
|
this.maxRes_ = undefined;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -64,12 +76,23 @@ ol.Map.prototype.DEFAULT_PROJECTION = "EPSG:3857";
|
|||||||
@type {string}
|
@type {string}
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.DEFAULT_USER_PROJECTION = "EPSG:4326";
|
ol.Map.prototype.DEFAULT_USER_PROJECTION = "EPSG:4326";
|
||||||
|
/**
|
||||||
|
@const
|
||||||
|
@type {number}
|
||||||
|
*/
|
||||||
|
ol.Map.ZOOM_FACTOR = 2;
|
||||||
|
/**
|
||||||
|
@const
|
||||||
|
@type {number}
|
||||||
|
*/
|
||||||
|
ol.Map.DEFAULT_TILE_SIZE = 256;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {ol.Loc} Location.
|
* @return {ol.Loc} Location.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.getCenter = function() {
|
ol.Map.prototype.getCenter = function() {
|
||||||
|
var proj = this.getUserProjection();
|
||||||
|
this.center_ = this.center_.transform(proj);
|
||||||
return this.center_;
|
return this.center_;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -145,11 +168,47 @@ ol.Map.prototype.getMaxExtent = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {number} the max resolution for the map
|
||||||
|
*/
|
||||||
|
ol.Map.prototype.getMaxRes = function() {
|
||||||
|
if (goog.isDefAndNotNull(this.maxRes_)) {
|
||||||
|
return this.maxRes_;
|
||||||
|
} else {
|
||||||
|
var extent = this.getMaxExtent();
|
||||||
|
var dim = Math.max(
|
||||||
|
(extent.getMaxX()-extent.getMinX()),
|
||||||
|
(extent.getMaxY()-extent.getMinY())
|
||||||
|
);
|
||||||
|
return dim/ol.Map.DEFAULT_TILE_SIZE;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} zoom the zoom level being requested
|
||||||
|
* @return {number} the resolution for the map at the given zoom level
|
||||||
|
*/
|
||||||
|
ol.Map.prototype.getResolutionForZoom = function(zoom) {
|
||||||
|
if (goog.isDefAndNotNull(this.resolutions_)) {
|
||||||
|
return this.resolutions_[zoom];
|
||||||
|
} else {
|
||||||
|
var maxRes = this.getMaxRes();
|
||||||
|
return maxRes/Math.pow(ol.Map.ZOOM_FACTOR, zoom);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Loc} center Center.
|
* @param {ol.Loc} center Center.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.setCenter = function(center) {
|
ol.Map.prototype.setCenter = function(center) {
|
||||||
this.center_ = center;
|
var proj = center.getProjection();
|
||||||
|
if (goog.isNull(proj)) {
|
||||||
|
proj = this.getUserProjection();
|
||||||
|
center.setProjection(proj);
|
||||||
|
}
|
||||||
|
this.center_ = center.transform(this.getProjection());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -199,12 +258,19 @@ ol.Map.prototype.setLayers = function(layers) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Bounds} extent the maxExtent for the map
|
* @param {ol.UnreferencedBounds} extent the maxExtent for the map
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.setMaxExtent = function(extent) {
|
ol.Map.prototype.setMaxExtent = function(extent) {
|
||||||
this.maxExtent_ = extent;
|
this.maxExtent_ = extent;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} res the max resolution for the map
|
||||||
|
*/
|
||||||
|
ol.Map.prototype.setMaxRes = function(res) {
|
||||||
|
this.maxRes_ = res;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.destroy = function() {
|
ol.Map.prototype.destroy = function() {
|
||||||
|
|||||||
@@ -22,15 +22,15 @@ ol.Projection = function(code) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {!Object|undefined}
|
* @type {Object}
|
||||||
*/
|
*/
|
||||||
this.proj_ = undefined;
|
this.proj_ = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {!ol.UnreferencedBounds|undefined}
|
* @type {ol.UnreferencedBounds}
|
||||||
*/
|
*/
|
||||||
this.extent_ = undefined;
|
this.extent_ = null;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -66,9 +66,18 @@ ol.Projection.prototype.setUnits = function(units) {
|
|||||||
/**
|
/**
|
||||||
* Get the validity extent of the coordinate reference system.
|
* Get the validity extent of the coordinate reference system.
|
||||||
*
|
*
|
||||||
* @return {!ol.UnreferencedBounds|undefined} The valididty extent.
|
* @return {ol.UnreferencedBounds} The valididty extent.
|
||||||
*/
|
*/
|
||||||
ol.Projection.prototype.getExtent = function() {
|
ol.Projection.prototype.getExtent = function() {
|
||||||
|
if (goog.isNull(this.extent_)) {
|
||||||
|
var defs = ol.Projection['defaults'][this.code_];
|
||||||
|
if (goog.isDef(defs)) {
|
||||||
|
var ext = defs['maxExtent'];
|
||||||
|
if (goog.isDef(ext)) {
|
||||||
|
this.setExtent(new ol.UnreferencedBounds(ext[0],ext[1],ext[2],ext[3]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return this.extent_;
|
return this.extent_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -11,21 +11,21 @@ goog.require('goog.style');
|
|||||||
/**
|
/**
|
||||||
* Determine whether event was caused by a single touch
|
* Determine whether event was caused by a single touch
|
||||||
*
|
*
|
||||||
* @param {Event} evt
|
* @param {!Event} evt
|
||||||
* @return {boolean}
|
* @return {boolean}
|
||||||
*/
|
*/
|
||||||
ol.event.isSingleTouch = function(evt) {
|
ol.event.isSingleTouch = function(evt) {
|
||||||
return evt.touches && evt.touches.length == 1;
|
return !!(evt.touches && evt.touches.length == 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine whether event was caused by a multi touch
|
* Determine whether event was caused by a multi touch
|
||||||
*
|
*
|
||||||
* @param {Event} evt
|
* @param {!Event} evt
|
||||||
* @return {boolean}
|
* @return {boolean}
|
||||||
*/
|
*/
|
||||||
ol.event.isMultiTouch = function(evt) {
|
ol.event.isMultiTouch = function(evt) {
|
||||||
return evt.touches && evt.touches.length > 1;
|
return !!(evt.touches && evt.touches.length > 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ ol.event.Events.prototype.getObject = function() {
|
|||||||
* @param {boolean} includeXY
|
* @param {boolean} includeXY
|
||||||
*/
|
*/
|
||||||
ol.event.Events.prototype.setIncludeXY = function(includeXY) {
|
ol.event.Events.prototype.setIncludeXY = function(includeXY) {
|
||||||
this._includeXY = includeXY;
|
this.includeXY_ = includeXY;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -215,7 +215,7 @@ ol.event.Events.prototype.un = function(object) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unregister a listener for an egent
|
* Unregister a listener for an event
|
||||||
*
|
*
|
||||||
* @param {string} type Name of the event to unregister
|
* @param {string} type Name of the event to unregister
|
||||||
* @param {Function} listener The callback function.
|
* @param {Function} listener The callback function.
|
||||||
@@ -242,6 +242,9 @@ ol.event.Events.prototype.triggerEvent = function(type, evt) {
|
|||||||
var returnValue,
|
var returnValue,
|
||||||
listeners = goog.events.getListeners(this, type, true)
|
listeners = goog.events.getListeners(this, type, true)
|
||||||
.concat(goog.events.getListeners(this, type, false));
|
.concat(goog.events.getListeners(this, type, false));
|
||||||
|
if (arguments.length === 1) {
|
||||||
|
evt = {type: type};
|
||||||
|
}
|
||||||
for (var i=0, ii=listeners.length; i<ii; ++i) {
|
for (var i=0, ii=listeners.length; i<ii; ++i) {
|
||||||
returnValue = listeners[i].handleEvent(evt);
|
returnValue = listeners[i].handleEvent(evt);
|
||||||
if (returnValue === false) {
|
if (returnValue === false) {
|
||||||
@@ -283,7 +286,7 @@ ol.event.Events.prototype.handleBrowserEvent = function(evt) {
|
|||||||
evt.clientX = x / num;
|
evt.clientX = x / num;
|
||||||
evt.clientY = y / num;
|
evt.clientY = y / num;
|
||||||
}
|
}
|
||||||
if (this.includeXY) {
|
if (this.includeXY_) {
|
||||||
var element = /** @type {!Element} */ this.element_;
|
var element = /** @type {!Element} */ this.element_;
|
||||||
evt.xy = goog.style.getRelativePosition(evt, element);
|
evt.xy = goog.style.getRelativePosition(evt, element);
|
||||||
}
|
}
|
||||||
@@ -294,6 +297,7 @@ ol.event.Events.prototype.handleBrowserEvent = function(evt) {
|
|||||||
* Destroy this Events instance.
|
* Destroy this Events instance.
|
||||||
*/
|
*/
|
||||||
ol.event.Events.prototype.destroy = function() {
|
ol.event.Events.prototype.destroy = function() {
|
||||||
|
this.setElement();
|
||||||
for (var p in this) {
|
for (var p in this) {
|
||||||
delete this[p];
|
delete this[p];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,3 +106,37 @@ ol.geom.Point.prototype.setZ = function(z) {
|
|||||||
this.z_ = z;
|
this.z_ = z;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transform this point to another coordinate reference system. This
|
||||||
|
* requires that this point has a projection set already (if not, an error
|
||||||
|
* will be thrown). Returns a new point object and does not modify this
|
||||||
|
* point.
|
||||||
|
*
|
||||||
|
* @param {string|!ol.Projection} proj The destination projection. Can be
|
||||||
|
* supplied as a projection instance of a string identifier.
|
||||||
|
* @returns {!ol.geom.Point} A new location.
|
||||||
|
*/
|
||||||
|
ol.geom.Point.prototype.transform = function(proj) {
|
||||||
|
if (goog.isString(proj)) {
|
||||||
|
proj = new ol.Projection(proj);
|
||||||
|
}
|
||||||
|
return this.transform_(proj);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transform this point to a new location given a projection object.
|
||||||
|
*
|
||||||
|
* @param {!ol.Projection} proj The destination projection.
|
||||||
|
* @returns {!ol.geom.Point}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
ol.geom.Point.prototype.transform_ = function(proj) {
|
||||||
|
var point = {x: this.x_, y: this.y_};
|
||||||
|
var sourceProj = this.projection_;
|
||||||
|
if (!goog.isDefAndNotNull(sourceProj)) {
|
||||||
|
throw new Error("Cannot transform a point without a source projection.");
|
||||||
|
}
|
||||||
|
ol.Projection.transform(point, sourceProj, proj);
|
||||||
|
return new ol.geom.Point(point.x, point.y, this.z_, proj);
|
||||||
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ goog.require('ol.TileSet');
|
|||||||
* Class for XYZ layers.
|
* Class for XYZ layers.
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param {string} url URL template. E.g.
|
* @param {string} url URL template. E.g.
|
||||||
* http://a.tile.openstreetmap.org/${z}/${x}/${y}.png.
|
* http://a.tile.openstreetmap.org/{z}/{x}/{y}.png.
|
||||||
*/
|
*/
|
||||||
ol.layer.XYZ = function(url) {
|
ol.layer.XYZ = function(url) {
|
||||||
|
|
||||||
@@ -108,9 +108,10 @@ ol.layer.XYZ.prototype.setResolutions = function(resolutions) {
|
|||||||
*/
|
*/
|
||||||
ol.layer.XYZ.prototype.getData = function(bounds, resolution) {
|
ol.layer.XYZ.prototype.getData = function(bounds, resolution) {
|
||||||
var me = this,
|
var me = this,
|
||||||
zoom = me.zoomForResolution_(resolution);
|
zoom = me.zoomForResolution(resolution);
|
||||||
resolution = me.resolutions_[zoom];
|
resolution = me.resolutions_[zoom];
|
||||||
|
|
||||||
|
// define some values used for the actual tiling
|
||||||
var boundsMinX = bounds.getMinX(),
|
var boundsMinX = bounds.getMinX(),
|
||||||
boundsMaxX = bounds.getMaxX(),
|
boundsMaxX = bounds.getMaxX(),
|
||||||
boundsMinY = bounds.getMinY(),
|
boundsMinY = bounds.getMinY(),
|
||||||
@@ -130,26 +131,27 @@ ol.layer.XYZ.prototype.getData = function(bounds, resolution) {
|
|||||||
offsetY = Math.floor(
|
offsetY = Math.floor(
|
||||||
(tileOriginY - boundsMaxY) / tileHeightGeo),
|
(tileOriginY - boundsMaxY) / tileHeightGeo),
|
||||||
|
|
||||||
gridWidth = Math.ceil(
|
gridLeft = tileOriginX + tileWidthGeo * offsetX,
|
||||||
(boundsMaxX - boundsMinX) / tileWidthGeo),
|
gridTop = tileOriginY - tileHeightGeo * offsetY;
|
||||||
gridHeight = Math.ceil(
|
|
||||||
(boundsMaxY - boundsMinY) / tileHeightGeo);
|
|
||||||
|
|
||||||
|
// now tile
|
||||||
var tiles = [],
|
var tiles = [],
|
||||||
tile,
|
tile,
|
||||||
url,
|
url,
|
||||||
i, ii,
|
x = 0,
|
||||||
j, jj;
|
y = 0;
|
||||||
|
while (gridTop - (y * tileHeightGeo) > boundsMinY) {
|
||||||
for (i=0, ii=gridWidth; i<ii; i++) {
|
tiles[y] = [];
|
||||||
tiles[i] = [];
|
while (gridLeft + (x * tileWidthGeo) < boundsMaxX) {
|
||||||
for (j=0, jj=gridHeight; j<jj; j++) {
|
url = me.url_.replace('{x}', offsetX + x + '')
|
||||||
url = me.url_.replace('{x}', offsetX + i + '')
|
.replace('{y}', offsetY + y + '')
|
||||||
.replace('{y}', offsetY + j + '')
|
|
||||||
.replace('{z}', zoom);
|
.replace('{z}', zoom);
|
||||||
tile = new ol.Tile(url);
|
tile = new ol.Tile(url);
|
||||||
tiles[i][j] = tile;
|
tiles[y][x] = tile;
|
||||||
|
x++;
|
||||||
}
|
}
|
||||||
|
y++;
|
||||||
|
x = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ol.TileSet(tiles, tileWidth, tileHeight, resolution);
|
return new ol.TileSet(tiles, tileWidth, tileHeight, resolution);
|
||||||
@@ -157,10 +159,9 @@ ol.layer.XYZ.prototype.getData = function(bounds, resolution) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the zoom level (z) for the given resolution.
|
* Get the zoom level (z) for the given resolution.
|
||||||
* @private
|
|
||||||
* @param {number} resolution
|
* @param {number} resolution
|
||||||
*/
|
*/
|
||||||
ol.layer.XYZ.prototype.zoomForResolution_ = function(resolution) {
|
ol.layer.XYZ.prototype.zoomForResolution = function(resolution) {
|
||||||
var delta = Number.POSITIVE_INFINITY,
|
var delta = Number.POSITIVE_INFINITY,
|
||||||
currentDelta,
|
currentDelta,
|
||||||
resolutions = this.resolutions_;
|
resolutions = this.resolutions_;
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
goog.provide('ol.mixins.coordinate');
|
|
||||||
goog.require('goog.object');
|
|
||||||
|
|
||||||
goog.object.extend(ol.mixins.coordinate, {
|
|
||||||
|
|
||||||
getX : function() {
|
|
||||||
return this.x_;
|
|
||||||
},
|
|
||||||
|
|
||||||
getY : function() {
|
|
||||||
return this.y_;
|
|
||||||
},
|
|
||||||
|
|
||||||
getZ : function() {
|
|
||||||
return this.z_;
|
|
||||||
},
|
|
||||||
|
|
||||||
setX : function(x) {
|
|
||||||
this.x_ = x;
|
|
||||||
return this;
|
|
||||||
},
|
|
||||||
|
|
||||||
setY : function(y) {
|
|
||||||
this.y_ = y;
|
|
||||||
return this;
|
|
||||||
},
|
|
||||||
setZ: function(z) {
|
|
||||||
this.z_ = z;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
@@ -9,14 +9,46 @@
|
|||||||
<script type="text/javascript" src="jasmine-1.2.0/jasmine-html.js"></script>
|
<script type="text/javascript" src="jasmine-1.2.0/jasmine-html.js"></script>
|
||||||
|
|
||||||
<!-- include source files here... -->
|
<!-- include source files here... -->
|
||||||
<script type="text/javascript" src="http://localhost:9810/compile?id=ol&mode=SIMPLE"></script>
|
<script type="text/javascript">
|
||||||
|
// the following code includes the sourc-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',
|
||||||
|
script = '<sc' + 'ript type="text/javascript" '
|
||||||
|
+ 'src="http://' + host + '/compile?id=ol&mode=' + mode + '">'
|
||||||
|
+ '</scr' + 'ipt>';
|
||||||
|
doc.write(script);
|
||||||
|
})(document, location);
|
||||||
|
</script>
|
||||||
<!-- common jasmine extensions -->
|
<!-- common jasmine extensions -->
|
||||||
<script type="text/javascript" src="jasmine-extensions.js"></script>
|
<script type="text/javascript" src="jasmine-extensions.js"></script>
|
||||||
|
|
||||||
<!-- include spec files here... -->
|
<!-- include spec files here... -->
|
||||||
<script type="text/javascript" src="spec/api/bounds.test.js"></script>
|
<script type="text/javascript" src="spec/api/bounds.test.js"></script>
|
||||||
<script type="text/javascript" src="spec/api/geom/geom.test.js"></script>
|
<script type="text/javascript" src="spec/api/geom/geom.test.js"></script>
|
||||||
|
<script type="text/javascript" src="spec/api/geom/point.test.js"></script>
|
||||||
<script type="text/javascript" src="spec/api/loc.test.js"></script>
|
<script type="text/javascript" src="spec/api/loc.test.js"></script>
|
||||||
<script type="text/javascript" src="spec/api/map.test.js"></script>
|
<script type="text/javascript" src="spec/api/map.test.js"></script>
|
||||||
<script type="text/javascript" src="spec/api/projection.test.js"></script>
|
<script type="text/javascript" src="spec/api/projection.test.js"></script>
|
||||||
|
|||||||
162
test/spec/api/geom/point.test.js
Normal file
162
test/spec/api/geom/point.test.js
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
describe("ol.geom.point", function() {
|
||||||
|
var pNoArgs,
|
||||||
|
pNoZ_arr,
|
||||||
|
pWithZ_arr,
|
||||||
|
p_arr,
|
||||||
|
pNoZ_obj,
|
||||||
|
pWithZ_obj,
|
||||||
|
p_obj,
|
||||||
|
proj = "EPSG:4326";
|
||||||
|
|
||||||
|
var instances = {
|
||||||
|
"no arguments passed": ol.geom.point(),
|
||||||
|
"one argument <Array[x,y]> passed": ol.geom.point([21, 4]),
|
||||||
|
"one argument <Array[x,y,z]> passed": ol.geom.point([21, 4, 8]),
|
||||||
|
"one argument <Array[x,y,z,projection]> passed": ol.geom.point([21, 4, 8, proj]),
|
||||||
|
"one argument <Object{x,y}> passed": ol.geom.point({x: 21, y: 4}),
|
||||||
|
"one argument <Object{x,y,z}> passed": ol.geom.point({x: 21, y: 4, z: 8}),
|
||||||
|
"one argument <Object{x,y,z,projection}> passed": ol.geom.point({x: 21, y: 4, z: 8, projection: proj})
|
||||||
|
};
|
||||||
|
|
||||||
|
beforeEach(function() {
|
||||||
|
proj = ol.projection("EPSG:4326");
|
||||||
|
instances = {
|
||||||
|
"no arguments passed": ol.geom.point(),
|
||||||
|
"one argument <Array[x,y]> passed": ol.geom.point([21, 4]),
|
||||||
|
"one argument <Array[x,y,z]> passed": ol.geom.point([21, 4, 8]),
|
||||||
|
"one argument <Array[x,y,z,projection]> passed": ol.geom.point([21, 4, 8, proj]),
|
||||||
|
"one argument <Object{x,y}> passed": ol.geom.point({x: 21, y: 4}),
|
||||||
|
"one argument <Object{x,y,z}> passed": ol.geom.point({x: 21, y: 4, z: 8}),
|
||||||
|
"one argument <Object{x,y,z,projection}> passed": ol.geom.point({x: 21, y: 4, z: 8, projection: proj})
|
||||||
|
};
|
||||||
|
pNoArgs = instances["no arguments passed"];
|
||||||
|
pNoZ_arr = instances["one argument <Array[x,y]> passed"];
|
||||||
|
pWithZ_arr = instances["one argument <Array[x,y,z]> passed"];
|
||||||
|
p_arr = instances["one argument <Array[x,y,z,projection]> passed"];
|
||||||
|
pNoZ_obj = instances["one argument <Object{x,y}> passed"];
|
||||||
|
pWithZ_obj = instances["one argument <Object{x,y,z}> passed"];
|
||||||
|
p_obj = instances["one argument <Object{x,y,z,projection}> passed"];
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(function() {
|
||||||
|
pNoArgs = null;
|
||||||
|
pNoZ_arr = pWithZ_arr = p_arr = null;
|
||||||
|
PNoZ_obj = pWithZ_obj = p_obj = null;
|
||||||
|
instances = {
|
||||||
|
"no arguments passed": ol.geom.point(),
|
||||||
|
"one argument <Array[x,y]> passed": ol.geom.point([21, 4]),
|
||||||
|
"one argument <Array[x,y,z]> passed": ol.geom.point([21, 4, 8]),
|
||||||
|
"one argument <Array[x,y,z,projection]> passed": ol.geom.point([21, 4, 8, proj]),
|
||||||
|
"one argument <Object{x,y}> passed": ol.geom.point({x: 21, y: 4}),
|
||||||
|
"one argument <Object{x,y,z}> passed": ol.geom.point({x: 21, y: 4, z: 8}),
|
||||||
|
"one argument <Object{x,y,z,projection}> passed": ol.geom.point({x: 21, y: 4, z: 8, projection: proj})
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
for (instancesDesc in instances) {
|
||||||
|
if (instances.hasOwnProperty(instancesDesc)) {
|
||||||
|
var instance = instances[instancesDesc];
|
||||||
|
|
||||||
|
it("constructs instances (" + instancesDesc + ")", function() {
|
||||||
|
expect(instance).toEqual(jasmine.any(ol.geom.Point));
|
||||||
|
});
|
||||||
|
|
||||||
|
it("constructs instances of ol.geom.Geometry (" + instancesDesc + ")", function() {
|
||||||
|
expect(instance).toEqual(jasmine.any(ol.geom.Geometry));
|
||||||
|
});
|
||||||
|
|
||||||
|
it("has coordinate getter/setter methods (" + instancesDesc + ")", function() {
|
||||||
|
expect(instance.x).not.toBeUndefined();
|
||||||
|
expect(instance.y).not.toBeUndefined();
|
||||||
|
expect(instance.z).not.toBeUndefined();
|
||||||
|
|
||||||
|
// always a number
|
||||||
|
expect( !isNaN( instance.x() ) ).toBe(true);
|
||||||
|
// setter returns self
|
||||||
|
expect(instance.x(47)).toBeA(ol.geom.Point);
|
||||||
|
// getter returns correct number
|
||||||
|
expect(instance.x()).toBe(47);
|
||||||
|
|
||||||
|
// always a number
|
||||||
|
expect( !isNaN( instance.y() ) ).toBe(true);
|
||||||
|
// setter returns self
|
||||||
|
expect(instance.y(74)).toBeA(ol.geom.Point);
|
||||||
|
// getter returns correct number
|
||||||
|
expect(instance.y()).toBe(74);
|
||||||
|
|
||||||
|
// always number or undefined
|
||||||
|
expect(instance.z() === undefined || !isNaN(instance.z()) ).toBe(true);
|
||||||
|
// setter returns self
|
||||||
|
expect(instance.z(0.074)).toBeA(ol.geom.Point);
|
||||||
|
// getter returns correct number
|
||||||
|
expect(instance.z()).toBe(0.074);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
it("has projection getter/setter methods (" + instancesDesc + ")", function() {
|
||||||
|
expect(instance.projection).not.toBeUndefined();
|
||||||
|
|
||||||
|
var getRes = instance.projection();
|
||||||
|
expect(getRes === null || getRes instanceof ol.Projection).toBe(true);
|
||||||
|
|
||||||
|
var setRes = instance.projection("EPSG:12345");
|
||||||
|
expect(setRes instanceof ol.geom.Point).toBe(true);
|
||||||
|
|
||||||
|
getRes = instance.projection();
|
||||||
|
expect(getRes).toBeA(ol.Projection);
|
||||||
|
expect(getRes.code()).toEqual("EPSG:12345");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
it("has functional getters (no arguments passed)", function(){
|
||||||
|
expect(pNoArgs.x()).toBe(0);
|
||||||
|
expect(pNoArgs.y()).toBe(0);
|
||||||
|
expect(pNoArgs.z()).toBeUndefined();
|
||||||
|
expect(pNoArgs.projection()).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("has functional getters (one argument <Array[x,y]> passed)", function(){
|
||||||
|
expect(pNoZ_arr.x()).toBe(21);
|
||||||
|
expect(pNoZ_arr.y()).toBe(4);
|
||||||
|
expect(pNoZ_arr.z()).toBeUndefined();
|
||||||
|
expect(pNoZ_arr.projection()).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("has functional getters (one argument <Array[x,y,z]> passed)", function(){
|
||||||
|
expect(pWithZ_arr.x()).toBe(21);
|
||||||
|
expect(pWithZ_arr.y()).toBe(4);
|
||||||
|
expect(pWithZ_arr.z()).toBe(8);
|
||||||
|
expect(pWithZ_arr.projection()).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("has functional getters (one argument <Array[x,y,z,projection]> passed)", function(){
|
||||||
|
expect(p_arr.x()).toBe(21);
|
||||||
|
expect(p_arr.y()).toBe(4);
|
||||||
|
expect(p_arr.z()).toBe(8);
|
||||||
|
expect(p_arr.projection()).not.toBeNull();
|
||||||
|
expect(p_arr.projection()).toBeA(ol.Projection);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("has functional getters (one argument <Object{x,y}> passed)", function(){
|
||||||
|
expect(pNoZ_obj.x()).toBe(21);
|
||||||
|
expect(pNoZ_obj.y()).toBe(4);
|
||||||
|
expect(pNoZ_obj.z()).toBeUndefined();
|
||||||
|
expect(pNoZ_obj.projection()).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("has functional getters (one argument <Object{x,y,z}> passed)", function(){
|
||||||
|
expect(pWithZ_obj.x()).toBe(21);
|
||||||
|
expect(pWithZ_obj.y()).toBe(4);
|
||||||
|
expect(pWithZ_obj.z()).toBe(8);
|
||||||
|
expect(pWithZ_obj.projection()).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("has functional getters (one argument <Object{x,y,z,projection}> passed)", function(){
|
||||||
|
expect(p_obj.x()).toBe(21);
|
||||||
|
expect(p_obj.y()).toBe(4);
|
||||||
|
expect(p_obj.z()).toBe(8);
|
||||||
|
expect(p_obj.projection()).not.toBeNull();
|
||||||
|
expect(p_obj.projection()).toEqual(jasmine.any(ol.Projection));
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,11 +1,12 @@
|
|||||||
describe("ol.loc", function() {
|
describe("ol.loc", function() {
|
||||||
|
|
||||||
it("allows empty construction", function() {
|
it("doesn't allow empty construction", function() {
|
||||||
var loc;
|
|
||||||
|
expect(function() {
|
||||||
|
// nowhere
|
||||||
|
var loc = ol.loc();
|
||||||
|
}).toThrow();
|
||||||
|
|
||||||
// nowhere
|
|
||||||
loc = ol.loc();
|
|
||||||
expect(loc).toBeA(ol.Loc);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("allows construction from an obj config", function() {
|
it("allows construction from an obj config", function() {
|
||||||
@@ -58,7 +59,7 @@ describe("ol.loc", function() {
|
|||||||
|
|
||||||
var loc = ol.loc({x: 1, y: 2});
|
var loc = ol.loc({x: 1, y: 2});
|
||||||
|
|
||||||
expect(loc.projection()).toBeUndefined();
|
expect(loc.projection()).toBeNull();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ describe("ol.map", function() {
|
|||||||
|
|
||||||
map.destroy();
|
map.destroy();
|
||||||
|
|
||||||
expect(goog.isDef(map.layers)).toBe(false);
|
expect(goog.isDef(map.getLayers())).toBe(false);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -199,11 +199,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.Bounds);
|
expect(extent).toBeA(ol.UnreferencedBounds);
|
||||||
expect(extent.minX()).toBe(-20037508.34);
|
expect(extent.getMinX()).toBe(-20037508.34);
|
||||||
expect(extent.maxX()).toBe(-20037508.34);
|
expect(extent.getMaxX()).toBe(20037508.34);
|
||||||
expect(extent.minY()).toBe(20037508.34);
|
expect(extent.getMinY()).toBe(-20037508.34);
|
||||||
expect(extent.maxY()).toBe(20037508.34);
|
expect(extent.getMaxY()).toBe(20037508.34);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -212,11 +212,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.Bounds);
|
expect(extent).toBeA(ol.UnreferencedBounds);
|
||||||
expect(extent.minX()).toBe(-5);
|
expect(extent.getMinX()).toBe(-5);
|
||||||
expect(extent.maxX()).toBe(-4);
|
expect(extent.getMaxX()).toBe(7);
|
||||||
expect(extent.minY()).toBe(7);
|
expect(extent.getMinY()).toBe(-4);
|
||||||
expect(extent.maxY()).toBe(9);
|
expect(extent.getMaxY()).toBe(9);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -225,11 +225,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.Bounds);
|
expect(extent).toBeA(ol.UnreferencedBounds);
|
||||||
expect(extent.minX()).toBe(-180);
|
expect(extent.getMinX()).toBe(-180);
|
||||||
expect(extent.maxX()).toBe(-90);
|
expect(extent.getMaxX()).toBe(180);
|
||||||
expect(extent.minY()).toBe(180);
|
expect(extent.getMinY()).toBe(-90);
|
||||||
expect(extent.maxY()).toBe(90);
|
expect(extent.getMaxY()).toBe(90);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -244,7 +244,7 @@ describe("ol.map", function() {
|
|||||||
var map = ol.map();
|
var map = ol.map();
|
||||||
|
|
||||||
var res = map.maxRes();
|
var res = map.maxRes();
|
||||||
expect(res.toFixed(5)).toBe(1.40625);
|
expect(res.toFixed(5)).toBe("156543.03391");
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -261,22 +261,35 @@ describe("ol.map", function() {
|
|||||||
it("getMaxRes returns correct for custom maxExtent", function() {
|
it("getMaxRes returns correct for custom maxExtent", function() {
|
||||||
var map = ol.map({
|
var map = ol.map({
|
||||||
projection: ol.projection({
|
projection: ol.projection({
|
||||||
|
code: 'foo',
|
||||||
maxExtent: [0,0,90,90]
|
maxExtent: [0,0,90,90]
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
var res = map.maxRes();
|
var res = map.maxRes();
|
||||||
expect(res.toFixed(7)).toBe(0.3515625);
|
expect(res.toFixed(7)).toBe("0.3515625");
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("getResForZoom returns correct defaults", function() {
|
it("returns correct getResForZoom for default map", function() {
|
||||||
var map = ol.map();
|
var map = ol.map();
|
||||||
|
|
||||||
res = map.getResForZoom(0);
|
var res = map.getResForZoom(0);
|
||||||
expect(res.toFixed(5)).toBe(1.40625);
|
expect(res.toFixed(5)).toBe("156543.03391");
|
||||||
res = map.getResForZoom(5);
|
res = map.getResForZoom(5);
|
||||||
expect(res.toFixed(10)).toBe(0.0439453125);
|
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);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,31 +1,164 @@
|
|||||||
describe("ol.Events", function() {
|
describe("ol.Events", function() {
|
||||||
|
|
||||||
|
var log = [],
|
||||||
|
logFn = function(e) {log.push({scope: this, evt: e});};
|
||||||
|
|
||||||
it("constructs instances", function() {
|
it("constructs instances", function() {
|
||||||
var events, element = document.createElement("div");
|
var events, element = document.createElement("div");
|
||||||
events = new ol.event.Events("foo");
|
|
||||||
|
events = new ol.event.Events("foo");
|
||||||
expect(events.getObject()).toBe("foo");
|
expect(events.getObject()).toBe("foo");
|
||||||
expect(events.getElement()).toBe(null);
|
expect(events.getElement()).toBe(null);
|
||||||
events.destroy();
|
events.destroy();
|
||||||
events = new ol.event.Events("foo", element, true);
|
|
||||||
|
events = new ol.event.Events("foo", element, true);
|
||||||
expect(events.getElement()).toBe(element);
|
expect(events.getElement()).toBe(element);
|
||||||
expect(events.includeXY_).toBe(true);
|
expect(events.includeXY_).toBe(true);
|
||||||
events.destroy();
|
events.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("destroys properly", function() {
|
it("destroys properly", function() {
|
||||||
var events = new ol.event.Events("foo");
|
var events = new ol.event.Events("foo");
|
||||||
events.destroy();
|
events.destroy();
|
||||||
expect(events.getObject()).toBe(undefined);
|
expect(events.getObject()).toBe(undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("relays browser events and knows about pointer position", function() {
|
||||||
|
var element = document.createElement("div"),
|
||||||
|
events = new ol.event.Events("foo", element);
|
||||||
|
|
||||||
|
//TODO Figure out a good way to deal with fixtures
|
||||||
|
element.style.position = "absolute";
|
||||||
|
element.style.left = "5px";
|
||||||
|
element.style.top = "10px";
|
||||||
|
document.body.appendChild(element);
|
||||||
|
// mock dom element so we can trigger events on it
|
||||||
|
goog.object.extend(element, new goog.events.EventTarget());
|
||||||
|
|
||||||
|
log = [];
|
||||||
|
events.register("click", logFn);
|
||||||
|
element.dispatchEvent("click");
|
||||||
|
expect(log.length).toBe(1);
|
||||||
|
|
||||||
|
// detach from the element
|
||||||
|
events.setElement();
|
||||||
|
element.dispatchEvent("click");
|
||||||
|
expect(log.length).toBe(1);
|
||||||
|
|
||||||
|
// attach to the element again
|
||||||
|
events.setElement(element);
|
||||||
|
events.setIncludeXY(true);
|
||||||
|
element.dispatchEvent({
|
||||||
|
type: "click",
|
||||||
|
touches: [{clientX: 9, clientY: 22}, {clientX: 11, clientY: 18}]
|
||||||
|
});
|
||||||
|
expect(log.length).toBe(2);
|
||||||
|
expect(log[1].evt.xy.x).toBe(5);
|
||||||
|
expect(log[1].evt.xy.y).toBe(10);
|
||||||
|
expect(log[1].evt.clientX).toBe(10);
|
||||||
|
expect(log[1].evt.clientY).toBe(20);
|
||||||
|
|
||||||
|
events.destroy();
|
||||||
|
document.body.removeChild(element);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("calls listeners with a scope and an event object", function() {
|
||||||
|
var scope = {}, evt = {}, events = new ol.event.Events("foo");
|
||||||
|
|
||||||
|
log = [];
|
||||||
|
events.register("bar", logFn, scope);
|
||||||
|
events.triggerEvent("bar", evt);
|
||||||
|
expect(log[0].scope).toBe(scope);
|
||||||
|
expect(log[0].evt).toBe(evt);
|
||||||
|
});
|
||||||
|
|
||||||
it("respects event priority", function() {
|
it("respects event priority", function() {
|
||||||
var log = [], events = new ol.event.Events("foo");
|
var log = [], events = new ol.event.Events("foo");
|
||||||
|
|
||||||
|
// register a normal listener
|
||||||
events.register("bar", function() {log.push("normal");});
|
events.register("bar", function() {log.push("normal");});
|
||||||
|
// register a priority listener
|
||||||
events.register(
|
events.register(
|
||||||
"bar", function() {log.push("priority");}, undefined, true);
|
"bar", function() {log.push("priority");}, undefined, true);
|
||||||
events.triggerEvent("bar");
|
events.triggerEvent("bar");
|
||||||
expect(log[0]).toBe("priority");
|
expect(log[0]).toBe("priority");
|
||||||
expect(log[1]).toBe("normal");
|
expect(log[1]).toBe("normal");
|
||||||
|
|
||||||
|
events.destroy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("allows to abort the event chain", function() {
|
||||||
|
var events = new ol.event.Events("foo");
|
||||||
|
|
||||||
|
log = [];
|
||||||
|
// register a listener that aborts the event chain
|
||||||
|
events.register("bar", function(e) {logFn(e); return false;});
|
||||||
|
// register a listener that just does something
|
||||||
|
events.register("bar", logFn);
|
||||||
|
events.triggerEvent("bar");
|
||||||
|
expect(log.length).toBe(1);
|
||||||
|
|
||||||
|
log = [];
|
||||||
|
// register a priority listener that just does something
|
||||||
|
events.register("bar", logFn, undefined, true);
|
||||||
|
events.triggerEvent("bar");
|
||||||
|
expect(log.length).toBe(2);
|
||||||
|
|
||||||
|
events.destroy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("allows to unregister events", function() {
|
||||||
|
var events = new ol.event.Events("foo");
|
||||||
|
|
||||||
|
log = [];
|
||||||
|
events.register("bar", logFn);
|
||||||
|
events.triggerEvent("bar");
|
||||||
|
expect(log.length).toBe(1);
|
||||||
|
|
||||||
|
events.unregister("bar", logFn);
|
||||||
|
events.triggerEvent("bar");
|
||||||
|
expect(log.length).toBe(1);
|
||||||
|
|
||||||
|
events.destroy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("has on() and un() convenience methods", function() {
|
||||||
|
var scope = {}, events = new ol.event.Events("foo");
|
||||||
|
|
||||||
|
log = [];
|
||||||
|
events.on({
|
||||||
|
"bar": logFn,
|
||||||
|
"baz": logFn,
|
||||||
|
scope: scope
|
||||||
|
});
|
||||||
|
events.triggerEvent("bar");
|
||||||
|
expect(log[0].evt.type).toBe("bar");
|
||||||
|
events.triggerEvent("baz");
|
||||||
|
expect(log[1].scope).toBe(scope);
|
||||||
|
expect(log[1].evt.type).toBe("baz");
|
||||||
|
|
||||||
|
events.un({
|
||||||
|
"bar": logFn,
|
||||||
|
"baz": logFn,
|
||||||
|
scope: scope
|
||||||
|
});
|
||||||
|
events.triggerEvent("bar");
|
||||||
|
events.triggerEvent("baz");
|
||||||
|
expect(log.length).toBe(2);
|
||||||
|
|
||||||
|
events.destroy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("provides an isSingleTouch() function", function() {
|
||||||
|
expect(ol.event.isSingleTouch({touches: [{}, {}]})).toBe(false);
|
||||||
|
expect(ol.event.isSingleTouch({touches: [{}]})).toBe(true);
|
||||||
|
expect(ol.event.isSingleTouch({})).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("provides an isMultiTouch() function", function() {
|
||||||
|
expect(ol.event.isMultiTouch({touches: [{}, {}]})).toBe(true);
|
||||||
|
expect(ol.event.isMultiTouch({touches: [{}]})).toBe(false);
|
||||||
|
expect(ol.event.isMultiTouch({})).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,44 +1,33 @@
|
|||||||
describe("ol.geom.Point", function() {
|
describe("ol.geom.Point", function() {
|
||||||
var pNoArgs,
|
var p2Args,
|
||||||
pNoZ_arr,
|
p3Args,
|
||||||
pWithZ_arr,
|
p4Args,
|
||||||
p_arr,
|
|
||||||
pNoZ_obj,
|
|
||||||
pWithZ_obj,
|
|
||||||
p_obj,
|
|
||||||
proj = "EPSG:4326";
|
proj = "EPSG:4326";
|
||||||
|
|
||||||
var instances = {
|
var instances = {
|
||||||
"no arguments passed": ol.geom.point(),
|
"two arguments <x>,<y> passed": new ol.geom.Point(21, 4),
|
||||||
"one argument [x,y] passed": ol.geom.point([21, 4]),
|
"three arguments <x>,<y>,<z> passed": new ol.geom.Point(21, 4, 8),
|
||||||
"one argument [x,y,z] passed": ol.geom.point([21, 4, 8]),
|
"four arguments <x>,<y>,<z>,<projection> passed": new ol.geom.Point(21, 4, 8, proj)
|
||||||
"one argument [x,y,z,projection] passed": ol.geom.point([21, 4, 8, proj]),
|
|
||||||
"one argument {x,y} passed": ol.geom.point([21, 4]),
|
|
||||||
"one argument {x,y,z} passed": ol.geom.point([21, 4, 8]),
|
|
||||||
"one argument {x,y,z,projection} passed": ol.geom.point([21, 4, 8, proj])
|
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
proj = ol.projection("EPSG:4326");
|
proj = ol.projection("EPSG:4326");
|
||||||
instances = {
|
instances = {
|
||||||
"no arguments passed": ol.geom.point(),
|
"two arguments <x>,<y> passed": new ol.geom.Point(21, 4),
|
||||||
"one argument [x,y] passed": ol.geom.point([21, 4]),
|
"three arguments <x>,<y>,<z> passed": new ol.geom.Point(21, 4, 8),
|
||||||
"one argument [x,y,z] passed": ol.geom.point([21, 4, 8]),
|
"four arguments <x>,<y>,<z>,<projection> passed": new ol.geom.Point(21, 4, 8, proj)
|
||||||
"one argument [x,y,z,projection] passed": ol.geom.point([21, 4, 8, proj])
|
|
||||||
};
|
};
|
||||||
pNoArgs = instances['no arguments passed'];
|
p2Args = instances['two arguments <x>,<y> passed'];
|
||||||
pNoZ = instances['one argument [x,y] passed'];
|
p3Args = instances['three arguments <x>,<y>,<z> passed'];
|
||||||
pWithZ = instances['one argument [x,y,z] passed'];
|
p4Args = instances['four arguments <x>,<y>,<z>,<projection> passed'];
|
||||||
p = instances['one argument [x,y,z,projection] passed'];
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
pNoArgs = pNoZ = pWithZ = p = null;
|
p2Args = p3Args = p4Args = null;
|
||||||
instances = {
|
instances = {
|
||||||
"no arguments passed": ol.geom.point(),
|
"two arguments <x>,<y> passed": new ol.geom.Point(21, 4),
|
||||||
"one argument [x,y] passed": ol.geom.point([21, 4]),
|
"three arguments <x>,<y>,<z> passed": new ol.geom.Point(21, 4, 8),
|
||||||
"one argument [x,y,z] passed": ol.geom.point([21, 4, 8]),
|
"four arguments <x>,<y>,<z>,<projection> passed": new ol.geom.Point(21, 4, 8, proj)
|
||||||
"one argument [x,y,z,projection] passed": ol.geom.point([21, 4, 8, proj])
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -67,35 +56,68 @@ describe("ol.geom.Point", function() {
|
|||||||
expect(instance.getProjection).not.toBeUndefined();
|
expect(instance.getProjection).not.toBeUndefined();
|
||||||
expect(instance.setProjection).not.toBeUndefined();
|
expect(instance.setProjection).not.toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
it("has functional getters (no arguments passed)", function(){
|
it("has functional getters (two arguments <x>,<y> passed)", function(){
|
||||||
expect(pNoArgs.getX()).toBe(0);
|
|
||||||
expect(pNoArgs.getY()).toBe(0);
|
expect(p2Args.getX()).toBe(21);
|
||||||
expect(pNoArgs.getZ()).toBeUndefined();
|
expect(p2Args.getY()).toBe(4);
|
||||||
expect(pNoArgs.getProjection()).toBeNull();
|
expect(p2Args.getZ()).toBeUndefined();
|
||||||
|
expect(p2Args.getProjection()).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has functional getters (one argument [x,y] passed)", function(){
|
it("has functional getters (three arguments <x>,<y>,<z> passed)", function(){
|
||||||
expect(pNoZ.getX()).toBe(21);
|
expect(p3Args.getX()).toBe(21);
|
||||||
expect(pNoZ.getY()).toBe(4);
|
expect(p3Args.getY()).toBe(4);
|
||||||
expect(pNoZ.getZ()).toBeUndefined();
|
expect(p3Args.getZ()).not.toBeUndefined();
|
||||||
expect(pNoZ.getProjection()).toBeNull();
|
expect(p3Args.getZ()).toBe(8);
|
||||||
|
expect(p3Args.getProjection()).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has functional getters (one argument [x,y,z] passed)", function(){
|
it("has functional getters (four arguments <x>,<y>,<z>,<projection> passed)", function(){
|
||||||
expect(pWithZ.getX()).toBe(21);
|
expect(p4Args.getX()).toBe(21);
|
||||||
expect(pWithZ.getY()).toBe(4);
|
expect(p4Args.getY()).toBe(4);
|
||||||
expect(pWithZ.getZ()).toBe(8);
|
expect(p4Args.getZ()).toBe(8);
|
||||||
expect(pWithZ.getProjection()).toBeNull();
|
expect(p4Args.getProjection()).not.toBeNull();
|
||||||
|
expect(p4Args.getProjection()).toBeA(ol.Projection);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has functional getters (one argument [x,y,z,projection] passed)", function(){
|
it("can be transformed", function(){
|
||||||
expect(p.getX()).toBe(21);
|
// save for later comparison
|
||||||
expect(p.getY()).toBe(4);
|
var old = {
|
||||||
expect(p.getZ()).toBe(8);
|
x: p4Args.getX().toFixed(3),
|
||||||
expect(p.getProjection()).not.toBeNull();
|
y: p4Args.getY().toFixed(3)
|
||||||
expect(p.getProjection()).toEqual(jasmine.any(ol.Projection));
|
};
|
||||||
|
// with code only
|
||||||
|
var transformedPoint = p4Args.transform("EPSG:3857");
|
||||||
|
|
||||||
|
// is it still an instance of ol.geom.Point?
|
||||||
|
expect(transformedPoint).toBeA(ol.geom.Point);
|
||||||
|
// coordinates OK?
|
||||||
|
expect(transformedPoint.getX().toFixed(3)).toBe("2337709.306");
|
||||||
|
expect(transformedPoint.getY().toFixed(3)).toBe("445640.110");
|
||||||
|
|
||||||
|
// with an ol.Projection
|
||||||
|
var retransformedPoint = transformedPoint.transform(new ol.Projection("EPSG:4326"));
|
||||||
|
expect(retransformedPoint).toBeA(ol.geom.Point);
|
||||||
|
|
||||||
|
// coordinates shopulkd be the originally configured
|
||||||
|
expect(retransformedPoint.getX().toFixed(3)).toBe(old.x);
|
||||||
|
expect(retransformedPoint.getY().toFixed(3)).toBe(old.y);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("throws an exception when you try to transform without a source projection", function(){
|
||||||
|
|
||||||
|
expect(function() {
|
||||||
|
p2Args.transform("EPSG:3857");
|
||||||
|
}).toThrow();
|
||||||
|
|
||||||
|
expect(function() {
|
||||||
|
p3Args.transform("EPSG:3857");
|
||||||
|
}).toThrow();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -51,11 +51,11 @@ describe('ol.layer.XYZ', function() {
|
|||||||
expect(tile.getImg()).toBeDefined();
|
expect(tile.getImg()).toBeDefined();
|
||||||
|
|
||||||
tile = tiles[0][1];
|
tile = tiles[0][1];
|
||||||
expect(tile.getUrl()).toEqual('/1/0/1');
|
expect(tile.getUrl()).toEqual('/1/1/0');
|
||||||
expect(tile.getImg()).toBeDefined();
|
expect(tile.getImg()).toBeDefined();
|
||||||
|
|
||||||
tile = tiles[1][0];
|
tile = tiles[1][0];
|
||||||
expect(tile.getUrl()).toEqual('/1/1/0');
|
expect(tile.getUrl()).toEqual('/1/0/1');
|
||||||
expect(tile.getImg()).toBeDefined();
|
expect(tile.getImg()).toBeDefined();
|
||||||
|
|
||||||
tile = tiles[1][1];
|
tile = tiles[1][1];
|
||||||
@@ -64,7 +64,6 @@ describe('ol.layer.XYZ', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
|
||||||
describe('extent -64,-64,64,64, resolution 0.5', function() {
|
describe('extent -64,-64,64,64, resolution 0.5', function() {
|
||||||
|
|
||||||
it('returns the expected data', function() {
|
it('returns the expected data', function() {
|
||||||
@@ -82,11 +81,11 @@ describe('ol.layer.XYZ', function() {
|
|||||||
expect(tile.getImg()).toBeDefined();
|
expect(tile.getImg()).toBeDefined();
|
||||||
|
|
||||||
tile = tiles[0][1];
|
tile = tiles[0][1];
|
||||||
expect(tile.getUrl()).toEqual('/1/0/1');
|
expect(tile.getUrl()).toEqual('/1/1/0');
|
||||||
expect(tile.getImg()).toBeDefined();
|
expect(tile.getImg()).toBeDefined();
|
||||||
|
|
||||||
tile = tiles[1][0];
|
tile = tiles[1][0];
|
||||||
expect(tile.getUrl()).toEqual('/1/1/0');
|
expect(tile.getUrl()).toEqual('/1/0/1');
|
||||||
expect(tile.getImg()).toBeDefined();
|
expect(tile.getImg()).toBeDefined();
|
||||||
|
|
||||||
tile = tiles[1][1];
|
tile = tiles[1][1];
|
||||||
@@ -94,6 +93,69 @@ describe('ol.layer.XYZ', function() {
|
|||||||
expect(tile.getImg()).toBeDefined();
|
expect(tile.getImg()).toBeDefined();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
|
describe('extent -96,32,-32,96, resolution 0.5', function() {
|
||||||
|
|
||||||
|
it('returns the expected data', function() {
|
||||||
|
var tileset = layer.getData(
|
||||||
|
new ol.Bounds(-96, 32, -32, 96), 0.5);
|
||||||
|
|
||||||
|
var tiles = tileset.getTiles();
|
||||||
|
expect(tiles.length).toEqual(1);
|
||||||
|
expect(tiles[0].length).toEqual(1);
|
||||||
|
|
||||||
|
var tile;
|
||||||
|
|
||||||
|
tile = tiles[0][0];
|
||||||
|
expect(tile.getUrl()).toEqual('/1/0/0');
|
||||||
|
expect(tile.getImg()).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('extent -32,32,32,96, resolution 0.5', function() {
|
||||||
|
|
||||||
|
it('returns the expected data', function() {
|
||||||
|
var tileset = layer.getData(
|
||||||
|
new ol.Bounds(-32, 32, 32, 96), 0.5);
|
||||||
|
|
||||||
|
var tiles = tileset.getTiles();
|
||||||
|
expect(tiles.length).toEqual(1);
|
||||||
|
expect(tiles[0].length).toEqual(2);
|
||||||
|
|
||||||
|
var tile;
|
||||||
|
|
||||||
|
tile = tiles[0][0];
|
||||||
|
expect(tile.getUrl()).toEqual('/1/0/0');
|
||||||
|
expect(tile.getImg()).toBeDefined();
|
||||||
|
|
||||||
|
tile = tiles[0][1];
|
||||||
|
expect(tile.getUrl()).toEqual('/1/1/0');
|
||||||
|
expect(tile.getImg()).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('extent 32,-32,96,32, resolution 0.5', function() {
|
||||||
|
|
||||||
|
it('returns the expected data', function() {
|
||||||
|
var tileset = layer.getData(
|
||||||
|
new ol.Bounds(32, -32, 96, 32), 0.5);
|
||||||
|
|
||||||
|
var tiles = tileset.getTiles();
|
||||||
|
expect(tiles.length).toEqual(2);
|
||||||
|
expect(tiles[0].length).toEqual(1);
|
||||||
|
expect(tiles[1].length).toEqual(1);
|
||||||
|
|
||||||
|
var tile;
|
||||||
|
|
||||||
|
tile = tiles[0][0];
|
||||||
|
expect(tile.getUrl()).toEqual('/1/1/0');
|
||||||
|
expect(tile.getImg()).toBeDefined();
|
||||||
|
|
||||||
|
tile = tiles[1][0];
|
||||||
|
expect(tile.getUrl()).toEqual('/1/1/1');
|
||||||
|
expect(tile.getImg()).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user