Git Product home page Git Product logo

dbgeo's Introduction

dbgeo

Convert database query results to GeoJSON or TopoJSON. Inspired by Bryan McBride's PHP-Database-GeoJSON. Works with your database of choice - ideally paired with node-mysql, node-postgres, or mongodb. It is a more flexible version of postgeo and mysql2geojson (both deprecated).

Installation
npm install dbgeo
Example Usage
var dbgeo = require('dbgeo')

// Query a database...

dbgeo.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
geometryType Format of input geometry wkb, wkt, geojson, ll wkb
geometryColumn Name of column that contains geometry. If input geometry type is "ll", this is an array in the format ['longitude', 'latitude'] Any string geom
outputFormat Desired output format geojson, topojson geojson
precision Trim the coordinate precision of the output to a given number of digits using geojson-precision Any integer null (will not trim precision)
quantization Value for quantization process, typically specified as powers of ten, see topojson.quantize Any integer greater than one null (no quantization)
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

dbgeo's People

Contributors

jczaplew avatar jspeis avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.