comparison flys-backend/contrib/shpimporter/utils.py @ 4884:b457532dae63

Importer: Move copy fields into importer class and track imported/unimported fields
author Andre Heinecke <aheinecke@intevation.de>
date Mon, 28 Jan 2013 12:25:24 +0100
parents e9880b224c2f
children 1f6e544f7a7f
comparison
equal deleted inserted replaced
4883:186dd186d5bd 4884:b457532dae63
29 try: 29 try:
30 return unicode.encode(unicode(path, sys.getfilesystemencoding()), "UTF-8") 30 return unicode.encode(unicode(path, sys.getfilesystemencoding()), "UTF-8")
31 except UnicodeDecodeError: 31 except UnicodeDecodeError:
32 # Probably Windows iso-8859-x names so lets try again 32 # Probably Windows iso-8859-x names so lets try again
33 return unicode.encode(unicode(path, "iso-8859-15"), "UTF-8") 33 return unicode.encode(unicode(path, "iso-8859-15"), "UTF-8")
34
35
36 # 0 OFTInteger, Simple 32bit integer
37 # 1 OFTIntegerList, List of 32bit integers
38 # 2 OFTReal, Double Precision floating point
39 # 3 OFTRealList, List of doubles
40 # 4 OFTString, String of ASCII chars
41 # 5 OFTStringList, Array of strings
42 # 6 OFTWideString, deprecated
43 # 7 OFTWideStringList, deprecated
44 # 8 OFTBinary, Raw Binary data
45 # 9 OFTDate, Date
46 # 10 OFTTime, Time
47 # 11 OFTDateTime, Date and Time
48
49
50 def copyFields(src, target, mapping):
51 """
52 Checks the mapping dictonary for key value pairs to
53 copy from the source to the destination feature.
54
55 The Key is the attribute of the source feature to be copied
56 into the target attribute named by the dict's value.
57 """
58 for key, value in mapping.items():
59 if src.GetFieldIndex(key) == -1:
60 continue
61 if src.IsFieldSet(src.GetFieldIndex(key)):
62 if src.GetFieldType(key) == 2:
63 target.SetField(value, src.GetFieldAsDouble(key))
64 else:
65 target.SetField(value, src.GetField(key))

http://dive4elements.wald.intevation.org