# route_annotator

> Bindings for route-annotator

Latest version **0.0.5** (published 2017-06-21) · See LICENSE.txt file license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install route_annotator
pnpm add route_annotator
yarn add route_annotator
bun add route_annotator
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2017-06-21 |
| First published | 2016-04-22 |
| Weekly downloads | 0 |
| License | See LICENSE.txt file |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | yes |
| GitHub stars | 34 |
| Author | Mapbox |
| Maintainers | ghoshkaj, danpat |
| Keywords | addon, native, module |

## Links

- npm: https://www.npmjs.com/package/route_annotator
- Repository: https://github.com/mapbox/route-annotator
- Homepage: https://github.com/mapbox/route-annotator#readme
- Issues: https://github.com/mapbox/route-annotator/issues
- npm.io page: https://npm.io/package/route_annotator

## Dependencies (5)

- [nan](https://npm.io/package/nan.md) ^2.2.1
- [tape](https://npm.io/package/tape.md) ^4.6.3
- [aws-sdk](https://npm.io/package/aws-sdk.md) ^2.3.5
- [node-cmake](https://npm.io/package/node-cmake.md) ^1.2.0
- [node-pre-gyp](https://npm.io/package/node-pre-gyp.md) ^0.6.26

## Recent versions

- 0.0.5 (latest) — 2017-06-21
- 0.0.4 — 2017-05-19
- 0.0.3 — 2017-05-12
- 0.0.2 — 2016-04-27
- 0.0.1 — 2016-04-22

## README

[![Build Status](https://travis-ci.org/mapbox/route-annotator.svg?branch=master)](https://travis-ci.org/mapbox/route-annotator)

# Route Annotator

This is a NodeJS module that indexes connected node pairs in OSM data, and allows you to query for
meta-data.  It's useful for retrieving tag information when you have geometry from your basemap.

## Requires

- Node >= 4

## Building

To install via binaries:

```
npm install
```

To install from source, first install a C++14 capable compiler then run:


```
make
```

## Testing

To run the tests (which run both the JS tests and the C++ tests):

```
make test
```

To run just the JS tests:

```
npm test
```

To run the C++ tests:

```
./build/Release/basic-tests
```

## Usage

This library contains two main modules: `Annotator` and `SpeedLookup`

### Annotator

The `Annotator()` object is for looking up OSM tag data from OSM node IDs or coordinates.

**Example:**
```
var taglookup = new (require('route_annotator')).Annotator();

// Lookup some nodes and find out which ways they were on,
// and what tags they had
taglookup.loadOSMExtract(path.join(__dirname,'data/winthrop.osm'), (err) => {
  if (err) throw err;
  var nodes = [50253600,50253602,50137292];
  taglookup.annotateRouteFromNodeIds(nodes, (err, wayIds) => {
    if (err) throw err;
    annotator.getAllTagsForWayId(wayIds[0], (err, tags) => {
      if (err) throw err;
      console.log(tags);
    });
  });
}); 


// Do the same thing, but this time use coordinates instead
// of node ids.  Internally, a radius search finds the closest
// node within 5m
taglookup.loadOSMExtract(path.join(__dirname,'data/winthrop.osm'), (err) => {
  if (err) throw err;
  var coords = [[-120.1872774,48.4715898],[-120.1882910,48.4725110]];
  taglookup.annotateRouteFromLonLats(coords, (err, wayIds) => {
    if (err) throw err;
    annotator.getAllTagsForWayId(wayIds[0], (err, tags) => {
      if (err) throw err;
      console.log(tags);
    });
  });
}); 

```

### SpeedLookup

The `SpeedLookup()` object is for loading segment speed information from CSV files, then looking it up quickly from an in-memory hashtable.

**Example:**
```
var speedlookup = new (require('route_annotator')).SpeedLookup();

// Loads example.csv, then looks up the pairs 123-124, 124-125, 125-126
// and prints the speeds for those segments (3 values) as comma-separated
// data
speedlookup.loadCSV("example.csv", (err) => {
  if (err) throw err;
  speedlookup.getRouteSpeeds([123,124,125,126],(err,results) => {
    if (err) throw err;
    console.log(results.join(","));
  });
});
```

The `loadCSV` method can also be passed an array of filenames.

---

### Example HTTP server

```
npm install
curl --remote-name http://download.geofabrik.de/europe/monaco-latest.osm.pbf
node example-server.js monaco-latest.osm.pbf
```

Then, in a new terminal, you should be able to do:

```
curl "http://localhost:5000/coordlist/7.422155,43.7368838;7.4230139,43.7369751"
```
---

### Release

- `git checkout master`
- Update CHANGELOG.md
- Bump version in package.json
- `git commit -am "vx.y.z [publish binary]"` with Changelog list in commit message
- Wait for Travis to finish publishing binaries so that all travis tests pass for the publish binary commit.
- `git tag vx.y.z -a` with Changelog list in tag message
- `git push origin master; git push origin --tags`
- `npm publish`

---
_Source: https://npm.io/package/route_annotator · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
