https://github.com/simonpoole/conditionalrestrictionparser
Simplistic parser for OSM conditional restriction tags
https://github.com/simonpoole/conditionalrestrictionparser
openstreetmap
Last synced: 3 months ago
JSON representation
Simplistic parser for OSM conditional restriction tags
- Host: GitHub
- URL: https://github.com/simonpoole/conditionalrestrictionparser
- Owner: simonpoole
- License: mit
- Created: 2016-07-03T07:59:31.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2023-12-06T10:45:16.000Z (over 1 year ago)
- Last Synced: 2025-03-30T08:51:16.425Z (4 months ago)
- Topics: openstreetmap
- Language: Java
- Size: 280 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://github.com/simonpoole/ConditionalRestrictionParser/actions) [](https://sonarcloud.io/dashboard?id=ConditionalRestrictionParser) [](https://sonarcloud.io/dashboard?id=ConditionalRestrictionParser) [](https://sonarcloud.io/component_measures?id=ConditionalRestrictionParser&metric=bugs) [](https://sonarcloud.io/component_measures?id=ConditionalRestrictionParser&metric=Maintainability) [](https://sonarcloud.io/component_measures?id=ConditionalRestrictionParser&metric=Security) [](https://sonarcloud.io/component_measures?id=ConditionalRestrictionParser&metric=Reliability)
# ConditionalRestrictionParserThis is a very simplistic parser for string values according to the OSM conditional restriction "specification" see http://wiki.openstreetmap.org/wiki/Conditional_restrictions
As there is no grammar provided and a lot of the specification is extremely hand wavy, this is simply a best guess. If a condition can be parsed as a string according to the opening hours specification the corresponding flag in the Condition object will be set, if it is a numeric comparison expression both terms and the operation will be returned.
Running a valid (not so clear what that is, see above) conditional restriction through the parser and producing a string from the results will result in some normalization:
* nested parentheses are removed and expanded to encompasses all conditions in one restriction
* "and" is capitalized## Usage
try
{
ConditionalRestrictionParser parser = new ConditionalRestrictionParser(new ByteArrayInputStream(line.getBytes()));
List list = parser.restrictions();
...
} catch ...## Including in your project
You can either download the jar from github or add the following to your build.gradle
...
repositories {
...
mavenCentral()
...
}
...
dependencies {
...
compile 'ch.poole:ConditionalRestrictionParser:0.3.4'
...
}