wms_layerframe.php
3.18 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
<HTML>
<HEAD>
<LINK REL='stylesheet' TYPE='text/css' HREF='wms_style.css'>
<SCRIPT LANGUAGE='JavaScript'>
function toggle(event) {
var lyrs = new Array();
var qlyrs = new Array();
for( i = 0; i < document.layerform.elements.length; i++ ) {
if( document.layerform.elements[i].name == "checks" ) {
if( document.layerform.elements[i].checked ) {
lyrs.push(document.layerform.elements[i].value);
if( eval("document.layerform.query_" + document.layerform.elements[i].value + ".value") ) {
qlyrs.push(document.layerform.elements[i].value);
}
}
}
}
top.mapframe.document.mapform.layers.value = lyrs.join(",");
top.mapframe.document.mapform.qlayers.value = qlyrs.join(",");
top.mapframe.doSubmit();
}
</SCRIPT>
</HEAD>
<BODY>
<?
# -------------------------------------------------------------
# Import the WMS support functions for PHP. These are mostly responsible for
# handling the XML capabilities request, and creating appropriate JavaScript
# objects from that data.8
#
# PHP functions are also used to generate the query result page.
#
include("wms_functions.php");
# -------------------------------------------------------------
# Test that there is a wms service defined before proceding.
#
if ( ! $onlineresource ) {
# No WMS service provided.
wms_fatal("No 'onlineresource' defined.");
}
$wms_service_request = $onlineresource . "REQUEST=GetCapabilities&SERVICE=WMS";
# -------------------------------------------------------------
# Test that the capabilites file has successfully downloaded.
#
if( !($wms_capabilities = file($wms_service_request)) ) {
# Cannot download the capabilities file.
wms_fatal("Unable to retrieve capabilities file '$wms_service_request'.");
}
$wms_capabilities = implode("",$wms_capabilities);
# -------------------------------------------------------------
# Test that the capabilites file has successfully parsed.
#
if( !($dom = xmldoc($wms_capabilities)) ) {
# Cannot parse the capabilities file.
wms_fatal("Unable to parse capabilities file from '$onlineresource'.<P>" . xml2html($wms_capabilities));
}
# -------------------------------------------------------------
# Create the JavaScript map object and layer objects.
# Set the layer objects to have a valid reference to the map object.
#
#print xml2html($wms_capabilities); exit;
print "<H1>" . wms_title($dom) . "</H1>";
print "<FORM NAME='layerform'>";
foreach (wms_layers($dom) as $layer) {
print wms_layer2html($layer);
}
$bbox = wms_bbox($dom);
print wms_hidden("bbox",$bbox);
print wms_hidden("format","image/png");
print wms_hidden("mode","PAN");
print wms_hidden("width","500");
print wms_hidden("height","500");
print wms_hidden("onlineresource",$onlineresource);
print wms_hidden("srs",wms_srs($dom));
print "</FORM>";
$bbox = explode(",",$bbox);
print "<TABLE BORDER=0 WIDTH=100% CELLPADDING=3>";
print "<TR VALIGN=TOP><TH CLASS=SMALL ALIGN=RIGHT>BBOX:</TH><TD CLASS=SMALL>LL $bbox[0],$bbox[1]<BR> UR $bbox[2],$bbox[3]</TD></TR>";
print "<TR VALIGN=TOP><TH CLASS=SMALL ALIGN=RIGHT>SRS:</TH><TD CLASS=SMALL>".wms_srs($dom)."</TD></TR>";
print "</TABLE>";
?>
</BODY>
</HTML>