11"""This module contains the methods that the user will use directly to interact with MapRoulette challenges"""
22
3- import geojson
43from maproulette .api .maproulette_server import MapRouletteServer
54from maproulette .models .challenge import ChallengeModel
65
@@ -260,42 +259,6 @@ def add_tasks_to_challenge(self, data, challenge_id):
260259 body = data )
261260 return response
262261
263- def add_tasks_to_challenge_batch (self , data , challenge_id , batch_size = 100 ):
264- """Method to add tasks to an existing challenge
265-
266- :param data: a GeoJSON containing geometry of tasks to be added to a challenge
267- :param challenge_id: the ID corresponding to the challenge that tasks will be added to
268- :param batch_size: the number of features within the GeoJSON to send to the API at a time. Default is 100.
269- :returns: the API response from the PUT request
270- """
271- if isinstance (data , str ):
272- try :
273- geojson .loads (data )
274- except ValueError
275- features = data ['features' ]
276- feature_collection = {'type' : 'FeatureCollection' }
277- remaining_features = len (features )
278- bundle = []
279- count = 0
280- for index , feature in enumerate (features ):
281- bundle .append (feature )
282- count += 1
283- if count == batch_size :
284- feature_collection ['features' ] = bundle
285- self .add_tasks_to_challenge (
286- challenge_id = challenge_id ,
287- data = feature_collection
288- )
289- remaining_features -= count
290- bundle = []
291- count = 0
292- if remaining_features > 0 :
293- feature_collection ['features' ] = bundle
294- self .add_tasks_to_challenge (
295- challenge_id = challenge_id ,
296- data = feature_collection
297- )
298-
299262 def delete_challenge (self , challenge_id , immediate = "false" ):
300263 """Method to delete a challenge by using the corresponding challenge ID
301264
@@ -351,11 +314,3 @@ def is_challenge_model(input_object):
351314 :returns: True if instance of model
352315 """
353316 return bool (isinstance (input_object , ChallengeModel ))
354-
355- @staticmethod
356- def string_to_geojson (input_object ):
357- """Converts string to GeoJSON object using the geojson package
358-
359- :param input_object: string representing the GeoJSON object
360- :return: a valid
361- """
0 commit comments