patch for #487 -- dateline wrapping

git-svn-id: http://svn.openlayers.org/trunk/openlayers@3323 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2007-06-12 18:03:59 +00:00
parent 76f9234e3b
commit f56f136523
13 changed files with 519 additions and 25 deletions

View File

@@ -379,6 +379,98 @@
(bounds.top == object.y)), "obj Point to extends correclty modifies right and top");
}
function test_16_Bounds_wrapDateLine(t) {
t.plan( 13 );
var testBounds, wrappedBounds, desiredBounds;
var maxExtent = new OpenLayers.Bounds(-10,-10,10,10);
var exactBounds = maxExtent.clone();
var simpleBounds = new OpenLayers.Bounds( -5,-5,5,5);
//bad maxextent
testBounds = simpleBounds.clone();
wrappedBounds = testBounds.wrapDateLine(null);
t.ok(wrappedBounds.equals(simpleBounds), "wrapping a bounds with a bad maxextent does nothing");
//exactly inside
testBounds = exactBounds.clone();
wrappedBounds = testBounds.wrapDateLine(maxExtent);
t.ok(wrappedBounds.equals(exactBounds), "wrapping a bounds precisely within (equal to) maxextent does nothing");
//inside
testBounds = simpleBounds.clone();
wrappedBounds = testBounds.wrapDateLine(maxExtent);
t.ok(wrappedBounds.equals(simpleBounds), "wrapping a bounds within maxextent does nothing");
// LEFT //
//straddling left
testBounds = simpleBounds.add(-10,0);
wrappedBounds = testBounds.wrapDateLine(maxExtent);
t.ok(wrappedBounds.equals(testBounds), "wrapping a bounds that straddles the left of maxextent does nothing");
//left rightTolerance
testBounds = simpleBounds.add(-14,0);
wrappedBounds =
testBounds.wrapDateLine(maxExtent, {'rightTolerance': 1} );
desiredBounds = simpleBounds.add(6,0);
t.ok(wrappedBounds.equals(desiredBounds), "wrapping a bounds rightTolerance left of maxextent works");
//exactly left
testBounds = exactBounds.add(-20,0);
wrappedBounds = testBounds.wrapDateLine(maxExtent);
t.ok(wrappedBounds.equals(exactBounds), "wrapping an exact bounds once left of maxextent works");
//left
testBounds = simpleBounds.add(-20,0);
wrappedBounds = testBounds.wrapDateLine(maxExtent);
t.ok(wrappedBounds.equals(simpleBounds), "wrapping a bounds once left of maxextent works");
//way left
testBounds = simpleBounds.add(-200,0);
wrappedBounds = testBounds.wrapDateLine(maxExtent);
t.ok(wrappedBounds.equals(simpleBounds), "wrapping a bounds way left of maxextent works");
// RIGHT //
//straddling right
testBounds = simpleBounds.add(10,0);
wrappedBounds = testBounds.wrapDateLine(maxExtent);
t.ok(wrappedBounds.equals(testBounds), "wrapping a bounds that straddles the right of maxextent does nothing");
//right leftTolerance
testBounds = simpleBounds.add(14,0);
wrappedBounds =
testBounds.wrapDateLine(maxExtent, {'leftTolerance': 1} );
desiredBounds = simpleBounds.add(-6,0);
t.ok(wrappedBounds.equals(desiredBounds), "wrapping a bounds leftTolerance right of maxextent works");
//exactly right
testBounds = exactBounds.add(20,0);
wrappedBounds = testBounds.wrapDateLine(maxExtent);
t.ok(wrappedBounds.equals(exactBounds), "wrapping an exact bounds once right of maxextent works");
//right
testBounds = simpleBounds.add(20,0);
wrappedBounds = testBounds.wrapDateLine(maxExtent);
t.ok(wrappedBounds.equals(simpleBounds), "wrapping a bounds once right of maxextent works");
//way right
testBounds = simpleBounds.add(200,0);
wrappedBounds = testBounds.wrapDateLine(maxExtent);
t.ok(wrappedBounds.equals(simpleBounds), "wrapping a bounds way right of maxextent works");
}
// -->
</script>

View File

@@ -88,6 +88,50 @@
t.ok( lonlat.equals(ll), "lonlat is set correctly");
}
function test_08_LonLat_wrapDateLine(t) {
t.plan( 6 );
var goodLL = new OpenLayers.LonLat(0,0);
var testLL, wrappedLL;
//bad maxextent
var maxExtent = null;
testLL = goodLL.clone();
wrappedLL = testLL.wrapDateLine(maxExtent);
t.ok(wrappedLL.equals(goodLL), "wrapping a ll with a bad maxextent does nothing");
//good maxextent
maxExtent = new OpenLayers.Bounds(-10,-10,10,10);
//inside
testLL = goodLL.clone();
wrappedLL = testLL.wrapDateLine(maxExtent);
t.ok(wrappedLL.equals(goodLL), "wrapping a ll within the maxextent does nothing");
//left
testLL = goodLL.add(-20,0);
wrappedLL = testLL.wrapDateLine(maxExtent);
t.ok(wrappedLL.equals(goodLL), "wrapping a ll once left of maxextent works");
//way left
testLL = goodLL.add(-200,0);
wrappedLL = testLL.wrapDateLine(maxExtent);
t.ok(wrappedLL.equals(goodLL), "wrapping a ll way left of maxextent works");
//right
testLL = goodLL.add(20,0);
wrappedLL = testLL.wrapDateLine(maxExtent);
t.ok(wrappedLL.equals(goodLL), "wrapping a ll once right of maxextent works");
//way right
testLL = goodLL.add(200,0);
wrappedLL = testLL.wrapDateLine(maxExtent);
t.ok(wrappedLL.equals(goodLL), "wrapping a ll way right of maxextent works");
}
// -->
</script>
</head>