Skip to content

Commit

Permalink
wxGUI/modules: fix import PostGIS geometry data (OSGeo#2490)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmszi authored and marisn committed May 18, 2023
1 parent 97349a7 commit 86d0e79
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
1 change: 1 addition & 0 deletions gui/wxpython/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,7 @@ def _parseFormats(output, writableOnly=False):
continue
if name in (
"PostgreSQL",
"PostgreSQL/PostGIS",
"SQLite",
"SQLite / Spatialite",
"ODBC",
Expand Down
17 changes: 15 additions & 2 deletions gui/wxpython/gui_core/gselect.py
Original file line number Diff line number Diff line change
Expand Up @@ -2003,8 +2003,11 @@ def SetSourceType(self, sourceType):
if sourceType == "db":
self.dbWidgets["format"].SetItems(list(self.dbFormats.values()))
if self.dbFormats:
if "PostgreSQL" in self.dbFormats.values():
db_formats = self.dbFormats.values()
if "PostgreSQL" in db_formats:
self.dbWidgets["format"].SetStringSelection("PostgreSQL")
elif "PostgreSQL/PostGIS" in db_formats:
self.dbWidgets["format"].SetStringSelection("PostgreSQL/PostGIS")
else:
self.dbWidgets["format"].SetSelection(0)
self.dbWidgets["format"].Enable()
Expand Down Expand Up @@ -2102,6 +2105,7 @@ def GetDsn(self):
if self._sourceType == "db":
if self.dbWidgets["format"].GetStringSelection() in (
"PostgreSQL",
"PostgreSQL/PostGIS",
"PostGIS Raster driver",
):
ret = RunCommand("db.login", read=True, quiet=True, flags="p")
Expand Down Expand Up @@ -2171,10 +2175,19 @@ def SetDatabase(self, db):
showDirbrowse = db in ("FileGDB")
showChoice = db in (
"PostgreSQL",
"PostgreSQL/PostGIS",
"PostGIS WKT Raster driver",
"PostGIS Raster driver",
)
enableFeatType = self.dest and self.ogr and db in ("PostgreSQL")
enableFeatType = (
self.dest
and self.ogr
and db
in (
"PostgreSQL",
"PostgreSQL/PostGIS",
)
)
showText = not (showBrowse or showChoice or showDirbrowse)

sizer.Show(self.dbWidgets["browse"], show=showBrowse)
Expand Down
8 changes: 7 additions & 1 deletion gui/wxpython/modules/import_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,13 +613,19 @@ def OnRun(self, event):
return

dsn = self.dsnInput.GetDsn()
if not dsn:
return
ext = self.dsnInput.GetFormatExt()

# determine data driver for PostGIS links
self.popOGR = False
if (
self.dsnInput.GetType() == "db"
and self.dsnInput.GetFormat() == "PostgreSQL"
and self.dsnInput.GetFormat()
in (
"PostgreSQL",
"PostgreSQL/PostGIS",
)
and "GRASS_VECTOR_OGR" not in os.environ
):
self.popOGR = True
Expand Down

0 comments on commit 86d0e79

Please sign in to comment.