mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
[processing] add method in OGR algorithms for getting layer name from source
This commit is contained in:
parent
c78a3783a9
commit
2417a82bd7
@ -25,8 +25,8 @@ __copyright__ = '(C) 2012, Victor Olaya'
|
||||
|
||||
__revision__ = '$Format:%H$'
|
||||
|
||||
import string
|
||||
import re
|
||||
import os
|
||||
|
||||
try:
|
||||
from osgeo import ogr
|
||||
@ -36,6 +36,7 @@ except:
|
||||
|
||||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
|
||||
from qgis.core import *
|
||||
|
||||
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
|
||||
@ -66,3 +67,21 @@ class OgrAlgorithm(GdalAlgorithm):
|
||||
else:
|
||||
ogrstr = unicode(layer.source())
|
||||
return ogrstr
|
||||
|
||||
def ogrLayerName(self, uri):
|
||||
layerName = None
|
||||
|
||||
if 'host' in uri:
|
||||
regex = re.compile('(table=")(.+?)(\.")(.+?)"')
|
||||
r = regex.search(uri)
|
||||
return r.groups()[1] + '.' + r.groups()[3]
|
||||
elif 'dbname' in uri:
|
||||
regex = re.compile('(table=")(.+?)"')
|
||||
r = regex.search(uri)
|
||||
return r.groups()[1]
|
||||
elif 'layername' in uri:
|
||||
regex = re.compile('(layername=)(.*)')
|
||||
r = regex.search(uri)
|
||||
return r.groups()[1]
|
||||
else:
|
||||
return os.path.basename(os.path.splitext(uri)[0])
|
||||
|
Loading…
x
Reference in New Issue
Block a user