当前位置: 首页>>代码示例>>Python>>正文


Python FeatureLayer.addFeature方法代码示例

本文整理汇总了Python中arcrest.agol.FeatureLayer.addFeature方法的典型用法代码示例。如果您正苦于以下问题:Python FeatureLayer.addFeature方法的具体用法?Python FeatureLayer.addFeature怎么用?Python FeatureLayer.addFeature使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在arcrest.agol.FeatureLayer的用法示例。


在下文中一共展示了FeatureLayer.addFeature方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from arcrest.agol import FeatureLayer [as 别名]
# 或者: from arcrest.agol.FeatureLayer import addFeature [as 别名]

#.........这里部分代码省略.........
                        proxy_port=proxy_port,
                        proxy_url=proxy_url,
                        initialize=True)                    
                    areaResults =  fl.query(**{'where':"1=1",'outSR':'102100','out_fields':assignmentAreaNameField,'returnGeometry':False,'returnCentroid':True})
                   
                    for area in areaResults:
                        arDict = area.asDictionary
                        areaNameToID[arDict['attributes'][assignmentAreaNameField]] = arDict['centroid']
                    
            #Get the workers
            item = portalAdmin.content.getItem(itemId=workforceProjectID)
            itemData = item.itemData()
            if 'workers' in itemData:
                fl = FeatureLayer(
                    url=itemData['workers']['url'],
                    securityHandler=fst.securityhandler,
                    proxy_port=proxy_port,
                    proxy_url=proxy_url,
                    initialize=True)
            
                workersResults = fl.query(where="1=1",out_fields='OBJECTID, NAME',returnGeometry=False)
                for worker in workersResults:
                    workerNameToID[worker.get_value('name')] = worker.get_value('OBJECTID')
            
            if 'dispatchers' in itemData:
                fl = FeatureLayer(
                    url=itemData['dispatchers']['url'],
                    securityHandler=fst.securityhandler,
                    proxy_port=proxy_port,
                    proxy_url=proxy_url,
                    initialize=True)
            
                dispatcherResults = fl.query(where="1=1",out_fields='OBJECTID, NAME',returnGeometry=False)
                for dispatcher in dispatcherResults:
                    dispatcherNameToID[dispatcher.get_value('name')] = dispatcher.get_value('OBJECTID')
                    
    
            if 'assignments' in itemData:
                features = []
                
                fl = FeatureLayer(
                    url=itemData['assignments']['url'],
                    securityHandler=fst.securityhandler,
                    proxy_port=proxy_port,
                    proxy_url=proxy_url,
                    initialize=True)
                print(fl.deleteFeatures(where="1=1"))
                with open(csvPath) as csvfile:
                    reader = UnicodeDictReader(csvfile)
                    for row in reader:
                        json_string={}
                        json_string['geometry'] = {}
                       
                        centroidInfo = areaNameToID[row[areaCol].strip()]
                        
                        json_string['geometry']['x'] = centroidInfo['x']
                        json_string['geometry']['y'] = centroidInfo['y']
                        json_string['attributes'] ={}
                        json_string['attributes']['workerId'] = workerNameToID[row[workerCol].strip()]
                        json_string['attributes']['description'] = row[descriptionCol]
                        json_string['attributes']['notes'] = row[notesCol]
                        json_string['attributes']['assignmentType'] = assignmentType
                        json_string['attributes']['status'] = status
                        json_string['attributes']['dispatcherId'] = dispatcherNameToID[row[supervisorCol].strip()]
                        
                         
                        features.append(Feature(json_string=json_string))
                    results = fl.addFeature(features=features)
    
                    if 'error' in results:
                        print ("Error in response from server:  %s" % results['error'])
    
                    else:
                        if results['addResults'] is not None:
                            featSucces = 0
                            for result in results['addResults']:
                                if 'success' in result:
                                    if result['success'] == False:
                                        if 'error' in result:
                                            print ("Error info: %s" % (result['error']))
                                    else:
                                        featSucces = featSucces + 1
    
                            print ("%s features added to %s" % (featSucces,fl.name))
                        else:
                            print ("0 features added to %s /n result info %s" % (fl.name,str(results)))             

    except (common.ArcRestHelperError) as e:
        print ("error in function: %s" % e[0]['function'])
        print ("error on line: %s" % e[0]['line'])
        print ("error in file name: %s" % e[0]['filename'])
        print ("with error message: %s" % e[0]['synerror'])
        if 'arcpyError' in e[0]:
            print ("with arcpy message: %s" % e[0]['arcpyError'])

    except:
        line, filename, synerror = trace()
        print ("error on line: %s" % line)
        print ("error in file name: %s" % filename)
        print ("with error message: %s" % synerror)
开发者ID:BrunoCaimar,项目名称:ArcREST,代码行数:104,代码来源:load_assignments_lookup.py


注:本文中的arcrest.agol.FeatureLayer.addFeature方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。