How to use the mapnik.MemoryDatasource function in mapnik

To help you get started, we’ve selected a few mapnik examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github spatialdev / PGRestAPI / endpoints / tiles / index.js View on Github external
function createInMemoryDatasource(name, path_to_shp) {
  var shapefile = new mapnik.Datasource({
    type: 'shape',
    file: path_to_shp
  });

  // get the featureset that exposes lazy next() iterator
  var featureset = shapefile.featureset();

  var mem_datasource = new mapnik.MemoryDatasource(
    {}
  );

  // build up memory datasource
  while (( feat = featureset.next(true))) {
    var e = feat.extent();
    // center longitude of polygon bbox
    var x = (e[0] + e[2]) / 2;
    // center latitude of polygon bbox
    var y = (e[1] + e[3]) / 2;
    var attr = feat.attributes();
    mem_datasource.add({
      'x': x,
      'y': y,
      'properties': {
        'feat_id': feat.id()//,
github spatialdev / PGRestAPI / endpoints / mapnik / index.js View on Github external
function createInMemoryDatasource(name, path_to_shp) {
    var shapefile = new mapnik.Datasource({
        type: 'shape',
        file: path_to_shp
    });

    // get the featureset that exposes lazy next() iterator
    var featureset = shapefile.featureset();

    var mem_datasource = new mapnik.MemoryDatasource(
        {}
    );

    // build up memory datasource
    while (( feat = featureset.next(true))) {
        var e = feat.extent();
        // center longitude of polygon bbox
        var x = (e[0] + e[2]) / 2;
        // center latitude of polygon bbox
        var y = (e[1] + e[3]) / 2;
        var attr = feat.attributes();
        mem_datasource.add({
            'x': x,
            'y': y,
            'properties': {
                'feat_id': feat.id()//,
github mapnik / node-mapnik-sample-code / memory_datasource / simple.js View on Github external
// create map object
var map = new mapnik.Map(256, 256);
map.fromStringSync(s);

// go get some arbitrary data that we can stream
var shp = path.join(__dirname, '../data/world_merc');

var ds = new mapnik.Datasource({
    type: 'shape',
    file: shp
});

// get the featureset that exposes lazy next() iterator
var featureset = ds.featureset();

var mem_datasource = new mapnik.MemoryDatasource(
    {'extent': '-20037508.342789,-8283343.693883,20037508.342789,18365151.363070'}
    );

// build up memory datasource
while ((feat = featureset.next(true))) {
    var e = feat.extent();
    // center longitude of polygon bbox
    var x = (e[0] + e[2]) / 2;
    // center latitude of polygon bbox
    var y = (e[1] + e[3]) / 2;
    var attr = feat.attributes();
    mem_datasource.add({ 'x' : x,
                         'y' : y,
                         'properties' : { 'feat_id': feat.id(), 'NAME': attr.NAME, 'POP2005': attr.POP2005 }
                       });
}
github mapnik / node-mapnik / examples / memory_datasource / simple.js View on Github external
// create map object
var map = new mapnik.Map(256,256);
map.from_string(s,'.');

// go get some arbitrary data that we can stream
var shp = path.join(__dirname,'../data/world_merc');

var ds = new mapnik.Datasource({
    type: 'shape',
    file: shp
});

// get the featureset that exposes lazy next() iterator
var featureset = ds.featureset();

var mem_datasource = new mapnik.MemoryDatasource(
    {'extent':'-20037508.342789,-8283343.693883,20037508.342789,18365151.363070'}
    )

// build up memory datasource
while (feat = featureset.next(true)) {
    // center longitude of polygon bbox
    var x = (feat._extent[0]+feat._extent[2])/2;
    // center latitude of polygon bbox
    var y = (feat._extent[1]+feat._extent[3])/2;
    mem_datasource.add({ 'x'          : x,
                         'y'          : y,
                         'properties' : { 'NAME':feat.NAME,'POP2005':feat.POP2005 }
                       });
}

var options = {
github mapnik / node-mapnik-sample-code / tile / elastic / app.js View on Github external
function(err, map) {
              if (err) {
                  res.writeHead(500, {
                    'Content-Type': 'text/plain'
                  });
                  res.end(err.message);
              }

              var options = {
                  extent: '-20037508.342789,-8283343.693883,20037508.342789,18365151.363070'
              };

              var mem_ds = new mapnik.MemoryDatasource(options);

              var el_query = {
                 'size': 100,
                 'query' : {
                     'match_all' : {}
                 },
                  'filter' : {
                      'geo_bounding_box' : {
                          'project.location' : {
                              'top_left' : {
                                  'lat' : bbox[3],
                                  'lon' : bbox[0]
                              },
                              'bottom_right' : {
                                  'lat' : bbox[1],
                                  'lon' : bbox[2]
github mapnik / node-mapnik / examples / tile / elastic / app.js View on Github external
function (err, map) {
              if (err) {
                  res.writeHead(500, {
                    'Content-Type': 'text/plain'
                  });
                  res.end(err.message);
              }

              var options = {
                  extent: '-20037508.342789,-8283343.693883,20037508.342789,18365151.363070',
              };
        
              var mem_ds = new mapnik.MemoryDatasource(options);
        
              var el_query = {
                 "size": 100,
                 "query" : {
                     "match_all" : {}
                 },
                  "filter" : {
                      "geo_bounding_box" : {
                          "project.location" : {
                              "top_left" : {
                                  "lat" : bbox[3],
                                  "lon" : bbox[0]
                              },
                              "bottom_right" : {
                                  "lat" : bbox[1],
                                  "lon" : bbox[2]