Przeglądaj źródła

v.unpack: fix importing to xy location

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@66019 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 9 lat temu
rodzic
commit
8cf7413f0c
1 zmienionych plików z 33 dodań i 26 usunięć
  1. 33 26
      scripts/v.unpack/v.unpack.py

+ 33 - 26
scripts/v.unpack/v.unpack.py

@@ -110,32 +110,39 @@ def main():
     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)
-
-    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."))
+    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 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."))
 
     # new db
     fromdb = os.path.join(tmp_dir, 'db.sqlite')