本文整理匯總了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