Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wxGUI loc wizard: Improve new location's CRS method selection page #721

Conversation

lindakarlovska
Copy link
Contributor

@lindakarlovska lindakarlovska commented Jun 19, 2020

In the third commit I have a issue after confirmation of WKT Summary page:
Screenshot from 2020-06-20 15-10-54
Still wants to open a WKT file but I am not able to figure out where is the core of this problem.

…J.4 page. Now I have a coding problem with passing wkt string as a stdin into the g.proj function.
@lindakarlovska lindakarlovska marked this pull request as draft June 19, 2020 10:36
@petrasovaa
Copy link
Contributor

Please see https://trac.osgeo.org/grass/wiki/Submitting/General#Commitmessages how to write commit messages. If you need help, please write it in the PR discussion.

@petrasovaa petrasovaa linked an issue Jun 19, 2020 that may be closed by this pull request
6 tasks
@petrasovaa petrasovaa added the gsoc Reserved for Google Summer of Code student(s) label Jun 19, 2020

# layout
self.sizer.SetVGap(10)
self.sizer.Add(StaticText(parent=self, label=_("Simple methods:")),
self.sizer.Add(StaticText(parent=self, label=_("Select Coordinate Reference System (CRS):")),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was suggestion dropping "simple methods" altogether and using "Select Coordinate Reference System (CRS)" as the title of the page.

self.sizer.Add(self.radioXy,
flag=wx.ALIGN_LEFT, pos=(4, 1))
self.sizer.Add(StaticText(parent=self, label=_("Advanced additional methods:")),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use "Additional methods", definitely not Advanced additional methods.

self.Bind(wiz.EVT_WIZARD_PAGE_CHANGING, self.OnPageChanging)
self.Bind(wiz.EVT_WIZARD_PAGE_CHANGED, self.OnEnterPage)

def OnEnterPage(self, event):
if len(self.wktfile) == 0:
if len(self.customstring) == 0:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name it something like wktstring

# disable 'next' button by default
wx.FindWindowById(wx.ID_FORWARD).Enable(False)
else:
wx.FindWindowById(wx.ID_FORWARD).Enable(True)

event.Skip()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WHITESPACE!

else:
if nextButton.IsEnabled():
nextButton.Enable(False)
# check for datum tranforms
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To keep things consistent with the rest, the WKTPage doesn't change much (except for the layout). g.proj is called in Summary page:

            elif coordsys == 'wkt':
                ret, projlabel, err = RunCommand(
                    'g.proj', flags='jft', wkt=self.parent.wktpage.wktfile, **extra_opts)

so you need to adjust the code here. So OnPageChanging should stay similar to what was there before. The RunCommand in Summary page should look something like this:

            elif coordsys == 'wkt':
                ret, projlabel, err = RunCommand(
                    'g.proj', flags='jft', wkt="-", stdin=self.parent.wktpage.wktstring, **extra_opts)

(not tested)

… of the page, used 'Additional methods' instead of 'Advanced additional methods', renamed 'customstring' to 'wktstring', removed a whitespace, changed run command of wkt selection in the summary page.
Copy link
Contributor

@petrasovaa petrasovaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am getting error when trying to create the location with wkt (after summary page):

Traceback (most recent call last):
  File "/home/anna/dev/grass/grass/dist.x86_64-pc-linux-gnu/gui/wxpython/gis_set.py", line 537, in OnWizard
    grassdatabase=self.tgisdbase.GetValue())
  File "/home/anna/dev/grass/grass/dist.x86_64-pc-linux-gnu/gui/wxpython/location_wizard/wizard.py", line 2396, in __init__
    msg = self.OnWizFinished()
  File "/home/anna/dev/grass/grass/dist.x86_64-pc-linux-gnu/gui/wxpython/location_wizard/wizard.py", line 2640, in OnWizFinished
    if not self.wktpage.wktfile or \
AttributeError: 'WKTPage' object has no attribute 'wktfile'

@@ -2259,7 +2237,7 @@ def OnEnterPage(self, event):
label = 'matches file %s' % self.parent.filepage.georeffile

elif coordsys == 'wkt':
label = 'matches file %s' % self.parent.wktpage.wktfile
label = 'matches string %s' % self.parent.wktpage.wktstring
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe "matches WKT string" would be better.
More importantly, the string is long, so you need to change the widget to enable scrolling, it should be similar to panelProj4string in SummaryPage.

def OnText(self, event):
"""File changed"""
self.wktfile = event.GetString()
def GetWktstring(self, event):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should still be called OnText, since it's event handler. If you name a function GetWKTString, I would expect it to return a string, which is not the case here.

@@ -329,47 +329,42 @@ def __init__(self, wizard, parent):

# toggles
self.radioEpsg = wx.RadioButton(parent=self, id=wx.ID_ANY, label=_(
"Select coordinate reference system by EPSG"), style=wx.RB_GROUP)
"Select CRS from a list by EPSG or description"), style=wx.RB_GROUP)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Select CRS from a list" should be the title of the EPSGPage as well.

@@ -1486,41 +1481,23 @@ def OnEnterPage(self, event):
event.Skip()

def OnPageChanging(self, event):
if event.GetDirection() and not os.path.isfile(self.wktfile):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There needs to be a condition, you are trying to prevent from going to next page if there is no text (previously - if the file doesn't exist). Ideally it would check the WKT string is valid, but that's very difficult, so we will just check for any string. It's technically not needed because you already deal with that by disabling the next button, but let's keep it there.

I was surprised your current code works since you don't have any condition there (so it would prevent the page from switching every time), but that's because of the event.Skip() - you need to remove it from there. Please also remove event Skip from GeoreferencedFilePage (the same function), it's the same case, it shouldn't be there.


grass.create_location(dbase=self.startpage.grassdatabase,
location=self.startpage.location,
wkt=self.wktpage.wktfile,
wkt=self.wktpage.wktstring,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error you are getting comes from this function, it expects file not string. I created a separate PR #723, so you don't need to deal with that.

…e title of EPSGpage, checked for any wktstring in OnPageChanging function, removed event.skip() from WKTPage and GeoreferencedFilePage.
@@ -1481,13 +1479,12 @@ def OnEnterPage(self, event):
event.Skip()

def OnPageChanging(self, event):
if event.GetDirection():
isblank = bool(self.wktstring and self.wktstring.strip())
if event.GetDirection() and isblank is False:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simply just if event.GetDirection() and not self.wktstring.strip(): should suffice.

@petrasovaa petrasovaa marked this pull request as ready for review June 23, 2020 02:31
@petrasovaa petrasovaa merged commit f56d21d into OSGeo:master Jun 23, 2020
@neteler neteler added this to the 8.0.0 milestone Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gsoc Reserved for Google Summer of Code student(s)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feat] wxGUI loc wizard: Improve new location's CRS method selection page
3 participants