Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/k-yle/osm-conditional-restrictions
📅🔒 Parser for OpenStreetMap conditional restrictions
https://github.com/k-yle/osm-conditional-restrictions
conditional openstreetmap osm restrictions
Last synced: 3 months ago
JSON representation
📅🔒 Parser for OpenStreetMap conditional restrictions
- Host: GitHub
- URL: https://github.com/k-yle/osm-conditional-restrictions
- Owner: k-yle
- License: mit
- Created: 2023-09-14T05:45:17.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-09T10:28:06.000Z (8 months ago)
- Last Synced: 2024-09-10T13:25:34.283Z (4 months ago)
- Topics: conditional, openstreetmap, osm, restrictions
- Language: TypeScript
- Homepage: https://kyle.kiwi/osm-conditional-restrictions
- Size: 2.04 MB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# OpenStreetMap conditional restriction parser
[![Build Status](https://github.com/k-yle/osm-conditional-restrictions/workflows/Build%20and%20Test/badge.svg)](https://github.com/k-yle/osm-conditional-restrictions/actions)
[![Coverage Status](https://coveralls.io/repos/github/k-yle/osm-conditional-restrictions/badge.svg?branch=main&t=LQmPNl)](https://coveralls.io/github/k-yle/osm-conditional-restrictions?branch=main)
[![npm version](https://badge.fury.io/js/osm-conditional-restrictions.svg)](https://badge.fury.io/js/osm-conditional-restrictions)
[![npm](https://img.shields.io/npm/dt/osm-conditional-restrictions.svg)](https://www.npmjs.com/package/osm-conditional-restrictions)
![npm bundle size](https://img.shields.io/bundlephobia/minzip/osm-conditional-restrictions)📅🔒 Javascript/Typescript parser for OpenStreetMap [conditional restrictions](https://osm.wiki/Conditional_restrictions).
## Install
```sh
npm install osm-conditional-restrictions
```## Usage
```js
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](https://osm.wiki/Key:opening_hours), check out the [opening_hours](https://npm.im/opening_hours) library.## Related Work
- [simonpoole/ConditionalRestrictionParser](https://github.com/simonpoole/ConditionalRestrictionParser) - An equivalent library written in Java