comparison flys-backend/contrib/shpimporter/importer.py @ 5386:6c2751c17869

Importer: Add function to search a value in all fields. I've also discovered that you can access fields of feature by using it as a dict. \o/
author Andre Heinecke <aheinecke@intevation.de>
date Fri, 22 Mar 2013 17:31:48 +0100
parents 90f1c5f67698
children ff11b178f152
comparison
equal deleted inserted replaced
5385:2da74705c29d 5386:6c2751c17869
42 if not name: 42 if not name:
43 return False 43 return False
44 if feat.GetFieldIndex(name) == -1: 44 if feat.GetFieldIndex(name) == -1:
45 return False # Avoids an Error in IsFieldSet 45 return False # Avoids an Error in IsFieldSet
46 return feat.IsFieldSet(feat.GetFieldIndex(name)) 46 return feat.IsFieldSet(feat.GetFieldIndex(name))
47
48 def searchValue(self, feat, regex):
49 """
50 Searches for a value that matches regx in all attribute
51 fields of a feature.
52 """
53 for val in feat.items():
54 match = re.match(regex, val, re.IGNORECASE)
55 return match != None
47 56
48 def searchField(self, regex): 57 def searchField(self, regex):
49 """ 58 """
50 Searches for a field in the current src layer that matches 59 Searches for a field in the current src layer that matches
51 the expression regex. 60 the expression regex.

http://dive4elements.wald.intevation.org