/usr/lib/grass70/gui/scripts/d.wms is in grass-gui 7.0.3-1build1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | #! /usr/bin/python
#
############################################################################
#
# MODULE: d.wms
#
# AUTHOR(S): Stepan Turek <stepan.turek seznam.cz> (mentor: Martin Landa)
#
# PURPOSE: Wrapper for wxGUI to add WMS into layer tree
#
# COPYRIGHT: (C) 2012 by Stepan Turek, and the GRASS Development Team
#
# This program is free software under the GNU General Public License
# (>=v2). Read the file COPYING that comes with GRASS for details.
#
#############################################################################
#%module
#% description: Downloads and displays data from WMS/WMTS/NASA OnEarth server.
#% keyword: raster
#% keyword: import
#% keyword: WMS
#% keyword: WMTS
#% keyword: OnEarth
#%end
#%option
#% key: url
#% type: string
#% description: Typically starts with "http://"
#% required: yes
#%end
#%option
#% key: map
#% type: string
#% description: Name for output WMS layer in the layer tree
#% required : yes
#%end
#%option
#% key: layers
#% type: string
#% description: Layer(s) to request from the map server
#% multiple: yes
#% required: yes
#%end
#%option
#% key: styles
#% type: string
#% description: Layer style(s) to request from the map server
#% multiple: yes
#% guisection: Map style
#%end
#%option
#% key: format
#% type: string
#% description: Image format requested from the server
#% options: geotiff,tiff,jpeg,gif,png,png8
#% answer: png
#% guisection: Request
#%end
#%option
#% key: srs
#% type: integer
#% description: EPSG code of requested source projection
#% answer:4326
#% guisection: Request
#%end
#%option
#% key: driver
#% type:string
#% description: Driver used to communication with server
#% descriptions: WMS_GDAL;Download data using GDAL WMS driver;WMS_GRASS;Download data using native GRASS-WMS driver;WMTS_GRASS;Download data using native GRASS-WMTS driver;OnEarth_GRASS;Download data using native GRASS-OnEarth driver;
#% options:WMS_GDAL, WMS_GRASS, WMTS_GRASS, OnEarth_GRASS
#% answer:WMS_GRASS
#% guisection: Connection
#%end
#%option
#% key: wms_version
#% type:string
#% description: WMS standard version
#% options: 1.1.1,1.3.0
#% answer: 1.1.1
#% guisection: Request
#%end
#%option
#% key: maxcols
#% type:integer
#% description: Maximum columns to request at a time
#% answer:512
#% guisection: Request
#%end
#%option
#% key: maxrows
#% type: integer
#% description: Maximum rows to request at a time
#% answer: 512
#% guisection: Request
#%end
#%option
#% key: urlparams
#% type:string
#% description: Additional query parameters to pass to the server
#% guisection: Request
#%end
#%option
#% key: username
#% type:string
#% description: Username for server connection
#% guisection: Connection
#%end
#%option
#% key: password
#% type:string
#% description: Password for server connection
#% guisection: Connection
#%end
#%option
#% key: method
#% type: string
#% description: Interpolation method to use in reprojection
#% options:nearest,linear,cubic,cubicspline
#% answer:nearest
#% required: no
#%end
#%option
#% key: bgcolor
#% type: string
#% description: Background color
#% guisection: Map style
#%end
#%option G_OPT_F_BIN_INPUT
#% key: capfile
#% required: no
#% description: Capabilities file to parse (input). It is relevant for WMTS_GRASS and OnEarth_GRASS drivers
#%end
#%flag
#% key: o
#% description: Don't request transparent data
#% guisection: Map style
#%end
import os
import sys
from grass.script import core as grass
sys.path.append(os.path.join(os.getenv("GISBASE"), "etc", "r.in.wms"))
def GetRegion():
"""!Parse region from GRASS_REGION env var.
"""
region = os.environ["GRASS_REGION"]
conv_reg_vals = {'east' : 'e',
'north' : 'n',
'west' : 'w',
'south' : 's',
'rows' : 'rows',
'cols' : 'cols',
'e-w resol' : 'ewres',
'n-s resol' : 'nsres'}
keys_to_convert = conv_reg_vals.keys()
conv_region = {}
region = region.split(';')
for r in region:
r = r.split(':')
r[0] = r[0].strip()
if r[0] in keys_to_convert:
conv_region[conv_reg_vals[r[0]]] = float(r[1])
return conv_region
def main():
options['region'] = GetRegion()
if 'GRASS' in options['driver']:
grass.debug("Using GRASS driver")
from wms_drv import WMSDrv
wms = WMSDrv()
elif 'GDAL' in options['driver']:
grass.debug("Using GDAL WMS driver")
from wms_gdal_drv import WMSGdalDrv
wms = WMSGdalDrv()
temp_map = wms.GetMap(options, flags)
os.rename(temp_map, os.environ["GRASS_RENDER_FILE"])
return 0
if __name__ == "__main__":
options, flags = grass.parser()
sys.exit(main())
|