Browse Source

r.in.wms: GDAL driver user:password support (#196)

* add wms_version 1.1.0
* add user:pw for GDAL driver
* add debug and if the params are set

Co-Authored-By: Markus Neteler <neteler@mundialis.de>
AnikaBettge 5 years ago
parent
commit
cd25ae236c
2 changed files with 10 additions and 2 deletions
  1. 1 1
      scripts/r.in.wms/r.in.wms.py
  2. 9 1
      scripts/r.in.wms/wms_gdal_drv.py

+ 1 - 1
scripts/r.in.wms/r.in.wms.py

@@ -79,7 +79,7 @@ This program is free software under the GNU General Public License
 #% key: wms_version
 #% key: wms_version
 #% type:string
 #% type:string
 #% description: WMS standard version
 #% description: WMS standard version
-#% options: 1.1.1,1.3.0
+#% options: 1.1.0,1.1.1,1.3.0
 #% answer: 1.1.1
 #% answer: 1.1.1
 #% guisection: Request
 #% guisection: Request
 #%end
 #%end

+ 9 - 1
scripts/r.in.wms/wms_gdal_drv.py

@@ -113,6 +113,10 @@ class WMSGdalDrv(WMSBase):
         block_size_y = etree.SubElement(gdal_wms, "BlockSizeY")
         block_size_y = etree.SubElement(gdal_wms, "BlockSizeY")
         block_size_y.text = str(self.tile_size['rows'])
         block_size_y.text = str(self.tile_size['rows'])
 
 
+        if self.params['username'] and self.params['password']:
+            user_password = etree.SubElement(gdal_wms, "UserPwd")
+            user_password.text = "%s:%s" % (self.params['username'], self.params['password'])
+
         xml_file = self._tempfile()
         xml_file = self._tempfile()
 
 
         etree.ElementTree(gdal_wms).write(xml_file)
         etree.ElementTree(gdal_wms).write(xml_file)
@@ -137,11 +141,15 @@ class WMSGdalDrv(WMSBase):
                             "geographic projection, \n try 'WMS_GRASS' driver or use WMS version 1.1.1."))
                             "geographic projection, \n try 'WMS_GRASS' driver or use WMS version 1.1.1."))
 
 
         self._debug("_download", "started")
         self._debug("_download", "started")
-
         temp_map = self._tempfile()
         temp_map = self._tempfile()
 
 
         xml_file = self._createXML()
         xml_file = self._createXML()
 
 
+        # print xml file content for debug level 1
+        file = open(xml_file, "r")
+        grass.debug("WMS request XML:\n%s" % file.read(), 1)
+        file.close()
+
         if self.proxy:
         if self.proxy:
             gdal.SetConfigOption('GDAL_HTTP_PROXY', str(self.proxy))
             gdal.SetConfigOption('GDAL_HTTP_PROXY', str(self.proxy))
         if self.proxy_user_pw:
         if self.proxy_user_pw: