Class InputProcessor

  • public class InputProcessor
    extends Object
    Holds general input processing and validation methods and validates specific parameters given by the request. Uses geometry methods from GeometryBuilder and inputProcessingUtils from InputProcessingUtils. Throws exceptions depending on their validity.
    • Field Detail

    • Constructor Detail

      • InputProcessor

        public InputProcessor​(ProcessingData processingData)
      • InputProcessor

        public InputProcessor​(javax.servlet.http.HttpServletRequest servletRequest,
                              boolean isSnapshot,
                              boolean isDensity)
    • Method Detail

      • processParameters

        public <T extends org.heigit.ohsome.oshdb.util.mappable.OSHDBMapReducible> org.heigit.ohsome.oshdb.api.mapreducer.MapReducer<T> processParameters​(org.heigit.ohsome.oshdb.api.db.OSHDBIgnite.ComputeMode forceComputeMode)
                                                                                                                                                   throws Exception
        Processes the input parameters from the given request.
        MapReducer object including the settings derived from the given parameters.
        BadRequestException - if the boundary parameter is not defined or it has an invalid format, if the geometry of given boundary cannot be parsed for the creation of the response GeoJSON or if the keys, values and types parameters are not empty, while the filter parameter is set.
        Exception - thrown by #extractTime(MapReducer, String[], boolean) extractTime
      • defineTypes

        public <T extends org.heigit.ohsome.oshdb.util.mappable.OSHDBMapReducible> org.heigit.ohsome.oshdb.api.mapreducer.MapReducer<T> defineTypes​(String[] types,
                                                                                                                                                    org.heigit.ohsome.oshdb.api.mapreducer.MapReducer<T> mapRed)
        Defines the type(s) out of the given String[].
        types - String array containing one, two, or all 3 OSM types (node, way, relation), or simple feature types (point, line, polygon, other). If the array is empty, all three OSM types are used.
      • defineSimpleFeatureTypes

        public EnumSet<SimpleFeatureType> defineSimpleFeatureTypes​(String[] types)
        Defines the simple feature types and corresponding OSM types out of the given String array.
      • splitParamOnComma

        public String[] splitParamOnComma​(String[] param)
        Splits the given input parameter on ',' if it has a length of 1 and contains ',' at [0]. Returns a String array containing the splits.
        param - String array containing the content to split
        String array containing the splitted parameter content
      • createEmptyArrayIfNull

        public String[] createEmptyArrayIfNull​(String[] toCheck)
        Creates an empty array if an input parameter of a POST request is null.
        toCheck - String array, which is checked.
        String array, which is empty.
      • createEmptyStringIfNull

        public String createEmptyStringIfNull​(String toCheck)
        Creates an empty String, if a given input parameter is null.
        toCheck - String, which is checked.
        String, which may be empty but not null.
      • checkKeysValues

        public void checkKeysValues​(String[] keys,
                                    String[] values)
        Checks the given keys and values String[] on their length.
        BadRequestException - if values_n doesn't fit to keys_n. There cannot be more input values in the values|values2 than in the keys|keys2 parameter.
      • compareKeysValues

        public boolean compareKeysValues​(String[] keys,
                                         String[] keys2,
                                         String[] values,
                                         String[] values2)
        Compares the keys and values arrays with each other. Returns true only if keys=keys2 and values=values2.
      • processKeys2Vals2

        public org.apache.commons.lang3.tuple.Pair<String[],​String[]> processKeys2Vals2​(String[] keys2,
                                                                                              String[] values2)
        Used in /ratio requests.
      • processPropertiesParam

        public void processPropertiesParam()
        Processes the properties parameter used in data-extraction resources and sets the respective boolean values includeTags, includeOSMMetadata, unclippedGeometries, and includeContributionTypes (only for the /contributions endpoints).
        BadRequestException - if the properties parameter contains invalid values
      • processIsUnclippedParam

        public void processIsUnclippedParam()
        Processes the clipGeometry parameter used in data-extraction resources and sets the respective boolean value 'clipGeometry'. Note: this method is called after processPropertiesParam() so it could overwrite the previously defined value of 'clipGeometry'.
      • getRequestUrlIfGetRequest

        public String getRequestUrlIfGetRequest​(javax.servlet.http.HttpServletRequest servletRequest)
        Returns the request URL if a GET request was sent.
      • filterOnSimpleFeatures

        public <T extends org.heigit.ohsome.oshdb.api.mapreducer.Mappable<? extends org.heigit.ohsome.oshdb.util.mappable.OSHDBMapReducible>> T filterOnSimpleFeatures​(T mapRed)
        Applies respective Puntal|Lineal|Polygonal filter(s) on features of the given MapReducer.
        MapReducer with filtered geometries
        RuntimeException - if #filterOnSimpleFeatures(Mappable) filterOnSimpleFeatures was called on mapped entries
      • checkFilter

        public void checkFilter​(String filter)
        Checks the given filter parameter if it's null or blank. Currently used for filter2 parameter of /ratio processing.
        filter - parameter to be checked
        BadRequestException - if the given filter parameter is null or blank.
      • getGeometry

        public org.locationtech.jts.geom.Geometry getGeometry()
        Gets the geometry from the currently in-use boundary object(s).
        Geometry object of the used boundary parameter.
      • setProcessingData

        public void setProcessingData​(ProcessingData processingData)
      • getRequestUrl

        public String getRequestUrl()
      • includeTags

        public boolean includeTags()
      • includeOSMMetadata

        public boolean includeOSMMetadata()
      • includeContributionTypes

        public boolean includeContributionTypes()
      • isClipGeometry

        public boolean isClipGeometry()