An open API service indexing awesome lists of open source software.

https://github.com/sharedstreets/sharedstreets-pbf

SharedStreets PBF Parser
https://github.com/sharedstreets/sharedstreets-pbf

Last synced: about 1 year ago
JSON representation

SharedStreets PBF Parser

Awesome Lists containing this project

README

          

# SharedStreets PBF Parser

[![npm version](https://badge.fury.io/js/sharedstreets-pbf.svg)](https://badge.fury.io/js/sharedstreets-pbf)
[![Build Status](https://travis-ci.org/sharedstreets/sharedstreets-pbf.svg?branch=master)](https://travis-ci.org/sharedstreets/sharedstreets-pbf)

Reads [SharedStreets Protobuf buffers](https://github.com/sharedstreets/sharedstreets-ref-system/tree/master/proto).

## Install

**In Node.js**

```bash
$ yarn add sharedstreets-pbf
```

**CommonJS**

```js
const sharedstreetsPbf = require('sharedstreets-pbf');
```

**Typescript**

```js
import * as sharedstreetsPbf from 'sharedstreets-pbf';
```

## In Browser

For a full list of web examples, check out [SharedStreets examples](https://github.com/sharedstreets/sharedstreets-examples).

## How to build

> `sharedstreets-pbf` uses submodules, make sure to include `--recursive` when cloning the repo.

```bash
$ git clone --recursive git@github.com:sharedstreets/sharedstreets-pbf.git
$ cd sharedstreets-pbf
$ yarn
$ yarn build
$ yarn test
```

## API

#### Table of Contents

- [geometry](#geometry)
- [intersection](#intersection)
- [reference](#reference)
- [metadata](#metadata)
- [readBuffer](#readbuffer)

### geometry

Geometry Pbf

Parser for SharedStreets Geometry Pbf Buffers

**Parameters**

- `buffer` **[Buffer](https://nodejs.org/api/buffer.html)** Pbf Buffer

**Examples**

```javascript
const buffer = fs.readFileSync('z-x-y.geometry.pbf')

const geoms = sharedstreetsPbf.geometry(buffer)
geoms[0].id // => '81f666c5e1e4de0f7df4fbd793d909b2'
```

Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<SharedStreetsGeometry>** An Array of SharedStreet Geometry

### intersection

Intersection Pbf

Parser for SharedStreets Intersection Pbf Buffers

**Parameters**

- `buffer` **[Buffer](https://nodejs.org/api/buffer.html)** Pbf Buffer

**Examples**

```javascript
const buffer = fs.readFileSync('z-x-y.intersection.pbf')

const intersections = sharedstreetsPbf.intersection(buffer)
intersections[0].id // => '8037a9444353cd7dd3f58d9a436f2537'
```

Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<SharedStreetsIntersection>** An Array of SharedStreet Intersections

### reference

Reference Pbf

Parser for SharedStreets Reference Pbf Buffers

**Parameters**

- `buffer` **[Buffer](https://nodejs.org/api/buffer.html)** Pbf Buffer

**Examples**

```javascript
const buffer = fs.readFileSync('z-x-y.reference.pbf')

const references = sharedstreetsPbf.reference(buffer)
references[0].id // => '41d73e28819470745fa1f93dc46d82a9'
```

Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<SharedStreetsReferencePbf>** An Array of SharedStreet References

### metadata

Metadata Pbf

Parser for SharedStreets Metadata Pbf Buffers

**Parameters**

- `buffer` **[Buffer](https://nodejs.org/api/buffer.html)** Pbf Buffer

**Examples**

```javascript
const buffer = fs.readFileSync('z-x-y.metadata.pbf')

const metadatas = sharedstreetsPbf.metadata(buffer)
metadatas[0].geometryID // => '81f666c5e1e4de0f7df4fbd793d909b2'
```

Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<SharedStreetsMetadata>** An Array of SharedStreet Metadatas

### readBuffer

Decode Delimited buffers using protobufjs

**Parameters**

- `buffer` **([Buffer](https://nodejs.org/api/buffer.html) \| [Uint8Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array))** Pbf Buffer
- `parser` **any** Protobufjs Parser

**Examples**

```javascript
const parser = sharedstreetsPbf.SharedStreetsProto.GISMetadata;
const results = sharedstreetsPbf.readBuffer(buffer, parser);
```

Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)>** An Array of based on given Protobufjs Parser