use of org.openstreetmap.atlas.checks.maproulette.data.Task in project atlas-checks by osmlab.
the class MapRouletteClient method upload.
private void upload(final Tuple<String, String> key) {
final Set<Task> batchList = this.batch.get(key);
if (batchList != null && batchList.size() > 0) {
try {
// retrieve the already created project and challenge
final Project project = this.projects.get(key.getFirst());
if (project == null) {
logger.warn("Failed to upload batch to MapRoulette, Project {} has not been created.", key.getFirst());
} else {
final Challenge challenge = this.challenges.get(project.getId()).get(key.getSecond());
if (challenge == null) {
logger.warn("Failed to upload batch to MapRoulette, Challenge {} has not been created.", key.getSecond());
} else {
this.connection.uploadBatchTasks(challenge.getId(), batchList);
batchList.clear();
}
}
} catch (final UnsupportedEncodingException e) {
logger.debug("Failed to upload batch to map roulette [{}]", this.connection.getConnectionInfo());
} catch (final URISyntaxException e) {
logger.debug("Failed to upload batch to map roulette", e);
}
}
}
use of org.openstreetmap.atlas.checks.maproulette.data.Task in project atlas-checks by osmlab.
the class CheckFlag method getMapRouletteTask.
/**
* Builds a MapRouletted {@link Task} from this {@link CheckFlag}
*
* @return a {@link Task}
*/
public Task getMapRouletteTask() {
final Task task = new Task();
task.setInstruction(this.getInstructions());
task.setProjectName(this.getCountryISO());
task.setChallengeName(this.getChallengeName().orElse(this.getClass().getSimpleName()));
task.setTaskIdentifier(this.identifier);
// Add custom pin point(s), if supplied.
final Set<Location> points = getPoints();
if (!points.isEmpty()) {
task.setPoints(points);
} else {
final Set<PolyLine> polyLines = getPolyLines();
if (!polyLines.isEmpty()) {
// Retrieve the first item in the list and retrieve the first point in the
// geometry for the object
task.setPoint(polyLines.iterator().next().iterator().next());
}
}
final JsonArray features = new JsonArray();
this.getLocationIterableProperties().forEach(shape -> features.add(new GeoJsonBuilder().create(shape)));
task.setGeoJson(Optional.of(features));
return task;
}
Aggregations