Search in sources :

Example 1 with GeoJsonBuilder

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);
}
Also used : ArrayList(java.util.ArrayList) GeoJsonBuilder(org.openstreetmap.atlas.geography.geojson.GeoJsonBuilder)

Example 2 with GeoJsonBuilder

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;
}
Also used : JsonArray(com.google.gson.JsonArray) Task(org.openstreetmap.atlas.checks.maproulette.data.Task) PolyLine(org.openstreetmap.atlas.geography.PolyLine) GeoJsonBuilder(org.openstreetmap.atlas.geography.geojson.GeoJsonBuilder) Location(org.openstreetmap.atlas.geography.Location)

Aggregations

GeoJsonBuilder (org.openstreetmap.atlas.geography.geojson.GeoJsonBuilder)2 JsonArray (com.google.gson.JsonArray)1 ArrayList (java.util.ArrayList)1 Task (org.openstreetmap.atlas.checks.maproulette.data.Task)1 Location (org.openstreetmap.atlas.geography.Location)1 PolyLine (org.openstreetmap.atlas.geography.PolyLine)1