本文整理汇总了Python中arccore.utils.AIUtils.AIUtils.dict2json方法的典型用法代码示例。如果您正苦于以下问题:Python AIUtils.dict2json方法的具体用法?Python AIUtils.dict2json怎么用?Python AIUtils.dict2json使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arccore.utils.AIUtils.AIUtils
的用法示例。
在下文中一共展示了AIUtils.dict2json方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AISde
# 需要导入模块: from arccore.utils.AIUtils import AIUtils [as 别名]
# 或者: from arccore.utils.AIUtils.AIUtils import dict2json [as 别名]
sdeServer = sdeInfos[0]
sdeInstance = sdeInfos[1]
sdeUsername = sdeInfos[2]
sdePassword = sdeInfos[3]
try:
sde = AISde(os.path.join(rootPath, 'resources', 'sde'), wksId, sdeServer + '/' + sdeInstance, sdeUsername, sdePassword)
sde.connect()
except Exception as e:
logger.info(unicode(e.message).encode("utf-8"))
logger.info('数据库服务器' + sdeServer + '上空间数据库' + sdeInstance + '实例连接失败')
logger.info('数据库服务器' + sdeServer + '上空间数据库' + sdeInstance + '实例连接成功')
wks = AIWks(sde.getSdeOutFullName(), sde.getSdeUserName())
logger.info('工作空间' + sde.getSdeOutFullName() + '初始化成功')
# 查询要素集
param2 = sys.argv[2]
param2 = param2.replace('null', '\'\'')
# fdsDict = AIUtils.str2dict(param2)
# name = fdsDict['name']
fds = AIFds()
fds = fds.fromStr(param2)
try:
fds = wks.queryFds(fds)
qr = AIUtils.dict2json(AIUtils.str2dict(str(fds)))
qr = '' if not qr else qr
except Exception as e:
logger.info(unicode(e.message).encode("utf-8"))
logger.info('要素集' + fds.getName() + '查询失败')
print qr
示例2: if
# 需要导入模块: from arccore.utils.AIUtils import AIUtils [as 别名]
# 或者: from arccore.utils.AIUtils.AIUtils import dict2json [as 别名]
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), \
'ftype' : AIUtils.unicode2utf8(desc.shapeType), 'wkid' : None if AIUtils.isEmpty(desc.spatialReference) else desc.spatialReference.factoryCode, \
'fds' : fcFds, 'fields' : flds}
qr = AIUtils.dict2json(qr)
except Exception as e:
logger.info(unicode(e.message).encode("utf-8"))
logger.info('要素类' + fcName + ' 查询失败')
print qr