#print('Created feature response: {} '.format(str(resp.status_code))) # While testing your environment - we stop the engine here # When ready comment these two lines out to run the actual engine print('It works!') # sys.exit() # Main Execution Loop for our Map Engine # while True: # Assuming we use the last Dataset found above # # Get features and decode the json object # https://docs.mapbox.com/api/maps/#the-feature-object collection = datasets.list_features(dataset['id']).json() found = len(collection['features']) if found == 0: print('No features found in dataset {}'.format(dataset['name'])) sys.exit() else: print('Found {} features in dataset {}'.format(str(found), dataset['name'])) # We need a dictionary of provinces # # We only load it once and keep it in RAM until the script is killed if (0 == len(provinceDict)): # http request and decode json object
idlayer = 'cin2p1rmm0bqvvhm47cjvcsor' access_token = 'pk.eyJ1Ijoic2Vkb25hY2hhbWJlciIsImEiOiJjaW13Zmp3cGswMzd0d2tsdXBnYmVjNmRjIn0.PlcjviLrxQht-_tBEbQQeg' secretkey = 'sk.eyJ1Ijoic2Vkb25hY2hhbWJlciIsImEiOiJjaW5qYXFjeHYweG5hdWlranFxZHpxYXhrIn0.2oaLx8HQUCtSzef6ozEaiQ' datasets = Datasets() #tokenurl = "https://www.mapbox.com/core/tokens/v1?_="+str(int(time.time())) #r = requests.get(tokenurl); datasets.session.params['access_token'] = access_token datasets.list().json() response = Datasets(access_token=secretkey).read_dataset(idlayer).json() collection = datasets.list_features(idlayer).json() for q in collection: #read #resp = datasets.read_feature(idlayer, '2') #update #update = {'type': 'Feature', 'id': '2', 'properties': {'name': 'Insula Nulla C'}, # 'geometry': {'type': 'Point', 'coordinates': [0, 0]}} #update = datasets.update_feature(idlayer, '2', update).json() #update['properties']['name']