[GRASS-SVN] r66358 - in grass/branches/releasebranch_7_0/scripts: r.unpack v.unpack

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Sep 27 15:57:43 PDT 2015


Author: annakrat
Date: 2015-09-27 15:57:43 -0700 (Sun, 27 Sep 2015)
New Revision: 66358

Modified:
   grass/branches/releasebranch_7_0/scripts/r.unpack/r.unpack.py
   grass/branches/releasebranch_7_0/scripts/v.unpack/v.unpack.py
Log:
r.unpack/v.unpack: fix importing to xy location, see #2726

Modified: grass/branches/releasebranch_7_0/scripts/r.unpack/r.unpack.py
===================================================================
--- grass/branches/releasebranch_7_0/scripts/r.unpack/r.unpack.py	2015-09-27 22:44:21 UTC (rev 66357)
+++ grass/branches/releasebranch_7_0/scripts/r.unpack/r.unpack.py	2015-09-27 22:57:43 UTC (rev 66358)
@@ -105,34 +105,41 @@
         diff_result_1 = diff_result_2 = None
         
         proj_info_file_1 = 'PROJ_INFO'
-        proj_info_file_2 = os.path.join(mset_dir, '..', 'PERMANENT', 'PROJ_INFO')    
-    
-        if not grass.compare_key_value_text_files(filename_a=proj_info_file_1,
-                                                  filename_b=proj_info_file_2,
-                                                  proj=True):                                                      
-            diff_result_1 = diff_files(proj_info_file_1, proj_info_file_2)
-    
-        proj_units_file_1 = 'PROJ_UNITS'
-        proj_units_file_2 = os.path.join(mset_dir, '..', 'PERMANENT', 'PROJ_UNITS')
-    
-        if not grass.compare_key_value_text_files(filename_a=proj_units_file_1,
-                                                  filename_b=proj_units_file_2,
-                                                  units=True):                                                      
-            diff_result_2 = diff_files(proj_units_file_1, proj_units_file_2)
-    
-        if diff_result_1 or diff_result_2:
-            
-            if diff_result_1:
-                grass.warning(_("Difference between PROJ_INFO file of packed map "
-                                "and of current location:\n{diff}").format(diff=''.join(diff_result_1)))
-            if diff_result_2:
-                grass.warning(_("Difference between PROJ_UNITS file of packed map "
-                                "and of current location:\n{diff}").format(diff=''.join(diff_result_2)))
-            grass.fatal(_("Projection of dataset does not appear to match current location."
-                          " In case of no significant differences in the projection definitions,"
-                          " use the -o flag to ignore them and use"
-                          " current location definition."))
+        proj_info_file_2 = os.path.join(mset_dir, '..', 'PERMANENT', 'PROJ_INFO')
 
+        skip_projection_check = False
+        if not os.path.exists(proj_info_file_1):
+            if os.path.exists(proj_info_file_2):
+                grass.fatal(_("PROJ_INFO file is missing, unpack raster map in XY (unprojected) location."))
+            skip_projection_check = True  # XY location
+
+        if not skip_projection_check:
+            if not grass.compare_key_value_text_files(filename_a=proj_info_file_1,
+                                                      filename_b=proj_info_file_2,
+                                                      proj=True):                                                      
+                diff_result_1 = diff_files(proj_info_file_1, proj_info_file_2)
+        
+            proj_units_file_1 = 'PROJ_UNITS'
+            proj_units_file_2 = os.path.join(mset_dir, '..', 'PERMANENT', 'PROJ_UNITS')
+        
+            if not grass.compare_key_value_text_files(filename_a=proj_units_file_1,
+                                                      filename_b=proj_units_file_2,
+                                                      units=True):                                                      
+                diff_result_2 = diff_files(proj_units_file_1, proj_units_file_2)
+        
+            if diff_result_1 or diff_result_2:
+                
+                if diff_result_1:
+                    grass.warning(_("Difference between PROJ_INFO file of packed map "
+                                    "and of current location:\n{diff}").format(diff=''.join(diff_result_1)))
+                if diff_result_2:
+                    grass.warning(_("Difference between PROJ_UNITS file of packed map "
+                                    "and of current location:\n{diff}").format(diff=''.join(diff_result_2)))
+                grass.fatal(_("Projection of dataset does not appear to match current location."
+                              " In case of no significant differences in the projection definitions,"
+                              " use the -o flag to ignore them and use"
+                              " current location definition."))
+
     # install in $MAPSET
     for element in ['cats', 'cell', 'cellhd', 'cell_misc', 'colr', 'fcell', 'hist']:
         if not os.path.exists(element):

Modified: grass/branches/releasebranch_7_0/scripts/v.unpack/v.unpack.py
===================================================================
--- grass/branches/releasebranch_7_0/scripts/v.unpack/v.unpack.py	2015-09-27 22:44:21 UTC (rev 66357)
+++ grass/branches/releasebranch_7_0/scripts/v.unpack/v.unpack.py	2015-09-27 22:57:43 UTC (rev 66358)
@@ -109,33 +109,40 @@
     loc_proj = os.path.join(mset_dir, '..', 'PERMANENT', 'PROJ_INFO')
     loc_proj_units = os.path.join(mset_dir, '..', 'PERMANENT', 'PROJ_UNITS')
 
-    diff_result_1 = diff_result_2 = None
-    if not grass.compare_key_value_text_files(filename_a=os.path.join(tmp_dir, 'PROJ_INFO'),
-                                              filename_b=loc_proj, proj=True):
-        diff_result_1 = diff_files(os.path.join(tmp_dir, 'PROJ_INFO'),
-                                         loc_proj)
+    skip_projection_check = False
+    if not os.path.exists(os.path.join(tmp_dir, 'PROJ_INFO')):
+        if os.path.exists(loc_proj):
+            grass.fatal(_("PROJ_INFO file is missing, unpack vector map in XY (unprojected) location."))
+        skip_projection_check = True  # XY location
 
-    if not grass.compare_key_value_text_files(filename_a=os.path.join(tmp_dir, 'PROJ_UNITS'),
-                                              filename_b=loc_proj_units,
-                                              units=True):
-        diff_result_2 = diff_files(os.path.join(tmp_dir, 'PROJ_UNITS'),
-                                         loc_proj_units)
+    if not skip_projection_check:
+        diff_result_1 = diff_result_2 = None
+        if not grass.compare_key_value_text_files(filename_a=os.path.join(tmp_dir, 'PROJ_INFO'),
+                                                  filename_b=loc_proj, proj=True):
+            diff_result_1 = diff_files(os.path.join(tmp_dir, 'PROJ_INFO'),
+                                             loc_proj)
+    
+        if not grass.compare_key_value_text_files(filename_a=os.path.join(tmp_dir, 'PROJ_UNITS'),
+                                                  filename_b=loc_proj_units,
+                                                  units=True):
+            diff_result_2 = diff_files(os.path.join(tmp_dir, 'PROJ_UNITS'),
+                                             loc_proj_units)
+    
+        if diff_result_1 or diff_result_2:
+            if flags['o']:
+                grass.warning(_("Projection information does not match. Proceeding..."))
+            else:
+                if diff_result_1:
+                    grass.warning(_("Difference between PROJ_INFO file of packed map "
+                                    "and of current location:\n{diff}").format(diff=''.join(diff_result_1)))
+                if diff_result_2:
+                    grass.warning(_("Difference between PROJ_UNITS file of packed map "
+                                    "and of current location:\n{diff}").format(diff=''.join(diff_result_2)))
+                grass.fatal(_("Projection of dataset does not appear to match current location."
+                              " In case of no significant differences in the projection definitions,"
+                              " use the -o flag to ignore them and use"
+                              " current location definition."))
 
-    if diff_result_1 or diff_result_2:
-        if flags['o']:
-            grass.warning(_("Projection information does not match. Proceeding..."))
-        else:
-            if diff_result_1:
-                grass.warning(_("Difference between PROJ_INFO file of packed map "
-                                "and of current location:\n{diff}").format(diff=''.join(diff_result_1)))
-            if diff_result_2:
-                grass.warning(_("Difference between PROJ_UNITS file of packed map "
-                                "and of current location:\n{diff}").format(diff=''.join(diff_result_2)))
-            grass.fatal(_("Projection of dataset does not appear to match current location."
-                          " In case of no significant differences in the projection definitions,"
-                          " use the -o flag to ignore them and use"
-                          " current location definition."))
-
     # new db
     fromdb = os.path.join(tmp_dir, 'db.sqlite')
     # copy file



More information about the grass-commit mailing list