forked from osmlab/atlas-checks
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WaterWayCheck: Add autofix suggestion (geometry) (osmlab#477)
* MapRoulette: Allow upload of OSC to MapRoulette Signed-off-by: Taylor Smock <[email protected]> * WaterWayCheck: Add autofix suggestion (geometry) Signed-off-by: Taylor Smock <[email protected]>
- Loading branch information
Showing
14 changed files
with
584 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...treetmap/atlas/checks/maproulette/data/cooperative_challenge/GeometryChangeOperation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package org.openstreetmap.atlas.checks.maproulette.data.cooperative_challenge; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.function.Predicate; | ||
|
||
import org.openstreetmap.atlas.geography.atlas.change.description.ChangeDescription; | ||
import org.openstreetmap.atlas.geography.atlas.change.description.descriptors.ChangeDescriptor; | ||
import org.openstreetmap.atlas.geography.atlas.change.description.descriptors.ChangeDescriptorName; | ||
|
||
import com.google.gson.JsonObject; | ||
import com.google.gson.JsonPrimitive; | ||
|
||
/** | ||
* Support geometry change operations | ||
* | ||
* @author Taylor Smock | ||
*/ | ||
public class GeometryChangeOperation extends CooperativeChallengeOperation | ||
{ | ||
private static final String CONTENT = "content"; | ||
private static final Map<String, String> FILE_MAP = new HashMap<>(3); | ||
static | ||
{ | ||
FILE_MAP.put("type", "xml"); | ||
FILE_MAP.put("format", "osc"); | ||
FILE_MAP.put("encoding", "base64"); | ||
} | ||
|
||
/** The OSC for the geometry change */ | ||
private final String osc; | ||
|
||
public GeometryChangeOperation(final ChangeDescription changeDescription) | ||
{ | ||
super(changeDescription); | ||
final var optionalOsc = changeDescription.getOsc(); | ||
if (optionalOsc.isPresent()) | ||
{ | ||
this.osc = optionalOsc.get(); | ||
} | ||
else if (changeDescription.toJsonElement().getAsJsonObject().has("osc")) | ||
{ | ||
this.osc = changeDescription.toJsonElement().getAsJsonObject().get("osc").getAsString(); | ||
} | ||
else | ||
{ | ||
this.osc = null; | ||
} | ||
} | ||
|
||
@Override | ||
public GeometryChangeOperation create() | ||
{ | ||
final var json = new JsonObject(); | ||
if (this.osc != null && !this.osc.isBlank()) | ||
{ | ||
FILE_MAP.forEach((key, value) -> json.add(key, new JsonPrimitive(value))); | ||
json.add(CONTENT, new JsonPrimitive(this.osc)); | ||
} | ||
this.setJson(json); | ||
return this; | ||
} | ||
|
||
@Override | ||
protected Predicate<ChangeDescriptor> operationFilter() | ||
{ | ||
return changeDescriptor -> changeDescriptor.getName() == ChangeDescriptorName.GEOMETRY; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.