GithubHelp home page GithubHelp logo

algunenano / grainstore Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cartodb/grainstore

0.0 2.0 0.0 694 KB

Generate Mapnik MML & XML for single postgis tables with style persistance.

License: BSD 3-Clause "New" or "Revised" License

Makefile 0.14% JavaScript 99.86%

grainstore's Introduction

Grainstore

[Build Status] (http://travis-ci.org/CartoDB/grainstore)

Need to simply generate a Mapnik map from a dynamic PostGIS table?

Grainstore is an opinionated Carto MML style store for PostGIS tables, views or sql queries that outputs Mapnik XML stylesheets.

Map styles can be defined in the Carto map styling language or use default styles. The Carto styles are persisted and Mapnik XML output cached in Redis, making it a good choice for use in map tile servers.

The generated Mapnik XML stylesheet plugs directly into Mapnik or Mapnik based tile server to render a map and interactivity layer.

Grainstore is braindead simple:

1 db + 1 table/query + 1 style = 1 Mapnik XML stylesheet.

or

1 db + N queries + N styles = 1 Mapnik XML stylesheet.

Typical use

For using multiple layers use an array type for the 'sql' parameter and for the 'style' parameter. Each resulting layer will be named 'layerN' with N starting from 0 (needed to properly reference the layers from the 'style' values).

Install

npm install

Dependencies

  • node.js >=6
  • npm

Additional test dependencies

  • libxml2
  • libxml2-devel

Examples

var grainstore = require('grainstore');

var params = {
  dbname: 'my_database',
  sql:'select * from my_table',
  style: '#my_table { polygon-fill: #fff; }'
}

// fully default.
var mmls = new grainstore.MMLStore();
var mmlb = mmls.mml_builder(params);
mmlb.toXML(function(err, data){
    console.log(data); // => Mapnik XML for your database with default styles
});


// custom pg settings.
var mmls = new grainstore.MMLStore();

// see mml_store.js for more customisation detail 
var options = {
  map: {srid: 4326},
  datasource: {
    user: "postgres",
    geometry_field: "my_geom"
  }   
}

mmlb = mmls.mml_builder(params, options);
mmlb.toXML(function(err, data){
    console.log(data); // => Mapnik XML of custom database with default style
});

For more examples, see the tests.

Tests

To run the tests, from the project root:

npm test

Release

npm publish

Contributing

See CONTRIBUTING.md.

grainstore's People

Contributors

andrewxhill avatar dgaubert avatar rochoa avatar strk avatar tokumine avatar

Watchers

 avatar  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.