Skip to content

k-yle/osm-conditional-restrictions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

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