idx int64 0 63k | question stringlengths 61 4.03k | target stringlengths 6 1.23k |
|---|---|---|
57,000 | def Y ( self , value ) : if isinstance ( value , ( int , float , long , types . NoneType ) ) : self . _y = value | sets the Y coordinate |
57,001 | def Z ( self , value ) : if isinstance ( value , ( int , float , long , types . NoneType ) ) : self . _z = value | sets the Z coordinate |
57,002 | def wkid ( self , value ) : if isinstance ( value , ( int , long ) ) : self . _wkid = value | sets the wkid |
57,003 | def asDictionary ( self ) : template = { "xmin" : self . _xmin , "ymin" : self . _ymin , "xmax" : self . _xmax , "ymax" : self . _ymax , "spatialReference" : self . spatialReference } if self . _zmax is not None and self . _zmin is not None : template [ 'zmin' ] = self . _zmin template [ 'zmax' ] = self . _zmax if self . _mmin is not None and self . _mmax is not None : template [ 'mmax' ] = self . _mmax template [ 'mmin' ] = self . _mmin return template | returns the envelope as a dictionary |
57,004 | def asArcPyObject ( self ) : env = self . asDictionary ring = [ [ Point ( env [ 'xmin' ] , env [ 'ymin' ] , self . _wkid ) , Point ( env [ 'xmax' ] , env [ 'ymin' ] , self . _wkid ) , Point ( env [ 'xmax' ] , env [ 'ymax' ] , self . _wkid ) , Point ( env [ 'xmin' ] , env [ 'ymax' ] , self . _wkid ) ] ] return Polygon ( rings = ring , wkid = self . _wkid , wkt = self . _wkid , hasZ = False , hasM = False ) . asArcPyObject | returns the Envelope as an ESRI arcpy . Polygon object |
57,005 | def _process_response ( self , resp , out_folder = None ) : CHUNK = 4056 maintype = self . _mainType ( resp ) contentDisposition = resp . headers . get ( 'content-disposition' ) contentEncoding = resp . headers . get ( 'content-encoding' ) contentType = resp . headers . get ( 'content-type' ) contentLength = resp . headers . get ( 'content-length' ) if maintype . lower ( ) in ( 'image' , 'application/x-zip-compressed' ) or contentType == 'application/x-zip-compressed' or ( contentDisposition is not None and contentDisposition . lower ( ) . find ( 'attachment;' ) > - 1 ) : fname = self . _get_file_name ( contentDisposition = contentDisposition , url = resp . geturl ( ) ) if out_folder is None : out_folder = tempfile . gettempdir ( ) if contentLength is not None : max_length = int ( contentLength ) if max_length < CHUNK : CHUNK = max_length file_name = os . path . join ( out_folder , fname ) with open ( file_name , 'wb' ) as writer : for data in self . _chunk ( response = resp ) : writer . write ( data ) del data del writer return file_name else : read = "" for data in self . _chunk ( response = resp , size = 4096 ) : if self . PY3 == True : read += data . decode ( 'utf-8' ) else : read += data del data try : return json . loads ( read . strip ( ) ) except : return read return None | processes the response object |
57,006 | def addUsersToRole ( self , rolename , users ) : params = { "f" : "json" , "rolename" : rolename , "users" : users } rURL = self . _url + "/roles/addUsersToRole" return self . _post ( url = rURL , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | Assigns a role to multiple users |
57,007 | def serverProperties ( self ) : return ServerProperties ( url = self . _url + "/properties" , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , initialize = True ) | gets the server properties for the site as an object |
57,008 | def serverDirectories ( self ) : directs = [ ] url = self . _url + "/directories" params = { "f" : "json" } res = self . _get ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) for direct in res [ 'directories' ] : directs . append ( ServerDirectory ( url = url + "/%s" % direct [ "name" ] , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , initialize = True ) ) return directs | returns the server directory object in a list |
57,009 | def Jobs ( self ) : url = self . _url + "/jobs" return Jobs ( url = url , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , initialize = True ) | get the Jobs object |
57,010 | def configurationStore ( self ) : url = self . _url + "/configstore" return ConfigurationStore ( url = url , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | returns the ConfigurationStore object for this site |
57,011 | def EnableEditingOnService ( self , url , definition = None ) : adminFS = AdminFeatureService ( url = url , securityHandler = self . _securityHandler ) if definition is None : definition = collections . OrderedDict ( ) definition [ 'hasStaticData' ] = False definition [ 'allowGeometryUpdates' ] = True definition [ 'editorTrackingInfo' ] = { } definition [ 'editorTrackingInfo' ] [ 'enableEditorTracking' ] = False definition [ 'editorTrackingInfo' ] [ 'enableOwnershipAccessControl' ] = False definition [ 'editorTrackingInfo' ] [ 'allowOthersToUpdate' ] = True definition [ 'editorTrackingInfo' ] [ 'allowOthersToDelete' ] = True definition [ 'capabilities' ] = "Query,Editing,Create,Update,Delete" existingDef = { } existingDef [ 'capabilities' ] = adminFS . capabilities existingDef [ 'allowGeometryUpdates' ] = adminFS . allowGeometryUpdates enableResults = adminFS . updateDefinition ( json_dict = definition ) if 'error' in enableResults : return enableResults [ 'error' ] adminFS = None del adminFS print ( enableResults ) return existingDef | Enables editing capabilities on a feature service . |
57,012 | def enableSync ( self , url , definition = None ) : adminFS = AdminFeatureService ( url = url , securityHandler = self . _securityHandler ) cap = str ( adminFS . capabilities ) existingDef = { } enableResults = 'skipped' if 'Sync' in cap : return "Sync is already enabled" else : capItems = cap . split ( ',' ) capItems . append ( 'Sync' ) existingDef [ 'capabilities' ] = ',' . join ( capItems ) enableResults = adminFS . updateDefinition ( json_dict = existingDef ) if 'error' in enableResults : return enableResults [ 'error' ] adminFS = None del adminFS return enableResults | Enables Sync capability for an AGOL feature service . |
57,013 | def GetFeatureService ( self , itemId , returnURLOnly = False ) : admin = None item = None try : admin = arcrest . manageorg . Administration ( securityHandler = self . _securityHandler ) if self . _securityHandler . valid == False : self . _valid = self . _securityHandler . valid self . _message = self . _securityHandler . message return None item = admin . content . getItem ( itemId = itemId ) if item . type == "Feature Service" : if returnURLOnly : return item . url else : fs = arcrest . agol . FeatureService ( url = item . url , securityHandler = self . _securityHandler ) if fs . layers is None or len ( fs . layers ) == 0 : fs = arcrest . ags . FeatureService ( url = item . url ) return fs return None except : line , filename , synerror = trace ( ) raise common . ArcRestHelperError ( { "function" : "GetFeatureService" , "line" : line , "filename" : filename , "synerror" : synerror , } ) finally : admin = None item = None del item del admin gc . collect ( ) | Obtains a feature service by item ID . |
57,014 | def GetLayerFromFeatureServiceByURL ( self , url , layerName = "" , returnURLOnly = False ) : fs = None try : fs = arcrest . agol . FeatureService ( url = url , securityHandler = self . _securityHandler ) return self . GetLayerFromFeatureService ( fs = fs , layerName = layerName , returnURLOnly = returnURLOnly ) except : line , filename , synerror = trace ( ) raise common . ArcRestHelperError ( { "function" : "GetLayerFromFeatureServiceByURL" , "line" : line , "filename" : filename , "synerror" : synerror , } ) finally : fs = None del fs gc . collect ( ) | Obtains a layer from a feature service by URL reference . |
57,015 | def GetLayerFromFeatureService ( self , fs , layerName = "" , returnURLOnly = False ) : layers = None table = None layer = None sublayer = None try : layers = fs . layers if ( layers is None or len ( layers ) == 0 ) and fs . url is not None : fs = arcrest . ags . FeatureService ( url = fs . url ) layers = fs . layers if layers is not None : for layer in layers : if layer . name == layerName : if returnURLOnly : return fs . url + '/' + str ( layer . id ) else : return layer elif not layer . subLayers is None : for sublayer in layer . subLayers : if sublayer == layerName : return sublayer if fs . tables is not None : for table in fs . tables : if table . name == layerName : if returnURLOnly : return fs . url + '/' + str ( layer . id ) else : return table return None except : line , filename , synerror = trace ( ) raise common . ArcRestHelperError ( { "function" : "GetLayerFromFeatureService" , "line" : line , "filename" : filename , "synerror" : synerror , } ) finally : layers = None table = None layer = None sublayer = None del layers del table del layer del sublayer gc . collect ( ) | Obtains a layer from a feature service by feature service reference . |
57,016 | def DeleteFeaturesFromFeatureLayer ( self , url , sql , chunksize = 0 ) : fl = None try : fl = FeatureLayer ( url = url , securityHandler = self . _securityHandler ) totalDeleted = 0 if chunksize > 0 : qRes = fl . query ( where = sql , returnIDsOnly = True ) if 'error' in qRes : print ( qRes ) return qRes elif 'objectIds' in qRes : oids = qRes [ 'objectIds' ] total = len ( oids ) if total == 0 : return { 'success' : True , 'message' : "No features matched the query" } i = 0 print ( "%s features to be deleted" % total ) while ( i <= len ( oids ) ) : oidsDelete = ',' . join ( str ( e ) for e in oids [ i : i + chunksize ] ) if oidsDelete == '' : continue else : results = fl . deleteFeatures ( objectIds = oidsDelete ) if 'deleteResults' in results : totalDeleted += len ( results [ 'deleteResults' ] ) print ( "%s%% Completed: %s/%s " % ( int ( totalDeleted / float ( total ) * 100 ) , totalDeleted , total ) ) i += chunksize else : print ( results ) return { 'success' : True , 'message' : "%s deleted" % totalDeleted } qRes = fl . query ( where = sql , returnIDsOnly = True ) if 'objectIds' in qRes : oids = qRes [ 'objectIds' ] if len ( oids ) > 0 : print ( "%s features to be deleted" % len ( oids ) ) results = fl . deleteFeatures ( where = sql ) if 'deleteResults' in results : totalDeleted += len ( results [ 'deleteResults' ] ) return { 'success' : True , 'message' : "%s deleted" % totalDeleted } else : return results return { 'success' : True , 'message' : "%s deleted" % totalDeleted } else : print ( qRes ) else : results = fl . deleteFeatures ( where = sql ) if results is not None : if 'deleteResults' in results : return { 'success' : True , 'message' : totalDeleted + len ( results [ 'deleteResults' ] ) } else : return results except : line , filename , synerror = trace ( ) raise common . ArcRestHelperError ( { "function" : "DeleteFeaturesFromFeatureLayer" , "line" : line , "filename" : filename , "synerror" : synerror , } ) finally : fl = None del fl gc . collect ( ) | Removes features from a hosted feature service layer by SQL query . |
57,017 | def QueryAllFeatures ( self , url = None , where = "1=1" , out_fields = "*" , timeFilter = None , geometryFilter = None , returnFeatureClass = False , out_fc = None , outSR = None , chunksize = 1000 , printIndent = "" ) : if ( url is None ) : return fl = None try : fl = FeatureLayer ( url = url , securityHandler = self . _securityHandler ) qRes = fl . query ( where = where , returnIDsOnly = True , timeFilter = timeFilter , geometryFilter = geometryFilter ) if 'error' in qRes : print ( printIndent + qRes ) return [ ] elif 'objectIds' in qRes : oids = qRes [ 'objectIds' ] total = len ( oids ) if total == 0 : return fl . query ( where = where , returnGeometry = True , out_fields = out_fields , timeFilter = timeFilter , geometryFilter = geometryFilter , outSR = outSR ) print ( printIndent + "%s features to be downloaded" % total ) chunksize = min ( chunksize , fl . maxRecordCount ) combinedResults = None totalQueried = 0 for chunk in chunklist ( l = oids , n = chunksize ) : oidsQuery = "," . join ( map ( str , chunk ) ) if not oidsQuery : continue else : results = fl . query ( objectIds = oidsQuery , returnGeometry = True , out_fields = out_fields , timeFilter = timeFilter , geometryFilter = geometryFilter , outSR = outSR ) if isinstance ( results , FeatureSet ) : if combinedResults is None : combinedResults = results else : for feature in results . features : combinedResults . features . append ( feature ) totalQueried += len ( results . features ) print ( printIndent + "{:.0%} Completed: {}/{}" . format ( totalQueried / float ( total ) , totalQueried , total ) ) else : print ( printIndent + results ) if returnFeatureClass == True : return combinedResults . save ( * os . path . split ( out_fc ) ) else : return combinedResults else : print ( printIndent + qRes ) except : line , filename , synerror = trace ( ) raise common . ArcRestHelperError ( { "function" : "QueryAllFeatures" , "line" : line , "filename" : filename , "synerror" : synerror , } ) finally : fl = None del fl gc . collect ( ) | Performs an SQL query against a hosted feature service layer and returns all features regardless of service limit . |
57,018 | def contributionStatus ( self ) : import time url = "%s/contributors/%s/activeContribution" % ( self . root , quote ( self . contributorUID ) ) params = { "agolUserToken" : self . _agolSH . token , "f" : "json" } res = self . _get ( url = url , param_dict = params , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) if 'Status' in res and res [ 'Status' ] == 'start' : return True return False | gets the contribution status of a user |
57,019 | def user ( self ) : if self . _user is None : url = "%s/users/%s" % ( self . root , self . _username ) self . _user = CMPUser ( url = url , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url , initialize = False ) return self . _user | gets the user properties |
57,020 | def metadataContributer ( self ) : if self . _metaFL is None : fl = FeatureService ( url = self . _metadataURL , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) self . _metaFS = fl return self . _metaFS | gets the metadata featurelayer object |
57,021 | def set_value ( self , field_name , value ) : if field_name in self . fields : if not value is None : self . _dict [ 'attributes' ] [ field_name ] = _unicode_convert ( value ) else : pass elif field_name . upper ( ) in [ 'SHAPE' , 'SHAPE@' , "GEOMETRY" ] : if isinstance ( value , dict ) : if 'geometry' in value : self . _dict [ 'geometry' ] = value [ 'geometry' ] elif any ( k in value . keys ( ) for k in [ 'x' , 'y' , 'points' , 'paths' , 'rings' , 'spatialReference' ] ) : self . _dict [ 'geometry' ] = value elif isinstance ( value , AbstractGeometry ) : self . _dict [ 'geometry' ] = value . asDictionary elif arcpyFound : if isinstance ( value , arcpy . Geometry ) and value . type == self . geometryType : self . _dict [ 'geometry' ] = json . loads ( value . JSON ) self . _geom = None self . _geom = self . geometry else : return False self . _json = json . dumps ( self . _dict , default = _date_handler ) return True | sets an attribute value for a given field name |
57,022 | def get_value ( self , field_name ) : if field_name in self . fields : return self . _dict [ 'attributes' ] [ field_name ] elif field_name . upper ( ) in [ 'SHAPE' , 'SHAPE@' , "GEOMETRY" ] : return self . _dict [ 'geometry' ] return None | returns a value for a given field name |
57,023 | def asDictionary ( self ) : feat_dict = { } if self . _geom is not None : if 'feature' in self . _dict : feat_dict [ 'geometry' ] = self . _dict [ 'feature' ] [ 'geometry' ] elif 'geometry' in self . _dict : feat_dict [ 'geometry' ] = self . _dict [ 'geometry' ] if 'feature' in self . _dict : feat_dict [ 'attributes' ] = self . _dict [ 'feature' ] [ 'attributes' ] else : feat_dict [ 'attributes' ] = self . _dict [ 'attributes' ] return self . _dict | returns the feature as a dictionary |
57,024 | def geometry ( self ) : if arcpyFound : if self . _geom is None : if 'feature' in self . _dict : self . _geom = arcpy . AsShape ( self . _dict [ 'feature' ] [ 'geometry' ] , esri_json = True ) elif 'geometry' in self . _dict : self . _geom = arcpy . AsShape ( self . _dict [ 'geometry' ] , esri_json = True ) return self . _geom return None | returns the feature geometry |
57,025 | def fields ( self ) : if 'feature' in self . _dict : self . _attributes = self . _dict [ 'feature' ] [ 'attributes' ] else : self . _attributes = self . _dict [ 'attributes' ] return self . _attributes . keys ( ) | returns a list of feature fields |
57,026 | def geometryType ( self ) : if self . _geomType is None : if self . geometry is not None : self . _geomType = self . geometry . type else : self . _geomType = "Table" return self . _geomType | returns the feature s geometry type |
57,027 | def value ( self ) : if self . mosaicMethod == "esriMosaicNone" or self . mosaicMethod == "esriMosaicCenter" or self . mosaicMethod == "esriMosaicNorthwest" or self . mosaicMethod == "esriMosaicNadir" : return { "mosaicMethod" : "esriMosaicNone" , "where" : self . _where , "ascending" : self . _ascending , "fids" : self . fids , "mosaicOperation" : self . _mosaicOperation } elif self . mosaicMethod == "esriMosaicViewpoint" : return { "mosaicMethod" : "esriMosaicViewpoint" , "viewpoint" : self . _viewpoint . asDictionary , "where" : self . _where , "ascending" : self . _ascending , "fids" : self . _fids , "mosaicOperation" : self . _mosaicOperation } elif self . mosaicMethod == "esriMosaicAttribute" : return { "mosaicMethod" : "esriMosaicAttribute" , "sortField" : self . _sortField , "sortValue" : self . _sortValue , "ascending" : self . _ascending , "where" : self . _where , "fids" : self . _fids , "mosaicOperation" : self . _mosaicOperation } elif self . mosaicMethod == "esriMosaicLockRaster" : return { "mosaicMethod" : "esriMosaicLockRaster" , "lockRasterIds" : self . _localRasterIds , "where" : self . _where , "ascending" : self . _ascending , "fids" : self . _fids , "mosaicOperation" : self . _mosaicOperation } elif self . mosaicMethod == "esriMosaicSeamline" : return { "mosaicMethod" : "esriMosaicSeamline" , "where" : self . _where , "fids" : self . _fids , "mosaicOperation" : self . _mosaicOperation } else : raise AttributeError ( "Invalid Mosaic Method" ) | gets the mosaic rule object as a dictionary |
57,028 | def fromJSON ( jsonValue ) : jd = json . loads ( jsonValue ) features = [ ] if 'fields' in jd : fields = jd [ 'fields' ] else : fields = { 'fields' : [ ] } if 'features' in jd : for feat in jd [ 'features' ] : wkid = None spatialReference = None if 'spatialReference' in jd : spatialReference = jd [ 'spatialReference' ] if 'wkid' in jd [ 'spatialReference' ] : wkid = jd [ 'spatialReference' ] [ 'wkid' ] elif 'latestWkid' in jd [ 'spatialReference' ] : wkid = jd [ 'spatialReference' ] [ 'latestWkid' ] features . append ( Feature ( json_string = feat , wkid = wkid , spatialReference = spatialReference ) ) return FeatureSet ( fields , features , hasZ = jd [ 'hasZ' ] if 'hasZ' in jd else False , hasM = jd [ 'hasM' ] if 'hasM' in jd else False , geometryType = jd [ 'geometryType' ] if 'geometryType' in jd else None , objectIdFieldName = jd [ 'objectIdFieldName' ] if 'objectIdFieldName' in jd else None , globalIdFieldName = jd [ 'globalIdFieldName' ] if 'globalIdFieldName' in jd else None , displayFieldName = jd [ 'displayFieldName' ] if 'displayFieldName' in jd else None , spatialReference = jd [ 'spatialReference' ] if 'spatialReference' in jd else None ) | returns a featureset from a JSON string |
57,029 | def spatialReference ( self , value ) : if isinstance ( value , SpatialReference ) : self . _spatialReference = value elif isinstance ( value , int ) : self . _spatialReference = SpatialReference ( wkid = value ) elif isinstance ( value , str ) and str ( value ) . isdigit ( ) : self . _spatialReference = SpatialReference ( wkid = int ( value ) ) elif isinstance ( value , dict ) : wkid = None wkt = None if 'wkid' in value and str ( value [ 'wkid' ] ) . isdigit ( ) : wkid = int ( value [ 'wkid' ] ) if 'latestWkid' in value and str ( value [ 'latestWkid' ] ) . isdigit ( ) : wkid = int ( value [ 'latestWkid' ] ) if 'wkt' in value : wkt = value [ 'wkt' ] self . _spatialReference = SpatialReference ( wkid = wkid , wkt = wkt ) | sets the featureset s spatial reference |
57,030 | def regions ( self ) : url = "%s/regions" % self . root params = { "f" : "json" } return self . _get ( url = url , param_dict = params , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | gets the regions value |
57,031 | def portalSelf ( self ) : url = "%s/self" % self . root return Portal ( url = url , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , ) | The portal to which the current user belongs . This is an organizational portal if the user belongs to an organization or the default portal if the user does not belong to one |
57,032 | def portal ( self , portalID = None ) : if portalID is None : portalID = self . portalSelf . id url = "%s/%s" % ( self . root , portalID ) return Portal ( url = url , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , initalize = True ) | returns a specific reference to a portal |
57,033 | def _findPortalId ( self ) : if not self . root . lower ( ) . endswith ( "/self" ) : url = self . root + "/self" else : url = self . root params = { "f" : "json" } res = self . _get ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) if 'id' in res : return res [ 'id' ] return None | gets the portal id for a site if not known . |
57,034 | def portalId ( self ) : if self . _portalId is None : self . _portalId = self . _findPortalId ( ) return self . _portalId | gets the portal Id |
57,035 | def featureServers ( self ) : if self . urls == { } : return { } featuresUrls = self . urls [ 'urls' ] [ 'features' ] if 'https' in featuresUrls : res = featuresUrls [ 'https' ] elif 'http' in featuresUrls : res = featuresUrls [ 'http' ] else : return None services = [ ] for urlHost in res : if self . isPortal : services . append ( AGSAdministration ( url = '%s/admin' % urlHost , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) ) else : services . append ( Services ( url = 'https://%s/%s/ArcGIS/admin' % ( urlHost , self . portalId ) , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) ) return services | gets the hosting feature AGS Server |
57,036 | def update ( self , updatePortalParameters , clearEmptyFields = False ) : url = self . root + "/update" params = { "f" : "json" , "clearEmptyFields" : clearEmptyFields } if isinstance ( updatePortalParameters , parameters . PortalParameters ) : params . update ( updatePortalParameters . value ) elif isinstance ( updatePortalParameters , dict ) : for k , v in updatePortalParameters . items ( ) : params [ k ] = v else : raise AttributeError ( "updatePortalParameters must be of type parameter.PortalParameters" ) return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | The Update operation allows administrators only to update the organization information such as name description thumbnail and featured groups . |
57,037 | def updateUserRole ( self , user , role ) : url = self . _url + "/updateuserrole" params = { "f" : "json" , "user" : user , "role" : role } return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | The Update User Role operation allows the administrator of an org anization to update the role of a user within a portal . |
57,038 | def isServiceNameAvailable ( self , name , serviceType ) : _allowedTypes = [ 'Feature Service' , "Map Service" ] url = self . _url + "/isServiceNameAvailable" params = { "f" : "json" , "name" : name , "type" : serviceType } return self . _get ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | Checks to see if a given service name and type are available for publishing a new service . true indicates that the name and type is not found in the organization s services and is available for publishing . false means the requested name and type are not available . |
57,039 | def servers ( self ) : url = "%s/servers" % self . root return Servers ( url = url , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | gets the federated or registered servers for Portal |
57,040 | def users ( self , start = 1 , num = 10 , sortField = "fullName" , sortOrder = "asc" , role = None ) : users = [ ] url = self . _url + "/users" params = { "f" : "json" , "start" : start , "num" : num } if not role is None : params [ 'role' ] = role if not sortField is None : params [ 'sortField' ] = sortField if not sortOrder is None : params [ 'sortOrder' ] = sortOrder from . _community import Community res = self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) if "users" in res : if len ( res [ 'users' ] ) > 0 : parsed = urlparse . urlparse ( self . _url ) if parsed . netloc . lower ( ) . find ( 'arcgis.com' ) == - 1 : cURL = "%s://%s/%s/sharing/rest/community" % ( parsed . scheme , parsed . netloc , parsed . path [ 1 : ] . split ( '/' ) [ 0 ] ) else : cURL = "%s://%s/sharing/rest/community" % ( parsed . scheme , parsed . netloc ) com = Community ( url = cURL , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) for r in res [ 'users' ] : users . append ( com . users . user ( r [ "username" ] ) ) res [ 'users' ] = users return res | Lists all the members of the organization . The start and num paging parameters are supported . |
57,041 | def roles ( self ) : return Roles ( url = "%s/roles" % self . root , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | gets the roles class that allows admins to manage custom roles on portal |
57,042 | def resources ( self , start = 1 , num = 10 ) : url = self . _url + "/resources" params = { "f" : "json" , "start" : start , "num" : num } return self . _get ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | Resources lists all file resources for the organization . The start and num paging parameters are supported . |
57,043 | def addResource ( self , key , filePath , text ) : url = self . root + "/addresource" params = { "f" : "json" , "token" : self . _securityHandler . token , "key" : key , "text" : text } files = { } files [ 'file' ] = filePath res = self . _post ( url = url , param_dict = params , files = files , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) return res | The add resource operation allows the administrator to add a file resource for example the organization s logo or custom banner . The resource can be used by any member of the organization . File resources use storage space from your quota and are scanned for viruses . |
57,044 | def updateSecurityPolicy ( self , minLength = 8 , minUpper = None , minLower = None , minLetter = None , minDigit = None , minOther = None , expirationInDays = None , historySize = None ) : params = { "f" : "json" , "minLength" : minLength , "minUpper" : minUpper , "minLower" : minLower , "minLetter" : minLetter , "minDigit" : minDigit , "minOther" : minOther , "expirationInDays" : expirationInDays , "historySize" : historySize } url = "%s/securityPolicy/update" % self . root return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | updates the Portals security policy |
57,045 | def portalAdmin ( self ) : from . . manageportal import PortalAdministration return PortalAdministration ( admin_url = "https://%s/portaladmin" % self . portalHostname , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , initalize = False ) | gets a reference to a portal administration class |
57,046 | def addUser ( self , invitationList , subject , html ) : url = self . _url + "/invite" params = { "f" : "json" } if isinstance ( invitationList , parameters . InvitationList ) : params [ 'invitationList' ] = invitationList . value ( ) params [ 'html' ] = html params [ 'subject' ] = subject return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | adds a user without sending an invitation email |
57,047 | def inviteByEmail ( self , emails , subject , text , html , role = "org_user" , mustApprove = True , expiration = 1440 ) : url = self . root + "/inviteByEmail" params = { "f" : "json" , "emails" : emails , "subject" : subject , "text" : text , "html" : html , "role" : role , "mustApprove" : mustApprove , "expiration" : expiration } return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | Invites a user or users to a site . |
57,048 | def usage ( self , startTime , endTime , vars = None , period = None , groupby = None , name = None , stype = None , etype = None , appId = None , deviceId = None , username = None , appOrgId = None , userOrgId = None , hostOrgId = None ) : url = self . root + "/usage" startTime = str ( int ( local_time_to_online ( dt = startTime ) ) ) endTime = str ( int ( local_time_to_online ( dt = endTime ) ) ) params = { 'f' : 'json' , 'startTime' : startTime , 'endTime' : endTime , 'vars' : vars , 'period' : period , 'groupby' : groupby , 'name' : name , 'stype' : stype , 'etype' : etype , 'appId' : appId , 'deviceId' : deviceId , 'username' : username , 'appOrgId' : appOrgId , 'userOrgId' : userOrgId , 'hostOrgId' : hostOrgId , } params = { key : item for key , item in params . items ( ) if item is not None } return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | returns the usage statistics value |
57,049 | def servers ( self ) : self . __init ( ) items = [ ] for k , v in self . _json_dict . items ( ) : if k == "servers" : for s in v : if 'id' in s : url = "%s/%s" % ( self . root , s [ 'id' ] ) items . append ( self . Server ( url = url , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) ) del k , v return items | gets all the server resources |
57,050 | def deleteRole ( self , roleID ) : url = self . _url + "/%s/delete" % roleID params = { "f" : "json" } return self . _post ( url = url , param_dict = params , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | deletes a role by ID |
57,051 | def updateRole ( self , roleID , name , description ) : params = { "name" : name , "description" : description , "f" : "json" } url = self . _url + "/%s/update" return self . _post ( url = url , param_dict = params , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | allows for the role name or description to be modified |
57,052 | def findRoleID ( self , name ) : for r in self : if r [ 'name' ] . lower ( ) == name . lower ( ) : return r [ 'id' ] del r return None | searches the roles by name and returns the role s ID |
57,053 | def get_config_value ( config_file , section , variable ) : try : parser = ConfigParser . SafeConfigParser ( ) parser . read ( config_file ) return parser . get ( section , variable ) except : return None | extracts a config file value |
57,054 | def users ( self ) : return Users ( url = "%s/users" % self . root , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | Provides access to all user resources |
57,055 | def getItem ( self , itemId ) : url = "%s/items/%s" % ( self . root , itemId ) return Item ( url = url , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | gets the refernce to the Items class which manages content on a given AGOL or Portal site . |
57,056 | def FeatureContent ( self ) : return FeatureContent ( url = "%s/%s" % ( self . root , "features" ) , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | Feature Content class id the parent resource for feature operations such as Analyze and Generate . |
57,057 | def user ( self , username = None ) : if username is None : username = self . __getUsername ( ) url = "%s/%s" % ( self . root , username ) return User ( url = url , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , initalize = True ) | gets the user s content . If None is passed the current user is used . |
57,058 | def saveThumbnail ( self , fileName , filePath ) : if self . _thumbnail is None : self . __init ( ) param_dict = { } if self . _thumbnail is not None : imgUrl = self . root + "/info/" + self . _thumbnail onlineFileName , file_ext = splitext ( self . _thumbnail ) fileNameSafe = "" . join ( x for x in fileName if x . isalnum ( ) ) + file_ext result = self . _get ( url = imgUrl , param_dict = param_dict , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , out_folder = filePath , file_name = fileNameSafe ) return result else : return None | URL to the thumbnail used for the item |
57,059 | def userItem ( self ) : if self . ownerFolder is not None : url = "%s/users/%s/%s/items/%s" % ( self . root . split ( '/items/' ) [ 0 ] , self . owner , self . ownerFolder , self . id ) else : url = "%s/users/%s/items/%s" % ( self . root . split ( '/items/' ) [ 0 ] , self . owner , self . id ) return UserItem ( url = url , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | returns a reference to the UserItem class |
57,060 | def addRating ( self , rating = 5.0 ) : if rating > 5.0 : rating = 5.0 elif rating < 1.0 : rating = 1.0 url = "%s/addRating" % self . root params = { "f" : "json" , "rating" : "%s" % rating } return self . _post ( url , params , proxy_port = self . _proxy_port , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url ) | Adds a rating to an item between 1 . 0 and 5 . 0 |
57,061 | def addComment ( self , comment ) : url = "%s/addComment" % self . root params = { "f" : "json" , "comment" : comment } return self . _post ( url , params , proxy_port = self . _proxy_port , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url ) | adds a comment to a given item . Must be authenticated |
57,062 | def itemComment ( self , commentId ) : url = "%s/comments/%s" % ( self . root , commentId ) params = { "f" : "json" } return self . _get ( url , params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) | returns details of a single comment |
57,063 | def itemComments ( self ) : url = "%s/comments/" % self . root params = { "f" : "json" } return self . _get ( url , params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) | returns all comments for a given item |
57,064 | def deleteComment ( self , commentId ) : url = "%s/comments/%s/delete" % ( self . root , commentId ) params = { "f" : "json" , } return self . _post ( url , params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) | removes a comment from an Item |
57,065 | def packageInfo ( self ) : url = "%s/item.pkinfo" % self . root params = { 'f' : 'json' } result = self . _get ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , out_folder = tempfile . gettempdir ( ) ) return result | gets the item s package information file |
57,066 | def item ( self ) : url = self . _contentURL return Item ( url = self . _contentURL , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , initalize = True ) | returns the Item class of an Item |
57,067 | def reassignItem ( self , targetUsername , targetFoldername ) : params = { "f" : "json" , "targetUsername" : targetUsername , "targetFoldername" : targetFoldername } url = "%s/reassign" % self . root return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | The Reassign Item operation allows the administrator of an organization to reassign a member s item to another member of the organization . |
57,068 | def updateItem ( self , itemParameters , clearEmptyFields = False , data = None , metadata = None , text = None , serviceUrl = None , multipart = False ) : thumbnail = None largeThumbnail = None files = { } params = { "f" : "json" , } if clearEmptyFields : params [ "clearEmptyFields" ] = clearEmptyFields if serviceUrl is not None : params [ 'url' ] = serviceUrl if text is not None : params [ 'text' ] = text if isinstance ( itemParameters , ItemParameter ) == False : raise AttributeError ( "itemParameters must be of type parameter.ItemParameter" ) keys_to_delete = [ 'id' , 'owner' , 'size' , 'numComments' , 'numRatings' , 'avgRating' , 'numViews' , 'overwrite' ] dictItem = itemParameters . value for key in keys_to_delete : if key in dictItem : del dictItem [ key ] for key in dictItem : if key == "thumbnail" : files [ 'thumbnail' ] = dictItem [ 'thumbnail' ] elif key == "largeThumbnail" : files [ 'largeThumbnail' ] = dictItem [ 'largeThumbnail' ] elif key == "metadata" : metadata = dictItem [ 'metadata' ] if os . path . basename ( metadata ) != 'metadata.xml' : tempxmlfile = os . path . join ( tempfile . gettempdir ( ) , "metadata.xml" ) if os . path . isfile ( tempxmlfile ) == True : os . remove ( tempxmlfile ) import shutil shutil . copy ( metadata , tempxmlfile ) metadata = tempxmlfile files [ 'metadata' ] = dictItem [ 'metadata' ] else : params [ key ] = dictItem [ key ] if data is not None : files [ 'file' ] = data if metadata and os . path . isfile ( metadata ) : files [ 'metadata' ] = metadata url = "%s/update" % self . root if multipart : itemID = self . id params [ 'multipart' ] = True params [ 'fileName' ] = os . path . basename ( data ) res = self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) itemPartJSON = self . addByPart ( filePath = data ) res = self . commit ( wait = True , additionalParams = { 'type' : self . type } ) else : res = self . _post ( url = url , param_dict = params , files = files , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , force_form_post = True ) self . __init ( ) return self | updates an item s properties using the ItemParameter class . |
57,069 | def status ( self , jobId = None , jobType = None ) : params = { "f" : "json" } if jobType is not None : params [ 'jobType' ] = jobType if jobId is not None : params [ "jobId" ] = jobId url = "%s/status" % self . root return self . _get ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) | Inquire about status when publishing an item adding an item in async mode or adding with a multipart upload . Partial is available for Add Item Multipart when only a part is uploaded and the item is not committed . |
57,070 | def commit ( self , wait = False , additionalParams = { } ) : url = "%s/commit" % self . root params = { "f" : "json" , } for key , value in additionalParams . items ( ) : params [ key ] = value if wait == True : res = self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) res = self . status ( ) import time while res [ 'status' ] . lower ( ) in [ "partial" , "processing" ] : time . sleep ( 2 ) res = self . status ( ) return res else : return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) | Commit is called once all parts are uploaded during a multipart Add Item or Update Item operation . The parts are combined into a file and the original file is overwritten during an Update Item operation . This is an asynchronous call and returns immediately . Status can be used to check the status of the operation until it is completed . |
57,071 | def folders ( self ) : if self . _folders is None : self . __init ( ) if self . _folders is not None and isinstance ( self . _folders , list ) : if len ( self . _folders ) == 0 : self . _loadFolders ( ) return self . _folders | gets the property value for folders |
57,072 | def items ( self ) : self . __init ( ) items = [ ] for item in self . _items : items . append ( UserItem ( url = "%s/items/%s" % ( self . location , item [ 'id' ] ) , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , initalize = True ) ) return items | gets the property value for items |
57,073 | def addRelationship ( self , originItemId , destinationItemId , relationshipType ) : url = "%s/addRelationship" % self . root params = { "originItemId" : originItemId , "destinationItemId" : destinationItemId , "relationshipType" : relationshipType , "f" : "json" } return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) | Adds a relationship of a certain type between two items . |
57,074 | def createService ( self , createServiceParameter , description = None , tags = "Feature Service" , snippet = None ) : url = "%s/createService" % self . location val = createServiceParameter . value params = { "f" : "json" , "outputType" : "featureService" , "createParameters" : json . dumps ( val ) , "tags" : tags } if snippet is not None : params [ 'snippet' ] = snippet if description is not None : params [ 'description' ] = description res = self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) if 'id' in res or 'serviceItemId' in res : if 'id' in res : url = "%s/items/%s" % ( self . location , res [ 'id' ] ) else : url = "%s/items/%s" % ( self . location , res [ 'serviceItemId' ] ) return UserItem ( url = url , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) return res | The Create Service operation allows users to create a hosted feature service . You can use the API to create an empty hosted feaure service from feature service metadata JSON . |
57,075 | def shareItems ( self , items , groups = "" , everyone = False , org = False ) : url = "%s/shareItems" % self . root params = { "f" : "json" , "items" : items , "everyone" : everyone , "org" : org , "groups" : groups } return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) | Shares a batch of items with the specified list of groups . Users can only share items with groups to which they belong . This operation also allows a user to share items with everyone in which case the items are publicly accessible or with everyone in their organization . |
57,076 | def createFolder ( self , name ) : url = "%s/createFolder" % self . root params = { "f" : "json" , "title" : name } self . _folders = None return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) | Creates a folder in which items can be placed . Folders are only visible to a user and solely used for organizing content within that user s content space . |
57,077 | def analyze ( self , itemId = None , filePath = None , text = None , fileType = "csv" , analyzeParameters = None ) : files = [ ] url = self . _url + "/analyze" params = { "f" : "json" } fileType = "csv" params [ "fileType" ] = fileType if analyzeParameters is not None and isinstance ( analyzeParameters , AnalyzeParameters ) : params [ 'analyzeParameters' ] = analyzeParameters . value if not ( filePath is None ) and os . path . isfile ( filePath ) : params [ 'text' ] = open ( filePath , 'rb' ) . read ( ) return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) elif itemId is not None : params [ "fileType" ] = fileType params [ 'itemId' ] = itemId return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) else : raise AttributeError ( "either an Item ID or a file path must be given." ) | The Analyze call helps a client analyze a CSV file prior to publishing or generating features using the Publish or Generate operation respectively . Analyze returns information about the file including the fields present as well as sample records . Analyze attempts to detect the presence of location fields that may be present as either X Y fields or address fields . Analyze packages its result so that publishParameters within the JSON response contains information that can be passed back to the server in a subsequent call to Publish or Generate . The publishParameters subobject contains properties that describe the resulting layer after publishing including its fields the desired renderer and so on . Analyze will suggest defaults for the renderer . In a typical workflow the client will present portions of the Analyze results to the user for editing before making the call to Publish or Generate . If the file to be analyzed currently exists in the portal as an item callers can pass in its itemId . Callers can also directly post the file . In this case the request must be a multipart post request pursuant to IETF RFC1867 . The third option for text files is to pass the text in as the value of the text parameter . |
57,078 | def __assembleURL ( self , url , groupId ) : from . . packages . six . moves . urllib_parse import urlparse parsed = urlparse ( url ) communityURL = "%s://%s%s/sharing/rest/community/groups/%s" % ( parsed . scheme , parsed . netloc , parsed . path . lower ( ) . split ( '/sharing/rest/' ) [ 0 ] , groupId ) return communityURL | private function that assembles the URL for the community . Group class |
57,079 | def group ( self ) : split_count = self . _url . lower ( ) . find ( "/content/" ) len_count = len ( '/content/' ) gURL = self . _url [ : self . _url . lower ( ) . find ( "/content/" ) ] + "/community/" + self . _url [ split_count + len_count : ] return CommunityGroup ( url = gURL , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | returns the community . Group class for the current group |
57,080 | def addUniqueValue ( self , value , label , description , symbol ) : if self . _uniqueValueInfos is None : self . _uniqueValueInfos = [ ] self . _uniqueValueInfos . append ( { "value" : value , "label" : label , "description" : description , "symbol" : symbol } ) | adds a unique value to the renderer |
57,081 | def removeUniqueValue ( self , value ) : for v in self . _uniqueValueInfos : if v [ 'value' ] == value : self . _uniqueValueInfos . remove ( v ) return True del v return False | removes a unique value in unique Value Info |
57,082 | def addClassBreak ( self , classMinValue , classMaxValue , label , description , symbol ) : if self . _classBreakInfos is None : self . _classBreakInfos = [ ] self . _classBreakInfos . append ( { "classMinValue" : classMinValue , "classMaxValue" : classMaxValue , "label" : label , "description" : description , "symbol" : symbol } ) | adds a classification break value to the renderer |
57,083 | def removeClassBreak ( self , label ) : for v in self . _classBreakInfos : if v [ 'label' ] == label : self . _classBreakInfos . remove ( v ) return True del v return False | removes a classification break value to the renderer |
57,084 | def downloadThumbnail ( self , outPath ) : url = self . _url + "/info/thumbnail" params = { } return self . _get ( url = url , out_folder = outPath , file_name = None , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | downloads the items s thumbnail |
57,085 | def __init ( self ) : params = { "f" : "json" } json_dict = self . _get ( self . _url , params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) self . _json = json . dumps ( json_dict ) self . _json_dict = json_dict attributes = [ attr for attr in dir ( self ) if not attr . startswith ( '__' ) and not attr . startswith ( '_' ) ] for k , v in json_dict . items ( ) : if k == "tables" : self . _tables = [ ] for tbl in v : url = self . _url + "/%s" % tbl [ 'id' ] self . _tables . append ( TableLayer ( url , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) ) elif k == "layers" : self . _layers = [ ] for lyr in v : url = self . _url + "/%s" % lyr [ 'id' ] layer_type = self . _getLayerType ( url ) if layer_type == "Feature Layer" : self . _layers . append ( FeatureLayer ( url , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) ) elif layer_type == "Raster Layer" : self . _layers . append ( RasterLayer ( url , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) ) elif layer_type == "Group Layer" : self . _layers . append ( GroupLayer ( url , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) ) elif layer_type == "Schematics Layer" : self . _layers . append ( SchematicsLayer ( url , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) ) else : print ( 'Type %s is not implemented' % layer_type ) elif k in attributes : setattr ( self , "_" + k , json_dict [ k ] ) else : print ( k , " is not implemented for mapservice." ) | populates all the properties for the map service |
57,086 | def getExtensions ( self ) : extensions = [ ] if isinstance ( self . supportedExtensions , list ) : for ext in self . supportedExtensions : extensionURL = self . _url + "/exts/%s" % ext if ext == "SchematicsServer" : extensions . append ( SchematicsService ( url = extensionURL , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) ) return extensions else : extensionURL = self . _url + "/exts/%s" % self . supportedExtensions if self . supportedExtensions == "SchematicsServer" : extensions . append ( SchematicsService ( url = extensionURL , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) ) return extensions | returns objects for all map service extensions |
57,087 | def allLayers ( self ) : url = self . _url + "/layers" params = { "f" : "json" } res = self . _get ( url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) return_dict = { "layers" : [ ] , "tables" : [ ] } for k , v in res . items ( ) : if k == "layers" : for val in v : return_dict [ 'layers' ] . append ( FeatureLayer ( url = self . _url + "/%s" % val [ 'id' ] , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) ) elif k == "tables" : for val in v : return_dict [ 'tables' ] . append ( TableLayer ( url = self . _url + "/%s" % val [ 'id' ] , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) ) del k , v return return_dict | returns all layers for the service |
57,088 | def find ( self , searchText , layers , contains = True , searchFields = "" , sr = "" , layerDefs = "" , returnGeometry = True , maxAllowableOffset = "" , geometryPrecision = "" , dynamicLayers = "" , returnZ = False , returnM = False , gdbVersion = "" ) : url = self . _url + "/find" params = { "f" : "json" , "searchText" : searchText , "contains" : self . _convert_boolean ( contains ) , "searchFields" : searchFields , "sr" : sr , "layerDefs" : layerDefs , "returnGeometry" : self . _convert_boolean ( returnGeometry ) , "maxAllowableOffset" : maxAllowableOffset , "geometryPrecision" : geometryPrecision , "dynamicLayers" : dynamicLayers , "returnZ" : self . _convert_boolean ( returnZ ) , "returnM" : self . _convert_boolean ( returnM ) , "gdbVersion" : gdbVersion , "layers" : layers } res = self . _get ( url , params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) qResults = [ ] for r in res [ 'results' ] : qResults . append ( Feature ( r ) ) return qResults | performs the map service find operation |
57,089 | def getFeatureDynamicLayer ( self , oid , dynamicLayer , returnZ = False , returnM = False ) : url = self . _url + "/dynamicLayer/%s" % oid params = { "f" : "json" , "returnZ" : returnZ , "returnM" : returnM , "layer" : { "id" : 101 , "source" : dynamicLayer . asDictionary } } return Feature ( json_string = self . _get ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) ) | The feature resource represents a single feature in a dynamic layer in a map service |
57,090 | def identify ( self , geometry , mapExtent , imageDisplay , tolerance , geometryType = "esriGeometryPoint" , sr = None , layerDefs = None , time = None , layerTimeOptions = None , layers = "top" , returnGeometry = True , maxAllowableOffset = None , geometryPrecision = None , dynamicLayers = None , returnZ = False , returnM = False , gdbVersion = None ) : params = { 'f' : 'json' , 'geometry' : geometry , 'geometryType' : geometryType , 'tolerance' : tolerance , 'mapExtent' : mapExtent , 'imageDisplay' : imageDisplay } if layerDefs is not None : params [ 'layerDefs' ] = layerDefs if layers is not None : params [ 'layers' ] = layers if sr is not None : params [ 'sr' ] = sr if time is not None : params [ 'time' ] = time if layerTimeOptions is not None : params [ 'layerTimeOptions' ] = layerTimeOptions if maxAllowableOffset is not None : params [ 'maxAllowableOffset' ] = maxAllowableOffset if geometryPrecision is not None : params [ 'geometryPrecision' ] = geometryPrecision if dynamicLayers is not None : params [ 'dynamicLayers' ] = dynamicLayers if gdbVersion is not None : params [ 'gdbVersion' ] = gdbVersion identifyURL = self . _url + "/identify" return self . _get ( url = identifyURL , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | The identify operation is performed on a map service resource to discover features at a geographic location . The result of this operation is an identify results resource . Each identified result includes its name layer ID layer name geometry and geometry type and other attributes of that result as name - value pairs . |
57,091 | def fromJSON ( value ) : if isinstance ( value , str ) : value = json . loads ( value ) elif isinstance ( value , dict ) : pass else : raise AttributeError ( "Invalid input" ) return Extension ( typeName = value [ 'typeName' ] , capabilities = value [ 'capabilities' ] , enabled = value [ 'enabled' ] == "true" , maxUploadFileSize = value [ 'maxUploadFileSize' ] , allowedUploadFileType = value [ 'allowedUploadFileTypes' ] , properties = value [ 'properties' ] ) | returns the object from json string or dictionary |
57,092 | def asList ( self ) : return [ self . _red , self . _green , self . _blue , self . _alpha ] | returns the value as the list object |
57,093 | def color ( self , value ) : if isinstance ( value , ( list , Color ) ) : if value is list : self . _color = value else : self . _color = value . asList | sets the color |
57,094 | def outlineColor ( self , value ) : if isinstance ( value , ( list , Color ) ) : if value is list : self . _outlineColor = value else : self . _outlineColor = value . asList | sets the outline color |
57,095 | def outline ( self , value ) : if isinstance ( value , SimpleLineSymbol ) : self . _outline = value . asDictionary | sets the outline |
57,096 | def base64ToImage ( imgData , out_path , out_file ) : fh = open ( os . path . join ( out_path , out_file ) , "wb" ) fh . write ( imgData . decode ( 'base64' ) ) fh . close ( ) del fh return os . path . join ( out_path , out_file ) | converts a base64 string to a file |
57,097 | def find ( self , text , magicKey = None , sourceCountry = None , bbox = None , location = None , distance = 3218.69 , outSR = 102100 , category = None , outFields = "*" , maxLocations = 20 , forStorage = False ) : if isinstance ( self . _securityHandler , ( AGOLTokenSecurityHandler , OAuthSecurityHandler ) ) : url = self . _url + "/find" params = { "f" : "json" , "text" : text , } if not magicKey is None : params [ 'magicKey' ] = magicKey if not sourceCountry is None : params [ 'sourceCountry' ] = sourceCountry if not bbox is None : params [ 'bbox' ] = bbox if not location is None : if isinstance ( location , Point ) : params [ 'location' ] = location . asDictionary if isinstance ( location , list ) : params [ 'location' ] = "%s,%s" % ( location [ 0 ] , location [ 1 ] ) if not distance is None : params [ 'distance' ] = distance if not outSR is None : params [ 'outSR' ] = outSR if not category is None : params [ 'category' ] = category if outFields is None : params [ 'outFields' ] = "*" else : params [ 'outFields' ] = outFields if not maxLocations is None : params [ 'maxLocations' ] = maxLocations if not forStorage is None : params [ 'forStorage' ] = forStorage return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) else : raise Exception ( "This function works on the ArcGIS Online World Geocoder" ) | The find operation geocodes one location per request ; the input address is specified in a single parameter . |
57,098 | def geocodeAddresses ( self , addresses , outSR = 4326 , sourceCountry = None , category = None ) : params = { "f" : "json" } url = self . _url + "/geocodeAddresses" params [ 'outSR' ] = outSR params [ 'sourceCountry' ] = sourceCountry params [ 'category' ] = category params [ 'addresses' ] = addresses return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) | The geocodeAddresses operation is performed on a Geocode Service resource . The result of this operation is a resource representing the list of geocoded addresses . This resource provides information about the addresses including the address location score and other geocode service - specific attributes . You can provide arguments to the geocodeAddresses operation as query parameters defined in the following parameters table . |
57,099 | def __init ( self ) : params = { "f" : "json" , } json_dict = self . _get ( self . _url , params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) self . _json_dict = json_dict self . _json = json . dumps ( self . _json_dict ) attributes = [ attr for attr in dir ( self ) if not attr . startswith ( '__' ) and not attr . startswith ( '_' ) ] for k , v in json_dict . items ( ) : if k in attributes : if k == "routeLayers" and json_dict [ k ] : self . _routeLayers = [ ] for rl in v : self . _routeLayers . append ( RouteNetworkLayer ( url = self . _url + "/%s" % rl , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , initialize = False ) ) elif k == "serviceAreaLayers" and json_dict [ k ] : self . _serviceAreaLayers = [ ] for sal in v : self . _serviceAreaLayers . append ( ServiceAreaNetworkLayer ( url = self . _url + "/%s" % sal , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , initialize = False ) ) elif k == "closestFacilityLayers" and json_dict [ k ] : self . _closestFacilityLayers = [ ] for cf in v : self . _closestFacilityLayers . append ( ClosestFacilityNetworkLayer ( url = self . _url + "/%s" % cf , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , initialize = False ) ) else : setattr ( self , "_" + k , v ) else : print ( "attribute %s is not implemented." % k ) | initializes the properties |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.