wms_mapframe.php
4.09 KB
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
<HTML>
<HEAD>
<LINK REL='stylesheet' TYPE='text/css' HREF='wms_style.css'>
<SCRIPT LANGUAGE='JavaScript'>
function doQuery() {
//
// If we are in query mode, we want a new window
// to submit the form into.
//
var win_size = "width=280,height=450";
var win_frame = "status=no,menubar=no,toolbar=no,resizeable=yes,scrollbars=yes";
window.qwin = open("","queryframe",win_size + "," + win_frame);
window.qwin.focus();
return(true);
}
function doSubmit() {
//
// This function takes submissions from the layer list and
// ensures they go to the right target if we happen to be
// in query mode at the time.
//
if ( document.mapform.mode.value == "qry" ) {
document.mapform.action = "wms_mapframe.php";
document.mapform.target = "mapframe";
}
document.mapform.submit();
}
function setMode(mode) {
//
// This takes mode changes from the titleframe and handles
// the interface state appropriately.
//
document.mapform.mode.value = mode;
if ( mode == "qry" ) {
//
// Set the target and action appropriately for query mode.
//
document.mapform.onsubmit = doQuery;
document.mapform.action = "wms_query.php";
document.mapform.target = "queryframe";
}
else {
//
// Set the target and action appropriately for other modes.
//
document.mapform.action = "wms_mapframe.php";
document.mapform.onsubmit = null;
document.mapform.target = "mapframe";
if( window.qwin != null ) {
window.qwin.close();
}
}
if ( mode == "all" ) {
document.mapform.submit();
}
}
</SCRIPT>
</HEAD>
<BODY TOPMARGIN=0 BOTTOMMARGIN=0 RIGHTMARGIN=0 LEFTMARGIN=0>
<FORM NAME='mapform' TARGET='mapframe' METHOD='post' ACTION='wms_mapframe.php'>
<?
include("wms_functions.php");
if ( $_POST["onlineresource"] ) {
$size = array($_POST["width"],$_POST["height"]);
$bbox = explode(",",$_POST["bbox"]);
if( $_POST["mapimg_x"] && $_POST["mapimg_y"] ) {
$click = array($_POST["mapimg_x"],$_POST["mapimg_y"]);
if( $_POST["mode"] == "pan" ) {
$bbox = wms_pan( $bbox, $size, $click );
}
elseif( $_POST["mode"] == "zin" ) {
$bbox = wms_pan( $bbox, $size, $click );
$bbox = wms_zoom( $bbox, 0.5 );
}
elseif( $_POST["mode"] == "zout" ) {
$bbox = wms_pan( $bbox, $size, $click );
$bbox = wms_zoom( $bbox, 2.0 );
}
}
#
# We are in zoom-to-extents mode, to override current
# extent with saved original extent. Then switch to
# the default mode (pan).
#
if( $_POST["mode"] == "all" ) {
$bbox = explode(",",$_POST["bbox0"]);
$_POST["mode"] = "pan";
}
#
# Resize the spatial extents to match the image
# aspect.
#
$bbox = wms_scale( $bbox, $size );
$_POST["bbox"] = implode(",",$bbox);
#
# Store the initial extent for future use.
#
if( ! $_POST["bbox0"] ) {
$_POST["bbox0"] = $_POST["bbox"];
}
#
# Create the GETMAP URL.
#
$url = $_POST["onlineresource"] .
"VERSION=" . urlencode("1.1.0") . "&" .
"REQUEST=GetMap&" .
"BBOX=" . urlencode($_POST["bbox"]) . "&" .
"LAYERS=" . urlencode($_POST["layers"]) . "&" .
"SRS=" . urlencode($_POST["srs"]) . "&" .
"WIDTH=" . urlencode($_POST["width"]) . "&" .
"HEIGHT=" . urlencode($_POST["height"]) . "&" .
"FORMAT=" . urlencode($_POST["format"]);
#
# Get the map image.
#
print "<INPUT BORDER=0 TYPE='image' NAME='mapimg' SRC='$url'>";
}
#
# Fill out the wraparound information. This saves the state of the
# system for use in the next action.
#
$wms_vars = array("bbox","format","width","height","layers","mode","srs","onlineresource","bbox0","qlayers");
foreach ( $wms_vars as $var ) {
print wms_hidden($var,$_POST[$var]);
}
?>
</FORM>
<SCRIPT LANGUAGE='JavaScript'>
//
// A silly hack to ensure that if we are in query mode the
// form target and action correspond to the query mode.
//
if ( document.mapform.mode.value == "qry" ) {
document.mapform.target = "queryframe";
document.mapform.action = "wms_query.php";
}
</SCRIPT>
</BODY>
</HTML>