π π Javascript/Typescript parser for OpenStreetMap conditional restrictions.
npm install osm-conditional-restrictions
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' },
],
},
},
],
});
This library doesn't try to parse the conditional values, such as 09:00-17:00
.
To parse the opening hours syntax, check out the opening_hours library.
- simonpoole/ConditionalRestrictionParser - An equivalent library written in Java