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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classJSONFlagDiffSubCommand.DiffReturnExpected returns fromgetDiff(HashMap, HashMap, DiffReturn).protected classJSONFlagDiffSubCommand.JSONFlagDiffHelper class for storing diff results.
-
Constructor Summary
Constructors Constructor Description JSONFlagDiffSubCommand(java.lang.String name, java.lang.String description, java.lang.String fileExtension)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intexecute(org.openstreetmap.atlas.utilities.runtime.CommandMap command)java.lang.StringgetDescription()protected JSONFlagDiffSubCommand.JSONFlagDiffgetDiff(java.util.HashMap source, java.util.HashMap target, JSONFlagDiffSubCommand.DiffReturn returnType)Takes twoHashMaps containing atlas-checks flags mapped by id.protected com.google.gson.GsongetGson()Getter forgsonjava.lang.StringgetName()protected java.util.HashMapgetSource()Getter forsourceprotected intgetSourceSize()A getter for the number of flags insourceprotected java.util.HashMapgetTarget()Getter fortargetprotected booleanidenticalFeatureIds(com.google.gson.JsonArray sourceArray, com.google.gson.JsonArray targetArray)Helper function forgetMissingAndChangedto check for changes in Atlas ids.protected voidmapFeatures(org.openstreetmap.atlas.streaming.resource.File file, java.util.HashMap map)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.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 void mapFeatures(org.openstreetmap.atlas.streaming.resource.File file, java.util.HashMap map)Parses an atlas-checks flag file and maps each flag to its id.- Parameters:
file-Filecontaining the flagsmap-HashMapto store the mapped flags
-
getDiff
protected JSONFlagDiffSubCommand.JSONFlagDiff getDiff(java.util.HashMap source, java.util.HashMap target, JSONFlagDiffSubCommand.DiffReturn returnType)
Takes twoHashMaps containing atlas-checks flags mapped by id. Finds missing elements in the target based on keys. Optionally computes changes in the AtlasObject ids found in each flag.- Parameters:
source-HashMapof the flags to compare fromtarget-HashMapof the flags to compare toreturnType-JSONFlagDiffSubCommand.DiffReturn; If this isCHANGEDthechangedattribute of the returnedJSONFlagDiffSubCommand.JSONFlagDiffwill be populated.- Returns:
- an
JSONFlagDiffSubCommand.JSONFlagDiff
-
identicalFeatureIds
protected boolean identicalFeatureIds(com.google.gson.JsonArray sourceArray, com.google.gson.JsonArray targetArray)Helper function forgetMissingAndChangedto check for changes in Atlas ids.- Parameters:
sourceArray-featureJsonArrayto check fromtargetArray-featureJsonArrayto check to- Returns:
- true if all Atlas ids in
sourceare present intarget, and visa versa
-
writeSetToGeoJSON
protected void writeSetToGeoJSON(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
-
getSourceSize
protected int getSourceSize()
A getter for the number of flags insource- Returns:
int
-
getGson
protected com.google.gson.Gson getGson()
Getter forgson- Returns:
Gson
-
getSource
protected java.util.HashMap getSource()
Getter forsource- Returns:
HashMap
-
getTarget
protected java.util.HashMap getTarget()
Getter fortarget- Returns:
HashMap
-
-