-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Feature #8725-revival: Fast rendering of geometries with provider simplification support #1053
Conversation
Hi @Matthias-Kuhn, about...
This code could fix your comment ?
But, I think that capability indication is useful because of the settings panel disable the 'simplification on provider side' checkbox when this capability is not supported. About my proposed code above, now I call to 'prepareLocalSimplification' method in QgsVectorLayerFeatureIterator class, this allows me to not have to call it in all providers, but with this change ... Also, I can not prepare the local/provider simplification in the constructor of QgsAbstractFeatureIterator class because of QgsVectorLayerFeatureIterator creates two QgsAbstractFeatureIterator instances (QgsVectorLayerFeatureIterator itself and mProviderIterator member) and the simplification of each geometry runs twice in local mode. Alvaro |
@Matthias-Kuhn said me: Concerning your comment about having two iterators on top of each other and therefore code being executed twice: please have a look at the filterExpression code, the same kind of problem had to be tackled there. I think it should be possible to apply almost the same logic to the simplification code. Edit |
One question - is it necessary to have the checkbox for simplifying at the provider? Couldn't we just always enable this? Is there any down sides to it? |
I think in situations where there are many applications using a server, then it is more interesting that simplification running locally to avoid overloading the server
|
How about leaving server-side simplification as default, with an opt-out checkbox "Force local simplification" hidden in a collapsible groupbox labelled "Advanced settings" along with other simplification fine-tuning options (collapsed by default)? Some pseudo-code to outline the concept I have in mind. Feel free to tear them apart and destroy them :) Main pro argument IMHO: It allows for the providers to make the decision, if a simplification can be done locally or remote based on a particular QgsFeatureRequest (as an iterator is always based on a request)
|
Hi @Matthias-Kuhn, thanks for your proposal, but one thing I do not like ( ;-) ), the exitence of public methods to do nothing, they are confuse to programmers who uses. IMHO I think better simplify the geometries within of iterator without a "simplify" method visible. The iterator will simplify the geometries how it knowns (arguments...) according how the simplification was defined or deactivated. I could write a more explicit method to configure the simplification, then it will be execute or not "within" nextFeature method as it decides. QgsAbstractFeatureIterator::setSimplifyMethod(const QgsSimplifyMethod& simplifyMethod); What do you think ? |
It is curious, in Geoserver-devel mailing list there is a similar debate about simplification and ST_simplify: They are implementing the "simplification" of geometries fetched using a similar strategy as we are thinking for QGIS |
about...
I agree, I will add a groupbox labelled "Advanced settings" containing the two current options: "Force local simplification" CheckBox and the "simplification threshold" slider. Alvaro |
You are right, they don't need to be public, they could be made private, so they could be overwritten, but not called. The pro of a method is, that it can contain logic. E.g.
|
Yes no other methods should be public on a |
Ok, I will apply your advices |
@ahuarte47 hi, I don't know what is the status of your work. But I observe that the last master is still much much slower than before the merge of the fast rendering. I tested this again with postgis layers (one line, one polygon, one point), with or without labeling. Am I the only one observing this? Thanks! |
Hi @3nids, this PR is a simple refactoring of PR #980 already merged. When you got normal results you tried the PR #1040 where the simplification runs directly in rendering loop. This new PR implements the simplification in FeatureIterator classes and I must investigate why it is so slow in your SO (Ubuntu). In Windows I get normal behavior. Thanks! |
I obtained normal results with QGIS 2.0 and speed issues with today's master. I can give it a try, if you'd like to. |
Then, I would greatly appreciate you to try this PR #1053, this should be the final (PR #1040 was a test), It only needs a small rearrangement in the code applying one advice of @Matthias-Kuhn, not how the geometries are simplified (This really has never changed). Thank you very much! |
@ahuarte47 It is at least as fast as before! can't wait to see this merged! |
@3nids Did you also test with provider-side postgis simplification? |
@Matthias-Kuhn yes. I can't tell a difference with/without simplification and provider/qgis side in terms of rendering speed. Would need further testing. |
@3nids Are both "too fast to tell" or is it "they are both in the same range of acceptable latency"? |
@Matthias-Kuhn I would say exactly as fast as it was in QGIS 2.0. So, something in between ;) To be more explicit: acceptable latency in my big project. It seems faster when using server side, but marginally. |
Cool. So all tests look good so far. Main issue for me is the architectural change which you seem to be ok with Alvaro. Looking forward to merging this soon, so we have some time to iron out any leftover issues before the release of 2.2. |
Hi @Matthias-Kuhn, I hope that last commit (ahuarte47@605b66b) implements the simplification methods as you advised me. I still have two tasks:
Alvaro |
Hi Alvaro, Is this branch ready to be reviewed? |
Hi @Matthias-Kuhn, I think so, but I have pending define a more precise value for the tolerance of ST_simplify calls in postgres provider. I am testing how geoserver define it but I could not complete this task, sorry. The current value used is very conservative (map2pixel tolerance calculated / 5.0 -> "src/providers/postgres/qgspostgresfeatureiterator.cpp+line 312") and may just be that the new value is greater. Alvaro |
Would it be possible to merge this and do the tuning later on? This pull request fixes (at least on Ubuntu) a major regression in terms of speed rendering. |
I will have a look at it ASAP. The fine-tuning of the postgres parameter is no requirement for this pull request. |
Hi Alvaro, I had a look at the code. Most things look good, sweet we now have also for postgres server side simplification. I hope other provider maintainer will bother to follow this good example. Basically that means adding the following new virtual method:
This should be overwritten by OGR, Postgres and VectorLayer iterators to return true. In the constructor of the QgsAbstractFeatureIterator, you can insert the following code
And in
There is a slight change in the requirements to before. My old comments would have meant a call to a virtual method per feature, while the updated comment (this message) is on a per-iterator basis. But as you still didn't change from a per-provider basis, I figure it's ok to adjust it. I assume it should not be much work, looking at the current state of the code. |
PostgresFeatureIterator implements simplification on provider side
…a line This ensure that the angles at the line start and end are the same after simplification
@NathanW2 That's fine with me as long as it's discussed before the release. I suggest to discuss the GUI on http://osgeo-org.1560.x6.nabble.com/Discuss-renderer-behavior-geometry-simplification-settings-GUI-tc5098020.html |
Yeah it will be discussed. We still have about a month and a half to make To me the main code needs to be merged after Matthais is happy with it so
On Wed, Jan 15, 2014 at 7:52 AM, anitagraser [email protected]:
|
+ add comment about 'prepareSimplification' in constructor + fix comment in 'providerCanSimplify' + improve UI messages
Last commit contains all advices received (I guess):
Also, I did rebase. I will implement the scale filter as Tim suggested me in other PR. Thanks for all! |
@ahuarte47 New UI looks better thanks. Last line can be simplified (ha!) to read:
@NathanW2 Fully agreed about UI tweaks being able to wait till after core stuff works - I just added my comment to the PR since they were not addressed when the last PR was closed and I didn't want them to get forgotten. |
Done: ahuarte47@c79cafc
Thanks @timlinux |
Merged to master A huge thank you to Alvaro, amazing work! Especially for the patience with all the wishes I had. Let's see how it works in the wild, and I assume you will be available for any follow-ups to this PR which may appear in the upcoming testing phase. |
So nice! Thanks a lot for the job! |
A big +1 from me to what Matthias and Denis have said. Thanks for putting in the time to implement these great changes @ahuarte47 ! |
it was a team effort, thanks for all! Alvaro |
Now, I still have tasks:
Before I would like fix bug #9060, I have partial fixes and code to finish it |
Wow Alvaro, congrats and kudos for your patience. Thanks for also taking on Regards Tim On Wed, Jan 15, 2014 at 12:53 PM, Alvaro Huarte [email protected]:
Tim Sutton - QGIS Project Steering Committee MemberVisit http://linfiniti.com to find out about:
|
Done:
|
Implements fast rendering of LineStrings and Polygons simplificating the geometries before render them in QGIS. Also disable 'Antialiasing' when it is possible.
This PR is inspired in merged PR #980, but it contains several changes based on advice received ( @Matthias-Kuhn thanks! ) and new features:
About postgres simplification, the ST_simplify function needs a tolerance parameter, I use map2pixel/5.0 as input value, it is experimental and I must define it better (All ideas are welcome). This simplification can be applicable to other database providers (MySQL, SQL Server, Oracle...)