0.0.7 • Published 7 years ago

dbgeo_gen v0.0.7

Weekly downloads
4
License
CC0
Repository
github
Last release
7 years ago

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 dbgeo. Should work with your database of choice (I only tested postgres) .

Installation
npm install dbgeo_gen
Example Usage
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:

argumentdescriptionvaluesdefault value
outputFormatDesired output formatgeojson, topojsongeojson
precisionTrim the coordinate precision of the output to a given number of digits using geojson-precisionAny integernull (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