浏览代码

v.import: Add layer to the projection check (#1328)

Layers in some formats (e.g., GeoPackage) can have different projections, so a test with v.in.ogr
without layer may report a difference although the user specified layer with matching projection for v.import.
Vaclav Petras 4 年之前
父节点
当前提交
32e9cc0003
共有 1 个文件被更改,包括 5 次插入3 次删除
  1. 5 3
      scripts/v.import/v.import.py

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

@@ -133,11 +133,13 @@ def GDAL_COMPUTE_VERSION(maj, min, rev):
     return (maj) * 1000000 + (min) * 10000 + (rev) * 100
 
 
-def is_projection_matching(OGRdatasource):
+def is_projection_matching(OGRdatasource, layer):
     """Returns True if current location projection
     matches dataset projection, otherwise False"""
     try:
-        grass.run_command("v.in.ogr", input=OGRdatasource, flags="j", quiet=True)
+        grass.run_command(
+            "v.in.ogr", input=OGRdatasource, layer=layer, flags="j", quiet=True
+        )
         return True
     except CalledModuleError:
         return False
@@ -215,7 +217,7 @@ def main():
     vopts["snap"] = options["snap"]
 
     # try v.in.ogr directly
-    if flags["o"] or is_projection_matching(OGRdatasource):
+    if flags["o"] or is_projection_matching(OGRdatasource, layers):
         try:
             grass.run_command(
                 "v.in.ogr",