Class InputProcessingUtils
java.lang.Object
org.heigit.ohsome.ohsomeapi.inputprocessing.InputProcessingUtils
- All Implemented Interfaces:
Serializable
Holds utility methods that are used by the input processing and executor classes.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Checks the given custom boundary id.boolean
checkGeometryOnSimpleFeatures
(org.locationtech.jts.geom.Geometry geom, Set<SimpleFeatureType> simpleFeatureTypes) Checks whether a geometry is of given feature type (Puntal|Lineal|Polygonal).protected void
checkPeriodOnIsoConformity
(String period) Checks the provided period on its ISO conformity.protected void
checkTemporalExtend
(String... timeInfo) Checks the provided time info on its temporal extent.protected void
checkTimestampsOnIsoConformity
(String... timeInfo) Checks the provided time info on its ISO conformity.String[]
defineToTimestamps
(String[] timeData) Defines the toTimestamps for the result json object for /users responses.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.<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.static boolean
filterSuitableForSnapshots
(org.heigit.ohsome.oshdb.filter.FilterExpression filter) Returns whether a given filter is suitable for snapshots based endpoints.findEpsg
(double lon, double lat) Finds and returns the EPSG code of the given point, which is needed forcreateCircularPolygons
.Object[]
String[]
boolean
isSimpleFeatureType
(String type) Checks if the given String is one of the simple feature types (point, line, polygon).boolean
isWithin
(org.locationtech.jts.geom.Geometry geom) Checks if the given geometry is within the underlying data-polygon.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.void
setBoundaryIds
(Serializable[] boundaryIds) void
setToTimestamps
(String[] toTimestamps) String[]
sortTimestamps
(String[] timestamps) Sorts the given timestamps from oldest to newest.splitBboxes
(String bboxes) Splits the given bounding boxes and returns them in aList
.splitBcircles
(String bcircles) Splits the given bounding circles and returns them in aList
.splitBpolys
(String bpolys) Splits the given bounding polygons and returns them in aList
.
-
Constructor Details
-
InputProcessingUtils
public InputProcessingUtils()
-
-
Method Details
-
findEpsg
Finds and returns the EPSG code of the given point, which is needed forcreateCircularPolygons
.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
Splits the given bounding boxes and returns them in aList
.- 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
Splits the given bounding circles and returns them in aList
.- 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
Splits the given bounding polygons and returns them in aList
.- 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
Defines the toTimestamps for the result json object for /users responses.- Parameters:
timeData
- contains the requested time- Returns:
- array having only the toTimestamps
-
extractIsoTime
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
Sorts the given timestamps from oldest to newest.- Throws:
BadRequestException
- if the given time parameter is not ISO-8601 conform
-
checkCustomBoundaryId
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
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.
-
filterSuitableForSnapshots
public static boolean filterSuitableForSnapshots(org.heigit.ohsome.oshdb.filter.FilterExpression filter) Returns whether a given filter is suitable for snapshots based endpoints.For example, `changeset:*` filter can only be used on contribution based endpoints, see also #289.
-
checkTemporalExtend
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 dataBadRequestException
- if the timestamps are not ISO-8601 conformRuntimeException
- if the Date or DateTime Format are not supported
-
checkTimestampsOnIsoConformity
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
Checks the provided period on its ISO conformity.- Throws:
BadRequestException
- if the interval is not ISO-8601 conform.
-
getBoundaryIds
-
getToTimestamps
-
setBoundaryIds
-
setToTimestamps
-