https://github.com/k-yle/osm-conditional-restrictions
📅🔒 Parser for OpenStreetMap conditional restrictions
https://github.com/k-yle/osm-conditional-restrictions
conditional openstreetmap osm restrictions
Last synced: 7 months ago
JSON representation
📅🔒 Parser for OpenStreetMap conditional restrictions
- Host: GitHub
- URL: https://github.com/k-yle/osm-conditional-restrictions
- Owner: k-yle
- License: mit
- Created: 2023-09-14T05:45:17.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-09T10:28:06.000Z (about 2 years ago)
- Last Synced: 2025-02-01T20:02:08.459Z (over 1 year ago)
- Topics: conditional, openstreetmap, osm, restrictions
- Language: TypeScript
- Homepage: https://kyle.kiwi/osm-conditional-restrictions
- Size: 2.04 MB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# OpenStreetMap conditional restriction parser
[](https://github.com/k-yle/osm-conditional-restrictions/actions)
[](https://coveralls.io/github/k-yle/osm-conditional-restrictions?branch=main)
[](https://badge.fury.io/js/osm-conditional-restrictions)
[](https://www.npmjs.com/package/osm-conditional-restrictions)

📅🔒 Javascript/Typescript parser for OpenStreetMap [conditional restrictions](https://osm.wiki/Conditional_restrictions).
## Install
```sh
npm install osm-conditional-restrictions
```
## Usage
```js
import { parseConditionalRestrictions } from 'osm-conditional-restrictions';
const tags = {
access: 'no',
'access:conditional': 'yes @ (09:00-17:00 ; weight < 3.5)',
};
const output = parseConditionalRestrictions('access', tags);
// `output` will be an object that looks like this:
({
default: 'no',
exceptions: [
{
value: 'yes',
if: {
type: 'LogicalOperator',
operator: 'OR',
children: [
{ type: 'Condition', string: '09:00-17:00' },
{ type: 'Condition', string: 'weight < 3.5' },
],
},
},
],
});
```
## Scope
This library doesn't try to parse the conditional values, such as `09:00-17:00`.
To parse the [opening hours syntax](https://osm.wiki/Key:opening_hours), check out the [opening_hours](https://npm.im/opening_hours) library.
## Related Work
- [simonpoole/ConditionalRestrictionParser](https://github.com/simonpoole/ConditionalRestrictionParser) - An equivalent library written in Java