Forráskód Böngészése

r.import + v.import: add -o flag
(merge https://trac.osgeo.org/grass/changeset/67632 + https://trac.osgeo.org/grass/changeset/67634 from trunk)


git-svn-id: https://svn.osgeo.org/grass/grass/branches/releasebranch_7_0@67746 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 9 éve
szülő
commit
e83592de9c
2 módosított fájl, 22 hozzáadás és 9 törlés
  1. 10 4
      scripts/r.import/r.import.py
  2. 12 5
      scripts/v.import/v.import.py

+ 10 - 4
scripts/r.import/r.import.py

@@ -8,7 +8,7 @@
 #
 #
 # PURPOSE:      Import and reproject on the fly
 # PURPOSE:      Import and reproject on the fly
 #
 #
-# COPYRIGHT:    (C) 2015 GRASS development team
+# COPYRIGHT:    (C) 2015-2016 GRASS development team
 #
 #
 #               This program is free software under the GNU General
 #               This program is free software under the GNU General
 #               Public License (>=v2). Read the file COPYING that
 #               Public License (>=v2). Read the file COPYING that
@@ -103,7 +103,11 @@
 #% key: l
 #% key: l
 #% description: Force Lat/Lon maps to fit into geographic coordinates (90N,S; 180E,W)
 #% description: Force Lat/Lon maps to fit into geographic coordinates (90N,S; 180E,W)
 #%end
 #%end
-
+#%flag
+#% key: o
+#% label: Override projection check (use current location's projection)
+#% description: Assume that the dataset has same projection as the current location
+#%end
 
 
 import sys
 import sys
 import os
 import os
@@ -188,8 +192,10 @@ def main():
 
 
     # try r.in.gdal directly first
     # try r.in.gdal directly first
     additional_flags = 'l' if flags['l'] else ''
     additional_flags = 'l' if flags['l'] else ''
-    if grass.run_command('r.in.gdal', input=GDALdatasource, flags='j',
-                         errors='status', quiet=True) == 0:
+    if flags['o']:
+        additional_flags += 'o'
+    if flags['o'] or grass.run_command('r.in.gdal', input=GDALdatasource, flags='j',
+                                       errors='status', quiet=True) == 0:
         parameters = dict(input=GDALdatasource, output=output,
         parameters = dict(input=GDALdatasource, output=output,
                           memory=memory, flags='k' + additional_flags)
                           memory=memory, flags='k' + additional_flags)
         if bands:
         if bands:

+ 12 - 5
scripts/v.import/v.import.py

@@ -86,7 +86,11 @@
 #% key: l
 #% key: l
 #% description: List available OGR layers in data source and exit
 #% description: List available OGR layers in data source and exit
 #%end
 #%end
-
+#%flag
+#% key: o
+#% label: Override projection check (use current location's projection)
+#% description: Assume that the dataset has same projection as the current location
+#%end
 
 
 import sys
 import sys
 import os
 import os
@@ -129,9 +133,12 @@ def main():
     output = options['output']
     output = options['output']
     layers = options['layer']
     layers = options['layer']
 
 
-    vflags = None
+    vflags = ''
     if options['extent'] == 'region':
     if options['extent'] == 'region':
-        vflags = 'r'
+        vflags += 'r'
+    if flags['o']:
+        vflags += 'o'
+
     vopts = {}
     vopts = {}
     if options['encoding']:
     if options['encoding']:
         vopts['encoding'] = options['encoding']
         vopts['encoding'] = options['encoding']
@@ -188,8 +195,8 @@ def main():
     os.environ['GISRC'] = str(tgtgisrc)
     os.environ['GISRC'] = str(tgtgisrc)
 
 
     # try v.in.ogr directly
     # try v.in.ogr directly
-    if grass.run_command('v.in.ogr', input=OGRdatasource, flags='j',
-                         errors='status', quiet=True) == 0:
+    if flags['o'] or grass.run_command('v.in.ogr', input=OGRdatasource, flags='j',
+                                       errors='status', quiet=True) == 0:
         try:
         try:
             grass.run_command('v.in.ogr', input=OGRdatasource,
             grass.run_command('v.in.ogr', input=OGRdatasource,
                               flags=vflags, **vopts)
                               flags=vflags, **vopts)