-
-
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
[processing] restore network analysis algorithms #4869
Conversation
@nyalldawson what do you think about adding to |
self.addOutput(OutputVector(self.OUTPUT_POLYGON, | ||
self.tr('Service area (convex hull)'), | ||
datatype=[dataobjects.TYPE_VECTOR_POLYGON])) | ||
self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT_POINTS, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about making this and OUTPUT_POLYGON optional outputs? I think it's unlikely that models will usually require both outputs, and there's potentially a speed boost by not calculating unwanted convex hulls (not to mention the memory savings from avoiding creating the unwanted memory layers or cost of writing to a disk based format).
I'd leave both of them created by default (i.e. not taking advantage of the change in #4868)
@@ -222,10 +221,16 @@ def processAlgorithm(self, parameters, context, feedback): | |||
feedback.pushInfo(self.tr('Loading start points...')) | |||
request = QgsFeatureRequest() | |||
request.setFlags(request.flags() ^ QgsFeatureRequest.SubsetOfAttributes) | |||
features = QgsProcessingUtils.getFeatures(startPoints, context, request) | |||
features = source.getFeatures(request) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could add a destinationCrs to the request here to match the CRS for layer - then we'd get transparent handling of network/points in different CRS.
Looks good :D - I've posted some potential areas for improvement (as in - not related to the port, but ways we could improve these algorithms in general now) Another potential improvement would be to modify QgsVectorLayerDirector to take a QgsFeatureSource as input instead of a QgsVectorLayer. I've had a look and QgsVectorLayerDirector only uses methods from the layer which are in the QgsFeatureSource interface anyway, so it should be a straightforward change. Another good improvement would be to make QgsGraphDirector::makeGraph take a QgsFeedback object so that the graph building could be cancelled, and use that for the progress reports during makeGraph instead of the buildProgress() signal. Again, this should be quite straightforward to add if you're interested. |
Agreed - we need to do something like this. I'm not sure how adding it to the parameter would help though. Wouldn't that "lock in" the crs that algorithm? My original intention behind #4720 was to handle this. I thought we could have referenced QgsRectangle + QgsPoint classes which are metatyped so they can be stored in QVariants. Then the CRS of the parameter value will be available. We could add logic like "if a extent parameter is specified as a QgsRectangle - assume it's in a matching CRS. if it's a QgsReferencedRectangle then reproject as required to match CRS". The gui wrappers for point/extent would return QgsReferencedRectangles/QgsReferencedPoints in the CRS of the canvas. Does that make sense to you? |
If reprojection enabled, then Seems your work in #4720 is exactly what I'm looking for. |
Description
Restore all network analysis algorithms
Checklist
fixes #11111
in the commit message next to the description[FEATURE]
in the commit message[needs-docs]
in the commit message and containt sufficient information in the commit message to be documentedscripts/prepare-commit.sh
script before each commit