Browse Source

v.import: add new parameters <epsg> and <datum_trans> to override input SRS

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@66969 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 9 years ago
parent
commit
7e9dc1425a
1 changed files with 32 additions and 0 deletions
  1. 32 0
      scripts/v.import/v.import.py

+ 32 - 0
scripts/v.import/v.import.py

@@ -67,6 +67,21 @@
 #% answer: 1e-13
 #% guisection: Output
 #%end
+#%option
+#% key: epsg
+#% type: integer
+#% options: 1-1000000
+#% guisection: Input SRS
+#% description: EPSG projection code
+#%end
+#%option
+#% key: datum_trans
+#% type: integer
+#% options: -1-100
+#% guisection: Input SRS
+#% label: Index number of datum transform parameters
+#% description: -1 to list available datum transform parameters
+#%end
 #%flag
 #% key: f
 #% description: List supported OGR formats and exit
@@ -126,6 +141,14 @@ def main():
     if options['encoding']:
         vopts['encoding'] = options['encoding']
 
+    if options['datum_trans'] and options['datum_trans'] == '-1':
+        # list datum transform parameters
+        if not options['epsg']:
+            grass.fatal(_("Missing value for parameter <%s>") % 'epsg')
+        
+        return grass.run_command('g.proj', epsg=options['epsg'],
+                                 datum_trans=options['datum_trans'])
+    
     grassenv = grass.gisenv()
     tgtloc = grassenv['LOCATION_NAME']
     tgtmapset = grassenv['MAPSET']
@@ -160,6 +183,12 @@ def main():
     # switch to temp location
     os.environ['GISRC'] = str(SRCGISRC)
 
+    if options['epsg']: # force given EPSG
+        kwargs = {}
+        if options['datum_trans']:
+            kwargs['datum_trans'] = options['datum_trans']
+        grass.run_command('g.proj', flags='c', epsg=options['epsg'], **kwargs)
+        
     # switch to target location
     os.environ['GISRC'] = str(tgtgisrc)
 
@@ -181,6 +210,9 @@ def main():
     # switch to temp location
     os.environ['GISRC'] = str(SRCGISRC)
 
+    # print projection at verbose level
+    grass.verbose(grass.read_command('g.proj', flags='p').rstrip(os.linesep))
+    
     # make sure input is not xy
     if grass.parse_command('g.proj', flags='g')['name'] == 'xy_location_unprojected':
         grass.fatal(_("Coordinate reference system not available for input <%s>") % OGRdatasource)