# dbgeo_gen

> A Node.js module for converting database queries to GeoJSON and TopoJSON

Latest version **0.0.7** (published 2017-01-03) · CC0 license · 0 weekly downloads

## Install

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

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.7 |
| Published | 2017-01-03 |
| First published | 2016-12-26 |
| Weekly downloads | 0 |
| License | CC0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | rajanski |
| Maintainers | rajanski |
| Keywords | TopoJSON, topojson, geojson, GeoJSON, postgis, postgres, sql, MySQL, Postgres, PostgreSQL, WKB, wkb, MariaDB, dbgeo_gen, dbgeo, gis, geometry, GIS, mysql2geojson, postgeo |

## Links

- npm: https://www.npmjs.com/package/dbgeo_gen
- Repository: https://github.com/rajanski/dbgeo_gen
- Homepage: https://github.com/rajanski/dbgeo_gen#readme
- Issues: https://github.com/rajanski/dbgeo_gen/issues
- npm.io page: https://npm.io/package/dbgeo_gen

## Dependencies (3)

- [wkx](https://npm.io/package/wkx.md) ~0.2.0
- [topojson](https://npm.io/package/topojson.md) ~1.6.26
- [geojson-precision](https://npm.io/package/geojson-precision.md) ^0.4.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.0.7 (latest) — 2017-01-03
- 0.0.6 — 2016-12-27
- 0.0.5 — 2016-12-26
- 0.0.4 — 2016-12-26
- 0.0.3 — 2016-12-26
- 0.0.1 — 2016-12-26

## README

# dbgeo_gen

Convert database query results with WKB geometries to GeoJSON or TopoJSON, regardless of geometry column name. Also allows for multiple geometry columns in query result (Those will be held in a geometrycollection). 

Heavily inspired by [John J Czaplewski's](https://github.com/jczaplew) [dbgeo](https://github.com/jczaplew/dbgeo). 
Should work with your database of choice (I only tested postgres) .

###### Installation
````
npm install dbgeo_gen
````

###### Example Usage
````javascript
var dbgeo_gen = require('dbgeo_gen')

// Query a database...

dbgeo_gen.parse(data, {
  outputFormat: 'geojson'
}, function(error, result) {
  // This will log a valid GeoJSON FeatureCollection
  console.log(result)  
});

````

See ````test/test.js```` for more examples.


## API

### .parse(data, options, callback)

##### data (***required***)  
An array of objects, usually results from a database query.

##### options (*optional*)
Configuration object that can contain the following keys:

| argument |  description  | values  |  default value  |
|----------|---------------|---------|-----------------|
| `outputFormat`  | Desired output format  | geojson, topojson  | geojson  |
| `precision`     | Trim the coordinate precision of the output to a given number of digits using [geojson-precision](https://github.com/jczaplew/geojson-precision) | *Any integer* | `null` (will not trim precision) |


##### callback (***required***)
A function with two parameters: an error, and a result object.

Examples can be found in ````test/test.js````.

### .defaults{}
The default options for ````.parse()````. You can set these before using ````.parse()```` if you plan to use the same options continuously.

## License
CC0

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