0.0.0 ā€¢ Published 8 months ago

osm-conditional-restrictions v0.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

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