LinearRing.getCentroid: return null if the geometry has no components. r=pgiraud (closes #2530)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@10116 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Frédéric Junod
2010-03-19 09:05:12 +00:00
parent c54dc76d15
commit 37e0c0b4f5
2 changed files with 22 additions and 3 deletions
+18 -1
View File
@@ -112,7 +112,24 @@
var ring = new OpenLayers.Geometry.LinearRing(components);
t.eq(ring.getLength(), 40, "getLength returns the correct perimiter");
}
function test_LinearRing_getCentroid(t) {
t.plan(2);
var components = [
new OpenLayers.Geometry.Point(0,0),
new OpenLayers.Geometry.Point(0,10),
new OpenLayers.Geometry.Point(10,10),
new OpenLayers.Geometry.Point(10,0)
];
var ring = new OpenLayers.Geometry.LinearRing(components);
var centroid = ring.getCentroid();
t.ok(centroid.x === 5 && centroid.y === 5, "getCentroid returns the correct centroid");
ring.destroy();
ring = new OpenLayers.Geometry.LinearRing();
t.eq(ring.getCentroid(), null, "getCentroid returns null if no components");
}
function test_LinearRing_move(t) {
var nvert = 4,