Replace with just f[idx]. Calling QgsFeature.attributes()
allocates a list of all attributes, which is inefficient
when only a single attribute value is needed.
Include descriptive text with the specified parameter value
in error, and always check that sources were loaded to avoid
raw Python exceptions when they are not
Instead of a separate Points In Polygon algorithm just for this
extra option, add it to the original Points In Polygon algorithm
as a non-default option.
initAlgorithm() method
This allows 2 benefits:
- algorithms can be subclassed and have subclasses add additional
parameters/outputs to the algorithm. With the previous approach
of declaring parameters/outputs in the constructor, it's not
possible to call virtual methods to add additional parameters/
outputs (since you can't call virtual methods from a constructor).
- initAlgorithm takes a variant map argument, allowing the algorithm
to dynamically adjust its declared parameters and outputs according
to this configuration map. This potentially allows model algorithms which
can be configured to have variable numbers of parameters and
outputs at run time. E.g. a "router" algorithm which directs
features to one of any number of output sinks depending on some
user configured criteria.
Algorithms and other processing code should use this method
(instead of dataobjects.getLayerFromString) to
retrieve layers from a string, as it considers the processing
context and allows resolving strings to temporarily stored layers.
This permits processing models to function correctly when
intermediate results are stored as memory layers. Subsequent
model algorithms can then access these temporary layers as inputs.
All temporary layers will be removed when the context object
is destroyed after the model algorithm is run.
Also
- simplify and add tests
- remove large memory leak (persistant store of all non-project layers)
- remove broken support for direct loading postgres/virtual layers
by string (Python version was very broken and would never match
a postgres/virtual layer)
- don't use setFilterFid() within loops to fetch features one
at time (as it's extremely slow), instead use setFilterFids()
outside the loop
- don't fetch unused attributes/geometry when it can be
avoided
Since the layer has more complete knowledge of the crs (ie, when
provider could not determine crs and user has selected it from
the list), and also better knowledge of layer fields (virtual
fields, joined fields) we should use these rather than the
provider methods.
- Avoid use of seperate feature requests for every point
- Use GEOS prepared geometries when testing for point containment
Quick stats:
~1500 point layer
BEFORE: 17 seconds
AFTER: 3 seconds
~900k point layer
BEFORE: 30 mins = canceled at 20%
AFTER: 2.5 mins = 100% complete