FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
MapServer/src/mapscript/python/examples/wxs.py at main · jbfrd/MapServer · GitHub
jbfrd
/
MapServer
Public
forked from
MapServer/MapServer
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
MapServer
/
src
/
mapscript
/
python
/
examples
/
wxs.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
61 lines (41 loc) · 1.46 KB
Breadcrumbs
MapServer
/
src
/
mapscript
/
python
/
examples
/
wxs.py
Copy path
File metadata and controls
61 lines (41 loc) · 1.46 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#!/usr/bin/env python
"""
Output WMS GetCapabilities response for a Mapfile
Usage:
python wxs.py test.map
"""
import
sys
import
xml
.
dom
.
minidom
import
mapscript
def
main
(
map_file
):
map
=
mapscript
.
mapObj
(
map_file
)
map
.
web
.
metadata
.
set
(
"ows_onlineresource"
,
"http://dummy.org/"
)
ows_req
=
mapscript
.
OWSRequest
()
ows_req
.
type
=
mapscript
.
MS_GET_REQUEST
ows_req
.
setParameter
(
"SERVICE"
,
"WMS"
)
ows_req
.
setParameter
(
"VERSION"
,
"1.1.0"
)
ows_req
.
setParameter
(
"REQUEST"
,
"GetCapabilities"
)
mapscript
.
msIO_installStdoutToBuffer
()
dispatch_status
=
map
.
OWSDispatch
(
ows_req
)
if
dispatch_status
!=
mapscript
.
MS_SUCCESS
:
print
(
"An error occurred"
)
content_type
=
mapscript
.
msIO_stripStdoutBufferContentType
()
mapscript
.
msIO_stripStdoutBufferContentHeaders
()
result
=
mapscript
.
msIO_getStdoutBufferBytes
()
# [('Content-Type', 'application/vnd.ogc.wms_xml; charset=UTF-8'), ('Content-Length', '11385')]
response_headers
=
[(
'Content-Type'
,
content_type
),
(
'Content-Length'
,
str
(
len
(
result
)))]
assert
int
(
response_headers
[
1
][
1
])
>
0
dom
=
xml
.
dom
.
minidom
.
parseString
(
result
)
print
(
dom
.
toprettyxml
(
indent
=
""
,
newl
=
""
))
def
usage
():
"""
Display usage if program is used incorrectly
"""
print
(
"Syntax: %s <mapfile_path>"
%
sys
.
argv
[
0
])
sys
.
exit
(
2
)
# make sure a filename argument is provided
if
len
(
sys
.
argv
)
!=
2
:
usage
()
map_file
=
sys
.
argv
[
1
]
main
(
map_file
)
Back
|
FazBrowse Home
|
New Git URL