-
Notifications
You must be signed in to change notification settings - Fork 0
/
jstests.html
156 lines (123 loc) · 6.64 KB
/
jstests.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="../thirdparty/js/jsUnitCore.js"></script>
<link type="text/css" href="thirdparty/css/no-theme/jquery-ui-1.8.5.custom.css" rel="stylesheet" />
<link type="text/css" href="css/sheetcomposer.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.4.2.min.js" ></script>
<script type="text/javascript" src="js/jquery-ui-1.8.5.custom.min.js"></script>
<script type="text/javascript" src="thirdparty/js/OpenLayers.js" ></script>
<script type="text/javascript" src="js/main.js" ></script>
<script type="text/javascript">
/*function testMapRectangle() {
var map = new OpenLayers.Map("map_canvas", {
maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
numZoomLevels:18,
maxResolution:156543.0339,
units:'m',
projection: "EPSG:900913",
displayProjection: new OpenLayers.Projection("EPSG:4326"),
allOverlays: true
});
assertNotNull("Can't create map", map);
//map.getProjectionObject() doesn't work without layers
var dumpLayer = new OpenLayers.Layer.Vector("Dump Layer");
map.addLayers([dumpLayer]);
assertNotNull("Not exists projection object", map.getProjectionObject());
var curLogger = new NullLogger();
var mapCenterLonLat = new OpenLayers.LonLat(37.98, 55.78)
map.setCenter(mapCenterLonLat.transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()), 8);
var m_mapManager = new MapManager(map, {fillColor: "#ff0000", fillOpacity: 0.5});
var m_mapSheetRectangle = new MapSheetRectangle( m_mapManager, mapCenterLonLat, curLogger, new Sheet() );
var moveEventCount = 0;
$(m_mapSheetRectangle).bind('move', function(){moveEventCount++;});
assertNull( m_mapSheetRectangle.getNE() );
assertNull( m_mapSheetRectangle.getSW() );
assertEquals( moveEventCount, 0 );
assertNotNull( m_mapManager.getDragCallback() );
m_mapSheetRectangle.setSize(15000, 15000);
assertNotNull( m_mapSheetRectangle.getNE() );
assertNotNull( m_mapSheetRectangle.getSW() );
assertEquals( moveEventCount, 1 );
m_mapManager.getDragCallback()( new OpenLayers.Bounds(10, 20, 10, 20) );
assertEquals( moveEventCount, 2 );
}*/
function testSheetOptionsWidget()
{
var sheet = new Sheet();
var m_sheetOptionsWidget = new SheetOptionsWidget( $("#sheetOptionsWidgetContainer"), new NullLogger(), sheet );
var sx = 100;
var sy = 200;
$("#sow_sizex").val(sx);
$("#sow_sizey").val(sy);
$("#sow_sizex").trigger("change");
$("#sow_sizey").trigger("change");
//var sheetOptions = m_sheetOptionsWidget.getSheetOptions();
assertEquals( sheet.get('size_x'), sx);
assertEquals( sheet.get('size_y'), sy);
$("#sow_landscape").attr("checked", "checked");
$("#sow_landscape").trigger("change");
//sheetOptions = m_sheetOptionsWidget.getSheetOptions();
assertEquals( sheet.get('size_x'), sy);
assertEquals( sheet.get('size_y'), sx);
$("#sow_sizex").val("aaaaaaaaaaaaaaaaaaaaaaa");
$("#sow_sizex").trigger("change");
//sheetOptions = m_sheetOptionsWidget.getSheetOptions();
assertNaN( sheet.get('size_x') );
}
function testSheet()
{
//used for transformations
var map = new OpenLayers.Map("map_canvas", {
maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
numZoomLevels:18,
maxResolution:156543.0339,
units:'m',
projection: "EPSG:900913",
displayProjection: new OpenLayers.Projection("EPSG:4326"),
allOverlays: true
});
var dumpLayer = new OpenLayers.Layer.Vector("Dump Layer");
map.addLayers([dumpLayer]);
var converter = new CoordinatesConverter( map )
var m_sheet = new Sheet( converter );
assertUndefined(m_sheet.get('aaa'));
assertNaN(m_sheet.get('size_x'));
assertNaN(m_sheet.get('size_y'));
assertNaN(m_sheet.get('scale'));
assertNaN(m_sheet.get('resolution'));
assertNull(m_sheet.get('center'));
assertNull(m_sheet.get('ne'));
assertNull(m_sheet.get('sw'));
assertNull(m_sheet.get('nw'));
assertNull(m_sheet.get('se'));
assertNaN(m_sheet.get('dpi'));
assertNaN(m_sheet.get('pixel_count'));
m_sheet.set({size_x: 100, size_y: 200, scale: 500, resolution: 14});
m_sheet.set({center: new OpenLayers.LonLat(37.98, 55.78)});
assertEquals( m_sheet.get('size_x'), 100 );
assertEquals( m_sheet.get('size_y'), 200 );
assertEquals( m_sheet.get('scale'), 500 );
assertEquals( m_sheet.get('resolution'), 14 );
var center = m_sheet.get('center');
assertEquals( center.lon, 37.98 );
assertEquals( center.lat, 55.78 );
assertNotNull(m_sheet.get('ne'));
assertNotNull(m_sheet.get('sw'));
assertNotNull(m_sheet.get('se'));
assertNotNull(m_sheet.get('nw'));
assertNotNaN(m_sheet.get('minx'));
assertNotNaN(m_sheet.get('miny'));
assertNotNaN(m_sheet.get('maxx'));
assertNotNaN(m_sheet.get('maxy'));
assertNotNaN(m_sheet.get('dpi'));
assertNotNaN(m_sheet.get('pixel_count'));
}
</script>
</head>
<body>
<div id="map_canvas" style="width: 100%; height: 100%; margin:0; padding:0; overflow:hidden;"></div>
<!--#include virtual="sheet_options_widget.html" -->
</body>
</html>