use of org.openstreetmap.atlas.geography.geojson.GeoJsonBuilder in project atlas-checks by osmlab.
the class FlagVisualizer method visualize.
/**
* Converts a list of {@link CheckFlag}s to GeoJson
*
* @param flags
* a list of {@link CheckFlag}s
* @return a {@link GeoJsonObject} representation
*/
public GeoJsonObject visualize(final Iterable<CheckFlag> flags) {
final GeoJsonBuilder result = new GeoJsonBuilder();
final List<GeoJsonBuilder.LocationIterableProperties> shapes = new ArrayList<>();
flags.forEach(flag -> {
shapes.addAll(flag.getLocationIterableProperties());
});
return result.create(shapes);
}
use of org.openstreetmap.atlas.geography.geojson.GeoJsonBuilder 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