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

[PROCESSING] Speed up dissolve (esp. when using dissolve field) #2263

Closed
wants to merge 3 commits into from

Conversation

bstroebl
Copy link

No description provided.

@pcav
Copy link
Member

pcav commented Aug 20, 2015

@volaya @alexbruy

fields = QgsFields()
if useField:
fieldname = self.getParameterValue(Dissolve.FIELD)
fieldIdx = vlayerA.fieldNameIndex(fieldname)
Copy link
Member

Choose a reason for hiding this comment

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

It's dangerous to request the index from the layer and then use it to get a field from the provider.
I would try to avoid direct access to the provider wherever possible. field = vlayerA.field(fieldname)should be sufficient.

Copy link
Author

Choose a reason for hiding this comment

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

Hi Matthias,
thanks for the hint. Will recode.

@m-kuhn
Copy link
Member

m-kuhn commented Sep 9, 2015

@bstroebl I tested it on a small file here and the dissolve field (string) was not respected.

It would be great to have a unit test come along with it (it's not a requirement but I'll buy you a beer next time if you sponsor the first ftools unit test)

@bstroebl
Copy link
Author

Matthias, did you untick Dissolve all (do not use field)? If yes, could you send me the data, please?
Concerning the UI I would prefer a different behaviour. I assume most people use a field to dissolve (otherwise they could just use merge selected features from the Advanced Digitizing toolbar), so the preferred behaviour would be to

  1. either have Dissolve all unticked by default but then there should be a way to make sure a field has been chosen before clicking Run
  2. or have the checkbox unticked when a field is chosen

@m-kuhn
Copy link
Member

m-kuhn commented Sep 10, 2015

Tried again and could not reproduce the error.

Can you clarify on untick dissolve all? For me there is no checkbox, it's just another entry in the combobox. Am I testing the wrong tool now?

@bstroebl
Copy link
Author

This is Dissolve from QGIS geoalgorithms, UI displayed below
dissolve

@m-kuhn
Copy link
Member

m-kuhn commented Sep 10, 2015

That's the same one from the Vector > Geoprocessing Tools menu.

screenshot from 2015-09-10 09-30-23

It seems to me that in the processing dialog the checkbox is superfluous?

@bstroebl
Copy link
Author

Probably you are right, so if unique id field is [not set] then dissolve all would be assumed. The derivation of the field index could be put into a try-except block to check if a field has been chosen. The labels would need to clearly state this behaviour.

@m-kuhn
Copy link
Member

m-kuhn commented Sep 10, 2015

Sounds good. Or adding logic to disable the combobox when the checkbox is checked.

@bstroebl
Copy link
Author

Would be the better solution but I do not know if in Processing you can change widgets' settings when user sets other widgets. Would need Qt's signal/slot stuff.

@m-kuhn
Copy link
Member

m-kuhn commented Sep 10, 2015

No idea, I never did a processing GUI. If it's not possible, your proposal sounds absolutely fine to me.

@bstroebl
Copy link
Author

So these two would work:

  1. Keeping the checkbox but
    * unticking it by default and
    * having the field as compulsory parameter (will be ignored if checkbox is ticked)
  2. Keeping only the field combo but
    * still as an optional parameter and
    * dissolve all if [not set] is chosen
    What do you think is better understandable?

@m-kuhn
Copy link
Member

m-kuhn commented Sep 10, 2015

I think it is confusing to have two different GUI controls which may be set to contradicting states - or having enabled widgets which do not have any meaning.
And if it's not possible to disable the combobox based on the checkbox that would be the case, right?
Therefore I would opt for #2.

@bstroebl
Copy link
Author

ok, I will implement No 2 then
Pull request will be updated soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants