Ejemplo n.º 1
0
            sdeInfo = cf.get("sde", wksId)
            sdeInfos = sdeInfo.split("/")
            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", "''")
            fds = AIFds()
            fds = fds.fromStr(param2)
            try:
                fdss = wks.queryFdsList(fds)
                if not AIUtils.isEmpty(fdss) and len(fdss) > 0:
                    qr = AIUtils.list2json([AIUtils.str2dict(str(fds)) for fds in fdss])
Ejemplo n.º 2
0
                                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
    
if __name__ == '__main__':
    try:
        sde = AISde('D:\\tmp\\sde', 'orcl21', '192.168.0.21/arcgis', 'gis', 'gis123')
        sdeOutFullName = sde.connect()
        print sdeOutFullName
        if not AIUtils.isEmpty(sdeOutFullName):
            wks = AIWks(sdeOutFullName, 'gis')
#             # query fds
#             qr = wks.queryFds(AIFds('gis.test'))
#             print qr
            
#             # add fds
#             flag = wks.addFds(AIFds('test334', 3857))
#             print flag

#             # delete fds
#             flag = wks.removeFds(AIFds('test334', 3857))
#             print flag