本文整理汇总了Python中arccore.utils.AIUtils.AIUtils.unicode2utf8方法的典型用法代码示例。如果您正苦于以下问题:Python AIUtils.unicode2utf8方法的具体用法?Python AIUtils.unicode2utf8怎么用?Python AIUtils.unicode2utf8使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arccore.utils.AIUtils.AIUtils
的用法示例。
在下文中一共展示了AIUtils.unicode2utf8方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: queryFcList
# 需要导入模块: from arccore.utils.AIUtils import AIUtils [as 别名]
# 或者: from arccore.utils.AIUtils.AIUtils import unicode2utf8 [as 别名]
def queryFcList(self, fc):
'''
查询要素类列表
'''
qrs = []
if isinstance(fc, AIFc):
name = fc.getName()
ftype = fc.getFtype()
ftype = 'All' if AIUtils.isEmpty(ftype) else ftype
fds = fc.getFds()
# 要素集名称
fdsName = None
if not AIUtils.isEmpty(fds) and isinstance(fds, AIFds) and not AIUtils.isEmpty(fds.getName()):
fdsName = fds.getName()
fdsName = fdsName if ('.' in fdsName) else fdsName if AIUtils.isEmpty(self.__userName) else (self.__userName + '.') + fdsName
fds = self.queryFds(fds)
featureclasses = arcpy.ListFeatureClasses(None if AIUtils.isEmpty(name) else ('*'+ name + '*'), ftype, fdsName)
for featureclass in featureclasses:
desc = arcpy.Describe(featureclass)
flds = []
for field in desc.fields:
fld = AIFld(AIUtils.unicode2utf8(field.name), AIUtils.unicode2utf8(field.aliasName), \
AIUtils.unicode2utf8(field.type), field.scale, \
field.length, field.isNullable)
flds.append(fld)
qrs.append(AIFc(AIUtils.unicode2utf8(desc.name), AIUtils.unicode2utf8(desc.aliasName), \
AIUtils.unicode2utf8(desc.shapeType), None if AIUtils.isEmpty(desc.spatialReference) else desc.spatialReference.factoryCode, \
fds, flds))
else:
raise Exception('input parameter type not correct!')
return qrs
示例2: queryFdsList
# 需要导入模块: from arccore.utils.AIUtils import AIUtils [as 别名]
# 或者: from arccore.utils.AIUtils.AIUtils import unicode2utf8 [as 别名]
def queryFdsList(self, fds):
'''
查询要素集列表
'''
qrs = []
if isinstance(fds, AIFds):
name = fds.getName()
datasets = arcpy.ListDatasets(None if AIUtils.isEmpty(name) else ('*'+ name + '*'), \
'Feature')
for dataset in datasets:
desc = arcpy.Describe(dataset)
sr = desc.spatialReference
qrs.append(AIFds(AIUtils.unicode2utf8(desc.name), None if AIUtils.isEmpty(sr) else sr.factoryCode))
else:
raise Exception('input parameter type not correct!')
return qrs
示例3: queryFds
# 需要导入模块: from arccore.utils.AIUtils import AIUtils [as 别名]
# 或者: from arccore.utils.AIUtils.AIUtils import unicode2utf8 [as 别名]
def queryFds(self, fds):
'''
查询要素集
'''
qr = None
if isinstance(fds, AIFds):
name = fds.getName()
if not AIUtils.isEmpty(name):
name = name if ('.' in name) else name if AIUtils.isEmpty(self.__userName) else (self.__userName + '.') + name
datasets = arcpy.ListDatasets(name, 'Feature')
if len(datasets) > 0 and not AIUtils.isEmpty(datasets[0]):
dataset = datasets[0]
desc = arcpy.Describe(dataset)
sr = desc.spatialReference
qr = AIFds(AIUtils.unicode2utf8(desc.name), None if AIUtils.isEmpty(sr) else sr.factoryCode)
else:
raise Exception('dataset name cannot be empty!')
else:
raise Exception('input parameter type not correct!')
return qr
示例4: if
# 需要导入模块: from arccore.utils.AIUtils import AIUtils [as 别名]
# 或者: from arccore.utils.AIUtils.AIUtils import unicode2utf8 [as 别名]
fcName = fcName if ('.' in fcName) else fcName if AIUtils.isEmpty(sdeUsername) else (sdeUsername + '.') + fcName
fcFtype = 'All' if AIUtils.isEmpty(fcFtype) else fcFtype
# 要素集名称
fdsName = None
if AIUtils.isDict(fcFds) and not AIUtils.isEmpty(fcFds['name']):
fdsName = fcFds['name']
fdsName = fdsName if ('.' in fdsName) else fdsName if AIUtils.isEmpty(sdeUsername) else (sdeUsername + '.') + fdsName
try:
if not AIUtils.isEmpty(fdsName):
fdsName = fdsName if ('.' in fdsName) else fdsName if AIUtils.isEmpty(sdeUsername) else (sdeUsername + '.') + fdsName
datasets = arcpy.ListDatasets(fdsName, 'Feature')
if len(datasets) > 0 and not AIUtils.isEmpty(datasets[0]):
dataset = datasets[0]
desc = arcpy.Describe(dataset)
sr = desc.spatialReference
fcFds = {'name' : AIUtils.unicode2utf8(desc.name), 'wkid' : None if AIUtils.isEmpty(sr) else sr.factoryCode}
except Exception as e:
logger.info(unicode(e.message).encode("utf-8"))
logger.info('要素集' + fdsName + '查询失败')
featureclasses = arcpy.ListFeatureClasses(fcName, fcFtype, fdsName)
if len(featureclasses) > 0 and not AIUtils.isEmpty(featureclasses[0]):
featureclass = featureclasses[0]
desc = arcpy.Describe(featureclass)
flds = []
for field in desc.fields:
flds.append({'name' : AIUtils.unicode2utf8(field.name), 'alias' : AIUtils.unicode2utf8(field.aliasName), \
'ftype' : AIUtils.unicode2utf8(field.type), 'scale' : field.scale, \
'length' : field.length, 'isNullable' : field.isNullable})
qr = {'name' : AIUtils.unicode2utf8(desc.name), 'alias' : AIUtils.unicode2utf8(desc.aliasName), \
示例5: if
# 需要导入模块: from arccore.utils.AIUtils import AIUtils [as 别名]
# 或者: from arccore.utils.AIUtils.AIUtils import unicode2utf8 [as 别名]
if not AIUtils.isEmpty(fcName):
fcName = fcName if ('.' in fcName) else fcName if AIUtils.isEmpty(sdeUsername) else (sdeUsername + '.') + fcName
fcFtype = 'All' if AIUtils.isEmpty(fcFtype) else fcFtype
# 要素集名称
fdsName = None
if AIUtils.isDict(fcFds) and 'name' in fcFds.keys() and not AIUtils.isEmpty(fcFds['name']):
fdsName = fcFds['name']
fdsName = fdsName if ('.' in fdsName) else fdsName if AIUtils.isEmpty(sdeUsername) else (sdeUsername + '.') + fdsName
wksName = sdeOutFullName if AIUtils.isEmpty(fdsName) else os.path.join(sdeOutFullName, fdsName).replace('\\', '/')
featureclasses = arcpy.ListFeatureClasses(fcName, fcFtype, fdsName)
if len(featureclasses) > 0 and not AIUtils.isEmpty(featureclasses[0]):
featureclass = featureclasses[0]
desc = arcpy.Describe(featureclass)
oalias = AIUtils.unicode2utf8(desc.aliasName) # 要素旧别名
oFields = desc.fields # 旧字段集合
oFieldNames = None
if AIUtils.isList(oFields):
oFieldNames = [ofld.name for ofld in oFields] # 旧字段名集合
# 更改别名
if not AIUtils.isEmpty(nalias) and not AIStrUtils.isEqual(oalias, nalias):
arcpy.AlterAliasName(fcName, nalias)
# 比对字段
if AIUtils.isList(oFieldNames) and AIUtils.isList(nFieldNames):
# 删除字段(排除保留字段)
for ofn in oFieldNames:
if ofn not in nFieldNames and \
not AIStrUtils.isEqual(ofn, 'OBJECTID') and \
not AIStrUtils.isEqual(ofn, 'NAME') and \
not AIStrUtils.isEqual(ofn, 'SHAPE') and \
示例6: if
# 需要导入模块: from arccore.utils.AIUtils import AIUtils [as 别名]
# 或者: from arccore.utils.AIUtils.AIUtils import unicode2utf8 [as 别名]
sdePassword = sdeInfos[3]
# 默认文件已经存在
sdeOutFullName = os.path.join(rootPath, 'resources', 'sde', wksId + ".sde").replace('\\', '/')
# 设置当前工作空间
arcpy.env.workspace = sdeOutFullName
logger.info('工作空间' + sdeOutFullName + '初始化成功')
# 查询要素集
param2 = sys.argv[2]
param2 = param2.replace('null', '\'\'')
param2 = param2.replace('true', 'True')
param2 = param2.replace('false', 'False')
fdsDict = AIUtils.str2dict(param2)
keys = fdsDict.keys()
fdsName = None if 'name' not in keys else fdsDict['name']
try:
if not AIUtils.isEmpty(fdsName):
fdsName = fdsName if ('.' in fdsName) else fdsName if AIUtils.isEmpty(sdeUsername) else (sdeUsername + '.') + fdsName
datasets = arcpy.ListDatasets(fdsName, 'Feature')
if len(datasets) > 0 and not AIUtils.isEmpty(datasets[0]):
dataset = datasets[0]
desc = arcpy.Describe(dataset)
sr = desc.spatialReference
qr = {'name' : AIUtils.unicode2utf8(desc.name), 'wkid' : None if AIUtils.isEmpty(sr) else sr.factoryCode}
qr = AIUtils.dict2json(qr)
except Exception as e:
logger.info(unicode(e.message).encode("utf-8"))
logger.info('要素集' + fdsName + '查询失败')
print qr