Skip to content


Browse files Browse the repository at this point in the history
[processing] Remove unused vector.duplicateInMemory() function
  • Loading branch information
nyalldawson committed May 2, 2017
1 parent 7eb7a7a commit bde1bf4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 48 deletions.
2 changes: 2 additions & 0 deletions doc/api_break.dox
Expand Up @@ -2233,6 +2233,8 @@ object of type QgsProcessingFeedback, and will need to adapt their use of progre
- ProcessingLog should not be used when reporting log messages from algorithms. Use QgsMessageLog.logMessage() instead.
- dataobjects.getLayerFromString() was removed. Use QgsProcessingUtils.mapLayerFromString() instead.
- vector.bufferedBoundingBox() was removed. Use QgsRectangle.grow() instead.
- vector.duplicateInMemory() was removed.

Triangulation {#qgis_api_break_3_0_Triangulation}
Expand Down
48 changes: 0 additions & 48 deletions python/plugins/processing/tools/
Expand Up @@ -302,54 +302,6 @@ def combineVectorFields(layerA, layerB):
return fields

def duplicateInMemory(layer, newName='', addToRegistry=False):
"""Return a memory copy of a layer
layer: QgsVectorLayer that shall be copied to memory.
new_name: The name of the copied layer.
add_to_registry: if True, the new layer will be added to the QgsMapRegistry
Returns an in-memory copy of a layer.
if newName is '':
newName = + ' (Memory)'

if layer.type() == QgsMapLayer.VectorLayer:
geomType = layer.geometryType()
if geomType == QgsWkbTypes.PointGeometry:
strType = 'Point'
elif geomType == QgsWkbTypes.LineGeometry:
strType = 'Line'
elif geomType == QgsWkbTypes.PolygonGeometry:
strType = 'Polygon'
raise RuntimeError('Layer is whether Point nor Line nor Polygon')
raise RuntimeError('Layer is not a VectorLayer')

crs =
myUuid = str(uuid.uuid4())
uri = '%s?crs=%s&index=yes&uuid=%s' % (strType, crs, myUuid)
memLayer = QgsVectorLayer(uri, newName, 'memory')
memProvider = memLayer.dataProvider()

provider = layer.dataProvider()
fields = layer.fields().toList()

for ft in provider.getFeatures():

if addToRegistry:
if memLayer.isValid():
raise RuntimeError('Layer invalid')

return memLayer

def checkMinDistance(point, index, distance, points):
"""Check if distance from given point to all other points is greater
than given value.
Expand Down

0 comments on commit bde1bf4

Please sign in to comment.