Merge branch 'master' of github.com:openlayers/ol3
This commit is contained in:
@@ -25,7 +25,6 @@
|
|||||||
// "generateExports": true
|
// "generateExports": true
|
||||||
// },
|
// },
|
||||||
|
|
||||||
|
|
||||||
"checks": {
|
"checks": {
|
||||||
// acceptable values are "ERROR", "WARNING", and "OFF"
|
// acceptable values are "ERROR", "WARNING", and "OFF"
|
||||||
"accessControls": "WARNING",
|
"accessControls": "WARNING",
|
||||||
@@ -4,8 +4,7 @@
|
|||||||
"output-file": "hello-epi-compiled.js",
|
"output-file": "hello-epi-compiled.js",
|
||||||
|
|
||||||
"inputs": [
|
"inputs": [
|
||||||
"hello-epi.js",
|
"hello-epi.js"
|
||||||
"../src/ol.js"
|
|
||||||
],
|
],
|
||||||
"paths": [
|
"paths": [
|
||||||
"../src"
|
"../src"
|
||||||
+8
-2
@@ -1,8 +1,14 @@
|
|||||||
/* This is a code which is going to be compiled together with the library */
|
/* This is a code which is going to be compiled together with the library */
|
||||||
|
|
||||||
|
goog.require('ol.Map');
|
||||||
|
goog.require('ol.layer.OSM');
|
||||||
|
goog.require('ol.Loc');
|
||||||
|
|
||||||
|
goog.require('goog.dom');
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
var map = new ol.Map()
|
var map = new ol.Map();
|
||||||
// .render('map')
|
map.setContainer(goog.dom.getElement('map'));
|
||||||
map.setLayers( [ new ol.layer.OSM() ] );
|
map.setLayers( [ new ol.layer.OSM() ] );
|
||||||
map.setCenter( new ol.Loc(45, 5));
|
map.setCenter( new ol.Loc(45, 5));
|
||||||
map.setZoom(10);
|
map.setZoom(10);
|
||||||
|
|||||||
+2
-2
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
var map = ol.map()
|
var map = ol.map()
|
||||||
.render('map')
|
.renderTo('map')
|
||||||
.layers([ol.layer.osm()])
|
.layers([ol.layer.osm()])
|
||||||
.center([45, 5])
|
.center([45, 5])
|
||||||
.zoom(10);
|
.zoom(10);
|
||||||
}
|
}
|
||||||
window['init'] = init;
|
window['init'] = init;
|
||||||
|
|||||||
+11
-11
@@ -1,7 +1,7 @@
|
|||||||
goog.provide('ol.geom.collection');
|
goog.provide('ol.geom.collection');
|
||||||
|
|
||||||
goog.require('ol.geom.Collection');
|
goog.require('ol.geom.Collection');
|
||||||
goog.require('ol.geom.point');
|
goog.require('ol.geom.point');
|
||||||
goog.require('ol.projection');
|
goog.require('ol.projection');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -10,11 +10,11 @@ goog.require('ol.projection');
|
|||||||
* @return {ol.geom.Collection} Collection.
|
* @return {ol.geom.Collection} Collection.
|
||||||
*/
|
*/
|
||||||
ol.geom.collection = function(opt_arg){
|
ol.geom.collection = function(opt_arg){
|
||||||
|
|
||||||
if (opt_arg instanceof ol.geom.Collection) {
|
if (opt_arg instanceof ol.geom.Collection) {
|
||||||
return opt_arg;
|
return opt_arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
var components = [];
|
var components = [];
|
||||||
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)) {
|
||||||
@@ -35,7 +35,7 @@ ol.geom.collection = function(opt_arg){
|
|||||||
throw new Error('ol.geom.collection');
|
throw new Error('ol.geom.collection');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var c = new ol.geom.Collection(components);
|
var c = new ol.geom.Collection(components);
|
||||||
return c;
|
return c;
|
||||||
};
|
};
|
||||||
@@ -50,7 +50,7 @@ ol.geom.Collection.prototype.components = function(opt_arg){
|
|||||||
if (arguments.length == 1 && goog.isDef(opt_arg)) {
|
if (arguments.length == 1 && goog.isDef(opt_arg)) {
|
||||||
var components = [],
|
var components = [],
|
||||||
allValid = false;
|
allValid = false;
|
||||||
|
|
||||||
allValid = goog.array.every(opt_arg, function(geom){
|
allValid = goog.array.every(opt_arg, function(geom){
|
||||||
if (geom instanceof ol.geom.Geometry) {
|
if (geom instanceof ol.geom.Geometry) {
|
||||||
components.push(geom);
|
components.push(geom);
|
||||||
@@ -90,23 +90,23 @@ ol.geom.Collection.prototype.add = function(geom, opt_index){
|
|||||||
* @export
|
* @export
|
||||||
* @param {Array.<ol.geom.Geometry>} components Some point specifications.
|
* @param {Array.<ol.geom.Geometry>} components Some point specifications.
|
||||||
* @param {number=} opt_index An optional index to add the components at. If not
|
* @param {number=} opt_index An optional index to add the components at. If not
|
||||||
* provided, the components will be added to the end of the list of
|
* provided, the components will be added to the end of the list of
|
||||||
* components.
|
* components.
|
||||||
* @return {ol.geom.Collection} The Collection instance.
|
* @return {ol.geom.Collection} The Collection instance.
|
||||||
*/
|
*/
|
||||||
ol.geom.Collection.prototype.addAll = function(components, opt_index){
|
ol.geom.Collection.prototype.addAll = function(components, opt_index){
|
||||||
var index = this.components_.length;
|
var index = this.components_.length;
|
||||||
|
|
||||||
if (arguments.length == 2 && goog.isDef(opt_index)) {
|
if (arguments.length == 2 && goog.isDef(opt_index)) {
|
||||||
index = opt_index;
|
index = opt_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
goog.array.every(components, function(c){
|
goog.array.every(components, function(c){
|
||||||
this.addComponent(c, index);
|
this.addComponent(c, index);
|
||||||
index++;
|
index++;
|
||||||
return true;
|
return true;
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -128,6 +128,6 @@ ol.geom.Collection.prototype.remove = function(components){
|
|||||||
this.removeComponent(c);
|
this.removeComponent(c);
|
||||||
return true;
|
return true;
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
goog.provide('ol.geom.geometry');
|
goog.provide('ol.geom.geometry');
|
||||||
|
|
||||||
goog.require('ol.geom.Geometry');
|
goog.require('ol.geom.Geometry');
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ ol.geom.geometry = function(){
|
|||||||
/**
|
/**
|
||||||
* @export
|
* @export
|
||||||
* @param {ol.Bounds=} opt_arg new Bounds.
|
* @param {ol.Bounds=} opt_arg new Bounds.
|
||||||
* @return {ol.geom.Geometry|ol.Bounds|undefined} either a Geometry (when used as
|
* @return {ol.geom.Geometry|ol.Bounds|undefined} either a Geometry (when used as
|
||||||
* setter) or a Bounds/undefined (if used as getter).
|
* setter) or a Bounds/undefined (if used as getter).
|
||||||
*/
|
*/
|
||||||
ol.geom.Geometry.prototype.bounds = function(opt_arg) {
|
ol.geom.Geometry.prototype.bounds = function(opt_arg) {
|
||||||
@@ -24,3 +24,12 @@ ol.geom.Geometry.prototype.bounds = function(opt_arg) {
|
|||||||
return this.getBounds();
|
return this.getBounds();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the centroid of the geometry.
|
||||||
|
*
|
||||||
|
* @returns {ol.geom.Point} The centroid of the geometry.
|
||||||
|
*/
|
||||||
|
ol.geom.Geometry.prototype.centroid = function() {
|
||||||
|
return this.getCentroid();
|
||||||
|
};
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
goog.provide('ol.geom.linestring');
|
goog.provide('ol.geom.linestring');
|
||||||
|
|
||||||
goog.require('ol.geom.LineString');
|
goog.require('ol.geom.LineString');
|
||||||
goog.require('ol.geom.point');
|
goog.require('ol.geom.point');
|
||||||
goog.require('ol.projection');
|
goog.require('ol.projection');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -10,11 +10,11 @@ goog.require('ol.projection');
|
|||||||
* @return {ol.geom.LineString} LineString.
|
* @return {ol.geom.LineString} LineString.
|
||||||
*/
|
*/
|
||||||
ol.geom.linestring = function(opt_arg){
|
ol.geom.linestring = function(opt_arg){
|
||||||
|
|
||||||
if (opt_arg instanceof ol.geom.LineString) {
|
if (opt_arg instanceof ol.geom.LineString) {
|
||||||
return opt_arg;
|
return opt_arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
var vertices = [];
|
var vertices = [];
|
||||||
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)) {
|
||||||
@@ -36,7 +36,7 @@ ol.geom.linestring = function(opt_arg){
|
|||||||
throw new Error('ol.geom.linestring');
|
throw new Error('ol.geom.linestring');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var ls = new ol.geom.LineString(vertices);
|
var ls = new ol.geom.LineString(vertices);
|
||||||
return ls;
|
return ls;
|
||||||
};
|
};
|
||||||
@@ -99,18 +99,18 @@ ol.geom.LineString.prototype.add = function(vertex, opt_index){
|
|||||||
ol.geom.LineString.prototype.addAll = function(vertices, opt_index){
|
ol.geom.LineString.prototype.addAll = function(vertices, opt_index){
|
||||||
var index = this.vertices_.length,
|
var index = this.vertices_.length,
|
||||||
v;
|
v;
|
||||||
|
|
||||||
if (arguments.length == 2 && goog.isDef(opt_index)) {
|
if (arguments.length == 2 && goog.isDef(opt_index)) {
|
||||||
index = opt_index;
|
index = opt_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
goog.array.every(vertices, function(vertexSpec){
|
goog.array.every(vertices, function(vertexSpec){
|
||||||
v = ol.geom.point(vertexSpec);
|
v = ol.geom.point(vertexSpec);
|
||||||
this.addVertex(v, index);
|
this.addVertex(v, index);
|
||||||
index++;
|
index++;
|
||||||
return true;
|
return true;
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+10
-10
@@ -1,8 +1,8 @@
|
|||||||
goog.provide('ol.geom.multipoint');
|
goog.provide('ol.geom.multipoint');
|
||||||
|
|
||||||
goog.require('ol.geom.MultiPoint');
|
goog.require('ol.geom.MultiPoint');
|
||||||
goog.require('ol.geom.point');
|
goog.require('ol.geom.point');
|
||||||
goog.require('ol.geom.collection');
|
goog.require('ol.geom.collection');
|
||||||
goog.require('ol.projection');
|
goog.require('ol.projection');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -11,11 +11,11 @@ goog.require('ol.projection');
|
|||||||
* @return {ol.geom.MultiPoint} MultiPoint.
|
* @return {ol.geom.MultiPoint} MultiPoint.
|
||||||
*/
|
*/
|
||||||
ol.geom.multipoint = function(opt_arg){
|
ol.geom.multipoint = function(opt_arg){
|
||||||
|
|
||||||
if (opt_arg instanceof ol.geom.MultiPoint) {
|
if (opt_arg instanceof ol.geom.MultiPoint) {
|
||||||
return opt_arg;
|
return opt_arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
var points = [];
|
var points = [];
|
||||||
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)) {
|
||||||
@@ -37,7 +37,7 @@ ol.geom.multipoint = function(opt_arg){
|
|||||||
throw new Error('ol.geom.multipoint');
|
throw new Error('ol.geom.multipoint');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var mp = new ol.geom.MultiPoint(points);
|
var mp = new ol.geom.MultiPoint(points);
|
||||||
return mp;
|
return mp;
|
||||||
};
|
};
|
||||||
@@ -99,18 +99,18 @@ ol.geom.MultiPoint.prototype.add = function(point, opt_index){
|
|||||||
ol.geom.MultiPoint.prototype.addAll = function(points, opt_index){
|
ol.geom.MultiPoint.prototype.addAll = function(points, opt_index){
|
||||||
var index = this.getPoints().length,
|
var index = this.getPoints().length,
|
||||||
p;
|
p;
|
||||||
|
|
||||||
if (arguments.length == 2 && goog.isDef(opt_index)) {
|
if (arguments.length == 2 && goog.isDef(opt_index)) {
|
||||||
index = opt_index;
|
index = opt_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
goog.array.every(points, function(pointSpec){
|
goog.array.every(points, function(pointSpec){
|
||||||
p = ol.geom.point(pointSpec);
|
p = ol.geom.point(pointSpec);
|
||||||
this.addPoint(p, index);
|
this.addPoint(p, index);
|
||||||
index++;
|
index++;
|
||||||
return true;
|
return true;
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -132,6 +132,6 @@ ol.geom.MultiPoint.prototype.remove = function(points){
|
|||||||
this.removePoint(p);
|
this.removePoint(p);
|
||||||
return true;
|
return true;
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|||||||
+16
-7
@@ -1,4 +1,4 @@
|
|||||||
goog.provide('ol.geom.point');
|
goog.provide('ol.geom.point');
|
||||||
|
|
||||||
goog.require('ol.geom.Point');
|
goog.require('ol.geom.Point');
|
||||||
goog.require('ol.projection');
|
goog.require('ol.projection');
|
||||||
@@ -14,23 +14,23 @@ ol.PointLike;
|
|||||||
* @return {ol.geom.Point} Point.
|
* @return {ol.geom.Point} Point.
|
||||||
*/
|
*/
|
||||||
ol.geom.point = function(opt_arg){
|
ol.geom.point = function(opt_arg){
|
||||||
|
|
||||||
if (opt_arg instanceof ol.geom.Point) {
|
if (opt_arg instanceof ol.geom.Point) {
|
||||||
return opt_arg;
|
return opt_arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
var x = 0;
|
var x = 0;
|
||||||
var y = 0;
|
var y = 0;
|
||||||
var z;
|
var z;
|
||||||
var projection;
|
var projection;
|
||||||
|
|
||||||
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];
|
||||||
y = opt_arg[1];
|
y = opt_arg[1];
|
||||||
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)) {
|
||||||
x = opt_arg['x'];
|
x = opt_arg['x'];
|
||||||
y = opt_arg['y'];
|
y = opt_arg['y'];
|
||||||
@@ -43,7 +43,7 @@ ol.geom.point = function(opt_arg){
|
|||||||
if (goog.isDef(projection)) {
|
if (goog.isDef(projection)) {
|
||||||
projection = ol.projection(projection);
|
projection = ol.projection(projection);
|
||||||
}
|
}
|
||||||
|
|
||||||
var p = new ol.geom.Point(x,y,z,projection);
|
var p = new ol.geom.Point(x,y,z,projection);
|
||||||
return p;
|
return p;
|
||||||
};
|
};
|
||||||
@@ -110,4 +110,13 @@ ol.geom.Point.prototype.projection = function(opt_arg){
|
|||||||
else {
|
else {
|
||||||
return this.getProjection();
|
return this.getProjection();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the centroid of this point; which is a clone of the point itself.
|
||||||
|
*
|
||||||
|
* @return {ol.geom.Point} The centroid.
|
||||||
|
*/
|
||||||
|
ol.geom.Point.prototype.centroid = function() {
|
||||||
|
return this.getCentroid();
|
||||||
|
};
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ goog.exportProperty(ol.Feature.prototype, 'geometry', ol.Feature.prototype.geome
|
|||||||
goog.exportSymbol('ol.geom.geometry', ol.geom.geometry);
|
goog.exportSymbol('ol.geom.geometry', ol.geom.geometry);
|
||||||
goog.exportSymbol('ol.geom.Geometry', ol.geom.Geometry);
|
goog.exportSymbol('ol.geom.Geometry', ol.geom.Geometry);
|
||||||
goog.exportProperty(ol.geom.Geometry.prototype, 'bounds', ol.geom.Geometry.prototype.bounds);
|
goog.exportProperty(ol.geom.Geometry.prototype, 'bounds', ol.geom.Geometry.prototype.bounds);
|
||||||
|
goog.exportProperty(ol.geom.Geometry.prototype, 'centroid', ol.geom.Geometry.prototype.centroid);
|
||||||
|
|
||||||
// ol.geom.collection
|
// ol.geom.collection
|
||||||
goog.exportSymbol('ol.geom.collection', ol.geom.collection);
|
goog.exportSymbol('ol.geom.collection', ol.geom.collection);
|
||||||
@@ -67,6 +68,7 @@ goog.exportProperty(ol.geom.Collection.prototype, 'components', ol.geom.Collecti
|
|||||||
goog.exportProperty(ol.geom.Collection.prototype, 'add', ol.geom.Collection.prototype.add);
|
goog.exportProperty(ol.geom.Collection.prototype, 'add', ol.geom.Collection.prototype.add);
|
||||||
goog.exportProperty(ol.geom.Collection.prototype, 'addAll', ol.geom.Collection.prototype.addAll);
|
goog.exportProperty(ol.geom.Collection.prototype, 'addAll', ol.geom.Collection.prototype.addAll);
|
||||||
goog.exportProperty(ol.geom.Collection.prototype, 'remove', ol.geom.Collection.prototype.remove);
|
goog.exportProperty(ol.geom.Collection.prototype, 'remove', ol.geom.Collection.prototype.remove);
|
||||||
|
goog.exportProperty(ol.geom.Collection.prototype, 'centroid', ol.geom.Collection.prototype.centroid);
|
||||||
|
|
||||||
// ol.geom.point
|
// ol.geom.point
|
||||||
goog.exportSymbol('ol.geom.point', ol.geom.point);
|
goog.exportSymbol('ol.geom.point', ol.geom.point);
|
||||||
@@ -75,6 +77,7 @@ 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.exportProperty(ol.geom.Point.prototype, 'y', ol.geom.Point.prototype.y);
|
||||||
goog.exportProperty(ol.geom.Point.prototype, 'z', ol.geom.Point.prototype.z);
|
goog.exportProperty(ol.geom.Point.prototype, 'z', ol.geom.Point.prototype.z);
|
||||||
goog.exportProperty(ol.geom.Point.prototype, 'projection', ol.geom.Point.prototype.projection);
|
goog.exportProperty(ol.geom.Point.prototype, 'projection', ol.geom.Point.prototype.projection);
|
||||||
|
goog.exportProperty(ol.geom.Point.prototype, 'centroid', ol.geom.Point.prototype.centroid);
|
||||||
|
|
||||||
// ol.geom.linestring
|
// ol.geom.linestring
|
||||||
goog.exportSymbol('ol.geom.linestring', ol.geom.linestring);
|
goog.exportSymbol('ol.geom.linestring', ol.geom.linestring);
|
||||||
@@ -83,6 +86,7 @@ goog.exportProperty(ol.geom.LineString.prototype, 'vertices', ol.geom.LineString
|
|||||||
goog.exportProperty(ol.geom.LineString.prototype, 'add', ol.geom.LineString.prototype.add);
|
goog.exportProperty(ol.geom.LineString.prototype, 'add', ol.geom.LineString.prototype.add);
|
||||||
goog.exportProperty(ol.geom.LineString.prototype, 'addAll', ol.geom.LineString.prototype.addAll);
|
goog.exportProperty(ol.geom.LineString.prototype, 'addAll', ol.geom.LineString.prototype.addAll);
|
||||||
goog.exportProperty(ol.geom.LineString.prototype, 'remove', ol.geom.LineString.prototype.remove);
|
goog.exportProperty(ol.geom.LineString.prototype, 'remove', ol.geom.LineString.prototype.remove);
|
||||||
|
goog.exportProperty(ol.geom.LineString.prototype, 'centroid', ol.geom.LineString.prototype.centroid);
|
||||||
|
|
||||||
// ol.geom.multipoint
|
// ol.geom.multipoint
|
||||||
goog.exportSymbol('ol.geom.multipoint', ol.geom.multipoint);
|
goog.exportSymbol('ol.geom.multipoint', ol.geom.multipoint);
|
||||||
@@ -91,6 +95,7 @@ goog.exportProperty(ol.geom.MultiPoint.prototype, 'points', ol.geom.MultiPoint.p
|
|||||||
goog.exportProperty(ol.geom.MultiPoint.prototype, 'add', ol.geom.MultiPoint.prototype.add);
|
goog.exportProperty(ol.geom.MultiPoint.prototype, 'add', ol.geom.MultiPoint.prototype.add);
|
||||||
goog.exportProperty(ol.geom.MultiPoint.prototype, 'addAll', ol.geom.MultiPoint.prototype.addAll);
|
goog.exportProperty(ol.geom.MultiPoint.prototype, 'addAll', ol.geom.MultiPoint.prototype.addAll);
|
||||||
goog.exportProperty(ol.geom.MultiPoint.prototype, 'remove', ol.geom.MultiPoint.prototype.remove);
|
goog.exportProperty(ol.geom.MultiPoint.prototype, 'remove', ol.geom.MultiPoint.prototype.remove);
|
||||||
|
goog.exportProperty(ol.geom.MultiPoint.prototype, 'centroid', ol.geom.MultiPoint.prototype.centroid);
|
||||||
|
|
||||||
// LOOKUP FOR DYNMICALLY REGISTERED CONTROLS DOES NOT RUN WELL NOW IN THE ADVANCED MODE
|
// LOOKUP FOR DYNMICALLY REGISTERED CONTROLS DOES NOT RUN WELL NOW IN THE ADVANCED MODE
|
||||||
// HACK TO PUSH COMPILER TO NOT STRIP THE NAVIGATION CONTROL. TO BE FIXED.
|
// HACK TO PUSH COMPILER TO NOT STRIP THE NAVIGATION CONTROL. TO BE FIXED.
|
||||||
|
|||||||
+5
-5
@@ -53,7 +53,7 @@ ol.Bounds.prototype.setProjection = function(projection) {
|
|||||||
ol.Bounds.prototype.intersects = function(bounds) {
|
ol.Bounds.prototype.intersects = function(bounds) {
|
||||||
var otherProj = bounds.getProjection();
|
var otherProj = bounds.getProjection();
|
||||||
if (!goog.isNull(otherProj) && !goog.isNull(this.projection_)) {
|
if (!goog.isNull(otherProj) && !goog.isNull(this.projection_)) {
|
||||||
bounds = bounds.transform(this.projection_);
|
bounds = bounds.doTransform(this.projection_);
|
||||||
}
|
}
|
||||||
return goog.base(this, "intersects", bounds.toUnreferencedBounds());
|
return goog.base(this, "intersects", bounds.toUnreferencedBounds());
|
||||||
};
|
};
|
||||||
@@ -70,13 +70,13 @@ ol.Bounds.prototype.doTransform = function(proj) {
|
|||||||
throw new Error("Bounds must have a projection before transforming.");
|
throw new Error("Bounds must have a projection before transforming.");
|
||||||
}
|
}
|
||||||
var tl = new ol.Loc(
|
var tl = new ol.Loc(
|
||||||
this.minX_, this.maxY_, undefined, this.projection_).transform(proj);
|
this.minX_, this.maxY_, undefined, this.projection_).doTransform(proj);
|
||||||
var tr = new ol.Loc(
|
var tr = new ol.Loc(
|
||||||
this.maxX_, this.maxY_, undefined, this.projection_).transform(proj);
|
this.maxX_, this.maxY_, undefined, this.projection_).doTransform(proj);
|
||||||
var bl = new ol.Loc(
|
var bl = new ol.Loc(
|
||||||
this.minX_, this.minY_, undefined, this.projection_).transform(proj);
|
this.minX_, this.minY_, undefined, this.projection_).doTransform(proj);
|
||||||
var br = new ol.Loc(
|
var br = new ol.Loc(
|
||||||
this.maxX_, this.minY_, undefined, this.projection_).transform(proj);
|
this.maxX_, this.minY_, undefined, this.projection_).doTransform(proj);
|
||||||
|
|
||||||
var x = [tl.getX(), tr.getX(), bl.getX(), br.getX()].sort();
|
var x = [tl.getX(), tr.getX(), bl.getX(), br.getX()].sort();
|
||||||
var y = [tl.getY(), tr.getY(), bl.getY(), br.getY()].sort();
|
var y = [tl.getY(), tr.getY(), bl.getY(), br.getY()].sort();
|
||||||
|
|||||||
+2
-2
@@ -143,7 +143,7 @@ ol.Map.DEFAULT_CONTROLS = ["navigation"];
|
|||||||
*/
|
*/
|
||||||
ol.Map.prototype.getCenter = function() {
|
ol.Map.prototype.getCenter = function() {
|
||||||
var proj = this.getUserProjection();
|
var proj = this.getUserProjection();
|
||||||
return this.center_.transform(proj);
|
return this.center_.doTransform(proj);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -271,7 +271,7 @@ ol.Map.prototype.setCenter = function(center) {
|
|||||||
proj = this.getUserProjection();
|
proj = this.getUserProjection();
|
||||||
center.setProjection(proj);
|
center.setProjection(proj);
|
||||||
}
|
}
|
||||||
this.center_ = center.transform(this.getProjection());
|
this.center_ = center.doTransform(this.getProjection());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+9
-9
@@ -9,9 +9,9 @@ goog.require('ol.event.Events');
|
|||||||
* The Tile class.
|
* The Tile class.
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param {string} url
|
* @param {string} url
|
||||||
* @param {ol.Bounds} bounds
|
* @param {ol.Bounds|undefined} opt_bounds
|
||||||
*/
|
*/
|
||||||
ol.Tile = function(url, bounds) {
|
ol.Tile = function(url, opt_bounds) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -21,9 +21,9 @@ ol.Tile = function(url, bounds) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {ol.Bounds}
|
* @type {ol.Bounds|undefined}
|
||||||
*/
|
*/
|
||||||
this.bounds_ = bounds;
|
this.bounds_ = opt_bounds;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -66,7 +66,7 @@ ol.Tile.prototype.createImage = function() {
|
|||||||
* Load the tile. A tile should loaded only once.
|
* Load the tile. A tile should loaded only once.
|
||||||
*/
|
*/
|
||||||
ol.Tile.prototype.load = function() {
|
ol.Tile.prototype.load = function() {
|
||||||
goog.asserts.assert(!this.loaded && this.loading_);
|
goog.asserts.assert(!this.loaded && !this.loading_);
|
||||||
this.loading_ = true;
|
this.loading_ = true;
|
||||||
this.img_.src = this.url_;
|
this.img_.src = this.url_;
|
||||||
};
|
};
|
||||||
@@ -81,7 +81,7 @@ ol.Tile.prototype.getUrl = function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the tile bounds.
|
* Get the tile bounds.
|
||||||
* @return {ol.Bounds}
|
* @return {ol.Bounds|undefined}
|
||||||
*/
|
*/
|
||||||
ol.Tile.prototype.getBounds = function() {
|
ol.Tile.prototype.getBounds = function() {
|
||||||
return this.bounds_;
|
return this.bounds_;
|
||||||
@@ -155,15 +155,15 @@ ol.Tile.createImage = (function() {
|
|||||||
* for the tiles.
|
* for the tiles.
|
||||||
* @param {number} width
|
* @param {number} width
|
||||||
* @param {number} height
|
* @param {number} height
|
||||||
* @return {function(new:ol.Tile, string, ol.Bounds)}
|
* @return {function(new:ol.Tile, string, ol.Bounds=)}
|
||||||
*/
|
*/
|
||||||
ol.Tile.createConstructor = function(width, height) {
|
ol.Tile.createConstructor = function(width, height) {
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.Tile}
|
* @extends {ol.Tile}
|
||||||
*/
|
*/
|
||||||
var Tile = function(url, bounds) {
|
var Tile = function(url, opt_bounds) {
|
||||||
goog.base(this, url, bounds);
|
goog.base(this, url, opt_bounds);
|
||||||
};
|
};
|
||||||
goog.inherits(Tile, ol.Tile);
|
goog.inherits(Tile, ol.Tile);
|
||||||
/** @inheritDoc */
|
/** @inheritDoc */
|
||||||
|
|||||||
@@ -219,6 +219,8 @@ ol.event.Events.prototype.unregister = function(type, listener, opt_scope) {
|
|||||||
*
|
*
|
||||||
* @param {string} type The type of the event to trigger.
|
* @param {string} type The type of the event to trigger.
|
||||||
* @param {Object=} opt_evt The event object that will be passed to listeners.
|
* @param {Object=} opt_evt The event object that will be passed to listeners.
|
||||||
|
* This object will always have a 'type' property with the event type and
|
||||||
|
* an 'object' property referencing this Events instance.
|
||||||
*
|
*
|
||||||
* @return {boolean} The last listener return. If a listener returns false,
|
* @return {boolean} The last listener return. If a listener returns false,
|
||||||
* the chain of listeners will stop getting called.
|
* the chain of listeners will stop getting called.
|
||||||
@@ -228,8 +230,9 @@ ol.event.Events.prototype.triggerEvent = function(type, opt_evt) {
|
|||||||
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) {
|
if (arguments.length === 1) {
|
||||||
opt_evt = {type: type};
|
opt_evt = {'type': type};
|
||||||
}
|
}
|
||||||
|
opt_evt['object'] = this.object_;
|
||||||
for (var i=0, ii=listeners.length; i<ii; ++i) {
|
for (var i=0, ii=listeners.length; i<ii; ++i) {
|
||||||
returnValue = listeners[i].handleEvent(opt_evt);
|
returnValue = listeners[i].handleEvent(opt_evt);
|
||||||
if (returnValue === false) {
|
if (returnValue === false) {
|
||||||
|
|||||||
+44
-23
@@ -6,16 +6,16 @@ goog.require('ol.Projection');
|
|||||||
goog.require('ol.base');
|
goog.require('ol.base');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates ol.geom.Collection objects.
|
* Creates ol.geom.Collection objects.
|
||||||
*
|
*
|
||||||
* @export
|
* @export
|
||||||
* @extends {ol.geom.Geometry}
|
* @extends {ol.geom.Geometry}
|
||||||
* @param {Array.<ol.geom.Geometry>} components An array of components.
|
* @param {Array.<ol.geom.Geometry>} components An array of components.
|
||||||
*
|
*
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
ol.geom.Collection = function(components) {
|
ol.geom.Collection = function(components) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {Array.<Function>}
|
* @type {Array.<Function>}
|
||||||
@@ -23,19 +23,19 @@ ol.geom.Collection = function(components) {
|
|||||||
this.typeBlacklist_ = [
|
this.typeBlacklist_ = [
|
||||||
ol.geom.Collection
|
ol.geom.Collection
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {Array.<Function>}
|
* @type {Array.<Function>}
|
||||||
*/
|
*/
|
||||||
this.typeWhitelist_ = [];
|
this.typeWhitelist_ = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {Array.<ol.geom.Geometry>}
|
* @type {Array.<ol.geom.Geometry>}
|
||||||
*/
|
*/
|
||||||
this.components_ = [];
|
this.components_ = [];
|
||||||
|
|
||||||
if (arguments.length === 1 && goog.isDef(components)) {
|
if (arguments.length === 1 && goog.isDef(components)) {
|
||||||
this.setComponents(components);
|
this.setComponents(components);
|
||||||
}
|
}
|
||||||
@@ -44,14 +44,14 @@ ol.geom.Collection = function(components) {
|
|||||||
goog.inherits(ol.geom.Collection, ol.geom.Geometry);
|
goog.inherits(ol.geom.Collection, ol.geom.Geometry);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the list of disallowed types for the collection.
|
* Sets the list of disallowed types for the collection.
|
||||||
* @param {Array.<Function>} typeBlacklist Array of constructors to disallow.
|
* @param {Array.<Function>} typeBlacklist Array of constructors to disallow.
|
||||||
*/
|
*/
|
||||||
ol.geom.Collection.prototype.setTypeBlacklist = function(typeBlacklist){
|
ol.geom.Collection.prototype.setTypeBlacklist = function(typeBlacklist){
|
||||||
this.typeBlacklist_ = typeBlacklist;
|
this.typeBlacklist_ = typeBlacklist;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Gets the list of disallowed types for the collection.
|
* Gets the list of disallowed types for the collection.
|
||||||
* @return {Array.<Function>} Array of constructors to disallow.
|
* @return {Array.<Function>} Array of constructors to disallow.
|
||||||
*/
|
*/
|
||||||
ol.geom.Collection.prototype.getTypeBlacklist = function(){
|
ol.geom.Collection.prototype.getTypeBlacklist = function(){
|
||||||
@@ -59,14 +59,14 @@ ol.geom.Collection.prototype.getTypeBlacklist = function(){
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the list of always allowed types for the collection.
|
* Sets the list of always allowed types for the collection.
|
||||||
* @param {Array.<Function>} typeWhitelist Array of constructors to allow.
|
* @param {Array.<Function>} typeWhitelist Array of constructors to allow.
|
||||||
*/
|
*/
|
||||||
ol.geom.Collection.prototype.setTypeWhitelist = function(typeWhitelist){
|
ol.geom.Collection.prototype.setTypeWhitelist = function(typeWhitelist){
|
||||||
this.typeWhitelist_ = typeWhitelist;
|
this.typeWhitelist_ = typeWhitelist;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Gets the list of always allowed types for the collection.
|
* Gets the list of always allowed types for the collection.
|
||||||
* @return {Array.<Function>} Array of constructors to allow.
|
* @return {Array.<Function>} Array of constructors to allow.
|
||||||
*/
|
*/
|
||||||
ol.geom.Collection.prototype.getTypeWhitelist = function(){
|
ol.geom.Collection.prototype.getTypeWhitelist = function(){
|
||||||
@@ -76,7 +76,7 @@ ol.geom.Collection.prototype.getTypeWhitelist = function(){
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the Collection's components.
|
* Sets the Collection's components.
|
||||||
*
|
*
|
||||||
* @return {Array.<ol.geom.Geometry>} An array of components.
|
* @return {Array.<ol.geom.Geometry>} An array of components.
|
||||||
*/
|
*/
|
||||||
ol.geom.Collection.prototype.getComponents = function() {
|
ol.geom.Collection.prototype.getComponents = function() {
|
||||||
@@ -85,12 +85,12 @@ ol.geom.Collection.prototype.getComponents = function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the Collection's components.
|
* Gets the Collection's components.
|
||||||
*
|
*
|
||||||
* @param {Array.<ol.geom.Geometry>} components An array of components.
|
* @param {Array.<ol.geom.Geometry>} components An array of components.
|
||||||
*/
|
*/
|
||||||
ol.geom.Collection.prototype.setComponents = function(components) {
|
ol.geom.Collection.prototype.setComponents = function(components) {
|
||||||
var allValidTypes = goog.array.every(
|
var allValidTypes = goog.array.every(
|
||||||
components,
|
components,
|
||||||
this.isAllowedComponent,
|
this.isAllowedComponent,
|
||||||
this
|
this
|
||||||
);
|
);
|
||||||
@@ -105,7 +105,7 @@ ol.geom.Collection.prototype.setComponents = function(components) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the given component to the list of components at the specified index.
|
* Adds the given component to the list of components at the specified index.
|
||||||
*
|
*
|
||||||
* @param {ol.geom.Geometry} component A component to be added.
|
* @param {ol.geom.Geometry} component A component to be added.
|
||||||
* @param {number} index The index where to add.
|
* @param {number} index The index where to add.
|
||||||
*/
|
*/
|
||||||
@@ -121,14 +121,14 @@ ol.geom.Collection.prototype.addComponent = function(component, index) {
|
|||||||
/**
|
/**
|
||||||
* Checks whether the passed component is an instance of any of the constructors
|
* Checks whether the passed component is an instance of any of the constructors
|
||||||
* listed in the passed list.
|
* listed in the passed list.
|
||||||
*
|
*
|
||||||
* @param {ol.geom.Geometry} component The component to check.
|
* @param {ol.geom.Geometry} component The component to check.
|
||||||
* @param {Array.<Function>} list The List of constructors to check the
|
* @param {Array.<Function>} list The List of constructors to check the
|
||||||
* component against.
|
* component against.
|
||||||
*
|
*
|
||||||
* @return {boolean} Whether the passed component is an instance of any of the
|
* @return {boolean} Whether the passed component is an instance of any of the
|
||||||
* constructors listed in the passed list.
|
* constructors listed in the passed list.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.geom.Collection.prototype.isOnList = function(component, list) {
|
ol.geom.Collection.prototype.isOnList = function(component, list) {
|
||||||
@@ -143,9 +143,9 @@ ol.geom.Collection.prototype.isOnList = function(component, list) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the passed component is allowed according to the black and
|
* Checks whether the passed component is allowed according to the black and
|
||||||
* whitelists.
|
* whitelists.
|
||||||
*
|
*
|
||||||
* @param {ol.geom.Geometry} component The component to check.
|
* @param {ol.geom.Geometry} component The component to check.
|
||||||
* @return {boolean} Whether the passed component is allowed as part of this
|
* @return {boolean} Whether the passed component is allowed as part of this
|
||||||
* collection according to black- and whitelist.
|
* collection according to black- and whitelist.
|
||||||
@@ -160,9 +160,30 @@ ol.geom.Collection.prototype.isAllowedComponent = function(component){
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the given component from the list of components.
|
* Removes the given component from the list of components.
|
||||||
*
|
*
|
||||||
* @param {ol.geom.Geometry} component A component to be removed.
|
* @param {ol.geom.Geometry} component A component to be removed.
|
||||||
*/
|
*/
|
||||||
ol.geom.Collection.prototype.removeComponent = function(component) {
|
ol.geom.Collection.prototype.removeComponent = function(component) {
|
||||||
goog.array.remove(this.components_, component);
|
goog.array.remove(this.components_, component);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compute the centroid for this geometry collection.
|
||||||
|
*
|
||||||
|
* @returns {ol.geom.Point} The centroid of the collection.
|
||||||
|
*/
|
||||||
|
ol.geom.Collection.prototype.getCentroid = function() {
|
||||||
|
var components = this.getComponents(),
|
||||||
|
len = components.length,
|
||||||
|
sum_x = 0, sum_y = 0,
|
||||||
|
centroid = null;
|
||||||
|
if (len > 0) {
|
||||||
|
goog.array.forEach(components, function(component){
|
||||||
|
var singleCentroid = component.getCentroid();
|
||||||
|
sum_x += singleCentroid.getX();
|
||||||
|
sum_y += singleCentroid.getX();
|
||||||
|
});
|
||||||
|
centroid = new ol.geom.Point(sum_x / len, sum_y / len);
|
||||||
|
}
|
||||||
|
return centroid;
|
||||||
|
};
|
||||||
+21
-6
@@ -1,15 +1,17 @@
|
|||||||
goog.provide('ol.geom.Geometry');
|
goog.provide('ol.geom.Geometry');
|
||||||
|
|
||||||
|
goog.require('ol.geom.IGeometry');
|
||||||
goog.require('ol.Bounds');
|
goog.require('ol.Bounds');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates ol.Geometry objects.
|
* Creates ol.Geometry objects.
|
||||||
*
|
*
|
||||||
* @export
|
* @export
|
||||||
|
* @implements {ol.geom.IGeometry}
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
ol.geom.Geometry = function() {
|
ol.geom.Geometry = function() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {ol.Bounds|undefined}
|
* @type {ol.Bounds|undefined}
|
||||||
@@ -34,10 +36,23 @@ ol.geom.Geometry.prototype.setBounds = function(bounds) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns ol.Loc
|
* Returns the centroid of the geometry.
|
||||||
|
*
|
||||||
|
* @returns {ol.geom.Point} The centroid of the geometry.
|
||||||
*/
|
*/
|
||||||
ol.geom.Geometry.prototype.getCentroid = function() {
|
ol.geom.Geometry.prototype.getCentroid = function() {
|
||||||
//FIXME: stub only to get popups working
|
// throw an error to enforce subclasses to implement it properly
|
||||||
return new ol.Loc(-76,45);
|
ol.error('ol.geom.Geometry: getCentroid must be implemented by subclasses');
|
||||||
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the area of the geometry.
|
||||||
|
*
|
||||||
|
* @returns {number} The area of the geometry.
|
||||||
|
*/
|
||||||
|
ol.geom.Geometry.prototype.getArea = function() {
|
||||||
|
// throw an error to enforce subclasses to implement it properly
|
||||||
|
ol.error('ol.geom.Geometry: getArea must be implemented by subclasses');
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
goog.provide('ol.geom.IGeometry');
|
||||||
|
|
||||||
|
//goog.require('ol.geom.Point');
|
||||||
|
//goog.require('ol.Bounds');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for geometry classes forcing ol.geom.* classes to implement
|
||||||
|
* expected functionality.
|
||||||
|
*
|
||||||
|
* @interface
|
||||||
|
*/
|
||||||
|
ol.geom.IGeometry = function(){};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {ol.geom.Point} The centroid of the geometry.
|
||||||
|
*/
|
||||||
|
ol.geom.IGeometry.prototype.getCentroid = function(){};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {ol.Bounds|undefined} The centroid of the geometry.
|
||||||
|
*/
|
||||||
|
ol.geom.IGeometry.prototype.getBounds = function(){};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {number} The area of the geometry.
|
||||||
|
*/
|
||||||
|
ol.geom.IGeometry.prototype.getArea = function(){};
|
||||||
@@ -2,17 +2,18 @@ goog.provide('ol.geom.LineString');
|
|||||||
|
|
||||||
goog.require('goog.array');
|
goog.require('goog.array');
|
||||||
goog.require('ol.geom.Geometry');
|
goog.require('ol.geom.Geometry');
|
||||||
|
goog.require('ol.geom.Collection');
|
||||||
goog.require('ol.geom.Point');
|
goog.require('ol.geom.Point');
|
||||||
goog.require('ol.Projection');
|
goog.require('ol.Projection');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates ol.geom.LineString objects.
|
* Creates ol.geom.LineString objects.
|
||||||
*
|
*
|
||||||
* @export
|
* @export
|
||||||
* @extends {ol.geom.Geometry}
|
* @extends {ol.geom.Geometry}
|
||||||
* @param {Array.<ol.geom.Point>} vertices An array of points building the
|
* @param {Array.<ol.geom.Point>} vertices An array of points building the
|
||||||
* linestrings vertices.
|
* linestrings vertices.
|
||||||
*
|
*
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
ol.geom.LineString = function(vertices) {
|
ol.geom.LineString = function(vertices) {
|
||||||
@@ -21,14 +22,14 @@ ol.geom.LineString = function(vertices) {
|
|||||||
* @type {Array.<ol.geom.Point>}
|
* @type {Array.<ol.geom.Point>}
|
||||||
*/
|
*/
|
||||||
this.vertices_ = vertices;
|
this.vertices_ = vertices;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
goog.inherits(ol.geom.LineString, ol.geom.Geometry);
|
goog.inherits(ol.geom.LineString, ol.geom.Geometry);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the LineString's points.
|
* Sets the LineString's points.
|
||||||
*
|
*
|
||||||
* @return {Array.<ol.geom.Point>} An array of points.
|
* @return {Array.<ol.geom.Point>} An array of points.
|
||||||
*/
|
*/
|
||||||
ol.geom.LineString.prototype.getVertices = function() {
|
ol.geom.LineString.prototype.getVertices = function() {
|
||||||
@@ -37,7 +38,7 @@ ol.geom.LineString.prototype.getVertices = function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the LineString's points.
|
* Gets the LineString's points.
|
||||||
*
|
*
|
||||||
* @param {Array.<ol.geom.Point>} vertices An array of points.
|
* @param {Array.<ol.geom.Point>} vertices An array of points.
|
||||||
*/
|
*/
|
||||||
ol.geom.LineString.prototype.setVertices = function(vertices) {
|
ol.geom.LineString.prototype.setVertices = function(vertices) {
|
||||||
@@ -46,7 +47,7 @@ ol.geom.LineString.prototype.setVertices = function(vertices) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the given vertex to the list of vertices at the specified index.
|
* Adds the given vertex to the list of vertices at the specified index.
|
||||||
*
|
*
|
||||||
* @param {ol.geom.Point} vertex A point to be added.
|
* @param {ol.geom.Point} vertex A point to be added.
|
||||||
* @param {number} index The index where to add.
|
* @param {number} index The index where to add.
|
||||||
*/
|
*/
|
||||||
@@ -56,9 +57,20 @@ ol.geom.LineString.prototype.addVertex = function(vertex, index) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the given vertex from the list of vertices.
|
* Removes the given vertex from the list of vertices.
|
||||||
*
|
*
|
||||||
* @param {ol.geom.Point} vertex A point to be removed.
|
* @param {ol.geom.Point} vertex A point to be removed.
|
||||||
*/
|
*/
|
||||||
ol.geom.LineString.prototype.removeVertex = function(vertex) {
|
ol.geom.LineString.prototype.removeVertex = function(vertex) {
|
||||||
goog.array.remove(this.vertices_, vertex);
|
goog.array.remove(this.vertices_, vertex);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compute the centroid for this linestring.
|
||||||
|
*
|
||||||
|
* @returns {ol.geom.Point} The centroid of the linestring.
|
||||||
|
*/
|
||||||
|
ol.geom.LineString.prototype.getCentroid = function() {
|
||||||
|
var vertices = this.getVertices(),
|
||||||
|
collection = new ol.geom.Collection(vertices);
|
||||||
|
return collection.getCentroid();
|
||||||
|
};
|
||||||
@@ -4,12 +4,12 @@ goog.require('goog.array');
|
|||||||
goog.require('ol.geom.Collection');
|
goog.require('ol.geom.Collection');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates ol.geom.MultiPoint objects.
|
* Creates ol.geom.MultiPoint objects.
|
||||||
*
|
*
|
||||||
* @export
|
* @export
|
||||||
* @extends {ol.geom.Collection}
|
* @extends {ol.geom.Collection}
|
||||||
* @param {Array.<ol.geom.Point>} points An array of points.
|
* @param {Array.<ol.geom.Point>} points An array of points.
|
||||||
*
|
*
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
ol.geom.MultiPoint = function(points) {
|
ol.geom.MultiPoint = function(points) {
|
||||||
@@ -18,14 +18,14 @@ ol.geom.MultiPoint = function(points) {
|
|||||||
if (arguments.length === 1 && goog.isDef(points)) {
|
if (arguments.length === 1 && goog.isDef(points)) {
|
||||||
this.setPoints(points);
|
this.setPoints(points);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
goog.inherits(ol.geom.MultiPoint, ol.geom.Collection);
|
goog.inherits(ol.geom.MultiPoint, ol.geom.Collection);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the MultiPoint's points.
|
* Sets the MultiPoint's points.
|
||||||
*
|
*
|
||||||
* @return {Array.<ol.geom.Point>} An array of points.
|
* @return {Array.<ol.geom.Point>} An array of points.
|
||||||
*/
|
*/
|
||||||
ol.geom.MultiPoint.prototype.getPoints = function() {
|
ol.geom.MultiPoint.prototype.getPoints = function() {
|
||||||
@@ -34,7 +34,7 @@ ol.geom.MultiPoint.prototype.getPoints = function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the MultiPoint's points.
|
* Gets the MultiPoint's points.
|
||||||
*
|
*
|
||||||
* @param {Array.<ol.geom.Point>} points An array of points.
|
* @param {Array.<ol.geom.Point>} points An array of points.
|
||||||
*/
|
*/
|
||||||
ol.geom.MultiPoint.prototype.setPoints = function(points) {
|
ol.geom.MultiPoint.prototype.setPoints = function(points) {
|
||||||
@@ -43,7 +43,7 @@ ol.geom.MultiPoint.prototype.setPoints = function(points) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the given point to the list of points at the specified index.
|
* Adds the given point to the list of points at the specified index.
|
||||||
*
|
*
|
||||||
* @param {ol.geom.Point} point A point to be added.
|
* @param {ol.geom.Point} point A point to be added.
|
||||||
* @param {number} index The index where to add.
|
* @param {number} index The index where to add.
|
||||||
*/
|
*/
|
||||||
@@ -53,7 +53,7 @@ ol.geom.MultiPoint.prototype.addPoint = function(point, index) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the given point from the list of points.
|
* Removes the given point from the list of points.
|
||||||
*
|
*
|
||||||
* @param {ol.geom.Point} point A point to be removed.
|
* @param {ol.geom.Point} point A point to be removed.
|
||||||
*/
|
*/
|
||||||
ol.geom.MultiPoint.prototype.removePoint = function(point) {
|
ol.geom.MultiPoint.prototype.removePoint = function(point) {
|
||||||
|
|||||||
+27
-10
@@ -7,17 +7,17 @@ goog.require('ol.coord.AccessorInterface');
|
|||||||
goog.require('ol.base');
|
goog.require('ol.base');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates ol.geom.Point objects.
|
* Creates ol.geom.Point objects.
|
||||||
*
|
*
|
||||||
* @export
|
* @export
|
||||||
* @extends {ol.geom.Geometry}
|
* @extends {ol.geom.Geometry}
|
||||||
* @param {number} x X.
|
* @param {number} x X.
|
||||||
* @param {number} y Y.
|
* @param {number} y Y.
|
||||||
* @param {number=} opt_z Z.
|
* @param {number=} opt_z Z.
|
||||||
* @param {ol.Projection=} opt_projection Projection.
|
* @param {ol.Projection=} opt_projection Projection.
|
||||||
*
|
*
|
||||||
* @implements {ol.coord.AccessorInterface}
|
* @implements {ol.coord.AccessorInterface}
|
||||||
*
|
*
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
ol.geom.Point = function(x, y, opt_z, opt_projection) {
|
ol.geom.Point = function(x, y, opt_z, opt_projection) {
|
||||||
@@ -26,19 +26,19 @@ ol.geom.Point = function(x, y, opt_z, opt_projection) {
|
|||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
this.x_ = x;
|
this.x_ = x;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
this.y_ = y;
|
this.y_ = y;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {number|undefined}
|
* @type {number|undefined}
|
||||||
*/
|
*/
|
||||||
this.z_ = opt_z;
|
this.z_ = opt_z;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {ol.Projection}
|
* @type {ol.Projection}
|
||||||
@@ -109,12 +109,12 @@ ol.geom.Point.prototype.setZ = function(z) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transform this point to another coordinate reference system. This
|
* Transform this point to another coordinate reference system. This
|
||||||
* requires that this point has a projection set already (if not, an error
|
* 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
|
* will be thrown). Returns a new point object and does not modify this
|
||||||
* point.
|
* point.
|
||||||
*
|
*
|
||||||
* @param {string|!ol.Projection} proj The destination projection. Can be
|
* @param {string|!ol.Projection} proj The destination projection. Can be
|
||||||
* supplied as a projection instance of a string identifier.
|
* supplied as a projection instance of a string identifier.
|
||||||
* @returns {!ol.geom.Point} A new location.
|
* @returns {!ol.geom.Point} A new location.
|
||||||
*/
|
*/
|
||||||
@@ -140,7 +140,24 @@ ol.geom.Point.prototype._transform = function(proj) {
|
|||||||
ol.error(msg);
|
ol.error(msg);
|
||||||
}
|
}
|
||||||
ol.Projection.transform(point, sourceProj, proj);
|
ol.Projection.transform(point, sourceProj, proj);
|
||||||
|
|
||||||
return new ol.geom.Point(point['x'], point['y'], this.z_, proj);
|
return new ol.geom.Point(point['x'], point['y'], this.z_, proj);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the centroid of the point.
|
||||||
|
*
|
||||||
|
* @returns {ol.geom.Point} The centroid of the point.
|
||||||
|
*/
|
||||||
|
ol.geom.Point.prototype.getCentroid = function() {
|
||||||
|
return new ol.geom.Point(this.x_, this.y_, this.z_, this.projection_);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the area of the geometry whcih is always 0.
|
||||||
|
*
|
||||||
|
* @returns {number} The area of the point (always 0).
|
||||||
|
*/
|
||||||
|
ol.geom.Point.prototype.getArea = function() {
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ ol.layer.TileLayer = function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
* @type {function(new:ol.Tile, string, ol.Bounds)}
|
* @type {function(new:ol.Tile, string, ol.Bounds=)}
|
||||||
*/
|
*/
|
||||||
this.Tile = ol.Tile.createConstructor(this.tileWidth_, this.tileHeight_);
|
this.Tile = ol.Tile.createConstructor(this.tileWidth_, this.tileHeight_);
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ ol.layer.TileLayer = function() {
|
|||||||
* @private
|
* @private
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
this.tileOriginCorner_ = 'bl';
|
this.tileOriginCorner_ = 'tl';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -70,6 +70,18 @@ ol.layer.TileLayer = function() {
|
|||||||
*/
|
*/
|
||||||
this.maxResolution_ = undefined;
|
this.maxResolution_ = undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
|
this.xRight_ = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
|
this.yDown_ = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {number|undefined}
|
* @type {number|undefined}
|
||||||
@@ -92,6 +104,33 @@ ol.layer.TileLayer = function() {
|
|||||||
|
|
||||||
goog.inherits(ol.layer.TileLayer, ol.layer.Layer);
|
goog.inherits(ol.layer.TileLayer, ol.layer.Layer);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {boolean} The tile index increases from left to right.
|
||||||
|
*/
|
||||||
|
ol.layer.TileLayer.prototype.getXRight = function() {
|
||||||
|
return this.xRight_;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {boolean} The tile index increases from top to bottom.
|
||||||
|
*/
|
||||||
|
ol.layer.TileLayer.prototype.getYDown = function() {
|
||||||
|
return this.yDown_;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {boolean} right The tile index increases from left to right.
|
||||||
|
*/
|
||||||
|
ol.layer.TileLayer.prototype.setXRight = function(right) {
|
||||||
|
this.xRight_ = right;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {boolean} down The tile index increases from top to bottom.
|
||||||
|
*/
|
||||||
|
ol.layer.TileLayer.prototype.setYDown = function(down) {
|
||||||
|
this.yDown_ = down;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get layer extent. Return null if the layer has no extent
|
* Get layer extent. Return null if the layer has no extent
|
||||||
@@ -172,7 +211,7 @@ ol.layer.TileLayer.prototype.getMaxResolution = function() {
|
|||||||
if (!goog.isNull(extent)) {
|
if (!goog.isNull(extent)) {
|
||||||
this.maxResolution_ = Math.max(
|
this.maxResolution_ = Math.max(
|
||||||
(extent.getMaxX() - extent.getMinX()) / this.tileWidth_,
|
(extent.getMaxX() - extent.getMinX()) / this.tileWidth_,
|
||||||
(extent.getMaxY() - extent.getMaxX()) / this.tileHeight_);
|
(extent.getMaxY() - extent.getMinY()) / this.tileHeight_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.maxResolution_;
|
return this.maxResolution_;
|
||||||
@@ -285,6 +324,25 @@ ol.layer.TileLayer.prototype.getTile = function(url, bounds) {
|
|||||||
return tile;
|
return tile;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a tile from the cache, or create a tile and add to
|
||||||
|
* the cache.
|
||||||
|
* @param {number} x
|
||||||
|
* @param {number} y
|
||||||
|
* @param {number} z
|
||||||
|
*/
|
||||||
|
ol.layer.TileLayer.prototype.getTileForXYZ = function(x, y, z) {
|
||||||
|
var url = this.url_.replace('{x}', x + '')
|
||||||
|
.replace('{y}', y + '')
|
||||||
|
.replace('{z}', z + '');
|
||||||
|
var tile = this.cache_.get(url);
|
||||||
|
if (!goog.isDef(tile)) {
|
||||||
|
tile = new this.Tile(url);
|
||||||
|
this.cache_.set(tile.getUrl(), tile);
|
||||||
|
}
|
||||||
|
return tile;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get data from the layer. This is the layer's main API function.
|
* Get data from the layer. This is the layer's main API function.
|
||||||
* @param {ol.Bounds} bounds
|
* @param {ol.Bounds} bounds
|
||||||
|
|||||||
@@ -26,6 +26,12 @@ ol.renderer.TileLayerRenderer = function(container, layer) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.rendererdBounds_ = null;
|
this.rendererdBounds_ = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {Array.<number>}
|
||||||
|
*/
|
||||||
|
this.layerResolutions_ = layer.getResolutions();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {number|undefined}
|
* @type {number|undefined}
|
||||||
@@ -43,7 +49,27 @@ ol.renderer.TileLayerRenderer = function(container, layer) {
|
|||||||
|
|
||||||
goog.inherits(ol.renderer.TileLayerRenderer, ol.renderer.LayerRenderer);
|
goog.inherits(ol.renderer.TileLayerRenderer, ol.renderer.LayerRenderer);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} resolution
|
||||||
|
* @return {Array.<number>}
|
||||||
|
*/
|
||||||
|
ol.renderer.TileLayerRenderer.prototype.getPreferredResAndZ_ = function(resolution) {
|
||||||
|
var minDiff = Number.POSITIVE_INFINITY;
|
||||||
|
var candidate, diff, z, r;
|
||||||
|
for (var i=0, ii=this.layerResolutions_.length; i<ii; ++i) {
|
||||||
|
// assumes sorted resolutions
|
||||||
|
candidate = this.layerResolutions_[i];
|
||||||
|
diff = Math.abs(resolution - candidate);
|
||||||
|
if (diff < minDiff) {
|
||||||
|
z = i;
|
||||||
|
r = candidate;
|
||||||
|
minDiff = diff;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [r, z];
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {goog.math.Size}
|
* @return {goog.math.Size}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
describe("ol.geom.collection", function() {
|
describe("ol.geom.collection", function() {
|
||||||
var c;
|
var c;
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
c = ol.geom.collection([
|
c = ol.geom.collection([
|
||||||
@@ -9,7 +9,7 @@ describe("ol.geom.collection", function() {
|
|||||||
])
|
])
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
c = null;
|
c = null;
|
||||||
});
|
});
|
||||||
@@ -18,149 +18,149 @@ describe("ol.geom.collection", function() {
|
|||||||
expect( c ).toBeA( ol.geom.Collection );
|
expect( c ).toBeA( ol.geom.Collection );
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("can construct instances without any components", function() {
|
describe("can construct instances without any components", function() {
|
||||||
|
|
||||||
it("works with an empty array", function(){
|
it("works with an empty array", function(){
|
||||||
c = ol.geom.collection([]);
|
c = ol.geom.collection([]);
|
||||||
|
|
||||||
expect( c ).toBeA( ol.geom.Collection );
|
expect( c ).toBeA( ol.geom.Collection );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("works without arguments", function(){
|
it("works without arguments", function(){
|
||||||
c = ol.geom.collection();
|
c = ol.geom.collection();
|
||||||
|
|
||||||
expect( c ).toBeA( ol.geom.Collection );
|
expect( c ).toBeA( ol.geom.Collection );
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("the method 'add'", function() {
|
describe("the method 'add'", function() {
|
||||||
it("exists", function(){
|
it("exists", function(){
|
||||||
expect( c.add ).toBeA( Function );
|
expect( c.add ).toBeA( Function );
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("can be used as setter", function(){
|
describe("can be used as setter", function(){
|
||||||
it("works with a single point specification and an index", function(){
|
it("works with a single point specification and an index", function(){
|
||||||
var p = ol.geom.point([24,7]);
|
var p = ol.geom.point([24,7]);
|
||||||
c.add(p, 0);
|
c.add(p, 0);
|
||||||
|
|
||||||
expect(c.components().length).toBe(3);
|
expect(c.components().length).toBe(3);
|
||||||
|
|
||||||
var firstComponent = c.components()[0];
|
var firstComponent = c.components()[0];
|
||||||
|
|
||||||
expect( firstComponent.x() + ',' + firstComponent.y() ).toBe( '24,7' );
|
expect( firstComponent.x() + ',' + firstComponent.y() ).toBe( '24,7' );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("the index is functional", function(){
|
it("the index is functional", function(){
|
||||||
var p = ol.geom.point([24,7]);
|
var p = ol.geom.point([24,7]);
|
||||||
c.add(p, 1);
|
c.add(p, 1);
|
||||||
|
|
||||||
expect(c.components().length).toBe(3);
|
expect(c.components().length).toBe(3);
|
||||||
|
|
||||||
var firstComponent = c.components()[0], // untouched
|
var firstComponent = c.components()[0], // untouched
|
||||||
secondComponent = c.components()[1], // this should be ours
|
secondComponent = c.components()[1], // this should be ours
|
||||||
thirdComponent = c.components()[2]; // shifted here
|
thirdComponent = c.components()[2]; // shifted here
|
||||||
|
|
||||||
expect( firstComponent.x() + ',' + firstComponent.y() ).toBe( '0,1' );
|
expect( firstComponent.x() + ',' + firstComponent.y() ).toBe( '0,1' );
|
||||||
expect( secondComponent.x() + ',' + secondComponent.y() ).toBe( '24,7' );
|
expect( secondComponent.x() + ',' + secondComponent.y() ).toBe( '24,7' );
|
||||||
expect( thirdComponent ).toBeA( ol.geom.LineString );
|
expect( thirdComponent ).toBeA( ol.geom.LineString );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("the index is optional", function(){
|
it("the index is optional", function(){
|
||||||
var p = ol.geom.point([24,7]);
|
var p = ol.geom.point([24,7]);
|
||||||
c.add(p);
|
c.add(p);
|
||||||
|
|
||||||
expect(c.components().length).toBe(3);
|
expect(c.components().length).toBe(3);
|
||||||
|
|
||||||
var thirdComponent = c.components()[2];
|
var thirdComponent = c.components()[2];
|
||||||
expect( thirdComponent.x() + ',' + thirdComponent.y() ).toBe( '24,7' );
|
expect( thirdComponent.x() + ',' + thirdComponent.y() ).toBe( '24,7' );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("returns the collection instance", function(){
|
it("returns the collection instance", function(){
|
||||||
var p = ol.geom.point([24,7]);
|
var p = ol.geom.point([24,7]);
|
||||||
var returned = c.add(p);
|
var returned = c.add(p);
|
||||||
|
|
||||||
expect(returned).toBe(c);
|
expect(returned).toBe(c);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("the method 'addAll'", function(){
|
describe("the method 'addAll'", function(){
|
||||||
it("exists", function(){
|
it("exists", function(){
|
||||||
expect( c.addAll ).toBeA( Function );
|
expect( c.addAll ).toBeA( Function );
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("can be used as setter", function(){
|
describe("can be used as setter", function(){
|
||||||
|
|
||||||
it("works with an array of points and an index", function(){
|
it("works with an array of points and an index", function(){
|
||||||
var ps = [
|
var ps = [
|
||||||
ol.geom.point([24,7]),
|
ol.geom.point([24,7]),
|
||||||
ol.geom.point([7,11])
|
ol.geom.point([7,11])
|
||||||
];
|
];
|
||||||
c.addAll(ps, 0);
|
c.addAll(ps, 0);
|
||||||
|
|
||||||
expect(c.components().length).toBe(4);
|
expect(c.components().length).toBe(4);
|
||||||
|
|
||||||
var firstComponent = c.components()[0],
|
var firstComponent = c.components()[0],
|
||||||
secondComponent = c.components()[1];
|
secondComponent = c.components()[1];
|
||||||
|
|
||||||
expect( firstComponent.x() + ',' + firstComponent.y() ).toBe( '24,7' );
|
expect( firstComponent.x() + ',' + firstComponent.y() ).toBe( '24,7' );
|
||||||
expect( secondComponent.x() + ',' + secondComponent.y() ).toBe( '7,11' );
|
expect( secondComponent.x() + ',' + secondComponent.y() ).toBe( '7,11' );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("the index is functional", function(){
|
it("the index is functional", function(){
|
||||||
var ps = [
|
var ps = [
|
||||||
ol.geom.point([24,7]),
|
ol.geom.point([24,7]),
|
||||||
ol.geom.point({x:7, y:11})
|
ol.geom.point({x:7, y:11})
|
||||||
];
|
];
|
||||||
c.addAll(ps, 1);
|
c.addAll(ps, 1);
|
||||||
|
|
||||||
expect(c.components().length).toBe(4);
|
expect(c.components().length).toBe(4);
|
||||||
|
|
||||||
var firstComponent = c.components()[0], // untouched
|
var firstComponent = c.components()[0], // untouched
|
||||||
secondComponent = c.components()[1], // this should be ours
|
secondComponent = c.components()[1], // this should be ours
|
||||||
thirdComponent = c.components()[2], // this should be ours
|
thirdComponent = c.components()[2], // this should be ours
|
||||||
fourthComponent = c.components()[3]; // shifted here
|
fourthComponent = c.components()[3]; // shifted here
|
||||||
|
|
||||||
expect( firstComponent.x() + ',' + firstComponent.y() ).toBe( '0,1' );
|
expect( firstComponent.x() + ',' + firstComponent.y() ).toBe( '0,1' );
|
||||||
expect( secondComponent.x() + ',' + secondComponent.y() ).toBe( '24,7' );
|
expect( secondComponent.x() + ',' + secondComponent.y() ).toBe( '24,7' );
|
||||||
expect( thirdComponent.x() + ',' + thirdComponent.y() ).toBe( '7,11' );
|
expect( thirdComponent.x() + ',' + thirdComponent.y() ).toBe( '7,11' );
|
||||||
expect( fourthComponent ).toBeA( ol.geom.LineString );
|
expect( fourthComponent ).toBeA( ol.geom.LineString );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("the index is optional", function(){
|
it("the index is optional", function(){
|
||||||
var ps = [
|
var ps = [
|
||||||
ol.geom.point([24,7]),
|
ol.geom.point([24,7]),
|
||||||
ol.geom.point({x:7, y:11})
|
ol.geom.point({x:7, y:11})
|
||||||
];
|
];
|
||||||
c.addAll(ps);
|
c.addAll(ps);
|
||||||
|
|
||||||
expect(c.components().length).toBe(4);
|
expect(c.components().length).toBe(4);
|
||||||
|
|
||||||
var thirdComponent = c.components()[2],
|
var thirdComponent = c.components()[2],
|
||||||
fourthComponent = c.components()[3];
|
fourthComponent = c.components()[3];
|
||||||
expect( thirdComponent.x() + ',' + thirdComponent.y() ).toBe( '24,7' );
|
expect( thirdComponent.x() + ',' + thirdComponent.y() ).toBe( '24,7' );
|
||||||
expect( fourthComponent.x() + ',' + fourthComponent.y() ).toBe( '7,11' );
|
expect( fourthComponent.x() + ',' + fourthComponent.y() ).toBe( '7,11' );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("returns the collection instance", function(){
|
it("returns the collection instance", function(){
|
||||||
var ps = [
|
var ps = [
|
||||||
ol.geom.point([24,7]),
|
ol.geom.point([24,7]),
|
||||||
ol.geom.point({x:7, y:11})
|
ol.geom.point({x:7, y:11})
|
||||||
];
|
];
|
||||||
var returned = c.addAll(ps);
|
var returned = c.addAll(ps);
|
||||||
|
|
||||||
expect(returned).toBe(c);
|
expect(returned).toBe(c);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
describe("the method 'remove'", function() {
|
describe("the method 'remove'", function() {
|
||||||
it("exists", function(){
|
it("exists", function(){
|
||||||
expect( c.add ).toBeA( Function );
|
expect( c.add ).toBeA( Function );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("works with a single point", function(){
|
it("works with a single point", function(){
|
||||||
var p = c.components()[0];
|
var p = c.components()[0];
|
||||||
c.remove(p);
|
c.remove(p);
|
||||||
@@ -168,7 +168,7 @@ describe("ol.geom.collection", function() {
|
|||||||
var firstComponent = c.components()[0];
|
var firstComponent = c.components()[0];
|
||||||
expect( firstComponent ).toBeA( ol.geom.LineString );
|
expect( firstComponent ).toBeA( ol.geom.LineString );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("works with an array of point specifications", function(){
|
it("works with an array of point specifications", function(){
|
||||||
var ps = [
|
var ps = [
|
||||||
c.components()[1],
|
c.components()[1],
|
||||||
|
|||||||
@@ -1,45 +1,45 @@
|
|||||||
describe("ol.geom.geometry", function() {
|
describe("ol.geom.geometry", function() {
|
||||||
var g;
|
var g;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
g = ol.geom.geometry();
|
g = ol.geom.geometry();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
g = null;
|
g = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it("constructs instances", function() {
|
it("constructs instances", function() {
|
||||||
expect( g ).toBeA( ol.geom.Geometry );
|
expect( g ).toBeA( ol.geom.Geometry );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("can set bounds", function() {
|
it("can set bounds", function() {
|
||||||
var oldBounds = g.bounds();
|
var oldBounds = g.bounds();
|
||||||
|
|
||||||
expect(oldBounds).toBeUndefined();
|
expect(oldBounds).toBeUndefined();
|
||||||
|
|
||||||
var b = ol.bounds([0,1,2,3]);
|
var b = ol.bounds([0,1,2,3]);
|
||||||
g.bounds(b);
|
g.bounds(b);
|
||||||
var gotBounds = g.bounds();
|
var gotBounds = g.bounds();
|
||||||
|
|
||||||
expect(gotBounds).not.toBeUndefined();
|
expect(gotBounds).not.toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("can get bounds", function() {
|
it("can get bounds", function() {
|
||||||
var b = ol.bounds([0,1,2,3]);
|
var b = ol.bounds([0,1,2,3]);
|
||||||
g.bounds(b);
|
g.bounds(b);
|
||||||
var gotBounds = g.bounds();
|
var gotBounds = g.bounds();
|
||||||
|
|
||||||
expect(gotBounds).toEqual(jasmine.any(ol.Bounds));
|
expect(gotBounds).toEqual(jasmine.any(ol.Bounds));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("sets and gets the correct bounds", function() {
|
it("sets and gets the correct bounds", function() {
|
||||||
var b = ol.bounds([0,1,2,3]);
|
var b = ol.bounds([0,1,2,3]);
|
||||||
g.bounds(b);
|
g.bounds(b);
|
||||||
var gotBounds = g.bounds();
|
var gotBounds = g.bounds();
|
||||||
|
|
||||||
expect(gotBounds.minX()).toEqual(0);
|
expect(gotBounds.minX()).toEqual(0);
|
||||||
expect(gotBounds.minY()).toEqual(1);
|
expect(gotBounds.minY()).toEqual(1);
|
||||||
expect(gotBounds.maxX()).toEqual(2);
|
expect(gotBounds.maxX()).toEqual(2);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
describe("ol.geom.linestring", function() {
|
describe("ol.geom.linestring", function() {
|
||||||
var ls;
|
var ls;
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
ls = ol.geom.linestring([
|
ls = ol.geom.linestring([
|
||||||
@@ -6,7 +6,7 @@ describe("ol.geom.linestring", function() {
|
|||||||
{x:2, y:3}
|
{x:2, y:3}
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
ls = null;
|
ls = null;
|
||||||
});
|
});
|
||||||
@@ -14,58 +14,58 @@ describe("ol.geom.linestring", function() {
|
|||||||
it("works for the object notation of vertices", function(){
|
it("works for the object notation of vertices", function(){
|
||||||
expect( ls ).toBeA( ol.geom.LineString );
|
expect( ls ).toBeA( ol.geom.LineString );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("works for the array notation of vertices", function(){
|
it("works for the array notation of vertices", function(){
|
||||||
ls = ol.geom.linestring([
|
ls = ol.geom.linestring([
|
||||||
[0, 1],
|
[0, 1],
|
||||||
[2, 3]
|
[2, 3]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
expect( ls ).toBeA( ol.geom.LineString );
|
expect( ls ).toBeA( ol.geom.LineString );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("works for real vertices", function(){
|
it("works for real vertices", function(){
|
||||||
ls = ol.geom.linestring([
|
ls = ol.geom.linestring([
|
||||||
ol.geom.point([0,1]),
|
ol.geom.point([0,1]),
|
||||||
ol.geom.point([2,3])
|
ol.geom.point([2,3])
|
||||||
]);
|
]);
|
||||||
|
|
||||||
expect( ls ).toBeA( ol.geom.LineString );
|
expect( ls ).toBeA( ol.geom.LineString );
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("can construct instances without any vertices", function() {
|
describe("can construct instances without any vertices", function() {
|
||||||
|
|
||||||
it("works with an empty array", function(){
|
it("works with an empty array", function(){
|
||||||
ls = ol.geom.linestring([]);
|
ls = ol.geom.linestring([]);
|
||||||
|
|
||||||
expect( ls ).toBeA( ol.geom.LineString );
|
expect( ls ).toBeA( ol.geom.LineString );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("works without arguments", function(){
|
it("works without arguments", function(){
|
||||||
ls = ol.geom.linestring();
|
ls = ol.geom.linestring();
|
||||||
|
|
||||||
expect( ls ).toBeA( ol.geom.LineString );
|
expect( ls ).toBeA( ol.geom.LineString );
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("the method 'add'", function() {
|
describe("the method 'add'", function() {
|
||||||
it("exists", function(){
|
it("exists", function(){
|
||||||
expect( ls.add ).toBeA( Function );
|
expect( ls.add ).toBeA( Function );
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("can be used as setter", function(){
|
describe("can be used as setter", function(){
|
||||||
it("works with a single vertex specification and an index", function(){
|
it("works with a single vertex specification and an index", function(){
|
||||||
var p = ol.geom.point([24,7]);
|
var p = ol.geom.point([24,7]);
|
||||||
ls.add(p, 0);
|
ls.add(p, 0);
|
||||||
|
|
||||||
expect(ls.vertices().length).toBe(3);
|
expect(ls.vertices().length).toBe(3);
|
||||||
|
|
||||||
var firstPoint = ls.vertices()[0];
|
var firstPoint = ls.vertices()[0];
|
||||||
|
|
||||||
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' );
|
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("works with point instance", function(){
|
it("works with point instance", function(){
|
||||||
ls = ol.geom.linestring();
|
ls = ol.geom.linestring();
|
||||||
ls.add(ol.geom.point([24,7]));
|
ls.add(ol.geom.point([24,7]));
|
||||||
@@ -73,7 +73,7 @@ describe("ol.geom.linestring", function() {
|
|||||||
var firstPoint = ls.vertices()[0];
|
var firstPoint = ls.vertices()[0];
|
||||||
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' );
|
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("works with array specifications", function(){
|
it("works with array specifications", function(){
|
||||||
ls = ol.geom.linestring();
|
ls = ol.geom.linestring();
|
||||||
ls.add([24,7]);
|
ls.add([24,7]);
|
||||||
@@ -81,7 +81,7 @@ describe("ol.geom.linestring", function() {
|
|||||||
var firstPoint = ls.vertices()[0];
|
var firstPoint = ls.vertices()[0];
|
||||||
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' );
|
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("works with object specifications", function(){
|
it("works with object specifications", function(){
|
||||||
ls = ol.geom.linestring();
|
ls = ol.geom.linestring();
|
||||||
ls.add({x:24,y:7});
|
ls.add({x:24,y:7});
|
||||||
@@ -89,117 +89,117 @@ describe("ol.geom.linestring", function() {
|
|||||||
var firstPoint = ls.vertices()[0];
|
var firstPoint = ls.vertices()[0];
|
||||||
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' );
|
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("the index is functional", function(){
|
it("the index is functional", function(){
|
||||||
var p = ol.geom.point([24,7]);
|
var p = ol.geom.point([24,7]);
|
||||||
ls.add(p, 1);
|
ls.add(p, 1);
|
||||||
|
|
||||||
expect(ls.vertices().length).toBe(3);
|
expect(ls.vertices().length).toBe(3);
|
||||||
|
|
||||||
var firstPoint = ls.vertices()[0], // untouched
|
var firstPoint = ls.vertices()[0], // untouched
|
||||||
secondPoint = ls.vertices()[1], // this should be ours
|
secondPoint = ls.vertices()[1], // this should be ours
|
||||||
thirdPoint = ls.vertices()[2]; // shifted here
|
thirdPoint = ls.vertices()[2]; // shifted here
|
||||||
|
|
||||||
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '0,1' );
|
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '0,1' );
|
||||||
expect( secondPoint.x() + ',' + secondPoint.y() ).toBe( '24,7' );
|
expect( secondPoint.x() + ',' + secondPoint.y() ).toBe( '24,7' );
|
||||||
expect( thirdPoint.x() + ',' + thirdPoint.y() ).toBe( '2,3' );
|
expect( thirdPoint.x() + ',' + thirdPoint.y() ).toBe( '2,3' );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("the index is optional", function(){
|
it("the index is optional", function(){
|
||||||
var p = ol.geom.point([24,7]);
|
var p = ol.geom.point([24,7]);
|
||||||
ls.add(p);
|
ls.add(p);
|
||||||
|
|
||||||
expect(ls.vertices().length).toBe(3);
|
expect(ls.vertices().length).toBe(3);
|
||||||
|
|
||||||
var thirdPoint = ls.vertices()[2];
|
var thirdPoint = ls.vertices()[2];
|
||||||
expect( thirdPoint.x() + ',' + thirdPoint.y() ).toBe( '24,7' );
|
expect( thirdPoint.x() + ',' + thirdPoint.y() ).toBe( '24,7' );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("returns the linestring instance", function(){
|
it("returns the linestring instance", function(){
|
||||||
var p = ol.geom.point([24,7]);
|
var p = ol.geom.point([24,7]);
|
||||||
var returned = ls.add(p);
|
var returned = ls.add(p);
|
||||||
|
|
||||||
expect(returned).toBe(ls);
|
expect(returned).toBe(ls);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("the method 'addAll'", function(){
|
describe("the method 'addAll'", function(){
|
||||||
it("exists", function(){
|
it("exists", function(){
|
||||||
expect( ls.addAll ).toBeA( Function );
|
expect( ls.addAll ).toBeA( Function );
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("can be used as setter", function(){
|
describe("can be used as setter", function(){
|
||||||
|
|
||||||
it("works with an array of point specifications and an index", function(){
|
it("works with an array of point specifications and an index", function(){
|
||||||
var ps = [
|
var ps = [
|
||||||
ol.geom.point([24,7]),
|
ol.geom.point([24,7]),
|
||||||
ol.geom.point([7,11])
|
ol.geom.point([7,11])
|
||||||
];
|
];
|
||||||
ls.addAll(ps, 0);
|
ls.addAll(ps, 0);
|
||||||
|
|
||||||
expect(ls.vertices().length).toBe(4);
|
expect(ls.vertices().length).toBe(4);
|
||||||
|
|
||||||
var firstPoint = ls.vertices()[0],
|
var firstPoint = ls.vertices()[0],
|
||||||
secondPoint = ls.vertices()[1];
|
secondPoint = ls.vertices()[1];
|
||||||
|
|
||||||
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' );
|
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' );
|
||||||
expect( secondPoint.x() + ',' + secondPoint.y() ).toBe( '7,11' );
|
expect( secondPoint.x() + ',' + secondPoint.y() ).toBe( '7,11' );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("the index is functional", function(){
|
it("the index is functional", function(){
|
||||||
var ps = [
|
var ps = [
|
||||||
[24,7],
|
[24,7],
|
||||||
{x:7, y:11}
|
{x:7, y:11}
|
||||||
];
|
];
|
||||||
ls.addAll(ps, 1);
|
ls.addAll(ps, 1);
|
||||||
|
|
||||||
expect(ls.vertices().length).toBe(4);
|
expect(ls.vertices().length).toBe(4);
|
||||||
|
|
||||||
var firstPoint = ls.vertices()[0], // untouched
|
var firstPoint = ls.vertices()[0], // untouched
|
||||||
secondPoint = ls.vertices()[1], // this should be ours
|
secondPoint = ls.vertices()[1], // this should be ours
|
||||||
thirdPoint = ls.vertices()[2], // this should be ours
|
thirdPoint = ls.vertices()[2], // this should be ours
|
||||||
fourthPoint = ls.vertices()[3]; // shifted here
|
fourthPoint = ls.vertices()[3]; // shifted here
|
||||||
|
|
||||||
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '0,1' );
|
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '0,1' );
|
||||||
expect( secondPoint.x() + ',' + secondPoint.y() ).toBe( '24,7' );
|
expect( secondPoint.x() + ',' + secondPoint.y() ).toBe( '24,7' );
|
||||||
expect( thirdPoint.x() + ',' + thirdPoint.y() ).toBe( '7,11' );
|
expect( thirdPoint.x() + ',' + thirdPoint.y() ).toBe( '7,11' );
|
||||||
expect( fourthPoint.x() + ',' + fourthPoint.y() ).toBe( '2,3' );
|
expect( fourthPoint.x() + ',' + fourthPoint.y() ).toBe( '2,3' );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("the index is optional", function(){
|
it("the index is optional", function(){
|
||||||
var ps = [
|
var ps = [
|
||||||
[24,7],
|
[24,7],
|
||||||
{x:7, y:11}
|
{x:7, y:11}
|
||||||
];
|
];
|
||||||
ls.addAll(ps);
|
ls.addAll(ps);
|
||||||
|
|
||||||
expect(ls.vertices().length).toBe(4);
|
expect(ls.vertices().length).toBe(4);
|
||||||
|
|
||||||
var thirdPoint = ls.vertices()[2],
|
var thirdPoint = ls.vertices()[2],
|
||||||
fourthPoint = ls.vertices()[3];
|
fourthPoint = ls.vertices()[3];
|
||||||
expect( thirdPoint.x() + ',' + thirdPoint.y() ).toBe( '24,7' );
|
expect( thirdPoint.x() + ',' + thirdPoint.y() ).toBe( '24,7' );
|
||||||
expect( fourthPoint.x() + ',' + fourthPoint.y() ).toBe( '7,11' );
|
expect( fourthPoint.x() + ',' + fourthPoint.y() ).toBe( '7,11' );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("returns the linestring instance", function(){
|
it("returns the linestring instance", function(){
|
||||||
var ps = [
|
var ps = [
|
||||||
[24,7],
|
[24,7],
|
||||||
{x:7, y:11}
|
{x:7, y:11}
|
||||||
];
|
];
|
||||||
var returned = ls.addAll(ps);
|
var returned = ls.addAll(ps);
|
||||||
|
|
||||||
expect(returned).toBe(ls);
|
expect(returned).toBe(ls);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
describe("the method 'remove'", function() {
|
describe("the method 'remove'", function() {
|
||||||
it("exists", function(){
|
it("exists", function(){
|
||||||
expect( ls.add ).toBeA( Function );
|
expect( ls.add ).toBeA( Function );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("works with a single point", function(){
|
it("works with a single point", function(){
|
||||||
var p = ls.vertices()[0];
|
var p = ls.vertices()[0];
|
||||||
ls.remove(p);
|
ls.remove(p);
|
||||||
@@ -207,7 +207,7 @@ describe("ol.geom.linestring", function() {
|
|||||||
var firstPoint = ls.vertices()[0];
|
var firstPoint = ls.vertices()[0];
|
||||||
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '2,3' );
|
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '2,3' );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("works with an array of point specifications", function(){
|
it("works with an array of point specifications", function(){
|
||||||
var ps = [
|
var ps = [
|
||||||
ls.vertices()[1],
|
ls.vertices()[1],
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
describe("ol.geom.multipoint", function() {
|
describe("ol.geom.multipoint", function() {
|
||||||
var mp;
|
var mp;
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
mp = ol.geom.multipoint([
|
mp = ol.geom.multipoint([
|
||||||
@@ -6,7 +6,7 @@ describe("ol.geom.multipoint", function() {
|
|||||||
{x:2, y:3}
|
{x:2, y:3}
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
mp = null;
|
mp = null;
|
||||||
});
|
});
|
||||||
@@ -14,58 +14,58 @@ describe("ol.geom.multipoint", function() {
|
|||||||
it("works for the object notation of points", function(){
|
it("works for the object notation of points", function(){
|
||||||
expect( mp ).toBeA( ol.geom.MultiPoint );
|
expect( mp ).toBeA( ol.geom.MultiPoint );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("works for the array notation of points", function(){
|
it("works for the array notation of points", function(){
|
||||||
mp = ol.geom.multipoint([
|
mp = ol.geom.multipoint([
|
||||||
[0, 1],
|
[0, 1],
|
||||||
[2, 3]
|
[2, 3]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
expect( mp ).toBeA( ol.geom.MultiPoint );
|
expect( mp ).toBeA( ol.geom.MultiPoint );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("works for real points", function(){
|
it("works for real points", function(){
|
||||||
mp = ol.geom.multipoint([
|
mp = ol.geom.multipoint([
|
||||||
ol.geom.point([0,1]),
|
ol.geom.point([0,1]),
|
||||||
ol.geom.point([2,3])
|
ol.geom.point([2,3])
|
||||||
]);
|
]);
|
||||||
|
|
||||||
expect( mp ).toBeA( ol.geom.MultiPoint );
|
expect( mp ).toBeA( ol.geom.MultiPoint );
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("can construct instances without any points", function() {
|
describe("can construct instances without any points", function() {
|
||||||
|
|
||||||
it("works with an empty array", function(){
|
it("works with an empty array", function(){
|
||||||
mp = ol.geom.multipoint([]);
|
mp = ol.geom.multipoint([]);
|
||||||
|
|
||||||
expect( mp ).toBeA( ol.geom.MultiPoint );
|
expect( mp ).toBeA( ol.geom.MultiPoint );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("works without arguments", function(){
|
it("works without arguments", function(){
|
||||||
mp = ol.geom.multipoint();
|
mp = ol.geom.multipoint();
|
||||||
|
|
||||||
expect( mp ).toBeA( ol.geom.MultiPoint );
|
expect( mp ).toBeA( ol.geom.MultiPoint );
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("the method 'add'", function() {
|
describe("the method 'add'", function() {
|
||||||
it("exists", function(){
|
it("exists", function(){
|
||||||
expect( mp.add ).toBeA( Function );
|
expect( mp.add ).toBeA( Function );
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("can be used as setter", function(){
|
describe("can be used as setter", function(){
|
||||||
it("works with a single point specification and an index", function(){
|
it("works with a single point specification and an index", function(){
|
||||||
var p = ol.geom.point([24,7]);
|
var p = ol.geom.point([24,7]);
|
||||||
mp.add(p, 0);
|
mp.add(p, 0);
|
||||||
|
|
||||||
expect(mp.points().length).toBe(3);
|
expect(mp.points().length).toBe(3);
|
||||||
|
|
||||||
var firstPoint = mp.points()[0];
|
var firstPoint = mp.points()[0];
|
||||||
|
|
||||||
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' );
|
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("works with point instance", function(){
|
it("works with point instance", function(){
|
||||||
mp = ol.geom.multipoint();
|
mp = ol.geom.multipoint();
|
||||||
mp.add(ol.geom.point([24,7]));
|
mp.add(ol.geom.point([24,7]));
|
||||||
@@ -73,7 +73,7 @@ describe("ol.geom.multipoint", function() {
|
|||||||
var firstPoint = mp.points()[0];
|
var firstPoint = mp.points()[0];
|
||||||
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' );
|
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("works with array specifications", function(){
|
it("works with array specifications", function(){
|
||||||
mp = ol.geom.multipoint();
|
mp = ol.geom.multipoint();
|
||||||
mp.add([24,7]);
|
mp.add([24,7]);
|
||||||
@@ -81,7 +81,7 @@ describe("ol.geom.multipoint", function() {
|
|||||||
var firstPoint = mp.points()[0];
|
var firstPoint = mp.points()[0];
|
||||||
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' );
|
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("works with object specifications", function(){
|
it("works with object specifications", function(){
|
||||||
mp = ol.geom.multipoint();
|
mp = ol.geom.multipoint();
|
||||||
mp.add({x:24,y:7});
|
mp.add({x:24,y:7});
|
||||||
@@ -89,117 +89,117 @@ describe("ol.geom.multipoint", function() {
|
|||||||
var firstPoint = mp.points()[0];
|
var firstPoint = mp.points()[0];
|
||||||
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' );
|
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("the index is functional", function(){
|
it("the index is functional", function(){
|
||||||
var p = ol.geom.point([24,7]);
|
var p = ol.geom.point([24,7]);
|
||||||
mp.add(p, 1);
|
mp.add(p, 1);
|
||||||
|
|
||||||
expect(mp.points().length).toBe(3);
|
expect(mp.points().length).toBe(3);
|
||||||
|
|
||||||
var firstPoint = mp.points()[0], // untouched
|
var firstPoint = mp.points()[0], // untouched
|
||||||
secondPoint = mp.points()[1], // this should be ours
|
secondPoint = mp.points()[1], // this should be ours
|
||||||
thirdPoint = mp.points()[2]; // shifted here
|
thirdPoint = mp.points()[2]; // shifted here
|
||||||
|
|
||||||
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '0,1' );
|
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '0,1' );
|
||||||
expect( secondPoint.x() + ',' + secondPoint.y() ).toBe( '24,7' );
|
expect( secondPoint.x() + ',' + secondPoint.y() ).toBe( '24,7' );
|
||||||
expect( thirdPoint.x() + ',' + thirdPoint.y() ).toBe( '2,3' );
|
expect( thirdPoint.x() + ',' + thirdPoint.y() ).toBe( '2,3' );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("the index is optional", function(){
|
it("the index is optional", function(){
|
||||||
var p = ol.geom.point([24,7]);
|
var p = ol.geom.point([24,7]);
|
||||||
mp.add(p);
|
mp.add(p);
|
||||||
|
|
||||||
expect(mp.points().length).toBe(3);
|
expect(mp.points().length).toBe(3);
|
||||||
|
|
||||||
var thirdPoint = mp.points()[2];
|
var thirdPoint = mp.points()[2];
|
||||||
expect( thirdPoint.x() + ',' + thirdPoint.y() ).toBe( '24,7' );
|
expect( thirdPoint.x() + ',' + thirdPoint.y() ).toBe( '24,7' );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("returns the multipoint instance", function(){
|
it("returns the multipoint instance", function(){
|
||||||
var p = ol.geom.point([24,7]);
|
var p = ol.geom.point([24,7]);
|
||||||
var returned = mp.add(p);
|
var returned = mp.add(p);
|
||||||
|
|
||||||
expect(returned).toBe(mp);
|
expect(returned).toBe(mp);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("the method 'addAll'", function(){
|
describe("the method 'addAll'", function(){
|
||||||
it("exists", function(){
|
it("exists", function(){
|
||||||
expect( mp.addAll ).toBeA( Function );
|
expect( mp.addAll ).toBeA( Function );
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("can be used as setter", function(){
|
describe("can be used as setter", function(){
|
||||||
|
|
||||||
it("works with an array of point specifications and an index", function(){
|
it("works with an array of point specifications and an index", function(){
|
||||||
var ps = [
|
var ps = [
|
||||||
ol.geom.point([24,7]),
|
ol.geom.point([24,7]),
|
||||||
ol.geom.point([7,11])
|
ol.geom.point([7,11])
|
||||||
];
|
];
|
||||||
mp.addAll(ps, 0);
|
mp.addAll(ps, 0);
|
||||||
|
|
||||||
expect(mp.points().length).toBe(4);
|
expect(mp.points().length).toBe(4);
|
||||||
|
|
||||||
var firstPoint = mp.points()[0],
|
var firstPoint = mp.points()[0],
|
||||||
secondPoint = mp.points()[1];
|
secondPoint = mp.points()[1];
|
||||||
|
|
||||||
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' );
|
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' );
|
||||||
expect( secondPoint.x() + ',' + secondPoint.y() ).toBe( '7,11' );
|
expect( secondPoint.x() + ',' + secondPoint.y() ).toBe( '7,11' );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("the index is functional", function(){
|
it("the index is functional", function(){
|
||||||
var ps = [
|
var ps = [
|
||||||
[24,7],
|
[24,7],
|
||||||
{x:7, y:11}
|
{x:7, y:11}
|
||||||
];
|
];
|
||||||
mp.addAll(ps, 1);
|
mp.addAll(ps, 1);
|
||||||
|
|
||||||
expect(mp.points().length).toBe(4);
|
expect(mp.points().length).toBe(4);
|
||||||
|
|
||||||
var firstPoint = mp.points()[0], // untouched
|
var firstPoint = mp.points()[0], // untouched
|
||||||
secondPoint = mp.points()[1], // this should be ours
|
secondPoint = mp.points()[1], // this should be ours
|
||||||
thirdPoint = mp.points()[2], // this should be ours
|
thirdPoint = mp.points()[2], // this should be ours
|
||||||
fourthPoint = mp.points()[3]; // shifted here
|
fourthPoint = mp.points()[3]; // shifted here
|
||||||
|
|
||||||
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '0,1' );
|
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '0,1' );
|
||||||
expect( secondPoint.x() + ',' + secondPoint.y() ).toBe( '24,7' );
|
expect( secondPoint.x() + ',' + secondPoint.y() ).toBe( '24,7' );
|
||||||
expect( thirdPoint.x() + ',' + thirdPoint.y() ).toBe( '7,11' );
|
expect( thirdPoint.x() + ',' + thirdPoint.y() ).toBe( '7,11' );
|
||||||
expect( fourthPoint.x() + ',' + fourthPoint.y() ).toBe( '2,3' );
|
expect( fourthPoint.x() + ',' + fourthPoint.y() ).toBe( '2,3' );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("the index is optional", function(){
|
it("the index is optional", function(){
|
||||||
var ps = [
|
var ps = [
|
||||||
[24,7],
|
[24,7],
|
||||||
{x:7, y:11}
|
{x:7, y:11}
|
||||||
];
|
];
|
||||||
mp.addAll(ps);
|
mp.addAll(ps);
|
||||||
|
|
||||||
expect(mp.points().length).toBe(4);
|
expect(mp.points().length).toBe(4);
|
||||||
|
|
||||||
var thirdPoint = mp.points()[2],
|
var thirdPoint = mp.points()[2],
|
||||||
fourthPoint = mp.points()[3];
|
fourthPoint = mp.points()[3];
|
||||||
expect( thirdPoint.x() + ',' + thirdPoint.y() ).toBe( '24,7' );
|
expect( thirdPoint.x() + ',' + thirdPoint.y() ).toBe( '24,7' );
|
||||||
expect( fourthPoint.x() + ',' + fourthPoint.y() ).toBe( '7,11' );
|
expect( fourthPoint.x() + ',' + fourthPoint.y() ).toBe( '7,11' );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("returns the multipoint instance", function(){
|
it("returns the multipoint instance", function(){
|
||||||
var ps = [
|
var ps = [
|
||||||
[24,7],
|
[24,7],
|
||||||
{x:7, y:11}
|
{x:7, y:11}
|
||||||
];
|
];
|
||||||
var returned = mp.addAll(ps);
|
var returned = mp.addAll(ps);
|
||||||
|
|
||||||
expect(returned).toBe(mp);
|
expect(returned).toBe(mp);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
describe("the method 'remove'", function() {
|
describe("the method 'remove'", function() {
|
||||||
it("exists", function(){
|
it("exists", function(){
|
||||||
expect( mp.add ).toBeA( Function );
|
expect( mp.add ).toBeA( Function );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("works with a single point", function(){
|
it("works with a single point", function(){
|
||||||
var p = mp.points()[0];
|
var p = mp.points()[0];
|
||||||
mp.remove(p);
|
mp.remove(p);
|
||||||
@@ -207,7 +207,7 @@ describe("ol.geom.multipoint", function() {
|
|||||||
var firstPoint = mp.points()[0];
|
var firstPoint = mp.points()[0];
|
||||||
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '2,3' );
|
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '2,3' );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("works with an array of point specifications", function(){
|
it("works with an array of point specifications", function(){
|
||||||
var ps = [
|
var ps = [
|
||||||
mp.points()[1],
|
mp.points()[1],
|
||||||
|
|||||||
@@ -166,4 +166,47 @@ describe("ol.geom.point", function() {
|
|||||||
expect(p_obj.projection()).toEqual(jasmine.any(ol.Projection));
|
expect(p_obj.projection()).toEqual(jasmine.any(ol.Projection));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("the centroid method is functional", function(){
|
||||||
|
it("returns an instance of ol.geom.Point", function(){
|
||||||
|
expect(pNoZ_arr.centroid()).toBeA(ol.geom.Point);
|
||||||
|
expect(pWithZ_arr.centroid()).toBeA(ol.geom.Point);
|
||||||
|
expect(p_arr.centroid()).toBeA(ol.geom.Point);
|
||||||
|
|
||||||
|
expect(pNoZ_obj.centroid()).toBeA(ol.geom.Point);
|
||||||
|
expect(pWithZ_obj.centroid()).toBeA(ol.geom.Point);
|
||||||
|
expect(p_obj.centroid()).toBeA(ol.geom.Point);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("does return a clone and not the point itself", function(){
|
||||||
|
expect(pNoZ_arr.centroid()).not.toBe(pNoZ_arr);
|
||||||
|
expect(pWithZ_arr.centroid()).not.toBe(pWithZ_arr);
|
||||||
|
expect(p_arr.centroid()).not.toBe(p_arr);
|
||||||
|
|
||||||
|
expect(pNoZ_obj.centroid()).not.toBe(pNoZ_obj);
|
||||||
|
expect(pWithZ_obj.centroid()).not.toBe(pWithZ_obj);
|
||||||
|
expect(p_obj.centroid()).not.toBe(p_obj);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("has the expected coordinates", function(){
|
||||||
|
var c1 = pNoZ_arr.centroid(),
|
||||||
|
c2 = pWithZ_arr.centroid(),
|
||||||
|
c3 = p_arr.centroid(),
|
||||||
|
c4 = pNoZ_obj.centroid(),
|
||||||
|
c5 = pWithZ_obj.centroid(),
|
||||||
|
c6 = p_obj.centroid();
|
||||||
|
|
||||||
|
expect(c1.x() + ',' + c1.y()).toBe('21,4');
|
||||||
|
expect(c2.x() + ',' + c2.y()).toBe('21,4');
|
||||||
|
expect(c3.x() + ',' + c3.y()).toBe('21,4');
|
||||||
|
expect(c4.x() + ',' + c4.y()).toBe('21,4');
|
||||||
|
expect(c5.x() + ',' + c5.y()).toBe('21,4');
|
||||||
|
expect(c6.x() + ',' + c6.y()).toBe('21,4');
|
||||||
|
});
|
||||||
|
|
||||||
|
it("returns point(0,0) when the point was constructed without args", function(){
|
||||||
|
var c = pNoArgs.centroid();
|
||||||
|
expect(c.x() + ',' + c.y()).toBe('0,0');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
describe("ol.geom.Collection", function() {
|
describe("ol.geom.Collection", function() {
|
||||||
var c;
|
var c;
|
||||||
|
|
||||||
beforeEach(function(){
|
beforeEach(function(){
|
||||||
c = new ol.geom.Collection([
|
c = new ol.geom.Collection([
|
||||||
new ol.geom.Point(10,20),
|
new ol.geom.Point(10,20),
|
||||||
@@ -10,25 +10,25 @@ describe("ol.geom.Collection", function() {
|
|||||||
])
|
])
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function(){
|
afterEach(function(){
|
||||||
c = null;
|
c = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
it("constructs instances", function() {
|
it("constructs instances", function() {
|
||||||
expect( c ).toBeA( ol.geom.Collection );
|
expect( c ).toBeA( ol.geom.Collection );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("can construct instances without any components", function() {
|
it("can construct instances without any components", function() {
|
||||||
// empty array
|
// empty array
|
||||||
c = new ol.geom.Collection([]);
|
c = new ol.geom.Collection([]);
|
||||||
expect( c ).toBeA( ol.geom.Collection );
|
expect( c ).toBeA( ol.geom.Collection );
|
||||||
|
|
||||||
// no argument at all
|
// no argument at all
|
||||||
c = new ol.geom.Collection();
|
c = new ol.geom.Collection();
|
||||||
expect( c ).toBeA( ol.geom.Collection );
|
expect( c ).toBeA( ol.geom.Collection );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("cannot construct instances when passed illegal components", function() {
|
it("cannot construct instances when passed illegal components", function() {
|
||||||
// collection cannot contain collections
|
// collection cannot contain collections
|
||||||
expect(function(){
|
expect(function(){
|
||||||
@@ -36,29 +36,29 @@ describe("ol.geom.Collection", function() {
|
|||||||
new ol.geom.Collection()
|
new ol.geom.Collection()
|
||||||
]);
|
]);
|
||||||
}).toThrow();
|
}).toThrow();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("inherits from ol.geom.Geometry", function() {
|
it("inherits from ol.geom.Geometry", function() {
|
||||||
expect( c ).toBeA( ol.geom.Geometry );
|
expect( c ).toBeA( ol.geom.Geometry );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has a working getter for components", function() {
|
it("has a working getter for components", function() {
|
||||||
|
|
||||||
var components = c.getComponents();
|
var components = c.getComponents();
|
||||||
|
|
||||||
expect( components ).toBeA( Array );
|
expect( components ).toBeA( Array );
|
||||||
expect( components.length ).toBe( 2 );
|
expect( components.length ).toBe( 2 );
|
||||||
expect( components[0] ).toBeA( ol.geom.Point );
|
expect( components[0] ).toBeA( ol.geom.Point );
|
||||||
expect( components[1] ).toBeA( ol.geom.LineString );
|
expect( components[1] ).toBeA( ol.geom.LineString );
|
||||||
|
|
||||||
expect( components[0].getX() + ',' + components[0].getY()).toBe( '10,20' );
|
expect( components[0].getX() + ',' + components[0].getY()).toBe( '10,20' );
|
||||||
expect( components[1].getVertices()[0].getX() + ',' + components[1].getVertices()[0].getY()).toBe( '47,11' );
|
expect( components[1].getVertices()[0].getX() + ',' + components[1].getVertices()[0].getY()).toBe( '47,11' );
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has a working setter for components", function() {
|
it("has a working setter for components", function() {
|
||||||
|
|
||||||
c.setComponents([
|
c.setComponents([
|
||||||
new ol.geom.Point(30,40),
|
new ol.geom.Point(30,40),
|
||||||
new ol.geom.LineString([
|
new ol.geom.LineString([
|
||||||
@@ -66,20 +66,20 @@ describe("ol.geom.Collection", function() {
|
|||||||
new ol.geom.Point(4,16)
|
new ol.geom.Point(4,16)
|
||||||
])
|
])
|
||||||
]);
|
]);
|
||||||
|
|
||||||
var components = c.getComponents();
|
var components = c.getComponents();
|
||||||
|
|
||||||
expect( components.length ).toBe( 2 );
|
expect( components.length ).toBe( 2 );
|
||||||
expect( components[0] ).toBeA( ol.geom.Point );
|
expect( components[0] ).toBeA( ol.geom.Point );
|
||||||
expect( components[1] ).toBeA( ol.geom.LineString );
|
expect( components[1] ).toBeA( ol.geom.LineString );
|
||||||
|
|
||||||
expect( components[0].getX() + ',' + components[0].getY()).toBe( '30,40' );
|
expect( components[0].getX() + ',' + components[0].getY()).toBe( '30,40' );
|
||||||
expect( components[1].getVertices()[0].getX() + ',' + components[1].getVertices()[0].getY()).toBe( '3,9' );
|
expect( components[1].getVertices()[0].getX() + ',' + components[1].getVertices()[0].getY()).toBe( '3,9' );
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has a method to add components", function() {
|
it("has a method to add components", function() {
|
||||||
|
|
||||||
c.addComponent(
|
c.addComponent(
|
||||||
new ol.geom.Point(30,40),
|
new ol.geom.Point(30,40),
|
||||||
1
|
1
|
||||||
@@ -91,17 +91,17 @@ describe("ol.geom.Collection", function() {
|
|||||||
]),
|
]),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
|
|
||||||
var components = c.getComponents();
|
var components = c.getComponents();
|
||||||
|
|
||||||
expect( components.length ).toBe( 4 );
|
expect( components.length ).toBe( 4 );
|
||||||
expect( components[0].getVertices()[0].getX() + ',' + components[0].getVertices()[0].getY()).toBe( '5,25' );
|
expect( components[0].getVertices()[0].getX() + ',' + components[0].getVertices()[0].getY()).toBe( '5,25' );
|
||||||
expect( components[1].getX() + ',' + components[1].getY()).toBe( '10,20' );
|
expect( components[1].getX() + ',' + components[1].getY()).toBe( '10,20' );
|
||||||
expect( components[2].getX() + ',' + components[2].getY()).toBe( '30,40' );
|
expect( components[2].getX() + ',' + components[2].getY()).toBe( '30,40' );
|
||||||
expect( components[3].getVertices()[0].getX() + ',' + components[3].getVertices()[0].getY()).toBe( '47,11' );
|
expect( components[3].getVertices()[0].getX() + ',' + components[3].getVertices()[0].getY()).toBe( '47,11' );
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("cannot add instances of 'ol.geom.Collection'", function(){
|
it("cannot add instances of 'ol.geom.Collection'", function(){
|
||||||
expect(function(){
|
expect(function(){
|
||||||
c.addComponent(
|
c.addComponent(
|
||||||
@@ -112,7 +112,7 @@ describe("ol.geom.Collection", function() {
|
|||||||
);
|
);
|
||||||
}).toThrow();
|
}).toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has a method to remove components", function() {
|
it("has a method to remove components", function() {
|
||||||
c.setComponents([
|
c.setComponents([
|
||||||
new ol.geom.Point(0,10),
|
new ol.geom.Point(0,10),
|
||||||
@@ -120,16 +120,16 @@ describe("ol.geom.Collection", function() {
|
|||||||
new ol.geom.Point(20,30),
|
new ol.geom.Point(20,30),
|
||||||
new ol.geom.Point(30,40)
|
new ol.geom.Point(30,40)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
var p = c.getComponents()[2]; // 20,30;
|
var p = c.getComponents()[2]; // 20,30;
|
||||||
|
|
||||||
c.removeComponent( p );
|
c.removeComponent( p );
|
||||||
|
|
||||||
var components = c.getComponents();
|
var components = c.getComponents();
|
||||||
|
|
||||||
expect( components.length ).toBe( 3 );
|
expect( components.length ).toBe( 3 );
|
||||||
expect( components[0].getX() + ',' + components[0].getY()).toBe( '0,10' );
|
expect( components[0].getX() + ',' + components[0].getY()).toBe( '0,10' );
|
||||||
expect( components[1].getX() + ',' + components[1].getY()).toBe( '10,20' );
|
expect( components[1].getX() + ',' + components[1].getY()).toBe( '10,20' );
|
||||||
expect( components[2].getX() + ',' + components[2].getY()).toBe( '30,40' );
|
expect( components[2].getX() + ',' + components[2].getY()).toBe( '30,40' );
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
describe("ol.geom.LineString", function() {
|
describe("ol.geom.LineString", function() {
|
||||||
var ls;
|
var ls;
|
||||||
|
|
||||||
beforeEach(function(){
|
beforeEach(function(){
|
||||||
ls = new ol.geom.LineString([
|
ls = new ol.geom.LineString([
|
||||||
new ol.geom.Point(0,0),
|
new ol.geom.Point(0,0),
|
||||||
@@ -9,61 +9,61 @@ describe("ol.geom.LineString", function() {
|
|||||||
new ol.geom.Point(20,20)
|
new ol.geom.Point(20,20)
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function(){
|
afterEach(function(){
|
||||||
ls = null;
|
ls = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
it("constructs instances", function() {
|
it("constructs instances", function() {
|
||||||
expect( ls ).toBeA( ol.geom.LineString );
|
expect( ls ).toBeA( ol.geom.LineString );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("can construct instances without any points", function() {
|
it("can construct instances without any points", function() {
|
||||||
// empty array
|
// empty array
|
||||||
mp = new ol.geom.LineString([]);
|
mp = new ol.geom.LineString([]);
|
||||||
expect( ls ).toBeA( ol.geom.LineString );
|
expect( ls ).toBeA( ol.geom.LineString );
|
||||||
|
|
||||||
// no argument at all
|
// no argument at all
|
||||||
mp = new ol.geom.LineString();
|
mp = new ol.geom.LineString();
|
||||||
expect( ls ).toBeA( ol.geom.LineString );
|
expect( ls ).toBeA( ol.geom.LineString );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("inherits from ol.geom.Geometry", function() {
|
it("inherits from ol.geom.Geometry", function() {
|
||||||
expect( ls ).toBeA( ol.geom.Geometry );
|
expect( ls ).toBeA( ol.geom.Geometry );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has a working getter for vertices", function() {
|
it("has a working getter for vertices", function() {
|
||||||
|
|
||||||
var vertices = ls.getVertices();
|
var vertices = ls.getVertices();
|
||||||
|
|
||||||
expect( vertices ).toBeA( Array );
|
expect( vertices ).toBeA( Array );
|
||||||
expect( vertices.length ).toBe( 4 );
|
expect( vertices.length ).toBe( 4 );
|
||||||
expect( vertices[0] ).toBeA( ol.geom.Point );
|
expect( vertices[0] ).toBeA( ol.geom.Point );
|
||||||
|
|
||||||
expect( vertices[0].getX() + ',' + vertices[0].getY()).toBe( '0,0' );
|
expect( vertices[0].getX() + ',' + vertices[0].getY()).toBe( '0,0' );
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has a working setter for vertices", function() {
|
it("has a working setter for vertices", function() {
|
||||||
|
|
||||||
ls.setVertices([
|
ls.setVertices([
|
||||||
new ol.geom.Point(30,40),
|
new ol.geom.Point(30,40),
|
||||||
new ol.geom.Point(50,60)
|
new ol.geom.Point(50,60)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
var vertices = ls.getVertices();
|
var vertices = ls.getVertices();
|
||||||
|
|
||||||
expect( vertices.length ).toBe( 2 );
|
expect( vertices.length ).toBe( 2 );
|
||||||
expect( vertices[0] ).toBeA( ol.geom.Point );
|
expect( vertices[0] ).toBeA( ol.geom.Point );
|
||||||
expect( vertices[1] ).toBeA( ol.geom.Point );
|
expect( vertices[1] ).toBeA( ol.geom.Point );
|
||||||
|
|
||||||
expect( vertices[0].getX() + ',' + vertices[0].getY()).toBe( '30,40' );
|
expect( vertices[0].getX() + ',' + vertices[0].getY()).toBe( '30,40' );
|
||||||
expect( vertices[1].getX() + ',' + vertices[1].getY()).toBe( '50,60' );
|
expect( vertices[1].getX() + ',' + vertices[1].getY()).toBe( '50,60' );
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has a method to add vertices", function() {
|
it("has a method to add vertices", function() {
|
||||||
|
|
||||||
ls.addVertex(
|
ls.addVertex(
|
||||||
new ol.geom.Point(30,40),
|
new ol.geom.Point(30,40),
|
||||||
1
|
1
|
||||||
@@ -76,9 +76,9 @@ describe("ol.geom.LineString", function() {
|
|||||||
new ol.geom.Point(-10,0),
|
new ol.geom.Point(-10,0),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
|
|
||||||
var vertices = ls.getVertices();
|
var vertices = ls.getVertices();
|
||||||
|
|
||||||
expect( vertices.length ).toBe( 7 );
|
expect( vertices.length ).toBe( 7 );
|
||||||
expect( vertices[0].getX() + ',' + vertices[0].getY()).toBe( '-10,0' );
|
expect( vertices[0].getX() + ',' + vertices[0].getY()).toBe( '-10,0' );
|
||||||
expect( vertices[1].getX() + ',' + vertices[1].getY()).toBe( '0,0' );
|
expect( vertices[1].getX() + ',' + vertices[1].getY()).toBe( '0,0' );
|
||||||
@@ -87,9 +87,9 @@ describe("ol.geom.LineString", function() {
|
|||||||
expect( vertices[4].getX() + ',' + vertices[4].getY()).toBe( '10,10' );
|
expect( vertices[4].getX() + ',' + vertices[4].getY()).toBe( '10,10' );
|
||||||
expect( vertices[5].getX() + ',' + vertices[5].getY()).toBe( '10,0' );
|
expect( vertices[5].getX() + ',' + vertices[5].getY()).toBe( '10,0' );
|
||||||
expect( vertices[6].getX() + ',' + vertices[6].getY()).toBe( '20,20' );
|
expect( vertices[6].getX() + ',' + vertices[6].getY()).toBe( '20,20' );
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has a method to remove vertices", function() {
|
it("has a method to remove vertices", function() {
|
||||||
ls.setVertices([
|
ls.setVertices([
|
||||||
new ol.geom.Point(0,10),
|
new ol.geom.Point(0,10),
|
||||||
@@ -97,16 +97,16 @@ describe("ol.geom.LineString", function() {
|
|||||||
new ol.geom.Point(20,30),
|
new ol.geom.Point(20,30),
|
||||||
new ol.geom.Point(30,40)
|
new ol.geom.Point(30,40)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
var v = ls.getVertices()[2]; // 20,30;
|
var v = ls.getVertices()[2]; // 20,30;
|
||||||
|
|
||||||
ls.removeVertex( v );
|
ls.removeVertex( v );
|
||||||
|
|
||||||
var vertices = ls.getVertices();
|
var vertices = ls.getVertices();
|
||||||
|
|
||||||
expect( vertices.length ).toBe( 3 );
|
expect( vertices.length ).toBe( 3 );
|
||||||
expect( vertices[0].getX() + ',' + vertices[0].getY()).toBe( '0,10' );
|
expect( vertices[0].getX() + ',' + vertices[0].getY()).toBe( '0,10' );
|
||||||
expect( vertices[1].getX() + ',' + vertices[1].getY()).toBe( '10,20' );
|
expect( vertices[1].getX() + ',' + vertices[1].getY()).toBe( '10,20' );
|
||||||
expect( vertices[2].getX() + ',' + vertices[2].getY()).toBe( '30,40' );
|
expect( vertices[2].getX() + ',' + vertices[2].getY()).toBe( '30,40' );
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,30 +1,30 @@
|
|||||||
describe("ol.geom.MultiPoint", function() {
|
describe("ol.geom.MultiPoint", function() {
|
||||||
var mp;
|
var mp;
|
||||||
|
|
||||||
beforeEach(function(){
|
beforeEach(function(){
|
||||||
mp = new ol.geom.MultiPoint([
|
mp = new ol.geom.MultiPoint([
|
||||||
new ol.geom.Point(10,20)
|
new ol.geom.Point(10,20)
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function(){
|
afterEach(function(){
|
||||||
mp = null;
|
mp = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
it("constructs instances", function() {
|
it("constructs instances", function() {
|
||||||
expect( mp ).toBeA( ol.geom.MultiPoint );
|
expect( mp ).toBeA( ol.geom.MultiPoint );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("can construct instances without any points", function() {
|
it("can construct instances without any points", function() {
|
||||||
// empty array
|
// empty array
|
||||||
mp = new ol.geom.MultiPoint([]);
|
mp = new ol.geom.MultiPoint([]);
|
||||||
expect( mp ).toBeA( ol.geom.MultiPoint );
|
expect( mp ).toBeA( ol.geom.MultiPoint );
|
||||||
|
|
||||||
// no argument at all
|
// no argument at all
|
||||||
mp = new ol.geom.MultiPoint();
|
mp = new ol.geom.MultiPoint();
|
||||||
expect( mp ).toBeA( ol.geom.MultiPoint );
|
expect( mp ).toBeA( ol.geom.MultiPoint );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("cannot be constructed with component-types other than 'ol.geom.Point'", function() {
|
it("cannot be constructed with component-types other than 'ol.geom.Point'", function() {
|
||||||
expect(function(){
|
expect(function(){
|
||||||
mp = new ol.geom.MultiPoint([
|
mp = new ol.geom.MultiPoint([
|
||||||
@@ -32,43 +32,43 @@ describe("ol.geom.MultiPoint", function() {
|
|||||||
]);
|
]);
|
||||||
}).toThrow();
|
}).toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("inherits from ol.geom.Geometry", function() {
|
it("inherits from ol.geom.Geometry", function() {
|
||||||
expect( mp ).toBeA( ol.geom.Geometry );
|
expect( mp ).toBeA( ol.geom.Geometry );
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has a working getter for points", function() {
|
it("has a working getter for points", function() {
|
||||||
|
|
||||||
var points = mp.getPoints();
|
var points = mp.getPoints();
|
||||||
|
|
||||||
expect( points ).toBeA( Array );
|
expect( points ).toBeA( Array );
|
||||||
expect( points.length ).toBe( 1 );
|
expect( points.length ).toBe( 1 );
|
||||||
expect( points[0] ).toBeA( ol.geom.Point );
|
expect( points[0] ).toBeA( ol.geom.Point );
|
||||||
|
|
||||||
expect( points[0].getX() + ',' + points[0].getY()).toBe( '10,20' );
|
expect( points[0].getX() + ',' + points[0].getY()).toBe( '10,20' );
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has a working setter for points", function() {
|
it("has a working setter for points", function() {
|
||||||
|
|
||||||
mp.setPoints([
|
mp.setPoints([
|
||||||
new ol.geom.Point(30,40),
|
new ol.geom.Point(30,40),
|
||||||
new ol.geom.Point(50,60)
|
new ol.geom.Point(50,60)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
var points = mp.getPoints();
|
var points = mp.getPoints();
|
||||||
|
|
||||||
expect( points.length ).toBe( 2 );
|
expect( points.length ).toBe( 2 );
|
||||||
expect( points[0] ).toBeA( ol.geom.Point );
|
expect( points[0] ).toBeA( ol.geom.Point );
|
||||||
expect( points[1] ).toBeA( ol.geom.Point );
|
expect( points[1] ).toBeA( ol.geom.Point );
|
||||||
|
|
||||||
expect( points[0].getX() + ',' + points[0].getY()).toBe( '30,40' );
|
expect( points[0].getX() + ',' + points[0].getY()).toBe( '30,40' );
|
||||||
expect( points[1].getX() + ',' + points[1].getY()).toBe( '50,60' );
|
expect( points[1].getX() + ',' + points[1].getY()).toBe( '50,60' );
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has a method to add points", function() {
|
it("has a method to add points", function() {
|
||||||
|
|
||||||
mp.addPoint(
|
mp.addPoint(
|
||||||
new ol.geom.Point(30,40),
|
new ol.geom.Point(30,40),
|
||||||
1
|
1
|
||||||
@@ -81,17 +81,17 @@ describe("ol.geom.MultiPoint", function() {
|
|||||||
new ol.geom.Point(-10,0),
|
new ol.geom.Point(-10,0),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
|
|
||||||
var points = mp.getPoints();
|
var points = mp.getPoints();
|
||||||
|
|
||||||
expect( points.length ).toBe( 4 );
|
expect( points.length ).toBe( 4 );
|
||||||
expect( points[0].getX() + ',' + points[0].getY()).toBe( '-10,0' );
|
expect( points[0].getX() + ',' + points[0].getY()).toBe( '-10,0' );
|
||||||
expect( points[1].getX() + ',' + points[1].getY()).toBe( '10,20' );
|
expect( points[1].getX() + ',' + points[1].getY()).toBe( '10,20' );
|
||||||
expect( points[2].getX() + ',' + points[2].getY()).toBe( '30,40' );
|
expect( points[2].getX() + ',' + points[2].getY()).toBe( '30,40' );
|
||||||
expect( points[3].getX() + ',' + points[3].getY()).toBe( '50,60' );
|
expect( points[3].getX() + ',' + points[3].getY()).toBe( '50,60' );
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("can only add ol.geom.Point as components", function() {
|
it("can only add ol.geom.Point as components", function() {
|
||||||
expect(function(){
|
expect(function(){
|
||||||
mp.addComponent(
|
mp.addComponent(
|
||||||
@@ -102,7 +102,7 @@ describe("ol.geom.MultiPoint", function() {
|
|||||||
);
|
);
|
||||||
}).toThrow();
|
}).toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has a method to remove points", function() {
|
it("has a method to remove points", function() {
|
||||||
mp.setPoints([
|
mp.setPoints([
|
||||||
new ol.geom.Point(0,10),
|
new ol.geom.Point(0,10),
|
||||||
@@ -110,16 +110,16 @@ describe("ol.geom.MultiPoint", function() {
|
|||||||
new ol.geom.Point(20,30),
|
new ol.geom.Point(20,30),
|
||||||
new ol.geom.Point(30,40)
|
new ol.geom.Point(30,40)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
var p = mp.getPoints()[2]; // 20,30;
|
var p = mp.getPoints()[2]; // 20,30;
|
||||||
|
|
||||||
mp.removePoint( p );
|
mp.removePoint( p );
|
||||||
|
|
||||||
var points = mp.getPoints();
|
var points = mp.getPoints();
|
||||||
|
|
||||||
expect( points.length ).toBe( 3 );
|
expect( points.length ).toBe( 3 );
|
||||||
expect( points[0].getX() + ',' + points[0].getY()).toBe( '0,10' );
|
expect( points[0].getX() + ',' + points[0].getY()).toBe( '0,10' );
|
||||||
expect( points[1].getX() + ',' + points[1].getY()).toBe( '10,20' );
|
expect( points[1].getX() + ',' + points[1].getY()).toBe( '10,20' );
|
||||||
expect( points[2].getX() + ',' + points[2].getY()).toBe( '30,40' );
|
expect( points[2].getX() + ',' + points[2].getY()).toBe( '30,40' );
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -123,4 +123,27 @@ describe("ol.geom.Point", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("the getCentroid method is functional", function(){
|
||||||
|
it("returns an instance of ol.geom.Point", function(){
|
||||||
|
expect(p2Args.getCentroid()).toBeA(ol.geom.Point);
|
||||||
|
expect(p3Args.getCentroid()).toBeA(ol.geom.Point);
|
||||||
|
expect(p4Args.getCentroid()).toBeA(ol.geom.Point);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("does return a clone and not the point itself", function(){
|
||||||
|
expect(p2Args.getCentroid()).not.toBe(p2Args);
|
||||||
|
expect(p3Args.getCentroid()).not.toBe(p3Args);
|
||||||
|
expect(p4Args.getCentroid()).not.toBe(p4Args);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("has the expected coordinates", function(){
|
||||||
|
var c2 = p2Args.getCentroid(),
|
||||||
|
c3 = p3Args.getCentroid(),
|
||||||
|
c4 = p4Args.getCentroid();
|
||||||
|
|
||||||
|
expect(c2.getX() + ',' + c2.getY()).toBe('21,4');
|
||||||
|
expect(c3.getX() + ',' + c3.getY()).toBe('21,4');
|
||||||
|
expect(c4.getX() + ',' + c4.getY()).toBe('21,4');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -22,6 +22,26 @@ describe('ol.layer.TileLayer', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('axis orientation', function() {
|
||||||
|
var layer = new ol.layer.TileLayer();
|
||||||
|
|
||||||
|
it('increases from left to right by default', function() {
|
||||||
|
expect(layer.getXRight()).toBe(true);
|
||||||
|
});
|
||||||
|
it('increases from top to bottom by default', function() {
|
||||||
|
expect(layer.getYDown()).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('allows people to set things backwards', function() {
|
||||||
|
var backwards = new ol.layer.TileLayer();
|
||||||
|
backwards.setXRight(false);
|
||||||
|
expect(backwards.getXRight()).toBe(false);
|
||||||
|
backwards.setYDown(false);
|
||||||
|
expect(backwards.getYDown()).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
describe('get tile origin', function() {
|
describe('get tile origin', function() {
|
||||||
var layer;
|
var layer;
|
||||||
|
|
||||||
@@ -50,7 +70,7 @@ describe('ol.layer.TileLayer', function() {
|
|||||||
|
|
||||||
it('returns the expected origin', function() {
|
it('returns the expected origin', function() {
|
||||||
var origin = layer.getTileOrigin();
|
var origin = layer.getTileOrigin();
|
||||||
expect(origin).toEqual([-180, -90]);
|
expect(origin).toEqual([-180, 90]);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -329,4 +349,26 @@ describe('ol.layer.TileLayer', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('get a tile', function() {
|
||||||
|
var layer;
|
||||||
|
|
||||||
|
beforeEach(function() {
|
||||||
|
layer = new ol.layer.TileLayer();
|
||||||
|
layer.setUrl('/{z}/{x}/{y}');
|
||||||
|
layer.setResolutions([1, 0.5, 0.25]);
|
||||||
|
layer.setTileOrigin(-128, 128);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns the expected tile', function() {
|
||||||
|
var tile = layer.getTileForXYZ(1, 2, 2);
|
||||||
|
expect(tile.getUrl()).toEqual('/2/1/2');
|
||||||
|
//var bounds = tile.getBounds();
|
||||||
|
//expect(bounds.getMinX()).toEqual(-64);
|
||||||
|
//expect(bounds.getMinY()).toEqual(0);
|
||||||
|
//expect(bounds.getMaxX()).toEqual(0);
|
||||||
|
//expect(bounds.getMaxY()).toEqual(64);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -15,5 +15,61 @@ describe("ol.renderer.TileLayerRenderer", function() {
|
|||||||
expect(ol.renderer.TileLayerRenderer.canRender(layer)).toBe(false);
|
expect(ol.renderer.TileLayerRenderer.canRender(layer)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("getPreferredResAndZ_", function() {
|
||||||
|
var layer = new ol.layer.TileLayer();
|
||||||
|
var resolutions = [100, 80, 50, 10, 1, 0.1];
|
||||||
|
layer.setResolutions(resolutions);
|
||||||
|
|
||||||
|
var container = document.createElement("div");
|
||||||
|
var renderer = new ol.renderer.TileLayerRenderer(container, layer);
|
||||||
|
|
||||||
|
it("gets the max resolution", function() {
|
||||||
|
var pair = renderer.getPreferredResAndZ_(100);
|
||||||
|
expect(pair[0]).toBe(100);
|
||||||
|
expect(pair[1]).toBe(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("gets the min resolution", function() {
|
||||||
|
var pair = renderer.getPreferredResAndZ_(0.1);
|
||||||
|
expect(pair[0]).toBe(0.1);
|
||||||
|
expect(pair[1]).toBe(5);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("gets the max when bigger", function() {
|
||||||
|
var pair = renderer.getPreferredResAndZ_(200);
|
||||||
|
expect(pair[0]).toBe(100);
|
||||||
|
expect(pair[1]).toBe(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("gets the min when smaller", function() {
|
||||||
|
var pair = renderer.getPreferredResAndZ_(0.01);
|
||||||
|
expect(pair[0]).toBe(0.1);
|
||||||
|
expect(pair[1]).toBe(5);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("gets the first when in the middle", function() {
|
||||||
|
var pair = renderer.getPreferredResAndZ_(90);
|
||||||
|
expect(pair[0]).toBe(100);
|
||||||
|
expect(pair[1]).toBe(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("gets the closer when elsewhere", function() {
|
||||||
|
var pair = renderer.getPreferredResAndZ_(89);
|
||||||
|
expect(pair[0]).toBe(80);
|
||||||
|
expect(pair[1]).toBe(1);
|
||||||
|
|
||||||
|
pair = renderer.getPreferredResAndZ_(49);
|
||||||
|
expect(pair[0]).toBe(50);
|
||||||
|
expect(pair[1]).toBe(2);
|
||||||
|
|
||||||
|
pair = renderer.getPreferredResAndZ_(0.5);
|
||||||
|
expect(pair[0]).toBe(0.1);
|
||||||
|
expect(pair[1]).toBe(5);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user