Skip to content

Commit 88c3b51

Browse files
authoredApr 5, 2017
Merge pull request #4333 from nyalldawson/dataobjects
Port more processing dataobjects methods to c++
2 parents 85d59e6 + 377b181 commit 88c3b51

File tree

161 files changed

+428
-275
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+428
-275
lines changed
 

‎python/core/processing/qgsprocessingutils.sip

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,34 @@ class QgsProcessingUtils
6464
\see compatibleVectorLayers()
6565
%End
6666

67+
68+
static QgsMapLayer *mapLayerFromProject( const QString &string, QgsProject *project );
69+
%Docstring
70+
Interprets a string as a map layer from a project.
71+
72+
This method attempts to match a string to a project map layer, using
73+
first the layer ID, then layer names, and finally layer source.
74+
If the string matches a normalized version of any layer source
75+
for layers in the specified project, then those matching layers will be
76+
returned.
77+
\see mapLayerFromString()
78+
%End
79+
80+
static QgsMapLayer *mapLayerFromString( const QString &string ) /Factory/;
81+
%Docstring
82+
Interprets a string as a map layer. The method will attempt to
83+
load a layer matching the passed string. E.g. if the string is a file path,
84+
then the layer at this file path will be loaded.
85+
The caller takes responsibility for deleting the returned map layer.
86+
\see mapLayerFromProject()
87+
%End
88+
89+
static QString normalizeLayerSource( const QString &source );
90+
%Docstring
91+
Normalizes a layer source string for safe comparison across different
92+
operating system environments.
93+
%End
94+
6795
};
6896

6997

‎python/plugins/processing/algs/exampleprovider/ExampleAlgorithm.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ def processAlgorithm(self, feedback):
8888
output = self.getOutputValue(self.OUTPUT_LAYER)
8989

9090
# Input layers vales are always a string with its location.
91-
# That string can be converted into a QGIS object (a
91+
# That string can be converted into a QGIS layer (a
9292
# QgsVectorLayer in this case) using the
93-
# processing.getObjectFromUri() method.
94-
vectorLayer = dataobjects.getObjectFromUri(inputFilename)
93+
# dataobjects.getLayerFromString() method.
94+
vectorLayer = dataobjects.getLayerFromString(inputFilename)
9595

9696
# And now we can process
9797

0 commit comments

Comments
 (0)
Please sign in to comment.