1 |
3032
|
perry
|
<html>
|
2 |
|
|
<head>
|
3 |
|
|
<script src="../lib/OpenLayers.js"></script>
|
4 |
|
|
<script type="text/javascript"><!--
|
5 |
|
|
|
6 |
|
|
var lonlat;
|
7 |
|
|
|
8 |
|
|
function test_01_LonLat_constructor (t) {
|
9 |
|
|
t.plan( 4 );
|
10 |
|
|
lonlat = new OpenLayers.LonLat(6, 5);
|
11 |
|
|
t.ok( lonlat instanceof OpenLayers.LonLat, "new OpenLayers.LonLat returns LonLat object" );
|
12 |
|
|
t.eq( lonlat.CLASS_NAME, "OpenLayers.LonLat", "lonlat.CLASS_NAME is set correctly");
|
13 |
|
|
t.eq( lonlat.lon, 6, "lonlat.lon is set correctly");
|
14 |
|
|
t.eq( lonlat.lat, 5, "lonlat.lat is set correctly");
|
15 |
|
|
}
|
16 |
|
|
|
17 |
|
|
function test_02_LonLat_toString(t) {
|
18 |
|
|
t.plan( 1 );
|
19 |
|
|
lonlat = new OpenLayers.LonLat(5,6);
|
20 |
|
|
t.eq( lonlat.toString(), "lon=5,lat=6", "lonlat.toString() returns correctly");
|
21 |
|
|
}
|
22 |
|
|
|
23 |
|
|
function test_02A_LonLat_toShortString(t) {
|
24 |
|
|
t.plan( 1 );
|
25 |
|
|
lonlat = new OpenLayers.LonLat(5,6);
|
26 |
|
|
t.eq( lonlat.toShortString(), "5, 6", "lonlat.toShortString() returns correctly");
|
27 |
|
|
}
|
28 |
|
|
|
29 |
|
|
function test_03_LonLat_clone(t) {
|
30 |
|
|
t.plan( 3 );
|
31 |
|
|
oldLonLat = new OpenLayers.LonLat(5,6);
|
32 |
|
|
lonlat = oldLonLat.clone();
|
33 |
|
|
t.ok( lonlat instanceof OpenLayers.LonLat, "clone returns new OpenLayers.LonLat object" );
|
34 |
|
|
t.ok( lonlat.equals(oldLonLat), "lonlat is set correctly");
|
35 |
|
|
|
36 |
|
|
oldLonLat.lon = 100;
|
37 |
|
|
t.eq( lonlat.lon, 5, "changing oldLonLat.lon doesn't change lonlat.lon");
|
38 |
|
|
}
|
39 |
|
|
|
40 |
|
|
function test_04_LonLat_add(t) {
|
41 |
|
|
t.plan( 2 );
|
42 |
|
|
|
43 |
|
|
lonlatA = new OpenLayers.LonLat(10,100);
|
44 |
|
|
|
45 |
|
|
addpx = lonlatA.add(5, 50);
|
46 |
|
|
var ll = new OpenLayers.LonLat(10,100);
|
47 |
|
|
t.ok( lonlatA.equals(ll), "lonlatA is not modified by add operation");
|
48 |
|
|
|
49 |
|
|
var ll = new OpenLayers.LonLat(15,150);
|
50 |
|
|
t.ok( addpx.equals(ll), "addpx is set correctly");
|
51 |
|
|
}
|
52 |
|
|
|
53 |
|
|
function test_06_LonLat_equals(t) {
|
54 |
|
|
t.plan( 5 );
|
55 |
|
|
lonlat = new OpenLayers.LonLat(5,6);
|
56 |
|
|
|
57 |
|
|
ll = new OpenLayers.LonLat(5,6);
|
58 |
|
|
t.eq( lonlat.equals(ll), true, "(5,6) equals (5,6)");
|
59 |
|
|
|
60 |
|
|
ll = new OpenLayers.LonLat(1,6);
|
61 |
|
|
t.eq( lonlat.equals(ll), false, "(5,6) does not equal (1,6)");
|
62 |
|
|
|
63 |
|
|
ll = new OpenLayers.LonLat(5,2);
|
64 |
|
|
t.eq( lonlat.equals(ll), false, "(5,6) does not equal (5,2)");
|
65 |
|
|
|
66 |
|
|
ll = new OpenLayers.LonLat(1,2);
|
67 |
|
|
t.eq( lonlat.equals(ll), false, "(5,6) does not equal (1,2)");
|
68 |
|
|
|
69 |
|
|
t.ok( !lonlat.equals(null), "equals() returns false on comparison to null");
|
70 |
|
|
|
71 |
|
|
}
|
72 |
|
|
|
73 |
|
|
function test_07_LonLat_fromString(t) {
|
74 |
|
|
t.plan( 2 );
|
75 |
|
|
lonlat = OpenLayers.LonLat.fromString("6,5");
|
76 |
|
|
t.ok( lonlat instanceof OpenLayers.LonLat, "new OpenLayers.LonLat returns LonLat object" );
|
77 |
|
|
|
78 |
|
|
var ll = new OpenLayers.LonLat(6, 5);
|
79 |
|
|
t.ok( lonlat.equals(ll), "lonlat is set correctly");
|
80 |
|
|
}
|
81 |
|
|
|
82 |
|
|
// -->
|
83 |
|
|
</script>
|
84 |
|
|
</head>
|
85 |
|
|
<body>
|
86 |
|
|
</body>
|
87 |
|
|
</html>
|