Whitespace changes only.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
goog.provide('ol.geom.collection');
|
||||
goog.provide('ol.geom.collection');
|
||||
|
||||
goog.require('ol.geom.Collection');
|
||||
goog.require('ol.geom.point');
|
||||
goog.require('ol.geom.point');
|
||||
goog.require('ol.projection');
|
||||
|
||||
/**
|
||||
@@ -10,11 +10,11 @@ goog.require('ol.projection');
|
||||
* @return {ol.geom.Collection} Collection.
|
||||
*/
|
||||
ol.geom.collection = function(opt_arg){
|
||||
|
||||
|
||||
if (opt_arg instanceof ol.geom.Collection) {
|
||||
return opt_arg;
|
||||
}
|
||||
|
||||
|
||||
var components = [];
|
||||
if (arguments.length == 1 && goog.isDef(opt_arg)) {
|
||||
if (goog.isArray(opt_arg)) {
|
||||
@@ -35,7 +35,7 @@ ol.geom.collection = function(opt_arg){
|
||||
throw new Error('ol.geom.collection');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var c = new ol.geom.Collection(components);
|
||||
return c;
|
||||
};
|
||||
@@ -50,7 +50,7 @@ ol.geom.Collection.prototype.components = function(opt_arg){
|
||||
if (arguments.length == 1 && goog.isDef(opt_arg)) {
|
||||
var components = [],
|
||||
allValid = false;
|
||||
|
||||
|
||||
allValid = goog.array.every(opt_arg, function(geom){
|
||||
if (geom instanceof ol.geom.Geometry) {
|
||||
components.push(geom);
|
||||
@@ -90,23 +90,23 @@ ol.geom.Collection.prototype.add = function(geom, opt_index){
|
||||
* @export
|
||||
* @param {Array.<ol.geom.Geometry>} components Some point specifications.
|
||||
* @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.
|
||||
* @return {ol.geom.Collection} The Collection instance.
|
||||
*/
|
||||
ol.geom.Collection.prototype.addAll = function(components, opt_index){
|
||||
var index = this.components_.length;
|
||||
|
||||
|
||||
if (arguments.length == 2 && goog.isDef(opt_index)) {
|
||||
index = opt_index;
|
||||
}
|
||||
|
||||
|
||||
goog.array.every(components, function(c){
|
||||
this.addComponent(c, index);
|
||||
index++;
|
||||
return true;
|
||||
}, this);
|
||||
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
goog.provide('ol.geom.geometry');
|
||||
goog.provide('ol.geom.geometry');
|
||||
|
||||
goog.require('ol.geom.Geometry');
|
||||
|
||||
@@ -14,7 +14,7 @@ ol.geom.geometry = function(){
|
||||
/**
|
||||
* @export
|
||||
* @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).
|
||||
*/
|
||||
ol.geom.Geometry.prototype.bounds = function(opt_arg) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
goog.provide('ol.geom.linestring');
|
||||
goog.provide('ol.geom.linestring');
|
||||
|
||||
goog.require('ol.geom.LineString');
|
||||
goog.require('ol.geom.point');
|
||||
goog.require('ol.geom.point');
|
||||
goog.require('ol.projection');
|
||||
|
||||
/**
|
||||
@@ -10,11 +10,11 @@ goog.require('ol.projection');
|
||||
* @return {ol.geom.LineString} LineString.
|
||||
*/
|
||||
ol.geom.linestring = function(opt_arg){
|
||||
|
||||
|
||||
if (opt_arg instanceof ol.geom.LineString) {
|
||||
return opt_arg;
|
||||
}
|
||||
|
||||
|
||||
var vertices = [];
|
||||
if (arguments.length == 1 && goog.isDef(opt_arg)) {
|
||||
if (goog.isArray(opt_arg)) {
|
||||
@@ -36,7 +36,7 @@ ol.geom.linestring = function(opt_arg){
|
||||
throw new Error('ol.geom.linestring');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var ls = new ol.geom.LineString(vertices);
|
||||
return ls;
|
||||
};
|
||||
@@ -99,18 +99,18 @@ ol.geom.LineString.prototype.add = function(vertex, opt_index){
|
||||
ol.geom.LineString.prototype.addAll = function(vertices, opt_index){
|
||||
var index = this.vertices_.length,
|
||||
v;
|
||||
|
||||
|
||||
if (arguments.length == 2 && goog.isDef(opt_index)) {
|
||||
index = opt_index;
|
||||
}
|
||||
|
||||
|
||||
goog.array.every(vertices, function(vertexSpec){
|
||||
v = ol.geom.point(vertexSpec);
|
||||
this.addVertex(v, index);
|
||||
index++;
|
||||
return true;
|
||||
}, this);
|
||||
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
goog.provide('ol.geom.multipoint');
|
||||
goog.provide('ol.geom.multipoint');
|
||||
|
||||
goog.require('ol.geom.MultiPoint');
|
||||
goog.require('ol.geom.point');
|
||||
goog.require('ol.geom.collection');
|
||||
goog.require('ol.geom.point');
|
||||
goog.require('ol.geom.collection');
|
||||
goog.require('ol.projection');
|
||||
|
||||
/**
|
||||
@@ -11,11 +11,11 @@ goog.require('ol.projection');
|
||||
* @return {ol.geom.MultiPoint} MultiPoint.
|
||||
*/
|
||||
ol.geom.multipoint = function(opt_arg){
|
||||
|
||||
|
||||
if (opt_arg instanceof ol.geom.MultiPoint) {
|
||||
return opt_arg;
|
||||
}
|
||||
|
||||
|
||||
var points = [];
|
||||
if (arguments.length == 1 && goog.isDef(opt_arg)) {
|
||||
if (goog.isArray(opt_arg)) {
|
||||
@@ -37,7 +37,7 @@ ol.geom.multipoint = function(opt_arg){
|
||||
throw new Error('ol.geom.multipoint');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var mp = new ol.geom.MultiPoint(points);
|
||||
return mp;
|
||||
};
|
||||
@@ -99,18 +99,18 @@ ol.geom.MultiPoint.prototype.add = function(point, opt_index){
|
||||
ol.geom.MultiPoint.prototype.addAll = function(points, opt_index){
|
||||
var index = this.getPoints().length,
|
||||
p;
|
||||
|
||||
|
||||
if (arguments.length == 2 && goog.isDef(opt_index)) {
|
||||
index = opt_index;
|
||||
}
|
||||
|
||||
|
||||
goog.array.every(points, function(pointSpec){
|
||||
p = ol.geom.point(pointSpec);
|
||||
this.addPoint(p, index);
|
||||
index++;
|
||||
return true;
|
||||
}, this);
|
||||
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
@@ -132,6 +132,6 @@ ol.geom.MultiPoint.prototype.remove = function(points){
|
||||
this.removePoint(p);
|
||||
return true;
|
||||
}, this);
|
||||
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
@@ -6,16 +6,16 @@ goog.require('ol.Projection');
|
||||
goog.require('ol.base');
|
||||
|
||||
/**
|
||||
* Creates ol.geom.Collection objects.
|
||||
*
|
||||
* Creates ol.geom.Collection objects.
|
||||
*
|
||||
* @export
|
||||
* @extends {ol.geom.Geometry}
|
||||
* @param {Array.<ol.geom.Geometry>} components An array of components.
|
||||
*
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
ol.geom.Collection = function(components) {
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Array.<Function>}
|
||||
@@ -23,19 +23,19 @@ ol.geom.Collection = function(components) {
|
||||
this.typeBlacklist_ = [
|
||||
ol.geom.Collection
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Array.<Function>}
|
||||
*/
|
||||
this.typeWhitelist_ = [];
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Array.<ol.geom.Geometry>}
|
||||
*/
|
||||
this.components_ = [];
|
||||
|
||||
|
||||
if (arguments.length === 1 && goog.isDef(components)) {
|
||||
this.setComponents(components);
|
||||
}
|
||||
@@ -44,14 +44,14 @@ ol.geom.Collection = function(components) {
|
||||
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.
|
||||
*/
|
||||
ol.geom.Collection.prototype.setTypeBlacklist = function(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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
ol.geom.Collection.prototype.setTypeWhitelist = function(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.
|
||||
*/
|
||||
ol.geom.Collection.prototype.getTypeWhitelist = function(){
|
||||
@@ -76,7 +76,7 @@ ol.geom.Collection.prototype.getTypeWhitelist = function(){
|
||||
|
||||
/**
|
||||
* Sets the Collection's components.
|
||||
*
|
||||
*
|
||||
* @return {Array.<ol.geom.Geometry>} An array of components.
|
||||
*/
|
||||
ol.geom.Collection.prototype.getComponents = function() {
|
||||
@@ -85,12 +85,12 @@ ol.geom.Collection.prototype.getComponents = function() {
|
||||
|
||||
/**
|
||||
* Gets the Collection's components.
|
||||
*
|
||||
*
|
||||
* @param {Array.<ol.geom.Geometry>} components An array of components.
|
||||
*/
|
||||
ol.geom.Collection.prototype.setComponents = function(components) {
|
||||
var allValidTypes = goog.array.every(
|
||||
components,
|
||||
components,
|
||||
this.isAllowedComponent,
|
||||
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.
|
||||
*
|
||||
*
|
||||
* @param {ol.geom.Geometry} component A component to be added.
|
||||
* @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
|
||||
* listed in the passed list.
|
||||
*
|
||||
*
|
||||
* @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.
|
||||
*
|
||||
* @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.
|
||||
*
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
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.
|
||||
*
|
||||
*
|
||||
* @param {ol.geom.Geometry} component The component to check.
|
||||
* @return {boolean} Whether the passed component is allowed as part of this
|
||||
* collection according to black- and whitelist.
|
||||
|
||||
@@ -2,17 +2,18 @@ goog.provide('ol.geom.LineString');
|
||||
|
||||
goog.require('goog.array');
|
||||
goog.require('ol.geom.Geometry');
|
||||
goog.require('ol.geom.Collection');
|
||||
goog.require('ol.geom.Point');
|
||||
goog.require('ol.Projection');
|
||||
|
||||
/**
|
||||
* Creates ol.geom.LineString objects.
|
||||
*
|
||||
* Creates ol.geom.LineString objects.
|
||||
*
|
||||
* @export
|
||||
* @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.
|
||||
*
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
ol.geom.LineString = function(vertices) {
|
||||
@@ -21,14 +22,14 @@ ol.geom.LineString = function(vertices) {
|
||||
* @type {Array.<ol.geom.Point>}
|
||||
*/
|
||||
this.vertices_ = vertices;
|
||||
|
||||
|
||||
};
|
||||
|
||||
goog.inherits(ol.geom.LineString, ol.geom.Geometry);
|
||||
|
||||
/**
|
||||
* Sets the LineString's points.
|
||||
*
|
||||
*
|
||||
* @return {Array.<ol.geom.Point>} An array of points.
|
||||
*/
|
||||
ol.geom.LineString.prototype.getVertices = function() {
|
||||
@@ -37,7 +38,7 @@ ol.geom.LineString.prototype.getVertices = function() {
|
||||
|
||||
/**
|
||||
* Gets the LineString's points.
|
||||
*
|
||||
*
|
||||
* @param {Array.<ol.geom.Point>} vertices An array of points.
|
||||
*/
|
||||
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.
|
||||
*
|
||||
*
|
||||
* @param {ol.geom.Point} vertex A point to be added.
|
||||
* @param {number} index The index where to add.
|
||||
*/
|
||||
|
||||
@@ -4,12 +4,12 @@ goog.require('goog.array');
|
||||
goog.require('ol.geom.Collection');
|
||||
|
||||
/**
|
||||
* Creates ol.geom.MultiPoint objects.
|
||||
*
|
||||
* Creates ol.geom.MultiPoint objects.
|
||||
*
|
||||
* @export
|
||||
* @extends {ol.geom.Collection}
|
||||
* @param {Array.<ol.geom.Point>} points An array of points.
|
||||
*
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
ol.geom.MultiPoint = function(points) {
|
||||
@@ -18,14 +18,14 @@ ol.geom.MultiPoint = function(points) {
|
||||
if (arguments.length === 1 && goog.isDef(points)) {
|
||||
this.setPoints(points);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
goog.inherits(ol.geom.MultiPoint, ol.geom.Collection);
|
||||
|
||||
/**
|
||||
* Sets the MultiPoint's points.
|
||||
*
|
||||
*
|
||||
* @return {Array.<ol.geom.Point>} An array of points.
|
||||
*/
|
||||
ol.geom.MultiPoint.prototype.getPoints = function() {
|
||||
@@ -34,7 +34,7 @@ ol.geom.MultiPoint.prototype.getPoints = function() {
|
||||
|
||||
/**
|
||||
* Gets the MultiPoint's points.
|
||||
*
|
||||
*
|
||||
* @param {Array.<ol.geom.Point>} points An array of 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.
|
||||
*
|
||||
*
|
||||
* @param {ol.geom.Point} point A point to be added.
|
||||
* @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.
|
||||
*
|
||||
*
|
||||
* @param {ol.geom.Point} point A point to be removed.
|
||||
*/
|
||||
ol.geom.MultiPoint.prototype.removePoint = function(point) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
describe("ol.geom.collection", function() {
|
||||
describe("ol.geom.collection", function() {
|
||||
var c;
|
||||
beforeEach(function() {
|
||||
c = ol.geom.collection([
|
||||
@@ -9,7 +9,7 @@ describe("ol.geom.collection", function() {
|
||||
])
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
afterEach(function() {
|
||||
c = null;
|
||||
});
|
||||
@@ -18,149 +18,149 @@ describe("ol.geom.collection", function() {
|
||||
expect( c ).toBeA( ol.geom.Collection );
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe("can construct instances without any components", function() {
|
||||
|
||||
|
||||
it("works with an empty array", function(){
|
||||
c = ol.geom.collection([]);
|
||||
|
||||
|
||||
expect( c ).toBeA( ol.geom.Collection );
|
||||
});
|
||||
|
||||
|
||||
it("works without arguments", function(){
|
||||
c = ol.geom.collection();
|
||||
|
||||
|
||||
expect( c ).toBeA( ol.geom.Collection );
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe("the method 'add'", function() {
|
||||
it("exists", function(){
|
||||
expect( c.add ).toBeA( Function );
|
||||
});
|
||||
|
||||
|
||||
describe("can be used as setter", function(){
|
||||
it("works with a single point specification and an index", function(){
|
||||
var p = ol.geom.point([24,7]);
|
||||
c.add(p, 0);
|
||||
|
||||
|
||||
expect(c.components().length).toBe(3);
|
||||
|
||||
|
||||
var firstComponent = c.components()[0];
|
||||
|
||||
|
||||
expect( firstComponent.x() + ',' + firstComponent.y() ).toBe( '24,7' );
|
||||
});
|
||||
|
||||
|
||||
it("the index is functional", function(){
|
||||
var p = ol.geom.point([24,7]);
|
||||
c.add(p, 1);
|
||||
|
||||
|
||||
expect(c.components().length).toBe(3);
|
||||
|
||||
|
||||
var firstComponent = c.components()[0], // untouched
|
||||
secondComponent = c.components()[1], // this should be ours
|
||||
thirdComponent = c.components()[2]; // shifted here
|
||||
|
||||
|
||||
expect( firstComponent.x() + ',' + firstComponent.y() ).toBe( '0,1' );
|
||||
expect( secondComponent.x() + ',' + secondComponent.y() ).toBe( '24,7' );
|
||||
expect( thirdComponent ).toBeA( ol.geom.LineString );
|
||||
});
|
||||
|
||||
|
||||
it("the index is optional", function(){
|
||||
var p = ol.geom.point([24,7]);
|
||||
c.add(p);
|
||||
|
||||
|
||||
expect(c.components().length).toBe(3);
|
||||
|
||||
|
||||
var thirdComponent = c.components()[2];
|
||||
expect( thirdComponent.x() + ',' + thirdComponent.y() ).toBe( '24,7' );
|
||||
});
|
||||
|
||||
|
||||
it("returns the collection instance", function(){
|
||||
var p = ol.geom.point([24,7]);
|
||||
var returned = c.add(p);
|
||||
|
||||
|
||||
expect(returned).toBe(c);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe("the method 'addAll'", function(){
|
||||
it("exists", function(){
|
||||
expect( c.addAll ).toBeA( Function );
|
||||
});
|
||||
|
||||
|
||||
describe("can be used as setter", function(){
|
||||
|
||||
|
||||
it("works with an array of points and an index", function(){
|
||||
var ps = [
|
||||
ol.geom.point([24,7]),
|
||||
ol.geom.point([7,11])
|
||||
];
|
||||
c.addAll(ps, 0);
|
||||
|
||||
|
||||
expect(c.components().length).toBe(4);
|
||||
|
||||
|
||||
var firstComponent = c.components()[0],
|
||||
secondComponent = c.components()[1];
|
||||
|
||||
|
||||
expect( firstComponent.x() + ',' + firstComponent.y() ).toBe( '24,7' );
|
||||
expect( secondComponent.x() + ',' + secondComponent.y() ).toBe( '7,11' );
|
||||
});
|
||||
|
||||
|
||||
it("the index is functional", function(){
|
||||
var ps = [
|
||||
ol.geom.point([24,7]),
|
||||
ol.geom.point({x:7, y:11})
|
||||
];
|
||||
c.addAll(ps, 1);
|
||||
|
||||
|
||||
expect(c.components().length).toBe(4);
|
||||
|
||||
|
||||
var firstComponent = c.components()[0], // untouched
|
||||
secondComponent = c.components()[1], // this should be ours
|
||||
thirdComponent = c.components()[2], // this should be ours
|
||||
fourthComponent = c.components()[3]; // shifted here
|
||||
|
||||
|
||||
expect( firstComponent.x() + ',' + firstComponent.y() ).toBe( '0,1' );
|
||||
expect( secondComponent.x() + ',' + secondComponent.y() ).toBe( '24,7' );
|
||||
expect( thirdComponent.x() + ',' + thirdComponent.y() ).toBe( '7,11' );
|
||||
expect( fourthComponent ).toBeA( ol.geom.LineString );
|
||||
});
|
||||
|
||||
|
||||
it("the index is optional", function(){
|
||||
var ps = [
|
||||
ol.geom.point([24,7]),
|
||||
ol.geom.point({x:7, y:11})
|
||||
];
|
||||
c.addAll(ps);
|
||||
|
||||
|
||||
expect(c.components().length).toBe(4);
|
||||
|
||||
|
||||
var thirdComponent = c.components()[2],
|
||||
fourthComponent = c.components()[3];
|
||||
expect( thirdComponent.x() + ',' + thirdComponent.y() ).toBe( '24,7' );
|
||||
expect( fourthComponent.x() + ',' + fourthComponent.y() ).toBe( '7,11' );
|
||||
});
|
||||
|
||||
|
||||
it("returns the collection instance", function(){
|
||||
var ps = [
|
||||
ol.geom.point([24,7]),
|
||||
ol.geom.point({x:7, y:11})
|
||||
];
|
||||
var returned = c.addAll(ps);
|
||||
|
||||
|
||||
expect(returned).toBe(c);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
describe("the method 'remove'", function() {
|
||||
it("exists", function(){
|
||||
expect( c.add ).toBeA( Function );
|
||||
});
|
||||
|
||||
|
||||
it("works with a single point", function(){
|
||||
var p = c.components()[0];
|
||||
c.remove(p);
|
||||
@@ -168,7 +168,7 @@ describe("ol.geom.collection", function() {
|
||||
var firstComponent = c.components()[0];
|
||||
expect( firstComponent ).toBeA( ol.geom.LineString );
|
||||
});
|
||||
|
||||
|
||||
it("works with an array of point specifications", function(){
|
||||
var ps = [
|
||||
c.components()[1],
|
||||
|
||||
@@ -1,45 +1,45 @@
|
||||
describe("ol.geom.geometry", function() {
|
||||
describe("ol.geom.geometry", function() {
|
||||
var g;
|
||||
|
||||
|
||||
beforeEach(function() {
|
||||
g = ol.geom.geometry();
|
||||
});
|
||||
|
||||
|
||||
afterEach(function() {
|
||||
g = null;
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
it("constructs instances", function() {
|
||||
expect( g ).toBeA( ol.geom.Geometry );
|
||||
});
|
||||
|
||||
|
||||
it("can set bounds", function() {
|
||||
var oldBounds = g.bounds();
|
||||
|
||||
|
||||
expect(oldBounds).toBeUndefined();
|
||||
|
||||
|
||||
var b = ol.bounds([0,1,2,3]);
|
||||
g.bounds(b);
|
||||
var gotBounds = g.bounds();
|
||||
|
||||
|
||||
expect(gotBounds).not.toBeUndefined();
|
||||
});
|
||||
|
||||
|
||||
it("can get bounds", function() {
|
||||
var b = ol.bounds([0,1,2,3]);
|
||||
g.bounds(b);
|
||||
var gotBounds = g.bounds();
|
||||
|
||||
|
||||
expect(gotBounds).toEqual(jasmine.any(ol.Bounds));
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
it("sets and gets the correct bounds", function() {
|
||||
var b = ol.bounds([0,1,2,3]);
|
||||
g.bounds(b);
|
||||
var gotBounds = g.bounds();
|
||||
|
||||
|
||||
expect(gotBounds.minX()).toEqual(0);
|
||||
expect(gotBounds.minY()).toEqual(1);
|
||||
expect(gotBounds.maxX()).toEqual(2);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
describe("ol.geom.linestring", function() {
|
||||
describe("ol.geom.linestring", function() {
|
||||
var ls;
|
||||
beforeEach(function() {
|
||||
ls = ol.geom.linestring([
|
||||
@@ -6,7 +6,7 @@ describe("ol.geom.linestring", function() {
|
||||
{x:2, y:3}
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
afterEach(function() {
|
||||
ls = null;
|
||||
});
|
||||
@@ -14,58 +14,58 @@ describe("ol.geom.linestring", function() {
|
||||
it("works for the object notation of vertices", function(){
|
||||
expect( ls ).toBeA( ol.geom.LineString );
|
||||
});
|
||||
|
||||
|
||||
it("works for the array notation of vertices", function(){
|
||||
ls = ol.geom.linestring([
|
||||
[0, 1],
|
||||
[2, 3]
|
||||
]);
|
||||
|
||||
|
||||
expect( ls ).toBeA( ol.geom.LineString );
|
||||
});
|
||||
|
||||
|
||||
it("works for real vertices", function(){
|
||||
ls = ol.geom.linestring([
|
||||
ol.geom.point([0,1]),
|
||||
ol.geom.point([2,3])
|
||||
]);
|
||||
|
||||
|
||||
expect( ls ).toBeA( ol.geom.LineString );
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe("can construct instances without any vertices", function() {
|
||||
|
||||
|
||||
it("works with an empty array", function(){
|
||||
ls = ol.geom.linestring([]);
|
||||
|
||||
|
||||
expect( ls ).toBeA( ol.geom.LineString );
|
||||
});
|
||||
|
||||
|
||||
it("works without arguments", function(){
|
||||
ls = ol.geom.linestring();
|
||||
|
||||
|
||||
expect( ls ).toBeA( ol.geom.LineString );
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe("the method 'add'", function() {
|
||||
it("exists", function(){
|
||||
expect( ls.add ).toBeA( Function );
|
||||
});
|
||||
|
||||
|
||||
describe("can be used as setter", function(){
|
||||
it("works with a single vertex specification and an index", function(){
|
||||
var p = ol.geom.point([24,7]);
|
||||
ls.add(p, 0);
|
||||
|
||||
|
||||
expect(ls.vertices().length).toBe(3);
|
||||
|
||||
|
||||
var firstPoint = ls.vertices()[0];
|
||||
|
||||
|
||||
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' );
|
||||
});
|
||||
|
||||
|
||||
it("works with point instance", function(){
|
||||
ls = ol.geom.linestring();
|
||||
ls.add(ol.geom.point([24,7]));
|
||||
@@ -73,7 +73,7 @@ describe("ol.geom.linestring", function() {
|
||||
var firstPoint = ls.vertices()[0];
|
||||
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' );
|
||||
});
|
||||
|
||||
|
||||
it("works with array specifications", function(){
|
||||
ls = ol.geom.linestring();
|
||||
ls.add([24,7]);
|
||||
@@ -81,7 +81,7 @@ describe("ol.geom.linestring", function() {
|
||||
var firstPoint = ls.vertices()[0];
|
||||
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' );
|
||||
});
|
||||
|
||||
|
||||
it("works with object specifications", function(){
|
||||
ls = ol.geom.linestring();
|
||||
ls.add({x:24,y:7});
|
||||
@@ -89,117 +89,117 @@ describe("ol.geom.linestring", function() {
|
||||
var firstPoint = ls.vertices()[0];
|
||||
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' );
|
||||
});
|
||||
|
||||
|
||||
it("the index is functional", function(){
|
||||
var p = ol.geom.point([24,7]);
|
||||
ls.add(p, 1);
|
||||
|
||||
|
||||
expect(ls.vertices().length).toBe(3);
|
||||
|
||||
|
||||
var firstPoint = ls.vertices()[0], // untouched
|
||||
secondPoint = ls.vertices()[1], // this should be ours
|
||||
thirdPoint = ls.vertices()[2]; // shifted here
|
||||
|
||||
|
||||
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '0,1' );
|
||||
expect( secondPoint.x() + ',' + secondPoint.y() ).toBe( '24,7' );
|
||||
expect( thirdPoint.x() + ',' + thirdPoint.y() ).toBe( '2,3' );
|
||||
});
|
||||
|
||||
|
||||
it("the index is optional", function(){
|
||||
var p = ol.geom.point([24,7]);
|
||||
ls.add(p);
|
||||
|
||||
|
||||
expect(ls.vertices().length).toBe(3);
|
||||
|
||||
|
||||
var thirdPoint = ls.vertices()[2];
|
||||
expect( thirdPoint.x() + ',' + thirdPoint.y() ).toBe( '24,7' );
|
||||
});
|
||||
|
||||
|
||||
it("returns the linestring instance", function(){
|
||||
var p = ol.geom.point([24,7]);
|
||||
var returned = ls.add(p);
|
||||
|
||||
|
||||
expect(returned).toBe(ls);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe("the method 'addAll'", function(){
|
||||
it("exists", function(){
|
||||
expect( ls.addAll ).toBeA( Function );
|
||||
});
|
||||
|
||||
|
||||
describe("can be used as setter", function(){
|
||||
|
||||
|
||||
it("works with an array of point specifications and an index", function(){
|
||||
var ps = [
|
||||
ol.geom.point([24,7]),
|
||||
ol.geom.point([7,11])
|
||||
];
|
||||
ls.addAll(ps, 0);
|
||||
|
||||
|
||||
expect(ls.vertices().length).toBe(4);
|
||||
|
||||
|
||||
var firstPoint = ls.vertices()[0],
|
||||
secondPoint = ls.vertices()[1];
|
||||
|
||||
|
||||
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' );
|
||||
expect( secondPoint.x() + ',' + secondPoint.y() ).toBe( '7,11' );
|
||||
});
|
||||
|
||||
|
||||
it("the index is functional", function(){
|
||||
var ps = [
|
||||
[24,7],
|
||||
{x:7, y:11}
|
||||
];
|
||||
ls.addAll(ps, 1);
|
||||
|
||||
|
||||
expect(ls.vertices().length).toBe(4);
|
||||
|
||||
|
||||
var firstPoint = ls.vertices()[0], // untouched
|
||||
secondPoint = ls.vertices()[1], // this should be ours
|
||||
thirdPoint = ls.vertices()[2], // this should be ours
|
||||
fourthPoint = ls.vertices()[3]; // shifted here
|
||||
|
||||
|
||||
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '0,1' );
|
||||
expect( secondPoint.x() + ',' + secondPoint.y() ).toBe( '24,7' );
|
||||
expect( thirdPoint.x() + ',' + thirdPoint.y() ).toBe( '7,11' );
|
||||
expect( fourthPoint.x() + ',' + fourthPoint.y() ).toBe( '2,3' );
|
||||
});
|
||||
|
||||
|
||||
it("the index is optional", function(){
|
||||
var ps = [
|
||||
[24,7],
|
||||
{x:7, y:11}
|
||||
];
|
||||
ls.addAll(ps);
|
||||
|
||||
|
||||
expect(ls.vertices().length).toBe(4);
|
||||
|
||||
|
||||
var thirdPoint = ls.vertices()[2],
|
||||
fourthPoint = ls.vertices()[3];
|
||||
expect( thirdPoint.x() + ',' + thirdPoint.y() ).toBe( '24,7' );
|
||||
expect( fourthPoint.x() + ',' + fourthPoint.y() ).toBe( '7,11' );
|
||||
});
|
||||
|
||||
|
||||
it("returns the linestring instance", function(){
|
||||
var ps = [
|
||||
[24,7],
|
||||
{x:7, y:11}
|
||||
];
|
||||
var returned = ls.addAll(ps);
|
||||
|
||||
|
||||
expect(returned).toBe(ls);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
describe("the method 'remove'", function() {
|
||||
it("exists", function(){
|
||||
expect( ls.add ).toBeA( Function );
|
||||
});
|
||||
|
||||
|
||||
it("works with a single point", function(){
|
||||
var p = ls.vertices()[0];
|
||||
ls.remove(p);
|
||||
@@ -207,7 +207,7 @@ describe("ol.geom.linestring", function() {
|
||||
var firstPoint = ls.vertices()[0];
|
||||
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '2,3' );
|
||||
});
|
||||
|
||||
|
||||
it("works with an array of point specifications", function(){
|
||||
var ps = [
|
||||
ls.vertices()[1],
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
describe("ol.geom.multipoint", function() {
|
||||
describe("ol.geom.multipoint", function() {
|
||||
var mp;
|
||||
beforeEach(function() {
|
||||
mp = ol.geom.multipoint([
|
||||
@@ -6,7 +6,7 @@ describe("ol.geom.multipoint", function() {
|
||||
{x:2, y:3}
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
afterEach(function() {
|
||||
mp = null;
|
||||
});
|
||||
@@ -14,58 +14,58 @@ describe("ol.geom.multipoint", function() {
|
||||
it("works for the object notation of points", function(){
|
||||
expect( mp ).toBeA( ol.geom.MultiPoint );
|
||||
});
|
||||
|
||||
|
||||
it("works for the array notation of points", function(){
|
||||
mp = ol.geom.multipoint([
|
||||
[0, 1],
|
||||
[2, 3]
|
||||
]);
|
||||
|
||||
|
||||
expect( mp ).toBeA( ol.geom.MultiPoint );
|
||||
});
|
||||
|
||||
|
||||
it("works for real points", function(){
|
||||
mp = ol.geom.multipoint([
|
||||
ol.geom.point([0,1]),
|
||||
ol.geom.point([2,3])
|
||||
]);
|
||||
|
||||
|
||||
expect( mp ).toBeA( ol.geom.MultiPoint );
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe("can construct instances without any points", function() {
|
||||
|
||||
|
||||
it("works with an empty array", function(){
|
||||
mp = ol.geom.multipoint([]);
|
||||
|
||||
|
||||
expect( mp ).toBeA( ol.geom.MultiPoint );
|
||||
});
|
||||
|
||||
|
||||
it("works without arguments", function(){
|
||||
mp = ol.geom.multipoint();
|
||||
|
||||
|
||||
expect( mp ).toBeA( ol.geom.MultiPoint );
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe("the method 'add'", function() {
|
||||
it("exists", function(){
|
||||
expect( mp.add ).toBeA( Function );
|
||||
});
|
||||
|
||||
|
||||
describe("can be used as setter", function(){
|
||||
it("works with a single point specification and an index", function(){
|
||||
var p = ol.geom.point([24,7]);
|
||||
mp.add(p, 0);
|
||||
|
||||
|
||||
expect(mp.points().length).toBe(3);
|
||||
|
||||
|
||||
var firstPoint = mp.points()[0];
|
||||
|
||||
|
||||
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' );
|
||||
});
|
||||
|
||||
|
||||
it("works with point instance", function(){
|
||||
mp = ol.geom.multipoint();
|
||||
mp.add(ol.geom.point([24,7]));
|
||||
@@ -73,7 +73,7 @@ describe("ol.geom.multipoint", function() {
|
||||
var firstPoint = mp.points()[0];
|
||||
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' );
|
||||
});
|
||||
|
||||
|
||||
it("works with array specifications", function(){
|
||||
mp = ol.geom.multipoint();
|
||||
mp.add([24,7]);
|
||||
@@ -81,7 +81,7 @@ describe("ol.geom.multipoint", function() {
|
||||
var firstPoint = mp.points()[0];
|
||||
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' );
|
||||
});
|
||||
|
||||
|
||||
it("works with object specifications", function(){
|
||||
mp = ol.geom.multipoint();
|
||||
mp.add({x:24,y:7});
|
||||
@@ -89,117 +89,117 @@ describe("ol.geom.multipoint", function() {
|
||||
var firstPoint = mp.points()[0];
|
||||
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' );
|
||||
});
|
||||
|
||||
|
||||
it("the index is functional", function(){
|
||||
var p = ol.geom.point([24,7]);
|
||||
mp.add(p, 1);
|
||||
|
||||
|
||||
expect(mp.points().length).toBe(3);
|
||||
|
||||
|
||||
var firstPoint = mp.points()[0], // untouched
|
||||
secondPoint = mp.points()[1], // this should be ours
|
||||
thirdPoint = mp.points()[2]; // shifted here
|
||||
|
||||
|
||||
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '0,1' );
|
||||
expect( secondPoint.x() + ',' + secondPoint.y() ).toBe( '24,7' );
|
||||
expect( thirdPoint.x() + ',' + thirdPoint.y() ).toBe( '2,3' );
|
||||
});
|
||||
|
||||
|
||||
it("the index is optional", function(){
|
||||
var p = ol.geom.point([24,7]);
|
||||
mp.add(p);
|
||||
|
||||
|
||||
expect(mp.points().length).toBe(3);
|
||||
|
||||
|
||||
var thirdPoint = mp.points()[2];
|
||||
expect( thirdPoint.x() + ',' + thirdPoint.y() ).toBe( '24,7' );
|
||||
});
|
||||
|
||||
|
||||
it("returns the multipoint instance", function(){
|
||||
var p = ol.geom.point([24,7]);
|
||||
var returned = mp.add(p);
|
||||
|
||||
|
||||
expect(returned).toBe(mp);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe("the method 'addAll'", function(){
|
||||
it("exists", function(){
|
||||
expect( mp.addAll ).toBeA( Function );
|
||||
});
|
||||
|
||||
|
||||
describe("can be used as setter", function(){
|
||||
|
||||
|
||||
it("works with an array of point specifications and an index", function(){
|
||||
var ps = [
|
||||
ol.geom.point([24,7]),
|
||||
ol.geom.point([7,11])
|
||||
];
|
||||
mp.addAll(ps, 0);
|
||||
|
||||
|
||||
expect(mp.points().length).toBe(4);
|
||||
|
||||
|
||||
var firstPoint = mp.points()[0],
|
||||
secondPoint = mp.points()[1];
|
||||
|
||||
|
||||
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' );
|
||||
expect( secondPoint.x() + ',' + secondPoint.y() ).toBe( '7,11' );
|
||||
});
|
||||
|
||||
|
||||
it("the index is functional", function(){
|
||||
var ps = [
|
||||
[24,7],
|
||||
{x:7, y:11}
|
||||
];
|
||||
mp.addAll(ps, 1);
|
||||
|
||||
|
||||
expect(mp.points().length).toBe(4);
|
||||
|
||||
|
||||
var firstPoint = mp.points()[0], // untouched
|
||||
secondPoint = mp.points()[1], // this should be ours
|
||||
thirdPoint = mp.points()[2], // this should be ours
|
||||
fourthPoint = mp.points()[3]; // shifted here
|
||||
|
||||
|
||||
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '0,1' );
|
||||
expect( secondPoint.x() + ',' + secondPoint.y() ).toBe( '24,7' );
|
||||
expect( thirdPoint.x() + ',' + thirdPoint.y() ).toBe( '7,11' );
|
||||
expect( fourthPoint.x() + ',' + fourthPoint.y() ).toBe( '2,3' );
|
||||
});
|
||||
|
||||
|
||||
it("the index is optional", function(){
|
||||
var ps = [
|
||||
[24,7],
|
||||
{x:7, y:11}
|
||||
];
|
||||
mp.addAll(ps);
|
||||
|
||||
|
||||
expect(mp.points().length).toBe(4);
|
||||
|
||||
|
||||
var thirdPoint = mp.points()[2],
|
||||
fourthPoint = mp.points()[3];
|
||||
expect( thirdPoint.x() + ',' + thirdPoint.y() ).toBe( '24,7' );
|
||||
expect( fourthPoint.x() + ',' + fourthPoint.y() ).toBe( '7,11' );
|
||||
});
|
||||
|
||||
|
||||
it("returns the multipoint instance", function(){
|
||||
var ps = [
|
||||
[24,7],
|
||||
{x:7, y:11}
|
||||
];
|
||||
var returned = mp.addAll(ps);
|
||||
|
||||
|
||||
expect(returned).toBe(mp);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
describe("the method 'remove'", function() {
|
||||
it("exists", function(){
|
||||
expect( mp.add ).toBeA( Function );
|
||||
});
|
||||
|
||||
|
||||
it("works with a single point", function(){
|
||||
var p = mp.points()[0];
|
||||
mp.remove(p);
|
||||
@@ -207,7 +207,7 @@ describe("ol.geom.multipoint", function() {
|
||||
var firstPoint = mp.points()[0];
|
||||
expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '2,3' );
|
||||
});
|
||||
|
||||
|
||||
it("works with an array of point specifications", function(){
|
||||
var ps = [
|
||||
mp.points()[1],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
describe("ol.geom.Collection", function() {
|
||||
var c;
|
||||
|
||||
|
||||
beforeEach(function(){
|
||||
c = new ol.geom.Collection([
|
||||
new ol.geom.Point(10,20),
|
||||
@@ -10,25 +10,25 @@ describe("ol.geom.Collection", function() {
|
||||
])
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
afterEach(function(){
|
||||
c = null;
|
||||
});
|
||||
|
||||
|
||||
it("constructs instances", function() {
|
||||
expect( c ).toBeA( ol.geom.Collection );
|
||||
});
|
||||
|
||||
|
||||
it("can construct instances without any components", function() {
|
||||
// empty array
|
||||
c = new ol.geom.Collection([]);
|
||||
expect( c ).toBeA( ol.geom.Collection );
|
||||
|
||||
|
||||
// no argument at all
|
||||
c = new ol.geom.Collection();
|
||||
expect( c ).toBeA( ol.geom.Collection );
|
||||
});
|
||||
|
||||
|
||||
it("cannot construct instances when passed illegal components", function() {
|
||||
// collection cannot contain collections
|
||||
expect(function(){
|
||||
@@ -36,29 +36,29 @@ describe("ol.geom.Collection", function() {
|
||||
new ol.geom.Collection()
|
||||
]);
|
||||
}).toThrow();
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
it("inherits from ol.geom.Geometry", function() {
|
||||
expect( c ).toBeA( ol.geom.Geometry );
|
||||
});
|
||||
|
||||
|
||||
it("has a working getter for components", function() {
|
||||
|
||||
|
||||
var components = c.getComponents();
|
||||
|
||||
|
||||
expect( components ).toBeA( Array );
|
||||
expect( components.length ).toBe( 2 );
|
||||
expect( components[0] ).toBeA( ol.geom.Point );
|
||||
expect( components[1] ).toBeA( ol.geom.LineString );
|
||||
|
||||
|
||||
expect( components[0].getX() + ',' + components[0].getY()).toBe( '10,20' );
|
||||
expect( components[1].getVertices()[0].getX() + ',' + components[1].getVertices()[0].getY()).toBe( '47,11' );
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
it("has a working setter for components", function() {
|
||||
|
||||
|
||||
c.setComponents([
|
||||
new ol.geom.Point(30,40),
|
||||
new ol.geom.LineString([
|
||||
@@ -66,20 +66,20 @@ describe("ol.geom.Collection", function() {
|
||||
new ol.geom.Point(4,16)
|
||||
])
|
||||
]);
|
||||
|
||||
|
||||
var components = c.getComponents();
|
||||
|
||||
|
||||
expect( components.length ).toBe( 2 );
|
||||
expect( components[0] ).toBeA( ol.geom.Point );
|
||||
expect( components[1] ).toBeA( ol.geom.LineString );
|
||||
|
||||
|
||||
expect( components[0].getX() + ',' + components[0].getY()).toBe( '30,40' );
|
||||
expect( components[1].getVertices()[0].getX() + ',' + components[1].getVertices()[0].getY()).toBe( '3,9' );
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
it("has a method to add components", function() {
|
||||
|
||||
|
||||
c.addComponent(
|
||||
new ol.geom.Point(30,40),
|
||||
1
|
||||
@@ -91,17 +91,17 @@ describe("ol.geom.Collection", function() {
|
||||
]),
|
||||
0
|
||||
);
|
||||
|
||||
|
||||
var components = c.getComponents();
|
||||
|
||||
|
||||
expect( components.length ).toBe( 4 );
|
||||
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[2].getX() + ',' + components[2].getY()).toBe( '30,40' );
|
||||
expect( components[3].getVertices()[0].getX() + ',' + components[3].getVertices()[0].getY()).toBe( '47,11' );
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
it("cannot add instances of 'ol.geom.Collection'", function(){
|
||||
expect(function(){
|
||||
c.addComponent(
|
||||
@@ -112,7 +112,7 @@ describe("ol.geom.Collection", function() {
|
||||
);
|
||||
}).toThrow();
|
||||
});
|
||||
|
||||
|
||||
it("has a method to remove components", function() {
|
||||
c.setComponents([
|
||||
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(30,40)
|
||||
]);
|
||||
|
||||
|
||||
var p = c.getComponents()[2]; // 20,30;
|
||||
|
||||
|
||||
c.removeComponent( p );
|
||||
|
||||
|
||||
var components = c.getComponents();
|
||||
|
||||
|
||||
expect( components.length ).toBe( 3 );
|
||||
expect( components[0].getX() + ',' + components[0].getY()).toBe( '0,10' );
|
||||
expect( components[1].getX() + ',' + components[1].getY()).toBe( '10,20' );
|
||||
expect( components[2].getX() + ',' + components[2].getY()).toBe( '30,40' );
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
describe("ol.geom.LineString", function() {
|
||||
var ls;
|
||||
|
||||
|
||||
beforeEach(function(){
|
||||
ls = new ol.geom.LineString([
|
||||
new ol.geom.Point(0,0),
|
||||
@@ -9,61 +9,61 @@ describe("ol.geom.LineString", function() {
|
||||
new ol.geom.Point(20,20)
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
afterEach(function(){
|
||||
ls = null;
|
||||
});
|
||||
|
||||
|
||||
it("constructs instances", function() {
|
||||
expect( ls ).toBeA( ol.geom.LineString );
|
||||
});
|
||||
|
||||
|
||||
it("can construct instances without any points", function() {
|
||||
// empty array
|
||||
mp = new ol.geom.LineString([]);
|
||||
expect( ls ).toBeA( ol.geom.LineString );
|
||||
|
||||
|
||||
// no argument at all
|
||||
mp = new ol.geom.LineString();
|
||||
expect( ls ).toBeA( ol.geom.LineString );
|
||||
});
|
||||
|
||||
|
||||
it("inherits from ol.geom.Geometry", function() {
|
||||
expect( ls ).toBeA( ol.geom.Geometry );
|
||||
});
|
||||
|
||||
|
||||
it("has a working getter for vertices", function() {
|
||||
|
||||
|
||||
var vertices = ls.getVertices();
|
||||
|
||||
|
||||
expect( vertices ).toBeA( Array );
|
||||
expect( vertices.length ).toBe( 4 );
|
||||
expect( vertices[0] ).toBeA( ol.geom.Point );
|
||||
|
||||
|
||||
expect( vertices[0].getX() + ',' + vertices[0].getY()).toBe( '0,0' );
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
it("has a working setter for vertices", function() {
|
||||
|
||||
|
||||
ls.setVertices([
|
||||
new ol.geom.Point(30,40),
|
||||
new ol.geom.Point(50,60)
|
||||
]);
|
||||
|
||||
|
||||
var vertices = ls.getVertices();
|
||||
|
||||
|
||||
expect( vertices.length ).toBe( 2 );
|
||||
expect( vertices[0] ).toBeA( ol.geom.Point );
|
||||
expect( vertices[1] ).toBeA( ol.geom.Point );
|
||||
|
||||
|
||||
expect( vertices[0].getX() + ',' + vertices[0].getY()).toBe( '30,40' );
|
||||
expect( vertices[1].getX() + ',' + vertices[1].getY()).toBe( '50,60' );
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
it("has a method to add vertices", function() {
|
||||
|
||||
|
||||
ls.addVertex(
|
||||
new ol.geom.Point(30,40),
|
||||
1
|
||||
@@ -76,9 +76,9 @@ describe("ol.geom.LineString", function() {
|
||||
new ol.geom.Point(-10,0),
|
||||
0
|
||||
);
|
||||
|
||||
|
||||
var vertices = ls.getVertices();
|
||||
|
||||
|
||||
expect( vertices.length ).toBe( 7 );
|
||||
expect( vertices[0].getX() + ',' + vertices[0].getY()).toBe( '-10,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[5].getX() + ',' + vertices[5].getY()).toBe( '10,0' );
|
||||
expect( vertices[6].getX() + ',' + vertices[6].getY()).toBe( '20,20' );
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
it("has a method to remove vertices", function() {
|
||||
ls.setVertices([
|
||||
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(30,40)
|
||||
]);
|
||||
|
||||
|
||||
var v = ls.getVertices()[2]; // 20,30;
|
||||
|
||||
|
||||
ls.removeVertex( v );
|
||||
|
||||
|
||||
var vertices = ls.getVertices();
|
||||
|
||||
|
||||
expect( vertices.length ).toBe( 3 );
|
||||
expect( vertices[0].getX() + ',' + vertices[0].getY()).toBe( '0,10' );
|
||||
expect( vertices[1].getX() + ',' + vertices[1].getY()).toBe( '10,20' );
|
||||
expect( vertices[2].getX() + ',' + vertices[2].getY()).toBe( '30,40' );
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
describe("ol.geom.MultiPoint", function() {
|
||||
var mp;
|
||||
|
||||
|
||||
beforeEach(function(){
|
||||
mp = new ol.geom.MultiPoint([
|
||||
new ol.geom.Point(10,20)
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
afterEach(function(){
|
||||
mp = null;
|
||||
});
|
||||
|
||||
|
||||
it("constructs instances", function() {
|
||||
expect( mp ).toBeA( ol.geom.MultiPoint );
|
||||
});
|
||||
|
||||
|
||||
it("can construct instances without any points", function() {
|
||||
// empty array
|
||||
mp = new ol.geom.MultiPoint([]);
|
||||
expect( mp ).toBeA( ol.geom.MultiPoint );
|
||||
|
||||
|
||||
// no argument at all
|
||||
mp = new ol.geom.MultiPoint();
|
||||
expect( mp ).toBeA( ol.geom.MultiPoint );
|
||||
});
|
||||
|
||||
|
||||
it("cannot be constructed with component-types other than 'ol.geom.Point'", function() {
|
||||
expect(function(){
|
||||
mp = new ol.geom.MultiPoint([
|
||||
@@ -32,43 +32,43 @@ describe("ol.geom.MultiPoint", function() {
|
||||
]);
|
||||
}).toThrow();
|
||||
});
|
||||
|
||||
|
||||
it("inherits from ol.geom.Geometry", function() {
|
||||
expect( mp ).toBeA( ol.geom.Geometry );
|
||||
});
|
||||
|
||||
|
||||
it("has a working getter for points", function() {
|
||||
|
||||
|
||||
var points = mp.getPoints();
|
||||
|
||||
|
||||
expect( points ).toBeA( Array );
|
||||
expect( points.length ).toBe( 1 );
|
||||
expect( points[0] ).toBeA( ol.geom.Point );
|
||||
|
||||
|
||||
expect( points[0].getX() + ',' + points[0].getY()).toBe( '10,20' );
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
it("has a working setter for points", function() {
|
||||
|
||||
|
||||
mp.setPoints([
|
||||
new ol.geom.Point(30,40),
|
||||
new ol.geom.Point(50,60)
|
||||
]);
|
||||
|
||||
|
||||
var points = mp.getPoints();
|
||||
|
||||
|
||||
expect( points.length ).toBe( 2 );
|
||||
expect( points[0] ).toBeA( ol.geom.Point );
|
||||
expect( points[1] ).toBeA( ol.geom.Point );
|
||||
|
||||
|
||||
expect( points[0].getX() + ',' + points[0].getY()).toBe( '30,40' );
|
||||
expect( points[1].getX() + ',' + points[1].getY()).toBe( '50,60' );
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
it("has a method to add points", function() {
|
||||
|
||||
|
||||
mp.addPoint(
|
||||
new ol.geom.Point(30,40),
|
||||
1
|
||||
@@ -81,17 +81,17 @@ describe("ol.geom.MultiPoint", function() {
|
||||
new ol.geom.Point(-10,0),
|
||||
0
|
||||
);
|
||||
|
||||
|
||||
var points = mp.getPoints();
|
||||
|
||||
|
||||
expect( points.length ).toBe( 4 );
|
||||
expect( points[0].getX() + ',' + points[0].getY()).toBe( '-10,0' );
|
||||
expect( points[1].getX() + ',' + points[1].getY()).toBe( '10,20' );
|
||||
expect( points[2].getX() + ',' + points[2].getY()).toBe( '30,40' );
|
||||
expect( points[3].getX() + ',' + points[3].getY()).toBe( '50,60' );
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
it("can only add ol.geom.Point as components", function() {
|
||||
expect(function(){
|
||||
mp.addComponent(
|
||||
@@ -102,7 +102,7 @@ describe("ol.geom.MultiPoint", function() {
|
||||
);
|
||||
}).toThrow();
|
||||
});
|
||||
|
||||
|
||||
it("has a method to remove points", function() {
|
||||
mp.setPoints([
|
||||
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(30,40)
|
||||
]);
|
||||
|
||||
|
||||
var p = mp.getPoints()[2]; // 20,30;
|
||||
|
||||
|
||||
mp.removePoint( p );
|
||||
|
||||
|
||||
var points = mp.getPoints();
|
||||
|
||||
|
||||
expect( points.length ).toBe( 3 );
|
||||
expect( points[0].getX() + ',' + points[0].getY()).toBe( '0,10' );
|
||||
expect( points[1].getX() + ',' + points[1].getY()).toBe( '10,20' );
|
||||
expect( points[2].getX() + ',' + points[2].getY()).toBe( '30,40' );
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user