Class JSONFlagDiffSubCommand
- java.lang.Object
-
- org.openstreetmap.atlas.checks.commands.JSONFlagDiffSubCommand
-
- All Implemented Interfaces:
org.openstreetmap.atlas.utilities.runtime.FlexibleSubCommand
- Direct Known Subclasses:
AtlasChecksGeoJSONDiffSubCommand,AtlasChecksLogDiffSubCommand
public abstract class JSONFlagDiffSubCommand extends java.lang.Object implements org.openstreetmap.atlas.utilities.runtime.FlexibleSubCommandAn abstract sub-command for creating json and flag based diffing commands.
-
-
Constructor Summary
Constructors Constructor Description JSONFlagDiffSubCommand(java.lang.String name, java.lang.String description, java.lang.String fileExtension)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description intexecute(org.openstreetmap.atlas.utilities.runtime.CommandMap command)java.lang.StringgetDescription()protected java.util.Map<java.lang.String,java.util.Set<com.google.gson.JsonObject>>getDiff(java.util.Map<java.lang.String,java.util.Map<java.util.Set<java.lang.String>,com.google.gson.JsonObject>> reference, java.util.Map<java.lang.String,java.util.Map<java.util.Set<java.lang.String>,com.google.gson.JsonObject>> input)Takes two 2dHashMaps containing atlas-checks flags mapped by id mapped by check.protected com.google.gson.GsongetGson()Getter forgsonprotected java.util.Map<java.lang.String,java.util.Map<java.util.Set<java.lang.String>,com.google.gson.JsonObject>>getInput()Getter forinputjava.lang.StringgetName()protected java.util.Map<java.lang.String,java.util.Map<java.util.Set<java.lang.String>,com.google.gson.JsonObject>>getReference()Getter forreferenceprotected intgetReferenceSize()A getter for the number of flags inreferenceprotected abstract java.util.Map<java.lang.String,java.util.Map<java.util.Set<java.lang.String>,com.google.gson.JsonObject>>mapFeatures(org.openstreetmap.atlas.streaming.resource.File file)Parses an atlas-checks flag file and maps each flag to its id.org.openstreetmap.atlas.utilities.runtime.Command.SwitchListswitches()voidusage(java.io.PrintStream writer)protected voidwriteSetToGeoJSON(java.util.Map<java.lang.String,java.util.Set<com.google.gson.JsonObject>> flags, org.openstreetmap.atlas.streaming.resource.File output)Writes a Set of geoJSON atlas-checks flags to a file.
-
-
-
Method Detail
-
getName
public java.lang.String getName()
- Specified by:
getNamein interfaceorg.openstreetmap.atlas.utilities.runtime.FlexibleSubCommand
-
getDescription
public java.lang.String getDescription()
- Specified by:
getDescriptionin interfaceorg.openstreetmap.atlas.utilities.runtime.FlexibleSubCommand
-
switches
public org.openstreetmap.atlas.utilities.runtime.Command.SwitchList switches()
- Specified by:
switchesin interfaceorg.openstreetmap.atlas.utilities.runtime.FlexibleSubCommand
-
usage
public void usage(java.io.PrintStream writer)
- Specified by:
usagein interfaceorg.openstreetmap.atlas.utilities.runtime.FlexibleSubCommand
-
execute
public int execute(org.openstreetmap.atlas.utilities.runtime.CommandMap command)
- Specified by:
executein interfaceorg.openstreetmap.atlas.utilities.runtime.FlexibleSubCommand
-
mapFeatures
protected abstract java.util.Map<java.lang.String,java.util.Map<java.util.Set<java.lang.String>,com.google.gson.JsonObject>> mapFeatures(org.openstreetmap.atlas.streaming.resource.File file)
Parses an atlas-checks flag file and maps each flag to its id.- Parameters:
file-Filecontaining the flags- Returns:
- a 2d
HashMapcontaining aHashMapofJsonObjects mapped toStringfeature ids, mapped toStringcheck names.
-
getDiff
protected java.util.Map<java.lang.String,java.util.Set<com.google.gson.JsonObject>> getDiff(java.util.Map<java.lang.String,java.util.Map<java.util.Set<java.lang.String>,com.google.gson.JsonObject>> reference, java.util.Map<java.lang.String,java.util.Map<java.util.Set<java.lang.String>,com.google.gson.JsonObject>> input)Takes two 2dHashMaps containing atlas-checks flags mapped by id mapped by check. Finds missing elements in the input based on ids.- Parameters:
reference-HashMapof the flags to compare frominput-HashMapof the flags to compare to- Returns:
- a
MapofJsonObjectby check
-
writeSetToGeoJSON
protected void writeSetToGeoJSON(java.util.Map<java.lang.String,java.util.Set<com.google.gson.JsonObject>> flags, org.openstreetmap.atlas.streaming.resource.File output)Writes a Set of geoJSON atlas-checks flags to a file.- Parameters:
flags-SetofJsonObjects representing geoJSON flagsoutput-Fileto output to
-
getReferenceSize
protected int getReferenceSize()
A getter for the number of flags inreference- Returns:
int
-
getGson
protected com.google.gson.Gson getGson()
Getter forgson- Returns:
Gson
-
getReference
protected java.util.Map<java.lang.String,java.util.Map<java.util.Set<java.lang.String>,com.google.gson.JsonObject>> getReference()
Getter forreference- Returns:
HashMap
-
getInput
protected java.util.Map<java.lang.String,java.util.Map<java.util.Set<java.lang.String>,com.google.gson.JsonObject>> getInput()
Getter forinput- Returns:
HashMap
-
-