Skip to content

Latest commit

 

History

History
54 lines (42 loc) · 1.93 KB

README.md

File metadata and controls

54 lines (42 loc) · 1.93 KB

OpenStreetMap conditional restriction parser

Build Status Coverage Status npm version npm npm bundle size

📅🔒 Javascript/Typescript parser for OpenStreetMap conditional restrictions.

Install

npm install osm-conditional-restrictions

Usage

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, check out the opening_hours library.

Related Work