osm-conditional-restrictions
TypeScript icon, indicating that this package has built-in type declarations

0.0.0Β β€’Β PublicΒ β€’Β Published

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 AND 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

Package Sidebar

Install

npm i osm-conditional-restrictions

Weekly Downloads

4

Version

0.0.0

License

MIT

Unpacked Size

17.6 kB

Total Files

11

Last publish

Collaborators

  • kyle.h