Merge vector-2.4 branch back to trunk.
svn merge sandbox/vector-2.4/@2307 sandbox/vector-2.4/@HEAD trunk/openlayers/ git-svn-id: http://svn.openlayers.org/trunk/openlayers@2803 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var bounds;
|
||||
function test_01_Bounds_constructor (t) {
|
||||
@@ -277,7 +277,7 @@
|
||||
t.eq( bounds.top, 4, "bounds.top is set correctly" );
|
||||
}
|
||||
|
||||
function test_14_Bounds_fromSize(t) {
|
||||
function test_15_Bounds_fromSize(t) {
|
||||
t.plan( 5 );
|
||||
|
||||
var height = 15;
|
||||
@@ -291,6 +291,95 @@
|
||||
t.eq( bounds.top, 0, "bounds.top is set correctly" );
|
||||
}
|
||||
|
||||
|
||||
function test_16_Bounds_extend(t) {
|
||||
t.plan( 8 );
|
||||
|
||||
var originalBounds = new OpenLayers.Bounds(10,20,50,80);
|
||||
|
||||
var bounds = originalBounds.clone();
|
||||
|
||||
//null obj
|
||||
bounds.extend(null);
|
||||
t.ok(bounds.equals(originalBounds), "null to extend does not crash or change original bounds");
|
||||
|
||||
//obj with no classname
|
||||
var object = new Object();
|
||||
bounds.extend(object);
|
||||
t.ok(bounds.equals(originalBounds), "extend() passing object with no classname does not crash or change original bounds")
|
||||
|
||||
//obj is bounds
|
||||
|
||||
//pushing all limits with bounds obj
|
||||
var testBounds = new OpenLayers.Bounds(5, 10, 60, 90);
|
||||
object = testBounds.clone();
|
||||
|
||||
bounds.extend(object);
|
||||
t.ok(bounds.equals(testBounds), "extend by valid bounds, pushing all limits, correctly extends bounds");
|
||||
|
||||
//pushing no limits with bounds obj
|
||||
bounds = originalBounds.clone();
|
||||
|
||||
testBounds = new OpenLayers.Bounds(15, 30, 40, 70);
|
||||
object = testBounds.clone();
|
||||
|
||||
bounds.extend(object);
|
||||
t.ok(bounds.equals(originalBounds), "extend by valid bounds, pushing no limits, correctly does not extend bounds");
|
||||
|
||||
// obj is lonlat
|
||||
|
||||
//left, bottom
|
||||
bounds = originalBounds.clone();
|
||||
|
||||
object = new OpenLayers.LonLat(5, 10);
|
||||
|
||||
bounds.extend(object);
|
||||
|
||||
t.ok( ((bounds.left == object.lon) &&
|
||||
(bounds.bottom == object.lat) &&
|
||||
(bounds.right == originalBounds.right) &&
|
||||
(bounds.top == originalBounds.top)), "obj lonlat to extends correclty modifies left and bottom");
|
||||
|
||||
//right, top
|
||||
bounds = originalBounds.clone();
|
||||
|
||||
object = new OpenLayers.LonLat(60,90);
|
||||
|
||||
bounds.extend(object);
|
||||
|
||||
t.ok( ((bounds.left == originalBounds.left) &&
|
||||
(bounds.bottom == originalBounds.bottom) &&
|
||||
(bounds.right == object.lon) &&
|
||||
(bounds.top == object.lat)), "obj lonlat to extends correclty modifies right and top");
|
||||
|
||||
// obj is point
|
||||
|
||||
//left, bottom
|
||||
bounds = originalBounds.clone();
|
||||
|
||||
object = new OpenLayers.Geometry.Point(5, 10);
|
||||
|
||||
bounds.extend(object);
|
||||
|
||||
t.ok( ((bounds.left == object.lon) &&
|
||||
(bounds.bottom == object.lat) &&
|
||||
(bounds.right == originalBounds.right) &&
|
||||
(bounds.top == originalBounds.top)), "obj Point to extends correclty modifies left and bottom");
|
||||
|
||||
//right, top
|
||||
bounds = originalBounds.clone();
|
||||
|
||||
object = new OpenLayers.Geometry.Point(60,90);
|
||||
|
||||
bounds.extend(object);
|
||||
|
||||
t.ok( ((bounds.left == originalBounds.left) &&
|
||||
(bounds.bottom == originalBounds.bottom) &&
|
||||
(bounds.right == object.lon) &&
|
||||
(bounds.top == object.lat)), "obj Point to extends correclty modifies right and top");
|
||||
|
||||
}
|
||||
|
||||
// -->
|
||||
</script>
|
||||
</head>
|
||||
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
|
||||
var lonlat;
|
||||
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var pixel;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var Size;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var map;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var map;
|
||||
function test_01_Control_MouseToolbar_constructor (t) {
|
||||
@@ -20,8 +20,8 @@
|
||||
t.ok( map.controls[3] === control, "map.controls contains control" );
|
||||
t.eq( parseInt(control.div.style.zIndex), map.Z_INDEX_BASE['Control'] + 4, "Control div zIndexed properly" );
|
||||
t.eq( parseInt(map.viewPortDiv.lastChild.style.zIndex), map.Z_INDEX_BASE['Control'] + 4, "Viewport div contains control div" );
|
||||
t.eq( control.div.style.top, "300px", "Control div top located correctly by default");
|
||||
t.eq( control.div.style.left, "6px", "Control div left located correctly by default");
|
||||
t.eq( control.div.style.top, "300px", "Control div top located correctly by default");
|
||||
|
||||
}
|
||||
function test_03_Control_MouseToolbar_control_events (t) {
|
||||
@@ -0,0 +1,33 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var map;
|
||||
function test_01_Control_NavToolbar_constructor (t) {
|
||||
t.plan( 3 );
|
||||
control = new OpenLayers.Control.NavToolbar();
|
||||
t.ok( control instanceof OpenLayers.Control.NavToolbar, "new OpenLayers.Control.NavToolbar returns object" );
|
||||
t.ok( control.controls[0] instanceof OpenLayers.Control.Navigation, "NavToolbar contains Control.Navigation object" );
|
||||
t.ok( control.controls[1] instanceof OpenLayers.Control.ZoomBox, "NavToolbar contains Control.ZoomBox object" );
|
||||
}
|
||||
function test_02_Control_NavToolbar_addControl (t) {
|
||||
t.plan( 6 );
|
||||
map = new OpenLayers.Map('map');
|
||||
control = new OpenLayers.Control.NavToolbar();
|
||||
t.ok( control instanceof OpenLayers.Control.NavToolbar, "new OpenLayers.Control.NavToolbar returns object" );
|
||||
t.ok( map instanceof OpenLayers.Map, "new OpenLayers.Map creates map" );
|
||||
map.addControl(control);
|
||||
t.ok( control.map === map, "Control.map is set to the map object" );
|
||||
t.ok( map.controls[3] === control, "map.controls contains control" );
|
||||
t.eq( parseInt(control.div.style.zIndex), map.Z_INDEX_BASE['Control'] + 6, "Control div zIndexed properly" );
|
||||
t.eq( parseInt(map.viewPortDiv.lastChild.style.zIndex), map.Z_INDEX_BASE['Control'] + 6, "Viewport div contains control div" );
|
||||
// t.eq( control.div.style.top, "6px", "Control div top located correctly by default");
|
||||
|
||||
}
|
||||
// -->
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" style="width: 1024px; height: 512px;"/>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var map;
|
||||
function test_01_Control_PanZoom_constructor (t) {
|
||||
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var map;
|
||||
function test_01_Control_PanZoom_constructor (t) {
|
||||
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var map;
|
||||
function test_01_Control_PanZoomBar_constructor (t) {
|
||||
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var map;
|
||||
function test_01_Control_Permalink_constructor (t) {
|
||||
@@ -20,11 +20,10 @@
|
||||
if (!map.getCenter()) map.zoomToMaxExtent();
|
||||
map.addControl(control);
|
||||
map.pan(5, 0);
|
||||
var pm = OpenLayers.Util.getElement('permalink');
|
||||
if (/MSIE/.test(navigator.userAgent)) {
|
||||
t.eq(pm.href, "?lat=0&lon=1.75781&zoom=2&layers=B", "Panning sets permalink");
|
||||
t.eq(OpenLayers.Util.getElement('permalink').href, "?lat=0&lon=1.75781&zoom=2&layers=B", "Panning sets permalink");
|
||||
} else {
|
||||
t.eq(pm.href, location+"?lat=0&lon=1.75781&zoom=2&layers=B", "Panning sets permalink");
|
||||
t.eq(OpenLayers.Util.getElement('permalink').href, location+"?lat=0&lon=1.75781&zoom=2&layers=B", "Panning sets permalink");
|
||||
}
|
||||
}
|
||||
function test_03_Control_Permalink_updateLinksBase (t) {
|
||||
@@ -38,9 +37,8 @@
|
||||
if (!map.getCenter()) map.zoomToMaxExtent();
|
||||
map.addControl(control);
|
||||
map.pan(5, 0);
|
||||
var edit_pm = OpenLayers.Util.getElement('edit_permalink');
|
||||
edit_pm.href = './edit.html?lat=0&lon=1.75781&zoom=2&layers=B';
|
||||
t.eq(OpenLayers.Util.getElement('permalink').href, edit_pm.href, "Panning sets permalink with base");
|
||||
OpenLayers.Util.getElement('edit_permalink').href = './edit.html?lat=0&lon=1.75781&zoom=2&layers=B';
|
||||
t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with base");
|
||||
}
|
||||
function test_04_Control_Permalink_noElement (t) {
|
||||
t.plan( 2 );
|
||||
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var map;
|
||||
function test_01_Control_Scale_constructor (t) {
|
||||
@@ -19,13 +19,12 @@
|
||||
map.addLayer(layer);
|
||||
map.zoomTo(0);
|
||||
map.addControl(control);
|
||||
var scaleElem = OpenLayers.Util.getElement('scale');
|
||||
t.eq(scaleElem.innerHTML, "Scale = 1 : 443M", "Scale set by default." );
|
||||
t.eq(OpenLayers.Util.getElement('scale').innerHTML, "Scale = 1 : 443M", "Scale set by default." );
|
||||
map.zoomIn();
|
||||
t.eq(scaleElem.innerHTML, "Scale = 1 : 221M", "Zooming in changes scale" );
|
||||
t.eq(OpenLayers.Util.getElement('scale').innerHTML, "Scale = 1 : 221M", "Zooming in changes scale" );
|
||||
map.baseLayer.resolutions = [OpenLayers.Util.getResolutionFromScale(110)];
|
||||
map.zoomTo(0);
|
||||
t.eq(scaleElem.innerHTML, "Scale = 1 : 110", "Scale of 100 isn't rounded" );
|
||||
t.eq(OpenLayers.Util.getElement('scale').innerHTML, "Scale = 1 : 110", "Scale of 100 isn't rounded" );
|
||||
}
|
||||
function test_03_Control_Scale_internalScale (t) {
|
||||
t.plan(2);
|
||||
@@ -0,0 +1,24 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
|
||||
var map;
|
||||
var feature;
|
||||
|
||||
function test_01_Feature_Vector_constructor (t) {
|
||||
t.plan( 1 );
|
||||
|
||||
feature = new OpenLayers.Feature.Vector();
|
||||
|
||||
t.ok( feature instanceof OpenLayers.Feature.Vector, "new OpenLayers.Feature.Vector returns Feature.Vector object" );
|
||||
}
|
||||
|
||||
|
||||
// -->
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" style="width: 500px; height: 300px;"></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,215 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var coll;
|
||||
|
||||
function test_01_Collection_constructor (t) {
|
||||
t.plan( 4 );
|
||||
|
||||
//null param
|
||||
coll = new OpenLayers.Geometry.Collection();
|
||||
t.ok( coll instanceof OpenLayers.Geometry.Collection, "new OpenLayers.Geometry.Collection returns coll object" );
|
||||
t.eq( coll.CLASS_NAME, "OpenLayers.Geometry.Collection", "coll.CLASS_NAME is set correctly");
|
||||
t.eq( coll.components.length, 0, "coll.components is set correctly");
|
||||
|
||||
OpenLayers.Geometry.Collection.prototype._addComponents =
|
||||
OpenLayers.Geometry.Collection.prototype.addComponents;
|
||||
OpenLayers.Geometry.Collection.prototype.addComponents =
|
||||
function(comps) { g_addcomponents = comps; };
|
||||
|
||||
//valid param
|
||||
g_addcomponents = null;
|
||||
var components = {};
|
||||
coll = new OpenLayers.Geometry.Collection(components);
|
||||
t.ok(g_addcomponents, components, "addcomponents called on non-null param")
|
||||
|
||||
OpenLayers.Geometry.Collection.prototype.addComponents =
|
||||
OpenLayers.Geometry.Collection.prototype._addComponents;
|
||||
}
|
||||
|
||||
function test_02_Collection_addComponents (t) {
|
||||
t.plan( 10 );
|
||||
|
||||
coll = new OpenLayers.Geometry.Collection();
|
||||
|
||||
//null
|
||||
coll.addComponents(null);
|
||||
t.ok(true, "doesn't break on add null components");
|
||||
|
||||
OpenLayers.Geometry.Collection.prototype._addComponent =
|
||||
OpenLayers.Geometry.Collection.prototype.addComponent;
|
||||
|
||||
OpenLayers.Geometry.Collection.prototype.addComponent =
|
||||
function(comp) { g_addComp = comp; g_added++};
|
||||
|
||||
|
||||
//nonarray argument
|
||||
var g_added = 0;
|
||||
var g_addComp = 0;
|
||||
var component = {};
|
||||
coll.addComponents(component);
|
||||
t.eq(g_added, 1, "added once");
|
||||
t.eq(g_addComp, component, "added component");
|
||||
|
||||
//array arg
|
||||
var g_added = 0;
|
||||
var g_addComp = 0;
|
||||
var component1 = {};
|
||||
var component2 = {};
|
||||
coll.addComponents([component1, component2]);
|
||||
t.eq(g_added, 2, "added twice");
|
||||
t.eq(g_addComp, component2, "added component");
|
||||
|
||||
OpenLayers.Geometry.Collection.prototype.addComponent =
|
||||
OpenLayers.Geometry.Collection.prototype._addComponent;
|
||||
|
||||
|
||||
|
||||
coll.addComponents(new OpenLayers.Geometry.Point(0,0));
|
||||
coll.addComponents(new OpenLayers.Geometry.Point(10,10));
|
||||
t.eq( coll.components.length, 2, "added two components to collection" );
|
||||
bounds = coll.getBounds();
|
||||
t.eq( bounds.left, 0, "left bound is 0" );
|
||||
t.eq( bounds.bottom, 0, "bottom bound is 0" );
|
||||
t.eq( bounds.right, 10, "right bound is 10" );
|
||||
t.eq( bounds.top, 10, "top bound is 10" );
|
||||
}
|
||||
|
||||
function test_03_Collection_clone (t) {
|
||||
t.plan( 3 );
|
||||
coll = new OpenLayers.Geometry.Collection();
|
||||
coll.addComponents(new OpenLayers.Geometry.Point(0,0));
|
||||
coll.addComponents(new OpenLayers.Geometry.Point(10,10));
|
||||
coll2 = coll.clone();
|
||||
t.ok( coll2 instanceof OpenLayers.Geometry.Collection, "coll.clone() returns collection object" );
|
||||
t.eq( coll2.getComponents().length, 2, "coll2.components.length is set correctly");
|
||||
t.ok( coll2.components[0] instanceof OpenLayers.Geometry.Point,
|
||||
"coll2.components.length is set correctly");
|
||||
}
|
||||
|
||||
function test_04_Collection_removeComponents (t) {
|
||||
t.plan( 4 );
|
||||
coll = new OpenLayers.Geometry.Collection();
|
||||
point = new OpenLayers.Geometry.Point(0,0);
|
||||
coll.addComponents(point);
|
||||
coll.addComponents(new OpenLayers.Geometry.Point(10,10));
|
||||
coll.removeComponents(coll.components[0]);
|
||||
t.eq( coll.getComponents().length, 1, "coll.components.length is smaller after removeComponent" );
|
||||
t.ok( coll.bounds == null, "bounds are nullified after call to remove (to trigger recalc on getBounds()");
|
||||
bounds = coll.getBounds();
|
||||
t.eq( bounds.left, 10, "left bound is 10 after removeComponent" );
|
||||
t.eq( bounds.bottom, 10, "bottom bound is 10 after removeComponent" );
|
||||
}
|
||||
|
||||
function test_05_Collection_getComponents (t) {
|
||||
t.plan(1);
|
||||
|
||||
coll = new OpenLayers.Geometry.Collection();
|
||||
coll.components = {};
|
||||
|
||||
t.eq( coll.getComponents(), coll.components, "getComponents returns great");
|
||||
}
|
||||
|
||||
function test_06_Collection_calculateBounds(t) {
|
||||
t.plan( 9 );
|
||||
|
||||
var coll = new OpenLayers.Geometry.Collection();
|
||||
coll.calculateBounds();
|
||||
t.eq(coll.bounds, null, "null components list gives null bounds on calculation()");
|
||||
|
||||
var p1 = new OpenLayers.Geometry.Point(10,20);
|
||||
var p2 = new OpenLayers.Geometry.Point(30,40);
|
||||
|
||||
var components = [p1, p2];
|
||||
coll = new OpenLayers.Geometry.Collection(components);
|
||||
|
||||
coll.calculateBounds();
|
||||
|
||||
t.eq(coll.bounds.left, 10, "good left bounds");
|
||||
t.eq(coll.bounds.bottom, 20, "good bottom bounds");
|
||||
t.eq(coll.bounds.right, 30, "good right bounds");
|
||||
t.eq(coll.bounds.top, 40, "good top bounds");
|
||||
|
||||
var newPoint = new OpenLayers.Geometry.Point(60,70);
|
||||
coll.addComponent(newPoint);
|
||||
coll.calculateBounds();
|
||||
|
||||
t.eq(coll.bounds.left, 10, "good left bounds");
|
||||
t.eq(coll.bounds.bottom, 20, "good bottom bounds");
|
||||
t.eq(coll.bounds.right, 60, "good right bounds");
|
||||
t.eq(coll.bounds.top, 70, "good top bounds");
|
||||
}
|
||||
|
||||
function test_07_Collection_addComponent(t) {
|
||||
t.plan(3);
|
||||
|
||||
var coll = new OpenLayers.Geometry.Collection();
|
||||
|
||||
//null
|
||||
coll.addComponent(null);
|
||||
t.ok(true, "no breakage, no executage from null input")
|
||||
|
||||
//good component
|
||||
var component = new OpenLayers.Geometry.Point(3,4);
|
||||
coll.addComponent(component);
|
||||
|
||||
t.ok(coll.bounds == null, "bounds cache correctly cleared");
|
||||
|
||||
var foundComponent = false;
|
||||
for(var i=0; i< coll.components.length; i++) {
|
||||
if (coll.components[i].equals(component)) {
|
||||
foundComponent = true;
|
||||
}
|
||||
}
|
||||
t.ok(foundComponent, "component added to internal array");
|
||||
|
||||
}
|
||||
|
||||
function test_08_collection_getLength(t) {
|
||||
t.plan(2);
|
||||
|
||||
//null
|
||||
var coll = new OpenLayers.Geometry.Collection();
|
||||
t.eq( coll.getLength(), 0, "null coll has 0 getlength");
|
||||
|
||||
//valid
|
||||
coll.components = [
|
||||
{ 'getLength': function() { return 50; } },
|
||||
{ 'getLength': function() { return 15; } }
|
||||
];
|
||||
t.eq( coll.getLength(), 65, "coll with valid components correctly sums getlength");
|
||||
}
|
||||
|
||||
function test_09_collection_getArea(t) {
|
||||
t.plan(2);
|
||||
|
||||
//null
|
||||
var coll = new OpenLayers.Geometry.Collection();
|
||||
t.eq( coll.getArea(), 0, "null coll has 0 getArea");
|
||||
|
||||
//valid
|
||||
coll.components = [
|
||||
{ 'getArea': function() { return 50; } },
|
||||
{ 'getArea': function() { return 15; } }
|
||||
];
|
||||
t.eq( coll.getArea(), 65, "coll with valid components correctly sums getArea");
|
||||
}
|
||||
|
||||
function test_99_Collection_destroy(t) {
|
||||
t.plan( 1 );
|
||||
coll = new OpenLayers.Geometry.Collection();
|
||||
coll.components = {};
|
||||
|
||||
coll.destroy();
|
||||
|
||||
t.ok(coll.components == null, "components array cleared");
|
||||
|
||||
}
|
||||
|
||||
// -->
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,157 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var curve;
|
||||
var components = [new OpenLayers.Geometry.Point(10,10),
|
||||
new OpenLayers.Geometry.Point(0,0)];
|
||||
|
||||
function test_01_Curve_constructor (t) {
|
||||
t.plan( 3 );
|
||||
curve = new OpenLayers.Geometry.Curve();
|
||||
t.ok( curve instanceof OpenLayers.Geometry.Curve, "new OpenLayers.Geometry.Curve returns curve object" );
|
||||
t.eq( curve.CLASS_NAME, "OpenLayers.Geometry.Curve", "curve.CLASS_NAME is set correctly");
|
||||
t.eq( curve.components, [], "curve.components is set correctly");
|
||||
}
|
||||
|
||||
function test_01a_Curve_constructor (t) {
|
||||
t.plan( 2 );
|
||||
curve = new OpenLayers.Geometry.Curve(components);
|
||||
t.ok( curve instanceof OpenLayers.Geometry.Curve, "new OpenLayers.Geometry.Curve returns curve object" );
|
||||
t.eq( curve.components.length, 2, "curve.components.length is set correctly");
|
||||
}
|
||||
|
||||
function test_02_Curve_clone (t) {
|
||||
t.plan( 2 );
|
||||
curve = new OpenLayers.Geometry.Curve(components);
|
||||
curve2 = curve.clone();
|
||||
t.ok( curve2 instanceof OpenLayers.Geometry.Curve, "curve.clone() returns curve object" );
|
||||
t.eq( curve2.components.length, 2, "curve2.components.length is set correctly");
|
||||
}
|
||||
|
||||
function test_03_Curve_calculateBounds(t) {
|
||||
t.plan( 17 );
|
||||
|
||||
|
||||
var curve = new OpenLayers.Geometry.Curve();
|
||||
curve.calculateBounds();
|
||||
t.eq(curve.bounds, null, "bounds null when no components");
|
||||
|
||||
var p1 = new OpenLayers.Geometry.Point(10,20);
|
||||
var p2 = new OpenLayers.Geometry.Point(30,40);
|
||||
|
||||
var components = [p1, p2];
|
||||
var curve = new OpenLayers.Geometry.Curve(components);
|
||||
|
||||
curve.calculateBounds();
|
||||
|
||||
t.eq(curve.bounds.left, 10, "good left bounds");
|
||||
t.eq(curve.bounds.bottom, 20, "good bottom bounds");
|
||||
t.eq(curve.bounds.right, 30, "good right bounds");
|
||||
t.eq(curve.bounds.top, 40, "good top bounds");
|
||||
|
||||
var newPoint = new OpenLayers.Geometry.Point(60,70);
|
||||
curve.addComponent(newPoint);
|
||||
curve.calculateBounds();
|
||||
|
||||
t.eq(curve.bounds.left, 10, "good left bounds");
|
||||
t.eq(curve.bounds.bottom, 20, "good bottom bounds");
|
||||
t.eq(curve.bounds.right, 60, "good right bounds");
|
||||
t.eq(curve.bounds.top, 70, "good top bounds");
|
||||
|
||||
//nullifying the bounds
|
||||
|
||||
//before calculation
|
||||
curve = new OpenLayers.Geometry.Curve(components);
|
||||
curve.bounds = null;
|
||||
curve.calculateBounds();
|
||||
|
||||
t.eq(curve.bounds.left, 10, "good left bounds");
|
||||
t.eq(curve.bounds.bottom, 20, "good bottom bounds");
|
||||
t.eq(curve.bounds.right, 30, "good right bounds");
|
||||
t.eq(curve.bounds.top, 40, "good top bounds");
|
||||
|
||||
//before addComponent
|
||||
curve.bounds = null;
|
||||
curve.addComponent(newPoint);
|
||||
curve.calculateBounds();
|
||||
|
||||
t.eq(curve.bounds.left, 10, "good left bounds");
|
||||
t.eq(curve.bounds.bottom, 20, "good bottom bounds");
|
||||
t.eq(curve.bounds.right, 60, "good right bounds");
|
||||
t.eq(curve.bounds.top, 70, "good top bounds");
|
||||
|
||||
}
|
||||
|
||||
function test_04_Curve_addComponent (t) {
|
||||
t.plan( 8 );
|
||||
curve = new OpenLayers.Geometry.Curve(components);
|
||||
curve.addComponent(new OpenLayers.Geometry.Point(20,30));
|
||||
bounds = curve.getBounds();
|
||||
t.eq( curve.components.length, 3, "new point added to array" );
|
||||
t.eq( bounds.top, 30, "top bound is 30 after addComponent" );
|
||||
t.eq( bounds.right, 20, "right bound is 20 after addComponent" );
|
||||
curve.addComponent(new OpenLayers.Geometry.Point(-20,-30), 1);
|
||||
bounds = curve.getBounds();
|
||||
t.eq( curve.components.length, 4, "new point added to array" );
|
||||
t.eq( bounds.bottom, -30, "bottom bound is -30 after 2nd addComponent" );
|
||||
t.eq( bounds.left, -20, "left bound is 20 after 2nd addComponent" );
|
||||
t.eq( curve.components[1].lon, -20, "new point.lon is -20 (index worked)" );
|
||||
t.eq( curve.components[1].lat, -30, "new point.lat is -30 (index worked)" );
|
||||
}
|
||||
|
||||
function test_05_Curve_removeComponent (t) {
|
||||
t.plan( 4 );
|
||||
curve = new OpenLayers.Geometry.Curve(components);
|
||||
curve.removeComponent(curve.components[1]);
|
||||
t.eq( curve.components.length, 1, "curve.components.length is smaller after removeComponent" );
|
||||
t.eq( curve.bounds, null, "curve.bounds nullified after removeComponent (for recalculation)" );
|
||||
bounds = curve.getBounds();
|
||||
t.eq( bounds.left, 10, "left bound is 10 after removeComponent" );
|
||||
t.eq( bounds.bottom, 10, "bottom bound is 10 after removeComponent" );
|
||||
}
|
||||
|
||||
function test_06_Curve_getLength (t) {
|
||||
t.plan( 4 );
|
||||
|
||||
//no components
|
||||
curve = new OpenLayers.Geometry.Curve();
|
||||
curve.components = null;
|
||||
t.eq(curve.getLength(), 0, "curve with no components has length 0");
|
||||
|
||||
//empty components
|
||||
curve.components = [];
|
||||
t.eq(curve.getLength(), 0, "curve with empty components has length 0");
|
||||
|
||||
//single point curve
|
||||
curve.components = [ new OpenLayers.Geometry.Point(0,0) ];
|
||||
t.eq(curve.getLength(), 0, "curve with only one point has length 0");
|
||||
|
||||
//multipoint
|
||||
var newcomponents = [ new OpenLayers.Geometry.Point(0,0),
|
||||
new OpenLayers.Geometry.Point(0,10),
|
||||
new OpenLayers.Geometry.Point(20,10),
|
||||
new OpenLayers.Geometry.Point(20,-10)
|
||||
];
|
||||
|
||||
curve = new OpenLayers.Geometry.Curve(newcomponents);
|
||||
t.eq(curve.getLength(), 50, "curve.getLength returns a reasonably accurate length" );
|
||||
}
|
||||
|
||||
function test_07_Curve_destroy(t) {
|
||||
t.plan(1);
|
||||
|
||||
var curve = new OpenLayers.Geometry.Curve();
|
||||
curve.components = {};
|
||||
|
||||
curve.destroy();
|
||||
|
||||
t.ok( curve.components == null, "components is cleared well in destruction");
|
||||
}
|
||||
|
||||
// -->
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,82 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var line;
|
||||
var components = [new OpenLayers.Geometry.Point(10,15),
|
||||
new OpenLayers.Geometry.Point(0,0)];
|
||||
|
||||
function test_01_LineString_constructor (t) {
|
||||
t.plan( 3 );
|
||||
line = new OpenLayers.Geometry.LineString();
|
||||
t.ok( line instanceof OpenLayers.Geometry.LineString, "new OpenLayers.Geometry.LineString returns line object" );
|
||||
t.eq( line.CLASS_NAME, "OpenLayers.Geometry.LineString", "line.CLASS_NAME is set correctly");
|
||||
t.eq( line.components, [], "line.components is set correctly");
|
||||
}
|
||||
|
||||
function test_01a_LineString_constructor (t) {
|
||||
t.plan( 3 );
|
||||
line = new OpenLayers.Geometry.LineString(components);
|
||||
t.ok( line instanceof OpenLayers.Geometry.LineString, "new OpenLayers.Geometry.LineString returns line object" );
|
||||
t.eq( line.CLASS_NAME, "OpenLayers.Geometry.LineString", "line.CLASS_NAME is set correctly");
|
||||
// TBD FIXME, recursion
|
||||
// t.eq( line.components, components, "line.components is set correctly");
|
||||
t.eq( line.components.length, 2, "line.components.length is set correctly");
|
||||
}
|
||||
|
||||
function test_02_LineString_toString(t) {
|
||||
t.plan(1);
|
||||
|
||||
line = new OpenLayers.Geometry.LineString(components);
|
||||
t.eq( line.toString(), components.toString(), "toString output checks in");
|
||||
}
|
||||
|
||||
function test_03_LineString_removeComponent(t) {
|
||||
t.plan(2);
|
||||
|
||||
OpenLayers.Geometry.Curve.prototype._removeComponent =
|
||||
OpenLayers.Geometry.Curve.prototype.removeComponent;
|
||||
OpenLayers.Geometry.Curve.prototype.removeComponent =
|
||||
function(point) { g_removeComponent = point; };
|
||||
|
||||
line = new OpenLayers.Geometry.LineString(components);
|
||||
|
||||
g_removeComponent = null;
|
||||
line.removeComponent(components[0]);
|
||||
t.ok(g_removeComponent == null, "point not removed if only 2 points in components");
|
||||
|
||||
line.components.push(new OpenLayers.Geometry.Point(4,4));
|
||||
line.removeComponent(components[0]);
|
||||
t.ok(g_removeComponent, components[0], "point removed if 3 points in components");
|
||||
|
||||
OpenLayers.Geometry.Curve.prototype.removeComponent =
|
||||
OpenLayers.Geometry.Curve.prototype._removeComponent;
|
||||
}
|
||||
|
||||
function test_04_LineString_move(t) {
|
||||
t.plan(4);
|
||||
|
||||
line = new OpenLayers.Geometry.LineString(components);
|
||||
|
||||
var x0 = components[0].x;
|
||||
var y0 = components[0].y;
|
||||
var x1 = components[1].x;
|
||||
var y1 = components[1].y;
|
||||
|
||||
var dx = 10 * Math.random();
|
||||
var dy = 10 * Math.random();
|
||||
line.move(dx, dy);
|
||||
|
||||
t.eq(line.components[0].x, x0 + dx, "move() correctly modifies first x");
|
||||
t.eq(line.components[0].y, y0 + dy, "move() correctly modifies first y");
|
||||
t.eq(line.components[1].x, x1 + dx, "move() correctly modifies second x");
|
||||
t.eq(line.components[1].y, y1 + dy, "move() correctly modifies second y");
|
||||
}
|
||||
|
||||
|
||||
// -->
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,98 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var line;
|
||||
var components = [new OpenLayers.Geometry.Point(10,10),
|
||||
new OpenLayers.Geometry.Point(0,0)];
|
||||
|
||||
function test_01_LinearRing_constructor (t) {
|
||||
t.plan( 6 );
|
||||
|
||||
//null
|
||||
ring = new OpenLayers.Geometry.LinearRing();
|
||||
t.ok( ring instanceof OpenLayers.Geometry.LinearRing, "new OpenLayers.Geometry.LinearRing returns ring object" );
|
||||
t.eq( ring.CLASS_NAME, "OpenLayers.Geometry.LinearRing", "ring.CLASS_NAME is set correctly");
|
||||
t.eq( ring.components, [], "ring.components is set correctly");
|
||||
|
||||
//valid components
|
||||
ring = new OpenLayers.Geometry.LinearRing(components);
|
||||
t.ok( ring instanceof OpenLayers.Geometry.LinearRing, "new OpenLayers.Geometry.LinearRing returns ring object" );
|
||||
t.eq( ring.CLASS_NAME, "OpenLayers.Geometry.LinearRing", "ring.CLASS_NAME is set correctly");
|
||||
t.eq( ring.components.length, 3, "ring.components.length is set correctly");
|
||||
}
|
||||
|
||||
function test_02_LinearRing_addComponent(t) {
|
||||
t.plan(12);
|
||||
|
||||
var ring = new OpenLayers.Geometry.LinearRing();
|
||||
|
||||
var point = new OpenLayers.Geometry.Point(0,0);
|
||||
ring.addComponent( point );
|
||||
t.eq(ring.components.length, 2, "add first point, correct length");
|
||||
t.ok(ring.components[0].equals(point), "point one correct");
|
||||
t.ok(ring.components[0].equals(ring.components[ring.components.length - 1]), "first and last point equal");
|
||||
|
||||
ring.addComponent( point );
|
||||
t.eq(ring.components.length, 3, "add second point, correct length");
|
||||
t.ok(ring.components[0].equals(point), "point one correct");
|
||||
t.ok(ring.components[1].equals(point), "point two correct");
|
||||
t.ok(ring.components[0].equals(ring.components[ring.components.length - 1]), "first and last point equal");
|
||||
|
||||
newPoint = new OpenLayers.Geometry.Point(10,10);
|
||||
ring.addComponent( newPoint );
|
||||
t.eq(ring.components.length, 4, "correctly adds 3rd point");
|
||||
t.ok(ring.components[0].equals(point), "point one correct");
|
||||
t.ok(ring.components[1].equals(point), "point two correct");
|
||||
t.ok(ring.components[2].equals(newPoint), "point one correct");
|
||||
t.ok(ring.components[0].equals(ring.components[ring.components.length - 1]), "first and last point equal");
|
||||
}
|
||||
|
||||
function test_03_LinearRing_removeComponent(t) {
|
||||
t.plan(11);
|
||||
|
||||
var components = [new OpenLayers.Geometry.Point(0,0),
|
||||
new OpenLayers.Geometry.Point(0,10),
|
||||
new OpenLayers.Geometry.Point(15,15),
|
||||
new OpenLayers.Geometry.Point(10,0)
|
||||
];
|
||||
var ring = new OpenLayers.Geometry.LinearRing(components);
|
||||
|
||||
ring.removeComponent( ring.components[2] );
|
||||
t.eq(ring.components.length, 4, "removing from linear ring with 5 points: length ok");
|
||||
t.ok(ring.components[0].equals(components[0]), "point one correct");
|
||||
t.ok(ring.components[1].equals(components[1]), "point two correct");
|
||||
t.ok(ring.components[2].equals(components[3]), "point one correct");
|
||||
t.ok(ring.components[0].equals(ring.components[ring.components.length - 1]), "first and last point equal");
|
||||
|
||||
var testBounds = new OpenLayers.Bounds(0,0,10,10);
|
||||
var ringBounds = ring.getBounds();
|
||||
t.ok(ringBounds.equals(testBounds), "bounds correctly recalculated");
|
||||
|
||||
ring.removeComponent( ring.components[2] );
|
||||
t.eq(ring.components.length, 4, "cant remove from linear ring with only 4 points. new length ok (unchanged)");
|
||||
t.ok(ring.components[0].equals(components[0]), "point one correct");
|
||||
t.ok(ring.components[1].equals(components[1]), "point two correct");
|
||||
t.ok(ring.components[2].equals(components[3]), "point one correct");
|
||||
t.ok(ring.components[0].equals(ring.components[ring.components.length - 1]), "first and last point equal");
|
||||
|
||||
}
|
||||
|
||||
function test_04_LinearRing_getArea(t) {
|
||||
t.plan(1);
|
||||
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);
|
||||
|
||||
t.eq(ring.getArea(), 100, "getArea works lovely");
|
||||
}
|
||||
|
||||
// -->
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,29 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var line;
|
||||
|
||||
function test_01_MultiLineString_constructor (t) {
|
||||
t.plan( 3 );
|
||||
mline = new OpenLayers.Geometry.MultiLineString();
|
||||
t.ok( mline instanceof OpenLayers.Geometry.MultiLineString, "new OpenLayers.Geometry.MultiLineString returns mline object" );
|
||||
t.eq( mline.CLASS_NAME, "OpenLayers.Geometry.MultiLineString", "mline.CLASS_NAME is set correctly");
|
||||
t.eq( mline.components, [], "line.components is set correctly");
|
||||
}
|
||||
|
||||
function test_01a_MultiLineString_constructor (t) {
|
||||
t.plan( 3 );
|
||||
line = new OpenLayers.Geometry.LineString();
|
||||
mline = new OpenLayers.Geometry.MultiLineString(line);
|
||||
t.ok( mline instanceof OpenLayers.Geometry.MultiLineString, "new OpenLayers.Geometry.MultiLineString returns mline object" );
|
||||
t.eq( mline.CLASS_NAME, "OpenLayers.Geometry.MultiLineString", "mline.CLASS_NAME is set correctly");
|
||||
t.eq( mline.components.length, 1, "mline.components.length is set correctly");
|
||||
}
|
||||
|
||||
// -->
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,44 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var point = new OpenLayers.Geometry.Point(10, 15);
|
||||
|
||||
|
||||
function test_01_MultiPoint_constructor (t) {
|
||||
t.plan( 2 );
|
||||
multipoint = new OpenLayers.Geometry.MultiPoint();
|
||||
t.ok( multipoint instanceof OpenLayers.Geometry.MultiPoint, "new OpenLayers.Geometry.MultiPoint returns multipoint object" );
|
||||
t.eq( multipoint.CLASS_NAME, "OpenLayers.Geometry.MultiPoint", "multipoint.CLASS_NAME is set correctly");
|
||||
}
|
||||
|
||||
function test_01a_MultiPoint_constructor (t) {
|
||||
t.plan( 3 );
|
||||
multipoint = new OpenLayers.Geometry.MultiPoint([point]);
|
||||
t.ok( multipoint instanceof OpenLayers.Geometry.MultiPoint, "new OpenLayers.Geometry.MultiPoint returns multipoint object" );
|
||||
t.eq( multipoint.CLASS_NAME, "OpenLayers.Geometry.MultiPoint", "multipoint.CLASS_NAME is set correctly");
|
||||
t.eq( multipoint.components.length, 1, "multipolygon.components.length is set correctly");
|
||||
}
|
||||
|
||||
function test_02_MultiPoint_move(t) {
|
||||
t.plan(4);
|
||||
|
||||
multipoint = new OpenLayers.Geometry.MultiPoint([point]);
|
||||
var x = point.x;
|
||||
var y = point.y;
|
||||
|
||||
var dx = 10 * Math.random();
|
||||
var dy = 10 * Math.random();
|
||||
multipoint.move(dx, dy);
|
||||
t.eq(multipoint.components[0].x, x + dx, "move() correctly modifies x");
|
||||
t.eq(multipoint.components[0].y, y + dy, "move() correctly modifies y");
|
||||
t.eq(multipoint.components[0].lon, x + dx, "move() correctly modifies lon");
|
||||
t.eq(multipoint.components[0].lat, y + dy, "move() correctly modifies lat");
|
||||
}
|
||||
|
||||
// -->
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,34 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var polygon;
|
||||
var components = [new OpenLayers.Geometry.Point(10,10), new OpenLayers.Geometry.Point(0,0)];
|
||||
var components2 = [new OpenLayers.Geometry.Point(10,10), new OpenLayers.Geometry.Point(0,0), new OpenLayers.Geometry.Point(10,0), new OpenLayers.Geometry.Point(10,10)];
|
||||
var linearRing = new OpenLayers.Geometry.LinearRing(components);
|
||||
var linearRing2 = new OpenLayers.Geometry.LinearRing(components2);
|
||||
|
||||
var polygon = new OpenLayers.Geometry.Polygon([linearRing]);
|
||||
var polygon2 = new OpenLayers.Geometry.Polygon([linearRing2]);
|
||||
|
||||
function test_01_MultiPolygon_constructor (t) {
|
||||
t.plan( 2 );
|
||||
multipolygon = new OpenLayers.Geometry.MultiPolygon();
|
||||
t.ok( multipolygon instanceof OpenLayers.Geometry.MultiPolygon, "new OpenLayers.Geometry.MultiPolygon returns multipolygon object" );
|
||||
t.eq( multipolygon.CLASS_NAME, "OpenLayers.Geometry.MultiPolygon", "multipolygon.CLASS_NAME is set correctly");
|
||||
}
|
||||
|
||||
function test_01a_MultiPolygon_constructor (t) {
|
||||
t.plan( 3 );
|
||||
multipolygon = new OpenLayers.Geometry.MultiPolygon([polygon, polygon2]);
|
||||
t.ok( multipolygon instanceof OpenLayers.Geometry.MultiPolygon, "new OpenLayers.Geometry.MultiPolygon returns multipolygon object" );
|
||||
t.eq( multipolygon.CLASS_NAME, "OpenLayers.Geometry.MultiPolygon", "multipolygon.CLASS_NAME is set correctly");
|
||||
t.eq( multipolygon.components.length, 2, "multipolygon.components.length is set correctly");
|
||||
}
|
||||
|
||||
// -->
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,112 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var point;
|
||||
|
||||
function test_01_Point_constructor (t) {
|
||||
t.plan( 8 );
|
||||
|
||||
//empty
|
||||
point = new OpenLayers.Geometry.Point();
|
||||
t.ok( point instanceof OpenLayers.Geometry.Point, "new OpenLayers.Geometry.Point returns point object" );
|
||||
t.eq( point.CLASS_NAME, "OpenLayers.Geometry.Point", "point.CLASS_NAME is set correctly");
|
||||
|
||||
//valid
|
||||
var x = 10;
|
||||
var y = 20;
|
||||
point = new OpenLayers.Geometry.Point(x, y);
|
||||
t.ok( point instanceof OpenLayers.Geometry.Point, "new OpenLayers.Geometry.Point returns point object" );
|
||||
t.eq( point.CLASS_NAME, "OpenLayers.Geometry.Point", "point.CLASS_NAME is set correctly");
|
||||
t.eq( point.x, x, "point.x is set correctly");
|
||||
t.eq( point.y, y, "point.y is set correctly");
|
||||
t.eq( point.lon, x, "point.lon is set correctly");
|
||||
t.eq( point.lat, y, "point.lat is set correctly");
|
||||
}
|
||||
|
||||
function test_02_Point_accessors(t) {
|
||||
t.plan( 6 )
|
||||
|
||||
//valid
|
||||
var x = 10;
|
||||
var y = 20;
|
||||
point = new OpenLayers.Geometry.Point(x, y);
|
||||
|
||||
t.eq( point.getX(), x, "point.x is get() correctly");
|
||||
t.eq( point.getY(), y, "point.y is get() correctly");
|
||||
|
||||
var x1 = 55;
|
||||
var y1 = 73;
|
||||
|
||||
point.setX(x1);
|
||||
point.setY(y1);
|
||||
|
||||
t.eq( point.x, x1, "point.x is set() correctly");
|
||||
t.eq( point.y, y1, "point.y is set() correctly");
|
||||
t.eq( point.lon, x1, "point.lon is set() correctly");
|
||||
t.eq( point.lat, y1, "point.lat is set() correctly");
|
||||
|
||||
}
|
||||
|
||||
function test_03_Point_calculateBounds (t) {
|
||||
t.plan(4);
|
||||
|
||||
var x = 10;
|
||||
var y = 20;
|
||||
point = new OpenLayers.Geometry.Point(x, y);
|
||||
point.calculateBounds();
|
||||
t.eq( point.bounds.left, x, "bounds.left is 10" );
|
||||
t.eq( point.bounds.right, x, "bounds.right is 10" );
|
||||
t.eq( point.bounds.top, y, "bounds.top is 20" );
|
||||
t.eq( point.bounds.bottom, y, "bounds.bottom is 20" );
|
||||
}
|
||||
|
||||
function test_04_Point_distanceTo(t) {
|
||||
t.plan(2);
|
||||
|
||||
var x1 = 10;
|
||||
var y1 = 20;
|
||||
point1 = new OpenLayers.Geometry.Point(x1, y1);
|
||||
|
||||
var x2 = 100;
|
||||
var y2 = 200;
|
||||
point2 = new OpenLayers.Geometry.Point(x2, y2);
|
||||
|
||||
var dist = point1.distanceTo(point2)
|
||||
t.eq( dist, 201.24611797498107267682563018581, "distances calculating correctly");
|
||||
t.eq( dist, Math.sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)), "distance calculation correct");
|
||||
}
|
||||
|
||||
function test_05_Point_toString(t) {
|
||||
t.plan(1);
|
||||
|
||||
var x = 10;
|
||||
var y = 20;
|
||||
point = new OpenLayers.Geometry.Point(x, y);
|
||||
bounds = point.getBounds();
|
||||
t.eq( point.toString(), x + ", " + y, "toString() works" );
|
||||
|
||||
}
|
||||
|
||||
function test_06_Point_move(t) {
|
||||
t.plan(4);
|
||||
|
||||
var x = 10;
|
||||
var y = 20;
|
||||
point = new OpenLayers.Geometry.Point(x, y);
|
||||
|
||||
var dx = 10 * Math.random();
|
||||
var dy = 10 * Math.random();
|
||||
point.move(dx, dy);
|
||||
t.eq(point.x, x + dx, "move() correctly modifies x");
|
||||
t.eq(point.y, y + dy, "move() correctly modifies y");
|
||||
t.eq(point.lon, x + dx, "move() correctly modifies lon");
|
||||
t.eq(point.lat, y + dy, "move() correctly modifies lat");
|
||||
}
|
||||
|
||||
// -->
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,114 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var polygon;
|
||||
var components = [new OpenLayers.Geometry.Point(10,14), new OpenLayers.Geometry.Point(5,3)];
|
||||
var components2 = [new OpenLayers.Geometry.Point(12,15), new OpenLayers.Geometry.Point(2,3), new OpenLayers.Geometry.Point(10,0), new OpenLayers.Geometry.Point(10,10)];
|
||||
var linearRing = new OpenLayers.Geometry.LinearRing(components);
|
||||
var linearRing2 = new OpenLayers.Geometry.LinearRing(components2);
|
||||
|
||||
function test_01_Polygon_constructor (t) {
|
||||
t.plan( 3 );
|
||||
polygon = new OpenLayers.Geometry.Polygon();
|
||||
t.ok( polygon instanceof OpenLayers.Geometry.Polygon, "new OpenLayers.Geometry.Polygon returns polygon object" );
|
||||
t.eq( polygon.CLASS_NAME, "OpenLayers.Geometry.Polygon", "polygon.CLASS_NAME is set correctly");
|
||||
t.eq( polygon.components.length, 0, "polygon.components is set correctly");
|
||||
}
|
||||
|
||||
function test_01a_Polygon_constructor (t) {
|
||||
t.plan( 3 );
|
||||
polygon = new OpenLayers.Geometry.Polygon([linearRing]);
|
||||
t.ok( polygon instanceof OpenLayers.Geometry.Polygon, "new OpenLayers.Geometry.Polygon returns polygon object" );
|
||||
t.eq( polygon.CLASS_NAME, "OpenLayers.Geometry.Polygon", "polygon.CLASS_NAME is set correctly");
|
||||
t.eq( polygon.components.length, 1, "polygon.components.length is set correctly");
|
||||
}
|
||||
|
||||
function test_01b_Polygon_constructor (t) {
|
||||
t.plan( 3 );
|
||||
polygon = new OpenLayers.Geometry.Polygon([linearRing, linearRing2]);
|
||||
t.ok( polygon instanceof OpenLayers.Geometry.Polygon, "new OpenLayers.Geometry.Polygon returns polygon object" );
|
||||
t.eq( polygon.CLASS_NAME, "OpenLayers.Geometry.Polygon", "polygon.CLASS_NAME is set correctly");
|
||||
t.eq( polygon.components.length, 2, "polygon.components.length is set correctly");
|
||||
}
|
||||
|
||||
function test_02_Polygon_getArea(t) {
|
||||
t.plan( 5 );
|
||||
|
||||
//no components
|
||||
var polygon = new OpenLayers.Geometry.Polygon();
|
||||
t.eq(polygon.getArea(), 0, "getArea empty polygon is 0");
|
||||
|
||||
var createSquareRing = function(area) {
|
||||
var points = [
|
||||
new OpenLayers.Geometry.Point(0, 0),
|
||||
new OpenLayers.Geometry.Point(0, area),
|
||||
new OpenLayers.Geometry.Point(area, area),
|
||||
new OpenLayers.Geometry.Point(area, 0)
|
||||
];
|
||||
var ring = new OpenLayers.Geometry.LinearRing(points);
|
||||
return ring;
|
||||
};
|
||||
|
||||
|
||||
//simple polygon
|
||||
var comps = [ createSquareRing(2) ];
|
||||
|
||||
var polygon = new OpenLayers.Geometry.Polygon(comps);
|
||||
t.eq(polygon.getArea(), 4, "getArea simple polygon works lovely");
|
||||
|
||||
//polygon with holes
|
||||
comps = [ createSquareRing(10),
|
||||
createSquareRing(2),
|
||||
createSquareRing(3),
|
||||
createSquareRing(4),
|
||||
];
|
||||
|
||||
var polygon = new OpenLayers.Geometry.Polygon(comps);
|
||||
t.eq(polygon.getArea(), 71, "getArea polygon with holes works lovely");
|
||||
|
||||
//simple polygon negative
|
||||
comps = [ createSquareRing(-2) ];
|
||||
|
||||
var polygon = new OpenLayers.Geometry.Polygon(comps);
|
||||
t.eq(polygon.getArea(), 4, "getArea simple polygon negative works lovely");
|
||||
|
||||
//polygon with holes negative
|
||||
comps = [ createSquareRing(-10),
|
||||
createSquareRing(-2),
|
||||
createSquareRing(-3),
|
||||
createSquareRing(-4),
|
||||
];
|
||||
|
||||
var polygon = new OpenLayers.Geometry.Polygon(comps);
|
||||
t.eq(polygon.getArea(), 71, "getArea negative polygon with holes works lovely");
|
||||
|
||||
}
|
||||
|
||||
function test_03_Polygon_move(t) {
|
||||
t.plan(4);
|
||||
|
||||
polygon = new OpenLayers.Geometry.Polygon([linearRing, linearRing2]);
|
||||
|
||||
var x = linearRing.components[0].x;
|
||||
var y = linearRing.components[0].y;
|
||||
var x2 = linearRing2.components[0].x;
|
||||
var y2 = linearRing2.components[0].y;
|
||||
|
||||
var dx = 10 * Math.random();
|
||||
var dy = 10 * Math.random();
|
||||
|
||||
polygon.move(dx, dy);
|
||||
|
||||
t.eq(polygon.components[0].components[0].x, x + dx, "move() correctly modifies first x");
|
||||
t.eq(polygon.components[0].components[0].y, y + dy, "move() correctly modifies first y");
|
||||
t.eq(polygon.components[1].components[0].x, x2 + dx, "move() correctly modifies second x");
|
||||
t.eq(polygon.components[1].components[0].y, y2 + dy, "move() correctly modifies second y");
|
||||
}
|
||||
|
||||
// -->
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,88 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
|
||||
function test_01_Rectangle_constructor (t) {
|
||||
t.plan( 8 );
|
||||
|
||||
//empty
|
||||
var rect = new OpenLayers.Geometry.Rectangle();
|
||||
t.ok( rect instanceof OpenLayers.Geometry.Rectangle, "new OpenLayers.Geometry.Rectangle returns Rectangle object" );
|
||||
t.eq( rect.CLASS_NAME, "OpenLayers.Geometry.Rectangle", "Rectangle.CLASS_NAME is set correctly");
|
||||
t.ok( rect.id != null, "rect.id is set");
|
||||
t.ok( ! (rect.x || rect.y || rect.width || rect.height), "empty construct leaves properties empty");
|
||||
|
||||
//good
|
||||
var x = {};
|
||||
var y = {};
|
||||
var w = {};
|
||||
var h = {};
|
||||
var rect = new OpenLayers.Geometry.Rectangle(x, y, w, h);
|
||||
t.eq( rect.x, x, "good init correctly sets x property");
|
||||
t.eq( rect.y, y, "good init correctly sets y property");
|
||||
t.eq( rect.width, w, "good init correctly sets width property");
|
||||
t.eq( rect.height, h, "good init correctly sets height property");
|
||||
}
|
||||
|
||||
function test_02_Rectangle_calculateBounds(t) {
|
||||
t.plan(1);
|
||||
|
||||
var x = 1;
|
||||
var y = 2;
|
||||
var w = 10;
|
||||
var h = 20;
|
||||
var rect = new OpenLayers.Geometry.Rectangle(x, y, w, h);
|
||||
rect.calculateBounds();
|
||||
|
||||
var testBounds = new OpenLayers.Bounds(x, y, x + w, y + h)
|
||||
|
||||
t.ok( rect.bounds.equals(testBounds), "calculateBounds works correctly");
|
||||
}
|
||||
|
||||
function test_03_Rectangle_getLength(t) {
|
||||
var x = 1;
|
||||
var y = 2;
|
||||
var w = 10;
|
||||
var h = 20;
|
||||
var rect = new OpenLayers.Geometry.Rectangle(x, y, w, h);
|
||||
|
||||
var testLength = (2 * w) + (2 * h);
|
||||
|
||||
t.eq(rect.getLength(), testLength, "getLength() works");
|
||||
}
|
||||
|
||||
function test_03_Rectangle_getLength(t) {
|
||||
t.plan(1);
|
||||
|
||||
var x = 1;
|
||||
var y = 2;
|
||||
var w = 10;
|
||||
var h = 20;
|
||||
var rect = new OpenLayers.Geometry.Rectangle(x, y, w, h);
|
||||
|
||||
var testLength = (2 * w) + (2 * h);
|
||||
|
||||
t.eq(rect.getLength(), testLength, "getLength() works");
|
||||
}
|
||||
|
||||
function test_04_Rectangle_getArea(t) {
|
||||
t.plan(1);
|
||||
|
||||
var x = 1;
|
||||
var y = 2;
|
||||
var w = 10;
|
||||
var h = 20;
|
||||
var rect = new OpenLayers.Geometry.Rectangle(x, y, w, h);
|
||||
|
||||
var testArea = w * h;
|
||||
t.eq(rect.getArea(), testArea, "testArea() works");
|
||||
}
|
||||
|
||||
|
||||
// -->
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,21 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
|
||||
function test_01_Surface_constructor (t) {
|
||||
t.plan( 2 );
|
||||
|
||||
var g = new OpenLayers.Geometry.Surface();
|
||||
|
||||
t.eq(g.CLASS_NAME, "OpenLayers.Geometry.Surface", "correct CLASS_NAME")
|
||||
t.ok(g.id.startsWith("OpenLayers.Geometry.Surface_"), "id correctly set");
|
||||
}
|
||||
|
||||
|
||||
// -->
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
|
||||
var isOpera = (navigator.userAgent.indexOf("Opera") != -1);
|
||||
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var layer;
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
|
||||
var name = "GML Layer";
|
||||
|
||||
function test_01_Layer_GML_constructor(t) {
|
||||
t.plan(3);
|
||||
|
||||
var layer = new OpenLayers.Layer.GML(name);
|
||||
t.ok(layer instanceof OpenLayers.Layer.GML, "new OpenLayers.Layer.GML returns correct object" );
|
||||
t.eq(layer.name, name, "layer name is correctly set");
|
||||
t.ok(layer.renderer.CLASS_NAME, "layer has a renderer");
|
||||
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" style="width:500px;height:550px"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
|
||||
var layer;
|
||||
@@ -2,7 +2,7 @@
|
||||
<head>
|
||||
<!-- this gmaps key generated for http://openlayers.org/dev/ -->
|
||||
<script src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA9XNhd8q0UdwNC7YSO4YZghSPUCi5aRYVveCcVYxzezM4iaj_gxQ9t-UajFL70jfcpquH5l1IJ-Zyyw'></script>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var layer;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
t.eq( layer.name, "Goog Layer", "layer.name is correct" );
|
||||
|
||||
t.ok ( layer.gmap != null, "GMap2 Object correctly loaded");
|
||||
t.ok ( layer.mapObject != null, "GMap2 Object correctly loaded");
|
||||
}
|
||||
|
||||
function test_02_Layer_Google_isBaseLayer (t) {
|
||||
@@ -30,30 +30,7 @@
|
||||
t.ok(layer.isBaseLayer, "a default load of google layer responds as a base layer");
|
||||
}
|
||||
|
||||
function test_03_Layer_Google_Translation_zoom (t) {
|
||||
|
||||
t.plan( 4 );
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
var layer = new OpenLayers.Layer.Google('Goog Layer');
|
||||
map.addLayer(layer);
|
||||
|
||||
// these two lines specify an appropriate translation.
|
||||
// the code afterwards works by itself to test that translation
|
||||
// works correctly both ways.
|
||||
var gZoom = 5;
|
||||
var correspondingOLZoom = 5;
|
||||
|
||||
|
||||
olZoom = layer.getOLZoomFromGZoom(gZoom);
|
||||
t.eq(olZoom, correspondingOLZoom, "Translation from GZoom to OL Zoom works");
|
||||
t.eq(layer.getGZoomFromOLZoom(olZoom), gZoom, "Translation from OL Zoom to GZoom works");
|
||||
|
||||
t.ok( layer.getGZoomFromOLZoom(null) == null, "getGZoomFromOLZoom(null) returns null");
|
||||
t.ok( layer.getOLZoomFromGZoom(null) == null, "getOLZoomFromGZoom(null) returns null");
|
||||
}
|
||||
|
||||
function test_04_Layer_Google_Translation_lonlat (t) {
|
||||
function test_03_Layer_Google_Translation_lonlat (t) {
|
||||
|
||||
t.plan( 4 );
|
||||
|
||||
@@ -68,17 +45,17 @@
|
||||
var correspondingOLLonLat = new OpenLayers.LonLat(100,50);
|
||||
|
||||
|
||||
olLonLat = layer.getOLLonLatFromGLatLng(gLatLng);
|
||||
olLonLat = layer.getOLLonLatFromMapObjectLonLat(gLatLng);
|
||||
t.ok(olLonLat.equals(correspondingOLLonLat), "Translation from GLatLng to OpenLayers.LonLat works");
|
||||
|
||||
var transGLatLng = layer.getGLatLngFromOLLonLat(olLonLat);
|
||||
var transGLatLng = layer.getMapObjectLonLatFromOLLonLat(olLonLat);
|
||||
t.ok( transGLatLng.equals(gLatLng), "Translation from OpenLayers.LonLat to GLatLng works");
|
||||
|
||||
t.ok( layer.getGLatLngFromOLLonLat(null) == null, "getGLatLngFromOLLonLat(null) returns null");
|
||||
t.ok( layer.getOLLonLatFromGLatLng(null) == null, "getOLLonLatFromGLatLng(null) returns null");
|
||||
t.ok( layer.getMapObjectLonLatFromOLLonLat(null) == null, "getGLatLngFromOLLonLat(null) returns null");
|
||||
t.ok( layer.getOLLonLatFromMapObjectLonLat(null) == null, "getOLLonLatFromGLatLng(null) returns null");
|
||||
}
|
||||
|
||||
function test_05_Layer_Google_Translation_pixel (t) {
|
||||
function test_04_Layer_Google_Translation_pixel (t) {
|
||||
|
||||
t.plan( 4 );
|
||||
|
||||
@@ -93,42 +70,14 @@
|
||||
var correspondingOLPixel = new OpenLayers.Pixel(50, 100);
|
||||
|
||||
|
||||
olPixel = layer.getOLPixelFromGPoint(gPoint);
|
||||
olPixel = layer.getOLPixelFromMapObjectPixel(gPoint);
|
||||
t.ok( olPixel.equals(correspondingOLPixel), "Translation from GPoint to OpenLayers.Pixel works");
|
||||
|
||||
var transGPoint = layer.getGPointFromOLPixel(olPixel);
|
||||
var transGPoint = layer.getMapObjectPixelFromOLPixel(olPixel);
|
||||
t.ok( transGPoint.equals(gPoint), "Translation from OpenLayers.Pixel to GPoint works");
|
||||
|
||||
t.ok( layer.getGPointFromOLPixel(null) == null, "getGPointFromOLPixel(null) returns null");
|
||||
t.ok( layer.getOLPixelFromGPoint(null) == null, "getOLPixelFromGPoint(null) returns null");
|
||||
}
|
||||
|
||||
function test_06_Layer_Google_Translation_bounds (t) {
|
||||
|
||||
t.plan( 4 );
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
var layer = new OpenLayers.Layer.Google('Goog Layer');
|
||||
map.addLayer(layer);
|
||||
|
||||
// these two lines specify an appropriate translation.
|
||||
// the code afterwards works by itself to test that translation
|
||||
// works correctly both ways.
|
||||
var sw = new GLatLng(10,20);
|
||||
var ne = new GLatLng(50,40)
|
||||
var gBounds = new GLatLngBounds(sw, ne);
|
||||
var correspondingOLBounds = new OpenLayers.Bounds(20, 10, 40, 50);
|
||||
|
||||
|
||||
olBounds = layer.getOLBoundsFromGLatLngBounds(gBounds);
|
||||
|
||||
t.ok(olBounds.equals(correspondingOLBounds), "Translation from GLatLngBounds to OpenLayers.Bounds works");
|
||||
|
||||
var transGBounds = layer.getGLatLngBoundsFromOLBounds(olBounds);
|
||||
t.ok( transGBounds.equals(gBounds), "Translation from OpenLayers.Bounds to GLatLngBounds works");
|
||||
|
||||
t.ok( layer.getGLatLngBoundsFromOLBounds(null) == null, "getGLatLngBoundsFromOLBounds(null) returns null");
|
||||
t.ok( layer.getOLBoundsFromGLatLngBounds(null) == null, "getOLBoundsFromGLatLngBounds(null) returns null");
|
||||
t.ok( layer.getMapObjectPixelFromOLPixel(null) == null, "getGPointFromOLPixel(null) returns null");
|
||||
t.ok( layer.getOLPixelFromMapObjectPixel(null) == null, "getOLPixelFromGPoint(null) returns null");
|
||||
}
|
||||
|
||||
function test_99_Layer_destroy (t) {
|
||||
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
|
||||
var layer;
|
||||
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var layer;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var layer;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
|
||||
var layer;
|
||||
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var layer;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript" src="http://clients.multimap.com/API/maps/1.1/metacarta_04"></script>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var layer;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
t.eq( layer.name, "Goog Layer", "layer.name is correct" );
|
||||
|
||||
t.ok ( layer.multimap != null, "MultiMap Object correctly loaded");
|
||||
t.ok ( layer.mapObject != null, "MultiMap Object correctly loaded");
|
||||
}
|
||||
|
||||
function test_02_Layer_MultiMap_isBaseLayer (t) {
|
||||
@@ -29,29 +29,6 @@
|
||||
t.ok(layer.isBaseLayer, "a default load of google layer responds as a base layer");
|
||||
}
|
||||
|
||||
function test_03_Layer_MultiMap_Translation_zoom (t) {
|
||||
|
||||
t.plan( 4 );
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
var layer = new OpenLayers.Layer.MultiMap('Goog Layer');
|
||||
map.addLayer(layer);
|
||||
|
||||
// these two lines specify an appropriate translation.
|
||||
// the code afterwards works by itself to test that translation
|
||||
// works correctly both ways.
|
||||
var gZoom = 5;
|
||||
var correspondingOLZoom = 4;
|
||||
|
||||
|
||||
olZoom = layer.getOLZoomFromMMZoom(gZoom);
|
||||
t.eq(olZoom, correspondingOLZoom, "Translation from GZoom to OL Zoom works");
|
||||
t.eq(layer.getMMZoomFromOLZoom(olZoom), gZoom, "Translation from OL Zoom to GZoom works");
|
||||
|
||||
t.ok( layer.getMMZoomFromOLZoom(null) == null, "getGZoomFromOLZoom(null) returns null");
|
||||
t.ok( layer.getOLZoomFromMMZoom(null) == null, "getOLZoomFromGZoom(null) returns null");
|
||||
}
|
||||
|
||||
function test_04_Layer_MultiMap_Translation_lonlat (t) {
|
||||
|
||||
t.plan( 4 );
|
||||
@@ -67,14 +44,14 @@
|
||||
var correspondingOLLonLat = new OpenLayers.LonLat(100,50);
|
||||
|
||||
|
||||
olLonLat = layer.getOLLonLatFromMMLatLong(gLatLng);
|
||||
olLonLat = layer.getOLLonLatFromMapObjectLonLat(gLatLng);
|
||||
t.ok(olLonLat.equals(correspondingOLLonLat), "Translation from GLatLng to OpenLayers.LonLat works");
|
||||
|
||||
var transGLatLng = layer.getMMLatLongFromOLLonLat(olLonLat);
|
||||
var transGLatLng = layer.getMapObjectLonLatFromOLLonLat(olLonLat);
|
||||
t.ok( (transGLatLng.lat == gLatLng.lat) && (transGLatLng.lon == transGLatLng.lon), "Translation from OpenLayers.LonLat to GLatLng works");
|
||||
|
||||
t.ok( layer.getMMLatLongFromOLLonLat(null) == null, "getGLatLngFromOLLonLat(null) returns null");
|
||||
t.ok( layer.getOLLonLatFromMMLatLong(null) == null, "getOLLonLatFromGLatLng(null) returns null");
|
||||
t.ok( layer.getMapObjectLonLatFromOLLonLat(null) == null, "getGLatLngFromOLLonLat(null) returns null");
|
||||
t.ok( layer.getOLLonLatFromMapObjectLonLat(null) == null, "getOLLonLatFromGLatLng(null) returns null");
|
||||
}
|
||||
|
||||
function test_05_Layer_MultiMap_Translation_pixel (t) {
|
||||
@@ -92,14 +69,14 @@
|
||||
var correspondingOLPixel = new OpenLayers.Pixel(50, 100);
|
||||
|
||||
|
||||
olPixel = layer.getOLPixelFromPixel(gPoint);
|
||||
olPixel = layer.getOLPixelFromMapObjectPixel(gPoint);
|
||||
t.ok( olPixel.equals(correspondingOLPixel), "Translation from GPoint to OpenLayers.Pixel works");
|
||||
|
||||
var transGPoint = layer.getPixelFromOLPixel(olPixel);
|
||||
var transGPoint = layer.getMapObjectPixelFromOLPixel(olPixel);
|
||||
t.ok( ((transGPoint.x == transGPoint.x) && (transGPoint.y == transGPoint.y)), "Translation from OpenLayers.Pixel to GPoint works");
|
||||
|
||||
t.ok( layer.getPixelFromOLPixel(null) == null, "getGPointFromOLPixel(null) returns null");
|
||||
t.ok( layer.getOLPixelFromPixel(null) == null, "getOLPixelFromGPoint(null) returns null");
|
||||
t.ok( layer.getMapObjectPixelFromOLPixel(null) == null, "getGPointFromOLPixel(null) returns null");
|
||||
t.ok( layer.getOLPixelFromMapObjectPixel(null) == null, "getOLPixelFromGPoint(null) returns null");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
|
||||
var layer;
|
||||
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
|
||||
var layer;
|
||||
@@ -0,0 +1,63 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
|
||||
var name = "Vector Layer";
|
||||
|
||||
function test_01_Layer_Vector_constructor(t) {
|
||||
t.plan(3);
|
||||
|
||||
var layer = new OpenLayers.Layer.Vector(name);
|
||||
t.ok(layer instanceof OpenLayers.Layer.Vector, "new OpenLayers.Layer.Vector returns correct object" );
|
||||
t.eq(layer.name, name, "layer name is correctly set");
|
||||
t.ok(layer.renderer.CLASS_NAME, "layer has a renderer");
|
||||
|
||||
}
|
||||
|
||||
function test_02_Layer_Vector_addFeatures(t) {
|
||||
t.plan(2);
|
||||
|
||||
var layer = new OpenLayers.Layer.Vector(name);
|
||||
|
||||
var point = new OpenLayers.Geometry.Point(-111.04, 45.68);
|
||||
var pointFeature = new OpenLayers.Feature.Vector(layer, point);
|
||||
|
||||
layer.addFeatures([pointFeature]);
|
||||
|
||||
t.eq(layer.features.length, 1, "OpenLayers.Layer.Vector.addFeatures adds something to the array");
|
||||
t.ok(layer.features[0] == pointFeature, "OpenLayers.Layer.Vector.addFeatures returns an array of features");
|
||||
}
|
||||
|
||||
function test_03_Layer_Vector_removeFeatures(t) {
|
||||
t.plan(1);
|
||||
|
||||
var layer = new OpenLayers.Layer.Vector(name);
|
||||
|
||||
var point1 = new OpenLayers.Geometry.Point(-111.04, 45.68);
|
||||
var pointFeature1 = new OpenLayers.Feature.Vector(layer, point1);
|
||||
var point2 = new OpenLayers.Geometry.Point(-111.14, 45.78);
|
||||
var pointFeature2 = new OpenLayers.Feature.Vector(layer, point2);
|
||||
|
||||
layer.addFeatures([pointFeature1, pointFeature2]);
|
||||
var features = layer.removeFeatures([pointFeature1]);
|
||||
|
||||
t.ok(layer.features.length == 1, "OpenLayers.Layer.Vector.removeFeatures removes a feature from the features array");
|
||||
}
|
||||
|
||||
function test_99_Layer_Vector_destroy (t) {
|
||||
t.plan(1);
|
||||
layer = new OpenLayers.Layer.Vector(name);
|
||||
var map = new OpenLayers.Map('map');
|
||||
map.addLayer(layer);
|
||||
layer.destroy();
|
||||
t.eq(layer.map, null, "layer.map is null after destroy");
|
||||
}
|
||||
|
||||
// -->
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" style="width:500px;height:550px"></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,7 +1,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ'></script>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
|
||||
var layer;
|
||||
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
|
||||
var tile;
|
||||
+43
-24
@@ -1,36 +1,55 @@
|
||||
<ul id="testlist">
|
||||
<li>test_Class.html</li>
|
||||
<li>test_Pixel.html</li>
|
||||
<li>test_Size.html</li>
|
||||
<li>test_LonLat.html</li>
|
||||
<li>BaseTypes/test_Class.html</li>
|
||||
<li>BaseTypes/test_Pixel.html</li>
|
||||
<li>BaseTypes/test_Size.html</li>
|
||||
<li>BaseTypes/test_LonLat.html</li>
|
||||
<li>BaseTypes/test_Bounds.html</li>
|
||||
<li>test_Geometry.html</li>
|
||||
<li>Geometry/test_Point.html</li>
|
||||
<li>Geometry/test_Curve.html</li>
|
||||
<li>Geometry/test_LineString.html</li>
|
||||
<li>Geometry/test_MultiLineString.html</li>
|
||||
<li>Geometry/test_LinearRing.html</li>
|
||||
<li>Geometry/test_Collection.html</li>
|
||||
<li>Geometry/test_MultiPoint.html</li>
|
||||
<li>Geometry/test_Polygon.html</li>
|
||||
<li>Geometry/test_MultiPolygon.html</li>
|
||||
<li>Geometry/test_Rectangle.html</li>
|
||||
<li>Geometry/test_Surface.html</li>
|
||||
<li>test_Icon.html</li>
|
||||
<li>test_Marker.html</li>
|
||||
<li>test_Popup.html</li>
|
||||
<li>test_Feature.html</li>
|
||||
<li>test_Bounds.html</li>
|
||||
<li>Feature/test_Vector.html</li>
|
||||
<li>test_Events.html</li>
|
||||
<li>test_Util.html</li>
|
||||
<li>test_Layer.html</li>
|
||||
<li>test_Layer_Image.html</li>
|
||||
<li>test_Layer_EventPane.html</li>
|
||||
<li>test_Layer_FixedZoomLevels.html</li>
|
||||
<li>test_Layer_HTTPRequest.html</li>
|
||||
<li>test_Layer_Grid.html</li>
|
||||
<li>test_Layer_Markers.html</li>
|
||||
<li>test_Layer_Text.html</li>
|
||||
<li>test_Layer_GeoRSS.html</li>
|
||||
<li>test_Layer_KaMap.html</li>
|
||||
<li>test_Layer_WMS.html</li>
|
||||
<li>test_Layer_TMS.html</li>
|
||||
<li>test_Renderer.html</li>
|
||||
<li>Layer/test_EventPane.html</li>
|
||||
<li>Layer/test_FixedZoomLevels.html</li>
|
||||
<li>Layer/test_GeoRSS.html</li>
|
||||
<li>Layer/test_Google.html</li>
|
||||
<li>Layer/test_Grid.html</li>
|
||||
<li>Layer/test_HTTPRequest.html</li>
|
||||
<li>Layer/test_Image.html</li>
|
||||
<li>Layer/test_KaMap.html</li>
|
||||
<li>Layer/test_Markers.html</li>
|
||||
<li>Layer/test_Multimap.html</li>
|
||||
<li>Layer/test_Text.html</li>
|
||||
<li>Layer/test_WMS.html</li>
|
||||
<li>Layer/test_TMS.html</li>
|
||||
<li>Layer/test_Vector.html</li>
|
||||
<li>Layer/test_GML.html</li>
|
||||
<li>test_Tile.html</li>
|
||||
<li>test_Tile_Image.html</li>
|
||||
<li>Tile/test_Image.html</li>
|
||||
<li>test_Control.html</li>
|
||||
<li>test_Control_OverviewMap.html</li>
|
||||
<li>test_Control_MouseToolbar.html</li>
|
||||
<li>test_Control_LayerSwitcher.html</li>
|
||||
<li>test_Control_PanZoom.html</li>
|
||||
<li>test_Control_PanZoomBar.html</li>
|
||||
<li>test_Control_Permalink.html</li>
|
||||
<li>test_Control_Scale.html</li>
|
||||
<li>Control/test_OverviewMap.html</li>
|
||||
<li>Control/test_NavToolbar.html</li>
|
||||
<li>Control/test_MouseToolbar.html</li>
|
||||
<li>Control/test_LayerSwitcher.html</li>
|
||||
<li>Control/test_PanZoom.html</li>
|
||||
<li>Control/test_PanZoomBar.html</li>
|
||||
<li>Control/test_Permalink.html</li>
|
||||
<li>Control/test_Scale.html</li>
|
||||
<li>test_Map.html</li>
|
||||
</ul>
|
||||
|
||||
@@ -0,0 +1,212 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
var map;
|
||||
|
||||
function test_01_Geometry_constructor (t) {
|
||||
t.plan( 2 );
|
||||
|
||||
var g = new OpenLayers.Geometry();
|
||||
|
||||
t.eq(g.CLASS_NAME, "OpenLayers.Geometry", "correct CLASS_NAME")
|
||||
t.ok(g.id.startsWith("OpenLayers.Geometry_"), "id correctly set");
|
||||
}
|
||||
|
||||
|
||||
function test_02_Geometry_setBounds(t) {
|
||||
t.plan( 2 );
|
||||
|
||||
var g = new OpenLayers.Geometry();
|
||||
|
||||
//null object
|
||||
g.setBounds(null);
|
||||
t.ok(g.bounds == null, "setbounds with null value does not crash or set bounds");
|
||||
|
||||
//no classname object
|
||||
g_clone = {};
|
||||
var object = {
|
||||
'clone': function() { return g_clone; }
|
||||
};
|
||||
g.setBounds(object);
|
||||
t.ok(g.bounds == g_clone, "setbounds with valid object sets bounds, calls clone");
|
||||
}
|
||||
|
||||
function test_03_Geometry_extendBounds(t) {
|
||||
t.plan(9);
|
||||
|
||||
OpenLayers.Bounds.prototype._extend =
|
||||
OpenLayers.Bounds.prototype.extend;
|
||||
OpenLayers.Bounds.prototype.extend = function(b) {
|
||||
g_extendBounds = b;
|
||||
};
|
||||
|
||||
var g = new OpenLayers.Geometry();
|
||||
|
||||
//this.bounds null (calculateBounds(), setBounds() called)
|
||||
g.setBounds = function(b) { g_setBounds = b; };
|
||||
g.calculateBounds = function() { g_calculateBounds = {}; };
|
||||
var object = {};
|
||||
g_setBounds = null;
|
||||
g_calculateBounds = null;
|
||||
g_extendBounds = null;
|
||||
g.extendBounds(object);
|
||||
t.ok(g_calculateBounds != null, "calculateBounds() called when this.bounds is null");
|
||||
t.ok(g_setBounds == object, "setBounds() called when this.bounds is null and calculateBounds() is null too");
|
||||
t.ok(g_extendBounds != object, "this.bounds.extend() not called when this.bounds is null and calculateBounds() is null too");
|
||||
|
||||
//this.bounds null (calculateBounds() sets this.bounds:
|
||||
// - setBounds() not called
|
||||
// - this.bounds.extend() called
|
||||
g_calcBounds = new OpenLayers.Bounds(1,2,3,4);
|
||||
g.calculateBounds = function() {
|
||||
g_calculateBounds = {};
|
||||
this.bounds = g_calcBounds;
|
||||
};
|
||||
var object = {};
|
||||
|
||||
g_setBounds = null;
|
||||
g_calculateBounds = null;
|
||||
g_extendBounds = null;
|
||||
g.extendBounds(object);
|
||||
t.ok(g_calculateBounds != null, "calculateBounds() called when this.bounds is null");
|
||||
t.ok(g_setBounds == null, "setBounds() not called when this.bounds is null and calculateBounds() sets this.bounds");
|
||||
t.ok(g_extendBounds == object, "this.bounds.extend() called when this.bounds is null and calculateBounds() sets this.bounds");
|
||||
|
||||
|
||||
//this.bounds non-null thus extend()
|
||||
// - setBounds() not called
|
||||
// - this.bounds.extend() called
|
||||
g_setBounds = null;
|
||||
g_calculateBounds = null;
|
||||
g_extendBounds = null;
|
||||
g.extendBounds(object);
|
||||
t.ok(g_calculateBounds == null, "calculateBounds() not called when this.bounds is non null");
|
||||
t.ok(g_setBounds == null, "setBounds() not called when this.bounds is nonnull");
|
||||
t.ok(g_extendBounds == object, "this.bounds.extend() called when this.bounds is non-null");
|
||||
|
||||
OpenLayers.Bounds.prototype.extend =
|
||||
OpenLayers.Bounds.prototype._extend;
|
||||
|
||||
|
||||
}
|
||||
|
||||
function test_04_Geometry_getBounds(t) {
|
||||
t.plan(1);
|
||||
|
||||
var g = new OpenLayers.Geometry();
|
||||
|
||||
var testBounds = new OpenLayers.Bounds(1,2,3,4);
|
||||
g.bounds = testBounds.clone();
|
||||
|
||||
t.ok(g.getBounds().equals(testBounds), "getBounds works");
|
||||
}
|
||||
|
||||
function test_05_Geometry_atPoint(t) {
|
||||
t.plan(6);
|
||||
|
||||
var g = new OpenLayers.Geometry();
|
||||
|
||||
var lonlat = null;
|
||||
var lon = 5;
|
||||
var lat = 10;
|
||||
|
||||
//null lonlat
|
||||
g.bounds = new OpenLayers.Bounds();
|
||||
|
||||
var atPoint = g.atPoint(lonlat, lon, lat);
|
||||
t.ok(!atPoint, "null lonlat")
|
||||
|
||||
//null this.bounds
|
||||
g.bounds = null;
|
||||
lonlat = new OpenLayers.LonLat(1,2);
|
||||
|
||||
atPoint = g.atPoint(lonlat, lon, lat);
|
||||
t.ok(!atPoint, "null this.bounds")
|
||||
|
||||
//toleranceLon/toleranceLat
|
||||
|
||||
//default toleranceLon/toleranceLat
|
||||
OpenLayers.Bounds.prototype._containsLonLat = OpenLayers.Bounds.prototype.containsLonLat;
|
||||
g_Return = {};
|
||||
OpenLayers.Bounds.prototype.containsLonLat = function(ll) {
|
||||
g_bounds = this;
|
||||
return g_Return;
|
||||
}
|
||||
|
||||
var testBounds = new OpenLayers.Bounds(10,20,30,40);
|
||||
g.bounds = testBounds.clone();
|
||||
lonlat = new OpenLayers.LonLat(20,30);
|
||||
|
||||
g_bounds = null;
|
||||
atPoint = g.atPoint(lonlat);
|
||||
t.ok(g_bounds.equals(testBounds), "default toleranceLon/Lat are 0");
|
||||
t.ok(atPoint == g_Return, "default toleranceLon/Lat returns correctly");
|
||||
|
||||
//real toleranceLon/toleranceLat
|
||||
var testBounds = new OpenLayers.Bounds(10,20,30,40);
|
||||
g.bounds = testBounds.clone();
|
||||
lonlat = new OpenLayers.LonLat(20,30);
|
||||
|
||||
g_bounds = null;
|
||||
atPoint = g.atPoint(lonlat, lon, lat);
|
||||
testBounds.left -= lon;
|
||||
testBounds.bottom -= lat;
|
||||
testBounds.right += lon;
|
||||
testBounds.top += lat;
|
||||
t.ok(g_bounds.equals(testBounds), "real toleranceLon/Lat are 0");
|
||||
t.ok(atPoint == g_Return, "real toleranceLon/Lat returns correctly");
|
||||
|
||||
OpenLayers.Bounds.prototype.containsLonLat = OpenLayers.Bounds.prototype._containsLonLat;
|
||||
|
||||
}
|
||||
|
||||
function test_06_Geometry_getLength(t) {
|
||||
t.plan(1);
|
||||
|
||||
var g = new OpenLayers.Geometry();
|
||||
|
||||
t.eq(g.getLength(), 0, "getLength is 0");
|
||||
}
|
||||
|
||||
function test_07_Geometry_getArea(t) {
|
||||
t.plan(1);
|
||||
|
||||
var g = new OpenLayers.Geometry();
|
||||
|
||||
t.eq(g.getArea(), 0, "getArea is 0");
|
||||
}
|
||||
|
||||
function test_99_Geometry_destroy(t) {
|
||||
t.plan( 5 );
|
||||
|
||||
var g = new OpenLayers.Geometry();
|
||||
g.bounds = new OpenLayers.Bounds();
|
||||
g.feature = new Object();
|
||||
g.events = {
|
||||
'destroy': function() {
|
||||
g_events_destroy = {};
|
||||
}
|
||||
};
|
||||
|
||||
g_style_destroy = null;
|
||||
g_events_destroy = {};
|
||||
g.destroy();
|
||||
|
||||
t.eq(g.id, null, "id nullified");
|
||||
|
||||
t.eq(g.bounds, null, "bounds nullified");
|
||||
t.eq(g.feature, null, "feature reference nullified");
|
||||
|
||||
t.ok(g_events_destroy != null, "events.destroy() called on non-null events");
|
||||
t.eq(g.events, null, "events nullified");
|
||||
}
|
||||
|
||||
|
||||
// -->
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" style="width: 1024px; height: 512px;"/>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,166 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
|
||||
var layer;
|
||||
|
||||
|
||||
function test_01_Renderer_drawGeometry(t) {
|
||||
t.plan(1);
|
||||
var r = new OpenLayers.Renderer();
|
||||
t.ok( r instanceof OpenLayers.Renderer, "new OpenLayers.Renderer returns REnderer object" );
|
||||
}
|
||||
/*
|
||||
function test_01_Renderer_drawGeometry(t) {
|
||||
t.plan(12);
|
||||
|
||||
var r = new OpenLayers.Renderer();
|
||||
r.root = document.body;
|
||||
r.setStyle = function() {};
|
||||
|
||||
var geometry = null;
|
||||
var style = null;
|
||||
|
||||
r.drawGeometry(geometry, style);
|
||||
t.ok(true, "didnt do anything on null style");
|
||||
|
||||
// point
|
||||
var properDraw = false;
|
||||
r.drawPoint = function(g) {
|
||||
properDraw = true;
|
||||
return {};
|
||||
}
|
||||
geometry = {CLASS_NAME: 'OpenLayers.Geometry.Point'};
|
||||
style = true;
|
||||
r.drawGeometry(geometry, style);
|
||||
t.ok(properDraw, "drawGeometry called drawPoint when passed a point");
|
||||
|
||||
// curve
|
||||
var properDraw = false;
|
||||
r.drawCurve = function(g) {
|
||||
properDraw = true;
|
||||
return {};
|
||||
}
|
||||
geometry = {CLASS_NAME: 'OpenLayers.Geometry.Curve'};
|
||||
style = true;
|
||||
r.drawGeometry(geometry, style);
|
||||
t.ok(properDraw, "drawGeometry called drawCurve when passed a curve");
|
||||
|
||||
// line segment
|
||||
var properDraw = false;
|
||||
r.drawLineString = function(g) {
|
||||
properDraw = true;
|
||||
return {};
|
||||
}
|
||||
geometry = {CLASS_NAME: 'OpenLayers.Geometry.LineSegment'};
|
||||
style = true;
|
||||
r.drawGeometry(geometry, style);
|
||||
t.ok(properDraw, "drawGeometry called drawLineString when passed a line segment");
|
||||
|
||||
// line string
|
||||
var properDraw = false;
|
||||
r.drawLineString = function(g) {
|
||||
properDraw = true;
|
||||
return {};
|
||||
}
|
||||
geometry = {CLASS_NAME: 'OpenLayers.Geometry.LineString'};
|
||||
style = true;
|
||||
r.drawGeometry(geometry, style);
|
||||
t.ok(properDraw, "drawGeometry called drawLineString when passed a line string");
|
||||
|
||||
// linear ring
|
||||
var properDraw = false;
|
||||
r.drawLinearRing = function(g) {
|
||||
properDraw = true;
|
||||
return {};
|
||||
}
|
||||
geometry = {CLASS_NAME: 'OpenLayers.Geometry.LinearRing'};
|
||||
style = true;
|
||||
r.drawGeometry(geometry, style);
|
||||
t.ok(properDraw, "drawGeometry called drawLinearRing when passed a linear ring");
|
||||
|
||||
// polygon
|
||||
var properDraw = false;
|
||||
r.drawPolygon = function(g) {
|
||||
properDraw = true;
|
||||
return {};
|
||||
}
|
||||
geometry = {CLASS_NAME: 'OpenLayers.Geometry.Polygon'};
|
||||
style = true;
|
||||
r.drawGeometry(geometry, style);
|
||||
t.ok(properDraw, "drawGeometry called drawPolygon when passed a polygon");
|
||||
|
||||
// surface
|
||||
var properDraw = false;
|
||||
r.drawSurface = function(g) {
|
||||
properDraw = true;
|
||||
return {};
|
||||
}
|
||||
geometry = {CLASS_NAME: 'OpenLayers.Geometry.Surface'};
|
||||
style = true;
|
||||
r.drawGeometry(geometry, style);
|
||||
t.ok(properDraw, "drawGeometry called drawSurface when passed a surface");
|
||||
|
||||
// rectangle
|
||||
var properDraw = false;
|
||||
r.drawRectangle = function(g) {
|
||||
properDraw = true;
|
||||
return {};
|
||||
}
|
||||
geometry = {CLASS_NAME: 'OpenLayers.Geometry.Rectangle'};
|
||||
style = true;
|
||||
r.drawGeometry(geometry, style);
|
||||
t.ok(properDraw, "drawGeometry called drawRectangle when passed a rectangle");
|
||||
|
||||
// multi-point
|
||||
var properDraw = false;
|
||||
r.drawPoint = function(g) {
|
||||
properDraw = true;
|
||||
return {};
|
||||
}
|
||||
geometry = {
|
||||
CLASS_NAME: 'OpenLayers.Geometry.MultiPoint',
|
||||
components: [{CLASS_NAME: 'OpenLayers.Geometry.Point'}]
|
||||
};
|
||||
style = true;
|
||||
r.drawGeometry(geometry, style);
|
||||
t.ok(properDraw, "drawGeometry called drawPoint when passed a multi-point");
|
||||
|
||||
// multi-linestring
|
||||
var properDraw = false;
|
||||
r.drawLineString = function(g) {
|
||||
properDraw = true;
|
||||
return {};
|
||||
}
|
||||
geometry = {
|
||||
CLASS_NAME: 'OpenLayers.Geometry.MultiLineString',
|
||||
components: [{CLASS_NAME: 'OpenLayers.Geometry.LineString'}]
|
||||
};
|
||||
style = true;
|
||||
r.drawGeometry(geometry, style);
|
||||
t.ok(properDraw, "drawGeometry called drawLineString when passed a multi-linestring");
|
||||
|
||||
// multi-polygon
|
||||
var properDraw = false;
|
||||
r.drawPolygon = function(g) {
|
||||
properDraw = true;
|
||||
return {};
|
||||
}
|
||||
geometry = {
|
||||
CLASS_NAME: 'OpenLayers.Geometry.MultiPolygon',
|
||||
components: [{CLASS_NAME: 'OpenLayers.Geometry.Polygon'}]
|
||||
};
|
||||
style = true;
|
||||
r.drawGeometry(geometry, style);
|
||||
t.ok(properDraw, "drawGeometry called drawPolygon when passed a multi-polygon");
|
||||
|
||||
}
|
||||
*/
|
||||
// -->
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" style="width:500px;height:550px"></div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user