GithubHelp home page GithubHelp logo

mapnik / node-mapnik Goto Github PK

View Code? Open in Web Editor NEW
526.0 35.0 162.0 20.87 MB

Bindings to mapnik for node.js

Home Page: http://mapnik.org/documentation/node-mapnik

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

Shell 2.43% JavaScript 38.17% Python 0.75% PowerShell 0.03% C++ 58.10% Makefile 0.23% Batchfile 0.03% HTML 0.24% Emacs Lisp 0.02%

node-mapnik's Introduction

node-mapnik

Bindings to Mapnik for node.

NPM

Build Status Coverage Status

Usage

Render a map from a stylesheet:

var mapnik = require('mapnik');
var fs = require('fs');

// register fonts and datasource plugins
mapnik.register_default_fonts();
mapnik.register_default_input_plugins();

var map = new mapnik.Map(256, 256);
map.load('./test/stylesheet.xml', function(err,map) {
    if (err) throw err;
    map.zoomAll();
    var im = new mapnik.Image(256, 256);
    map.render(im, function(err,im) {
      if (err) throw err;
      im.encode('png', function(err,buffer) {
          if (err) throw err;
          fs.writeFile('map.png',buffer, function(err) {
              if (err) throw err;
              console.log('saved map image to map.png');
          });
      });
    });
});

Convert a jpeg image to a png:

var mapnik = require('mapnik');
new mapnik.Image.open('input.jpg').save('output.png');

Convert a shapefile to GeoJSON:

var mapnik = require('mapnik');
mapnik.register_datasource(path.join(mapnik.settings.paths.input_plugins,'shape.input'));
var ds = new mapnik.Datasource({type:'shape',file:'test/data/world_merc.shp'});
var featureset = ds.featureset()
var geojson = {
  "type": "FeatureCollection",
  "features": [
  ]
}
var feat = featureset.next();
while (feat) {
    geojson.features.push(JSON.parse(feat.toJSON()));
    feat = featureset.next();
}
fs.writeFileSync("output.geojson",JSON.stringify(geojson,null,2));

For more sample code see the tests and sample code.

Requirements

Starting from v4.5.0, node-mapnik module is published as "universal" binaries using node-addon-api All Node.js versions >= 10 are known to work, consult N-API documentation for more details: https://nodejs.org/dist/latest/docs/api/n-api.html#n_api_node_api_version_matrix

An installation error like below indicates your system does not have a modern enough libstdc++/gcc-base toolchain:

Error: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version GLIBCXX_3.4.21 not found (required by /node_modules/mapnik/lib/binding/mapnik.node)

If you are running Ubuntu older than 16.04 you can easily upgrade your libstdc++ version like:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update -y
sudo apt-get install -y libstdc++-6-dev

To upgrade libstdc++ on travis (without sudo) you can do:

language: cpp

sudo: false

addons:
  apt:
    sources:
     - ubuntu-toolchain-r-test
    packages:
     - libstdc++-6-dev # upgrade libstdc++

Installing

With npm

Just do:

npm install mapnik

Note: This will install the latest node-mapnik 4.5.x series, which is recommended.

Source Build

There are two ways to build from source. These work on both OS X and Linux:

  • A) Against a binary package from Mapnik from mason
  • B) Against an existing version of Mapnik on your system

Using A) is recommended. You do not need to have Mapnik installed already, so this is the easiest and most predictable approach. When you use the route a binary package of Mapnik is downloaded dynamically from mason.

You can invoke this method simply by running:

make release

Or, for debug builds:

make debug

If you want to do a full rebuild do:

make distclean

And then re-run the build:

make release

Using B) is also possible, if you would like to build node-mapnik against an external, already installed Mapnik version.

In this case you need to have a Mapnik version installed that is at least as recent as the mapnik_version property in the package.json for the branch of node-mapnik you want to build.

And you need to have the mapnik-config program is available and on your ${PATH}.

Then run (within the cloned node-mapnik directory:

make release_base

or

make debug_base

for release and debug builds, respectively.

Note on SSE:

By default node mapnik is built with SSE support. If you are building on a platform that is not x86_64 you will need to disable feature by setting the environment variable SSE_MATH=false.

SSE_MATH=false make

Building against Mapnik 3.0.x

The master branch of node-mapnik is not compatible with 3.0.x series of Mapnik. To build against Mapnik 3.0.x, use v3.0.x branch.

Using node-mapnik from your node app

To require node-mapnik as a dependency of another package put in your package.json:

"dependencies"  : { "mapnik":"*" } // replace * with a given semver version string

Tests

To run the tests do:

npm test

License

BSD, see LICENSE.txt

node-mapnik's People

Contributors

algunenano avatar artemp avatar booo avatar brianreavis avatar calvinmetcalf avatar danpat avatar flippmoke avatar ingalls avatar j-d-b avatar jseppi avatar kkaefer avatar kkoopa avatar manaswinidas avatar mapsam avatar mikemorris avatar mithgol avatar mojodna avatar mscdex avatar rclark avatar rcoup avatar sebastic avatar springmeyer avatar stefanklug avatar taketime avatar talaj avatar tmcw avatar tomhughes avatar wilhelmberg avatar yhahn avatar zdila avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-mapnik's Issues

Including data changes join_key behavior with memory_datasource

This is an odd one: I've been working with memory_datasource on this project (working excellently otherwise), but, in the memory_datasource/simple.js

map._render_grid(
    0,
    4,
    'POP2005',
    false,
    [], function(err, data) {
        console.log(err, data);
    });

Returns

{ stack: [Getter/Setter],
  arguments: undefined,
  type: undefined,
  message: 'join_field: \'POP2005\' is not a valid attribute name\nValid fields are:' } undefined

while

map._render_grid(
    0,
    4,
    'POP2005',
    true,
    ['NAME'], function(err, data) {
        console.log(err, data);
    });

appears to work fine

add_layer problems

Having trouble with the add_layer function off of a map object - in Javascript, I can construct a Layer object, which passes a simple l instanceof mapnik.Layer test, but node-mapnik throws

/Users/tmcw/Code/js/sites/spinnaker/node_modules/tilelive/node_modules/step/lib/step.js:38
        throw arguments[0];
                       ^
TypeError: mapnik.Layer expected

Looking at the source, I don't think that there's much that could be going wrong, though HasInstance might behave differently than instanceof? Or something like that? I'm not sure.

The code in question is below:

var l = new mapnik.Layer('countries');
l.srs = map.mapnik.srs;
l.styles = ['countries'];
var mem_ds = new mapnik.MemoryDatasource({
    extent: '-20037508.342789,' +
        '20037508.342789,' +
        '20037508.342789,' +
        '20037508.342789'
});
collection.forEach(function(c) {
    mem_ds.add({
        x: c.lon,
        y: c.lat,
        name: c.name
    });
});
l.datasource = mem_ds;
console.log(l instanceof mapnik.Layer);
map.mapnik.add_layer(l);

Stable revision and Mac installer

We're getting close to another tag for TileMill, so we'll need to put together a stable revision for Linux users and a Mac installer.

reflect mapnik.Feature

mapnik.Featureset is exposed, but next() should return actual mapnik.Feature objects rather than flattened JSON.

Unable to build on OSX (10.6)

Gentlemen, I've been trying to build the latest TileMill and am unable to build a current version of node-mapnik. I've tried building from the repository and it bails in the same place as when I attempt to let it install as a TileMill dependency. I'm not converse enough in the node toolchain to know how to debug this. I've installed all dependencies with brew + npm.

Log follows:

refiner:node-mapnik sk$ npm install -g mapnik
/usr/local/bin/mapnik-inspect.js -> /usr/local/lib/node_modules/mapnik/bin/mapnik-inspect.js
/usr/local/bin/mapnik-render.js -> /usr/local/lib/node_modules/mapnik/bin/mapnik-render.js

> [email protected] install /usr/local/lib/node_modules/mapnik
> node-waf -v configure build

Setting srcdir to                        : /usr/local/lib/node_modules/mapnik 
Setting blddir to                        : /usr/local/lib/node_modules/mapnik/build 
Checking for program g++ or c++          : /usr/bin/g++ 
Checking for program cpp                 : /usr/bin/cpp 
Checking for program ar                  : /usr/bin/ar 
Checking for program ranlib              : /usr/bin/ranlib 
Checking for g++                         : ok  
Checking for node path                   : not found 
Checking for node prefix                 : ok /usr/local/Cellar/node/0.4.10 
Checking for program mapnik-config       : /Library/Frameworks/Mapnik.framework/Programs/mapnik-config 
Sweet, found cairo library, will attempt to compile with cairo support for pdf/svg output 
'configure' finished successfully (0.060s)
Waf: Entering directory `/usr/local/lib/node_modules/mapnik/build'
[ 1/16] cxx: src/node_mapnik.cpp -> build/default/src/node_mapnik_1.o
08:10:34 runner system command -> ['/usr/bin/g++', '-g', '-O3', '-D_FILE_OFFSET_BITS=64', '-D_LARGEFILE_SOURCE', '-fPIC', '-compatibility_version', '1', '-current_version', '1', '-I/Library/Frameworks/Mapnik.framework/Versions/2.0/unix/include/freetype2', '-I/Library/Frameworks/Mapnik.framework/Versions/2.0/unix/include', '-arch', 'i386', '-arch', 'x86_64', '-I/Library/Frameworks/Mapnik.framework/unix/include', '-I/Library/Frameworks/Mapnik.framework/unix/include/cairo', '-I/Library/Frameworks/Mapnik.framework/unix/include/cairomm-1.0', '-I/Library/Frameworks/Mapnik.framework/unix/include/sigc++-2.0', '-I/Library/Frameworks/Mapnik.framework/unix/lib/sigc++-2.0/include/', '-I/Library/Frameworks/Mapnik.framework/unix/include/freetype2', '-I/Library/Frameworks/UnixImageIO.framework/unix/include', '-I/Library/Frameworks/PROJ.framework/unix/include', '-I/usr/include/libxml2', '-DHAVE_CAIRO', '-I/Library/Frameworks/Mapnik.framework/Headers/cairomm-1.0', '-I/Library/Frameworks/Mapnik.framework/Headers/cairo', '-I/Library/Frameworks/Mapnik.framework/Headers/sigc++-2.0', '-I/Library/Frameworks/Mapnik.framework/unix/lib/sigc++-2.0/include', '-I/Library/Frameworks/Mapnik.framework/Headers', '-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64', '-D_GNU_SOURCE', '-DEV_MULTIPLICITY=0', '-Idefault', '-I..', '-I/usr/local/Cellar/node/0.4.10/include/node', '../src/node_mapnik.cpp', '-c', '-o', 'default/src/node_mapnik_1.o']
In file included from ../src/node_mapnik.cpp:14:
../src/mapnik_fonts.hpp: In function ‘v8::Handle<v8::Value> node_mapnik::available_font_files(const v8::Arguments&)’:
../src/mapnik_fonts.hpp:83: error: ‘get_mapping’ is not a member of ‘mapnik::freetype_engine’
In file included from ../src/node_mapnik.cpp:14:
../src/mapnik_fonts.hpp: In function ‘v8::Handle<v8::Value> node_mapnik::available_font_files(const v8::Arguments&)’:
../src/mapnik_fonts.hpp:83: error: ‘get_mapping’ is not a member of ‘mapnik::freetype_engine’
lipo: can't figure out the architecture type of: /var/folders/3V/3VrWj7k4FLWcvvQNnD2hwE+++TI/-Tmp-//ccumpALF.out
Waf: Leaving directory `/usr/local/lib/node_modules/mapnik/build'
Build failed:  -> task failed (err #1): 
    {task: cxx node_mapnik.cpp -> node_mapnik_1.o}
npm ERR! error installing [email protected] Error: [email protected] install: `node-waf -v configure build`
npm ERR! error installing [email protected] `sh "-c" "node-waf -v configure build"` failed with 1
npm ERR! error installing [email protected]     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/exec.js:49:20)
npm ERR! error installing [email protected]     at ChildProcess.emit (events.js:67:17)
npm ERR! error installing [email protected]     at ChildProcess.onexit (child_process.js:192:12)
npm ERR! [email protected] install: `node-waf -v configure build`
npm ERR! `sh "-c" "node-waf -v configure build"` failed with 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the mapnik package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-waf -v configure build
npm ERR! You can get their info via:
npm ERR!     npm owner ls mapnik
npm ERR! There is likely additional logging output above.
npm ERR! 
npm ERR! System Darwin 10.7.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "mapnik"
npm ERR! cwd /Users/sk/src/node-mapnik
npm ERR! node -v v0.4.10
npm ERR! npm -v 1.0.22
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/sk/src/node-mapnik/npm-debug.log
npm not ok

Suggestions would be appreciated. Thanks!

performance and locking concerns with UnicodeStrings

We may need to be careful about copying and locking of "thread-safe" Unicode strings (See: http://userguide.icu-project.org/strings).

Setting breaks in gdb on osx and seeing at lot of:

Thread 2 (process 936):
#0  0x00007fff8737a322 in semaphore_wait_signal_trap ()
#1  0x00007fff8737f96d in pthread_mutex_lock ()
#2  0x0000000126080e6a in umtx_lock_44 ()
#3  0x00000001260c95d7 in icu_44::UnicodeString::cloneArrayIfNeeded ()
#4  0x00000001260ca23b in icu_44::UnicodeString::setCharAt ()
#5  0x00000001252134fe in grid2utf (renbuf=@0x12973f860, str=, keys=, key_order=@0x129a12940, feature_keys=) at ../src/mapnik_map.cpp:982
#6  0x0000000125215598 in Map::EIO_RenderGrid (req=) at ../src/mapnik_map.cpp:1312
#7  0x000000010002caf2 in etp_proc (thr_arg=) at ../deps/libeio/eio.c:1693
#8  0x00007fff873b3536 in _pthread_start ()
#9  0x00007fff873b33e9 in thread_start ()

Adaptively determine grid size

Can we come up with an algorithm that changes the grid size depending on the complexity of the features? i.e. if there would be a benefit of having a 2x2 grid over a 4x4, how do we find that out?

error when installing

I got these error while install by npm install mapnik

npm info uninstall [email protected] complete
npm info install failed rolled back
npm ERR! Error: [email protected] install: node-waf -v configure build
npm ERR! sh "-c" "node-waf -v configure build" failed with 1
npm ERR! at ChildProcess. (/usr/local/lib/node/.npm/npm/0.3.15/package/lib/utils/exec.js:49:20)
npm ERR! at ChildProcess.emit (events.js:45:17)
npm ERR! at ChildProcess.onexit (child_process.js:171:12)
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the mapnik package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-waf -v configure build

and got these while manually ./configure

Checking for program mapnik-config : not found
/home/goldalworming/node/node-mapnik/wscript:95: error: The program ['mapnik-config'] is required

I hope there is any solution

in-memory, lazy, callback based js datasource

We can expose a new Javascript class in node-mapnik to create a valid mapnik::datasource_ptr (boost::shared_ptr) whose next() iterator actually calls back out to a function defined in pure javascript. Think dynamic, tile-based points coming out of a db as json that can be streamed on demand (and potentially manipulated on the fly) during rendering.

thread unsafe plugin initialization

Error: ECONNREFUSED, Connection refused
    at IOWatcher.callback (net:870:22)
    at node.js:773:9
terminate called after throwing an instance of 'boost::exception_detail::clone_impl >'
  what():  boost::lock_error
Abort trap
hread 5 (process 55400):
#0  0x00007fff86f4b80a in __getdirentries64 ()
#1  0x00007fff86f4b798 in _readdir_unlocked$INODE64 ()
#2  0x00007fff86f4b730 in readdir$INODE64 ()
#3  0x000000010002cd81 in eio__scandir [inlined] () at /Users/saman/mapbox-tilemill-4ba9aea/src/node-0.2.6/deps/libeio/eio.c:1235
#4  0x000000010002cd81 in etp_proc (thr_arg=) at ../deps/libeio/eio.c:1643
#5  0x00007fff86f7a4f6 in _pthread_start ()
#6  0x00007fff86f7a3a9 in thread_start ()

Thread 4 (process 55400):
#0  0x00007fff86f7bf8a in __semwait_signal ()
#1  0x00007fff86f7fda1 in _pthread_cond_wait ()
#2  0x000000010002c607 in etp_proc (thr_arg=) at ../deps/libeio/eio.c:1490
#3  0x00007fff86f7a4f6 in _pthread_start ()
#4  0x00007fff86f7a3a9 in thread_start ()

Thread 3 (process 55400):
#0  0x0000000129b1a158 in ?? ()
Cannot access memory at address 0x129b1a158
#1  0x0000000129b10609 in ?? ()
#2  0x000000012604f969 in atomic_exchange_and_add [inlined] () at /Library/Frameworks/Mapnik.framework/Versions/2.0/unix/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp:145
#3  0x000000012604f969 in boost::detail::sp_counted_base::weak_release () at /Library/Frameworks/Mapnik.framework/Versions/2.0/unix/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp:157
#4  0x000000012604f969 in boost::detail::sp_counted_base::release () at /Library/Frameworks/Mapnik.framework/Versions/2.0/unix/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp:146
#5  0x000000012604f969 in ~shared_ptr [inlined] () at sp_counted_base_gcc_x86.hpp:217
#6  0x000000012604f969 in ~shared_count [inlined] () at /Library/Frameworks/Mapnik.framework/Versions/2.0/unix/include/boost/smart_ptr/shared_ptr.hpp:244
#7  0x000000012604f969 in mapnik::feature_style_processor >::apply_to_layer (this=0x125483cc0, lay=@0x1008967e0, p=@0x125483cc0, proj0=, scale_denom=17061.836670810801) at sp_counted_base_gcc_x86.hpp:169
#8  0x000000012604fc10 in mapnik::feature_style_processor >::apply (this=) at feature_style_processor.hpp:114
#9  0x000000012600c430 in Map::EIO_Render (req=) at ../src/mapnik_map.cpp:635
#10 0x000000010002c9c2 in etp_proc (thr_arg=) at ../deps/libeio/eio.c:1693
#11 0x00007fff86f7a4f6 in _pthread_start ()
#12 0x00007fff86f7a3a9 in thread_start ()

Thread 2 (process 55400):
#0  0x00007fff86f7bf8a in __semwait_signal ()
#1  0x00007fff86f7fda1 in _pthread_cond_wait ()
#2  0x000000010002c607 in etp_proc (thr_arg=) at ../deps/libeio/eio.c:1490
#3  0x00007fff86f7a4f6 in _pthread_start ()
#4  0x00007fff86f7a3a9 in thread_start ()

Thread 1 (process 55400):
#0  0x00007fff5fc1face in __dyld_munmap ()
#1  0x00007fff5fc136f2 in __dyld__ZN26ImageLoaderMachOCompressedD0Ev ()
#2  0x00007fff5fc04bad in __dyld__ZN4dyld20garbageCollectImagesEv ()
#3  0x00007fff5fc09e9a in __dyld_dlclose ()
#4  0x00007fff86f48b85 in dlclose ()
#5  0x00000001257ebccd in dlopen_LTX_get_vtable ()
#6  0x00000001257e91a9 in lt_dlclose ()
#7  0x00000001262aef01 in mapnik::PluginInfo::~PluginInfo ()
#8  0x00000001261d713a in boost::detail::sp_counted_impl_p::dispose ()
#9  0x00000001261d79ac in std::_Rb_tree >, std::_Select1st > >, std::less, std::allocator > > >::_M_erase ()
#10 0x00000001263428b1 in __tcf_5 ()
#11 0x00007fff86f53894 in __cxa_finalize ()
#12 0x00007fff86f537ac in exit ()
#13 0x000000010000660a in node::FatalException (try_catch=@0x7fff5fbfe750) at ../src/node.cc:1434
#14 0x0000000100006888 in node::Tick () at ../src/node.cc:216
#15 0x0000000100030a35 in ev_invoke_pending () at ../deps/libev/ev.c:1997
#16 0x0000000100034583 in ev_loop (flags=) at ../deps/libev/ev.c:2271
#17 0x00000001000043ef in node::Loop (args=) at ../src/node.cc:1025
#18 0x0000000100084864 in v8::internal::Builtin_HandleApiCall ()
Previous frame inner to this frame (gdb could not unwind past this frame)

Render to PDF

As we discussed, we'd like to get direct access to outputting pdf, svg, and other cairo supported formats from node-mapnik. Not sure what the API will look like, if possible it would be great to hook into either .render_to_file() and/or .render_to_string().

generate_hit_grid tweaking

Currently generate_hit_grid has the signature

 generate_hit_grid(layer_idx, step, join_field) -> rle-encoded string

We're aiming to abandon the join_field concept and RLE - outputting an array of object indexes (the index of the given shape in a shapefile or datasource). Does this seem viable?

hangs under high seeding load

Seeing hangs in tilemill under high load while seeding tiles. Current hunch is that grid_renderer bugs are the culprit as they are seen in action in various backtraces. These are backtraces captured after segfaults in seeding in one process on ubuntu 10.10:

https://gist.github.com/871428

npm package.json needs to be corrected

npm install mapnik
Password:
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm info fetch http://registry.npmjs.org/mapnik/-/mapnik-0.2.10.tgz
npm info calculating sha1 /tmp/npm-1299008942231/1299008942231-0.32237716135568917/tmp.tgz
npm info shasum 0f9fbbaf8e01b73ca5373925f4a5dcd361f8180d
npm ERR! couldn't read package.json in /tmp/npm-1299008942231/1299008942231-0.32237716135568917/contents/package
npm ERR! Error installing [email protected]
npm ERR! Error: Failed to parse json
npm ERR! Unexpected token ILLEGAL
npm ERR!     at jsonParseFail (/usr/local/lib/node/.npm/npm/0.3.7/package/lib/utils/read-json.js:89:11)
npm ERR!     at /usr/local/lib/node/.npm/npm/0.3.7/package/lib/utils/read-json.js:82:14
npm ERR!     at P (/usr/local/lib/node/.npm/npm/0.3.7/package/lib/utils/read-json.js:62:40)
npm ERR!     at cb (/usr/local/lib/node/.npm/npm/0.3.7/package/lib/utils/graceful-fs.js:31:9)
npm ERR!     at [object Object]. (fs.js:86:5)
npm ERR!     at [object Object].emit (events.js:39:17)
npm ERR!     at afterRead (fs.js:843:12)
npm ERR! JSON.parse 
npm ERR! JSON.parse Failed to parse package.json data.
npm ERR! JSON.parse Note that package.json must be actual JSON, not
npm ERR! JSON.parse just a JavaScript object.
npm ERR! JSON.parse 
npm ERR! JSON.parse This changed in npm 0.3.0, and is not a bug in npm.
npm ERR! JSON.parse Tell the package author to fix their package.json file.
npm ERR! JSON.parse
npm ERR! System Darwin 10.6.0
npm not ok

Support MetaWriters

It would be super-useful if node-mapnik supported MetaWriters, as an additional argument to the callback of .render() or something similar, depending on what's right from the perspective of the API.

double free

During an extended benchmark, I got a random

node(14883,0x128a87000) malloc: *** error for object 0x100816a00: double free
*** set a breakpoint in malloc_error_break to debug

I realize this isn't very helpful information, but this occurs very infrequently (less than 1 in 100k tiles), so using gdb isn't really viable here :/

Support fetching only select features

map.features(), layer.features(), and datasource.features() all pull everything. That function should take further arguments of the index of the first and last feature desired. Since we don't know the length of features before querying them features(10,0) will return all features except the first 10.

And features(0,0) will also return ALL features, while features(0,10) would return first ten, and features(10,20) would return second ten or only 5 if the total available were only 15.

datasource.features() summary/inspection

A common use case (according to aj) is to know the min/max numbers (or shortest/longest strings) for a certain column. We're currently doing this outside of node-mapnik, we should evaluate whether it makes sense to do this within node-mapnik.

generate_hit_grid is slow

I could be wrong but this looks like it is related to the fact that we cannot efficiently retrieve features for a given bounding box. Generating a hit grid for a single 256x256 tile with just a couple of features can take seconds and I think it is because we're retrieving all datasource features at once for this.

Related: we'll need some exposed way of retrieving a subset of datasource features, limited by a given bounding box (e.g. the map zoom extent) in order to grab the metadata associated with grid features.

Error building node-mapnik on Mac OS X (10.6.7)

I've found problems building node-mapnik from source using both npm (npm install -g mapnik) or make.

In both cases, it seems to be a problem trying to find _mapnik/grid/grid_view.hpp:

In file included from ../src/node_mapnik.cpp:25:
../src/mapnik_grid_view.hpp:7:37: error: mapnik/grid/grid_view.hpp: No such file or directory
In file included from ../src/node_mapnik.cpp:25:
../src/mapnik_grid_view.hpp:14: error: ‘grid_view’ is not a member of ‘mapnik’
../src/mapnik_grid_view.hpp:14: error: ‘grid_view’ is not a member of ‘mapnik’
../src/mapnik_grid_view.hpp:14: error: template argument 1 is invalid
../src/mapnik_grid_view.hpp:14: error: invalid type in declaration before ‘;’ token
In file included from ../src/node_mapnik.cpp:25:
../src/mapnik_grid_view.hpp:7:37: error: mapnik/grid/grid_view.hpp: No such file or directory
In file included from ../src/node_mapnik.cpp:25:
../src/mapnik_grid_view.hpp:14: error: ‘grid_view’ is not a member of ‘mapnik’
../src/mapnik_grid_view.hpp:14: error: ‘grid_view’ is not a member of ‘mapnik’
../src/mapnik_grid_view.hpp:14: error: template argument 1 is invalid
../src/mapnik_grid_view.hpp:14: error: invalid type in declaration before ‘;’ token

Details can be found here: https://gist.github.com/1059542, https://gist.github.com/1059555

The environment:

Hardware: 8-core 64-bit
OS X: 10.6.7
Kernel Architecture: x86_64
Ruby: 1.8.7-174
/usr/bin/ruby => /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
Xcode: 4.0.2
GCC-4.0: N/A
GCC-4.2: build 5666
LLVM: build 2335

geojson files and 'id'

The ogr driver autodetects geojson properties named "id" and uses this as the OGR feature id, no matter if it is a string, which can lead to odd results. It also means that mapnik no longer reports the "id" field as available in the attributes list, which sucks.

This is not an issue in node-mapnik, but a workaround might be had here to avoid this pain point in the context of grid output.

configure && make should reflect changes in the directory name

git clone git://github.com/mapnik/node-mapnik.git && cd node-mapnik && ./configure && make && cd .. && mv node-mapnik node-bla && cd node-bla && ./configure && make

Should reveal a problem with the configure script you are using. Removing the hidden wc_lock file (don't know the name) does not help.

Reduce amount of memcpy()

Node's Buffer interface supports a way to declare an existing block of memory as a buffer, but it requires a free callback. This may be tricky to implement.

when statically linked to libmapnik.a Image.open() fails

New tilemill osx app statically links libmapnik.a. It appears that this kind of linking breaks the dynamic image_reader registration in mapnik. It is unclear whether this just affects the bindings open() or also images loaded via loading xml.

d:node-mapnik2 dane$ make test

   image.test.js test images: TypeError: Failed to load: tests/tmp/image.png
    at /Users/dane/projects/node-mapnik2/tests/image.test.js:31:15
    at next (/Users/dane/.nvm/v0.4.10/lib/node_modules/expresso/bin/expresso:853:25)
    at runSuite (/Users/dane/.nvm/v0.4.10/lib/node_modules/expresso/bin/expresso:871:6)
    at check (/Users/dane/.nvm/v0.4.10/lib/node_modules/expresso/bin/expresso:775:16)
    at runFile (/Users/dane/.nvm/v0.4.10/lib/node_modules/expresso/bin/expresso:779:10)
    at Array.forEach (native)
    at runFiles (/Users/dane/.nvm/v0.4.10/lib/node_modules/expresso/bin/expresso:756:13)
    at run (/Users/dane/.nvm/v0.4.10/lib/node_modules/expresso/bin/expresso:724:5)
    at Object.<anonymous> (/Users/dane/.nvm/v0.4.10/lib/node_modules/expresso/bin/expresso:939:13)
    at Module._compile (module.js:402:26)

Option for including full features in render_grid()

For live serving of grid data it would be great to have the full feature JS objects included from the result of render_grid(). Should this be an additional argument? e.g.

map.render_grid(0, 4, 'FIPS', true, function(err, grid) {
    console.log(grid);
    // { grid: {}, keys: {}, data: {} }
});

map.render_grid(0, 4, 'FIPS', function(err, grid) {
    console.log(grid);
    // { grid: {}, keys: {} }
});

If it is not expensive to do this it might be reasonable to always include data and those who don't need it can throw it out or ignore it.

The data key should be an object with keys matching the the values of keys and objects including the full feature data.

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.