Class InputProcessingUtils

    • Constructor Detail

      • InputProcessingUtils

        public InputProcessingUtils()
    • Method Detail

      • findEpsg

        public String findEpsg​(double lon,
                               double lat)
        Finds and returns the EPSG code of the given point, which is needed for createCircularPolygons.

        Adapted code from UTMCodeFromLonLat.java class in the osmatrix project (© by Michael Auer)

        Parameters:
        lon - Longitude coordinate of the point.
        lat - Latitude coordinate of the point.
        Returns:
        String representing the corresponding EPSG code.
      • splitBboxes

        public List<String> splitBboxes​(String bboxes)
        Splits the given bounding boxes and returns them in a List.
        Parameters:
        bboxes - contains the given bounding boxes
        Returns:
        List containing the splitted bounding boxes
        Throws:
        BadRequestException - if the bboxes parameter has an invalid format
      • splitBcircles

        public List<String> splitBcircles​(String bcircles)
        Splits the given bounding circles and returns them in a List.
        Parameters:
        bcircles - contains the given bounding circles
        Returns:
        List containing the splitted bounding circles
        Throws:
        BadRequestException - if the bcircles parameter has an invalid format
      • splitBpolys

        public List<String> splitBpolys​(String bpolys)
        Splits the given bounding polygons and returns them in a List.
        Parameters:
        bpolys - contains the given bounding polygons
        Returns:
        List containing the splitted bounding polygons
        Throws:
        BadRequestException - if the bpolys parameter has an invalid format
      • defineToTimestamps

        public String[] defineToTimestamps​(String[] timeData)
        Defines the toTimestamps for the result json object for /users responses.
        Parameters:
        timeData - contains the requested time
        Returns:
        array having only the toTimestamps
      • extractIsoTime

        public String[] extractIsoTime​(String time)
        Extracts the time information out of the time parameter and checks the content on its format, as well as ISO-8601 conformity. This method is used if one datetimestring is given. Following time formats are allowed:
        • YYYY-MM-DD or YYYY-MM-DDThh:mm:ss: When a timestamp includes 'T', hh:mm must also be given. This applies for all time formats, which use timestamps. If -MM-DD or only -DD is missing, '01' is used as default for month and day.
        • YYYY-MM-DD/YYYY-MM-DD: start/end timestamps
        • YYYY-MM-DD/YYYY-MM-DD/PnYnMnD: start/end/period where n refers to the size of the respective period
        • /YYYY-MM-DD: #/end where # equals the earliest timestamp
        • /YYYY-MM-DD/PnYnMnD: #/end/period
        • YYYY-MM-DD/: start/# where # equals the latest timestamp
        • YYYY-MM-DD//PnYnMnD: start/#/period
        • /: #/# where # equals the earliest and latest timestamp
        • //PnYnMnD: #/#/period
        • invalid: throws BadRequestException

        For clarification: the format YYYY-MM-DDThh:mm:ss can be applied to any format, where a timestamp is used and # is a replacement holder for "no value". Note that the positioning and using of the forward slash '/' is very important.

        Parameters:
        time - String holding the unparsed time information.
        Returns:
        String array containing the startTime at [0], the endTime at [1] and the period at [2].
        Throws:
        BadRequestException - if the given time parameter is not ISO-8601 conform
      • sortTimestamps

        public String[] sortTimestamps​(String[] timestamps)
        Sorts the given timestamps from oldest to newest.
        Throws:
        BadRequestException - if the given time parameter is not ISO-8601 conform
      • checkCustomBoundaryId

        public void checkCustomBoundaryId​(String id)
        Checks the given custom boundary id. At the moment only used if output format = csv.
        Throws:
        BadRequestException - if the custom ids contain semicolons
      • isWithin

        public boolean isWithin​(org.locationtech.jts.geom.Geometry geom)
        Checks if the given geometry is within the underlying data-polygon. Returns also true if no data-polygon is given.
        Parameters:
        geom - Geometry, which is tested against the data-polygon
        Returns:
        true - if inside
        false - if not inside
      • isSimpleFeatureType

        public boolean isSimpleFeatureType​(String type)
        Checks if the given String is one of the simple feature types (point, line, polygon).
      • filterOnPlanarRelations

        public <T extends org.heigit.ohsome.oshdb.util.mappable.OSHDBMapReducible> org.heigit.ohsome.oshdb.api.mapreducer.MapReducer<T> filterOnPlanarRelations​(org.heigit.ohsome.oshdb.api.mapreducer.MapReducer<T> mapRed)
        Applies an entity filter using only planar relations (relations with an area) on the given MapReducer object. It uses the tags "type=multipolygon" and "type=boundary".
      • checkGeometryOnSimpleFeatures

        public boolean checkGeometryOnSimpleFeatures​(org.locationtech.jts.geom.Geometry geom,
                                                     Set<SimpleFeatureType> simpleFeatureTypes)
        Checks whether a geometry is of given feature type (Puntal|Lineal|Polygonal).
        Parameters:
        simpleFeatureTypes - a set of feature types
        Returns:
        true if the geometry matches the given simpleFeatureTypes, otherwise false
      • parseFilter

        public org.heigit.ohsome.oshdb.filter.FilterExpression parseFilter​(org.heigit.ohsome.oshdb.filter.FilterParser fp,
                                                                           String filter)
        Tries to parse the given filter using the given parser.
        Throws:
        BadRequestException - if the filter contains wrong syntax.
      • checkTemporalExtend

        protected void checkTemporalExtend​(String... timeInfo)
        Checks the provided time info on its temporal extent.
        Parameters:
        timeInfo - time information to check
        Throws:
        NotFoundException - if the given time is not completely within the timerange of the underlying data
        BadRequestException - if the timestamps are not ISO-8601 conform
        RuntimeException - if the Date or DateTime Format are not supported
      • checkTimestampsOnIsoConformity

        protected void checkTimestampsOnIsoConformity​(String... timeInfo)
        Checks the provided time info on its ISO conformity.
        Parameters:
        timeInfo - time information to check
        Throws:
        BadRequestException - if the timestamps are not ISO-8601 conform.
      • checkPeriodOnIsoConformity

        protected void checkPeriodOnIsoConformity​(String period)
        Checks the provided period on its ISO conformity.
        Throws:
        BadRequestException - if the interval is not ISO-8601 conform.
      • getBoundaryIds

        public Object[] getBoundaryIds()
      • getToTimestamps

        public String[] getToTimestamps()
      • setBoundaryIds

        public void setBoundaryIds​(Serializable[] boundaryIds)
      • setToTimestamps

        public void setToTimestamps​(String[] toTimestamps)