Class 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.FlexibleSubCommand
    An 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 Concrete Methods 
      Modifier and Type Method Description
      int execute​(org.openstreetmap.atlas.utilities.runtime.CommandMap command)  
      java.lang.String getDescription()  
      protected JSONFlagDiffSubCommand.JSONFlagDiff getDiff​(java.util.HashMap source, java.util.HashMap target, JSONFlagDiffSubCommand.DiffReturn returnType)
      Takes two HashMaps containing atlas-checks flags mapped by id.
      protected com.google.gson.Gson getGson()
      Getter for gson
      java.lang.String getName()  
      protected java.util.HashMap getSource()
      Getter for source
      protected int getSourceSize()
      A getter for the number of flags in source
      protected java.util.HashMap getTarget()
      Getter for target
      protected boolean identicalFeatureIds​(com.google.gson.JsonArray sourceArray, com.google.gson.JsonArray targetArray)
      Helper function for getMissingAndChanged to check for changes in Atlas ids.
      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.
      org.openstreetmap.atlas.utilities.runtime.Command.SwitchList switches()  
      void usage​(java.io.PrintStream writer)  
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JSONFlagDiffSubCommand

        public JSONFlagDiffSubCommand​(java.lang.String name,
                                      java.lang.String description,
                                      java.lang.String fileExtension)
    • Method Detail

      • getName

        public java.lang.String getName()
        Specified by:
        getName in interface org.openstreetmap.atlas.utilities.runtime.FlexibleSubCommand
      • getDescription

        public java.lang.String getDescription()
        Specified by:
        getDescription in interface org.openstreetmap.atlas.utilities.runtime.FlexibleSubCommand
      • switches

        public org.openstreetmap.atlas.utilities.runtime.Command.SwitchList switches()
        Specified by:
        switches in interface org.openstreetmap.atlas.utilities.runtime.FlexibleSubCommand
      • usage

        public void usage​(java.io.PrintStream writer)
        Specified by:
        usage in interface org.openstreetmap.atlas.utilities.runtime.FlexibleSubCommand
      • execute

        public int execute​(org.openstreetmap.atlas.utilities.runtime.CommandMap command)
        Specified by:
        execute in interface org.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 - File containing the flags
        map - HashMap to store the mapped flags
      • identicalFeatureIds

        protected boolean identicalFeatureIds​(com.google.gson.JsonArray sourceArray,
                                              com.google.gson.JsonArray targetArray)
        Helper function for getMissingAndChanged to check for changes in Atlas ids.
        Parameters:
        sourceArray - feature JsonArray to check from
        targetArray - feature JsonArray to check to
        Returns:
        true if all Atlas ids in source are present in target, 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 - Set of JsonObjects representing geoJSON flags
        output - File to output to
      • getSourceSize

        protected int getSourceSize()
        A getter for the number of flags in source
        Returns:
        int
      • getGson

        protected com.google.gson.Gson getGson()
        Getter for gson
        Returns:
        Gson
      • getSource

        protected java.util.HashMap getSource()
        Getter for source
        Returns:
        HashMap
      • getTarget

        protected java.util.HashMap getTarget()
        Getter for target
        Returns:
        HashMap