Prechádzať zdrojové kódy

r.in.wms:
* fix list_layers()
* remove wget/curl options


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@37052 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 16 rokov pred
rodič
commit
fbdf8903e4
2 zmenil súbory, kde vykonal 17 pridanie a 33 odobranie
  1. 8 10
      scripts/r.in.wms/r.in.wms.html
  2. 9 23
      scripts/r.in.wms/r.in.wms.py

+ 8 - 10
scripts/r.in.wms/r.in.wms.html

@@ -1,15 +1,15 @@
 <h2>DESCRIPTION</h2>
 <h2>DESCRIPTION</h2>
 
 
-<em>r.in.wms</em>  handles all of downloading and importing raster data from
-an <a href="http://www.opengeospatial.org/specs/?page=specs">OpenGIS</a>
-WMS web mapping server. It need only be told the desired data to collect
-(bounds and resolution) via a region, the server to get the data from, and
-the layer or layers to get. It downloads the data in tiles, reprojects it,
-imports it, and patches it back together.
+<em>r.in.wms</em> handles all of downloading and importing raster data
+from an <a href="http://www.opengeospatial.org/standards/wms">OGC
+WMS</a> web mapping server. It need only be told the desired data to
+collect (bounds and resolution) via a region, the server to get the
+data from, and the layer or layers to get. It downloads the data in
+tiles, reprojects it, imports it, and patches it back together.
 
 
 <h2>NOTES</h2>
 <h2>NOTES</h2>
 
 
-By default data is downloaded to $GISDBASE/wms_download. This can be changed
+By default data is downloaded to <tt>$GISDBASE/wms_download</tt>. This can be changed
 by setting the <b>folder</b> option when using <em>r.in.wms</em>.
 by setting the <b>folder</b> option when using <em>r.in.wms</em>.
 
 
 <p>
 <p>
@@ -37,14 +37,12 @@ is where you should start. It tells you what data is offered, the projections
 it is in,  where to find meta data, resolutions, scales, and bounds for
 it is in,  where to find meta data, resolutions, scales, and bounds for
 data, etc.
 data, etc.
 
 
-<h3>NASA OnEarth server: Get Capabilities Request</h3>
+E.g. lists the layers available from the NASA OnEarth server.
 
 
 <div class="code"><pre>
 <div class="code"><pre>
 r.in.wms mapserver=http://wms.jpl.nasa.gov/wms.cgi -l
 r.in.wms mapserver=http://wms.jpl.nasa.gov/wms.cgi -l
 </pre></div>
 </pre></div>
 
 
-Lists the layers available from the NASA OnEarth server.
-
 <h3>US NED Elevation from OnEarth server download (metric units)</h3>
 <h3>US NED Elevation from OnEarth server download (metric units)</h3>
 
 
 Set the resolution to 30 (assuming you're in metric units):
 Set the resolution to 30 (assuming you're in metric units):

+ 9 - 23
scripts/r.in.wms/r.in.wms.py

@@ -5,7 +5,7 @@
 # MODULE:       r.in.wms
 # MODULE:       r.in.wms
 #
 #
 # AUTHOR(S):    Cedric Shock, 2006
 # AUTHOR(S):    Cedric Shock, 2006
-#               Pythonized by Martin Landa <landa.martin gmail.com>, 2009
+#               Upgraded for GRASS 7 by Martin Landa <landa.martin gmail.com>, 2009
 #
 #
 # PURPOSE:      To import data from web mapping servers
 # PURPOSE:      To import data from web mapping servers
 #               (based on Bash script by Cedric Shock)
 #               (based on Bash script by Cedric Shock)
@@ -149,22 +149,6 @@
 #% guisection: Download
 #% guisection: Download
 #%end
 #%end
 #%option
 #%option
-#% key: wgetoptions
-#% type: string
-#% description: Additional options for wget
-#% answer: -c -t 5 -nv
-#% required : no
-#% guisection: Download
-#%end
-#%option
-#% key: curloptions
-#% type: string
-#% description: Additional options for curl
-#% answer: -C - --retry 5 -s -S
-#% required : no
-#% guisection: Download
-#%end
-#%option
 #% key: method
 #% key: method
 #% type: string
 #% type: string
 #% description: Reprojection method to use
 #% description: Reprojection method to use
@@ -195,7 +179,6 @@ import grass
 
 
 wmsPath = os.path.join(os.getenv('GISBASE'), 'etc', 'r.in.wms')
 wmsPath = os.path.join(os.getenv('GISBASE'), 'etc', 'r.in.wms')
 sys.path.append(wmsPath)
 sys.path.append(wmsPath)
-print wmsPath
 import wms_request
 import wms_request
 import wms_download
 import wms_download
 
 
@@ -247,7 +230,10 @@ class ProcessCapFile(HandlerBase):
     def getLayers(self):
     def getLayers(self):
         """Print list of layers"""
         """Print list of layers"""
         for ly in self.layers:
         for ly in self.layers:
-            print "LAYER: " + ly['name']
+            if ly.has_key('name'):
+                print "LAYER: " + ly['name']
+            else:
+                print "LAYER: ???"
             if ly.has_key('title'):
             if ly.has_key('title'):
                 print "  Title: " + ly['title']
                 print "  Title: " + ly['title']
             if ly.has_key('srs'):
             if ly.has_key('srs'):
@@ -258,15 +244,15 @@ class ProcessCapFile(HandlerBase):
                     print "    Style title: " + ly['style']['title'][idx]
                     print "    Style title: " + ly['style']['title'][idx]
         
         
 def list_layers():
 def list_layers():
-    """Get available layers from WMS server"""
+    """Get list of available layers from WMS server"""
     qstring = "service=WMS&request=GetCapabilities&" + options['wmsquery']
     qstring = "service=WMS&request=GetCapabilities&" + options['wmsquery']
     grass.debug("POST-data: %s" % qstring)
     grass.debug("POST-data: %s" % qstring)
     
     
     # download capabilities file
     # download capabilities file
     grass.verbose("List of layers for server <%s>:" % options['mapserver'])
     grass.verbose("List of layers for server <%s>:" % options['mapserver'])
-    cap_file = urllib.urlopen(options['mapserver'] + qstring)
+    cap_file = urllib.urlopen(options['mapserver'] + '?' + qstring)
     if not cap_file:
     if not cap_file:
-        grass.fatal("Unable to get capabilities of <%s>" % options['mapserver'])
+        grass.fatal("Unable to get capabilities of '%s'" % options['mapserver'])
 
 
     # parse file with sax
     # parse file with sax
     cap_xml = ProcessCapFile()
     cap_xml = ProcessCapFile()
@@ -275,7 +261,7 @@ def list_layers():
     except xml.sax.SAXParseException, err:
     except xml.sax.SAXParseException, err:
         grass.fatal("Reading capabilities failed. "
         grass.fatal("Reading capabilities failed. "
                     "Unable to parse XML document: %s" % err)
                     "Unable to parse XML document: %s" % err)
-
+    
     cap_xml.getLayers()
     cap_xml.getLayers()
     
     
 def main():
 def main():