Esempio n. 1
0
import os
import json

from classmaprouletteloader import mapRouletteChallenge, mapRouletteTask

#constructing mapRouletteChallenge object,verifying API service exists
testchallenge=mapRouletteChallenge('http://192.168.1.12:5000/','testchallenge',challengeTitle='this is a test',challengeInstruction='test are instructions')

#creating challenge via API call
testchallenge.initChallenge()

#sample upload json objects/tasks
with open('example2.json', 'r') as infile:
    tasks = json.load(infile)

for task in tasks:
    osmid = task['geometries']['features'][0]['properties']['osmid']
    geom = task['geometries']
    testchallenge.addTask(mapRouletteTask(geom,osmid,testchallenge.slug,testchallenge.instruction)) 

httpresponse = testchallenge.uploadTasks()

Esempio n. 2
0
        rootlogger.setLevel(logging.INFO)
        requests_log.setLevel(logging.INFO)

    if args.debug:
        rootlogger.setLevel(logging.DEBUG)
        requests_log.setLevel(logging.DEBUG)

    #set slug and challenge title parameters
    slug = args.challenge_slug

    challenge_title = args.challenge_title
    if not args.challenge_title:
        challenge_title = slug

    #instatiate maproulette challenge loading object
    mrChallengeLoader = mapRouletteChallenge(args.server,slug,challenge_title)

    #maproulette challenge loading object checks for server existence
    if not args.dry and not mrChallengeLoader.serverExists:
        print 'There is no running MapRoulette API instance at {}'.format(base)
        print 'You can supply a MR server URL with the --server option.'
        exit(0)

    #maproulette challenge loading object checks if challenge exists, if not it creates a new one
    mrChallengeLoader.initChallenge()

    #adds tasks to task payload, by data source
    if 'query' in args:
        mrChallengeLoader = get_tasks_from_db(args,mrChallengeLoader)

    if 'json_file' in args: