MultiPoints shall only contain points.
This commit is contained in:
@@ -12,7 +12,12 @@ goog.require('ol.geom.Collection');
|
|||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
ol.geom.MultiPoint = function(points) {
|
ol.geom.MultiPoint = function(points) {
|
||||||
this.setComponents(points);
|
this.setTypeWhitelist([ol.geom.Point]);
|
||||||
|
this.setTypeBlacklist([ol.geom.Geometry]);
|
||||||
|
if (arguments.length === 1 && goog.isDef(points)) {
|
||||||
|
this.setPoints(points);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
goog.inherits(ol.geom.MultiPoint, ol.geom.Collection);
|
goog.inherits(ol.geom.MultiPoint, ol.geom.Collection);
|
||||||
|
|||||||
@@ -25,6 +25,14 @@ describe("ol.geom.MultiPoint", function() {
|
|||||||
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() {
|
||||||
|
expect(function(){
|
||||||
|
mp = new ol.geom.MultiPoint([
|
||||||
|
new ol.geom.LineString()
|
||||||
|
]);
|
||||||
|
}).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 );
|
||||||
});
|
});
|
||||||
@@ -84,6 +92,17 @@ describe("ol.geom.MultiPoint", function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("can only add ol.geom.Point as components", function() {
|
||||||
|
expect(function(){
|
||||||
|
mp.addComponent(
|
||||||
|
new ol.geom.LineString([
|
||||||
|
new ol.geom.Point(30,40),
|
||||||
|
new ol.geom.Point(50,60)
|
||||||
|
])
|
||||||
|
);
|
||||||
|
}).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),
|
||||||
|
|||||||
Reference in New Issue
Block a user