node-mapnik-sample-code icon indicating copy to clipboard operation
node-mapnik-sample-code copied to clipboard

Cannot get tile example to work with postgis

Open hallahan opened this issue 11 years ago • 6 comments
trafficstars

I have gotten node-mapnik to work, and the example that generates the map.png with the world shapefile is fine.

When trying to use the tile example, however, it is not connecting to a postgres database that i have tested to work. When doing a request for a tile I get the following response:

screenshot 2014-02-07 14 18 58

When installing mapnik, I did specify --with-postgis

I'm wondering if I still am having issues due to the fact that I installed mapnik via the pkg at one point.

The postgis database is on amazon and is a production server that is reliable.

hallahan avatar Feb 07 '14 22:02 hallahan

Add mapnik.register_datasource(path.join(mapnik.settings.paths.input_plugins,'postgis.input')); or just mapnik.register_default_input_plugins() at the top of the js code. The reason is that you are running latest node-mapnik and the examples have not been updated to account for this breaking change: https://github.com/mapnik/node-mapnik/commit/ef06b6f171da1ebac2c048cb85b8b2729aac38a6

springmeyer avatar Feb 07 '14 22:02 springmeyer

btw, you might be interested in https://github.com/springmeyer/coalition. It is the first iteration of what later turned into the cartodb tile api.

springmeyer avatar Feb 07 '14 22:02 springmeyer

Hmm, I get:

/Users/nick/node-mapnik-sample-code/tile/database/app.js:19
mapnik.register_datasource(path.join(mapnik.settings.paths.input_plugins,'post
       ^
TypeError: Object #<Object> has no method 'register_datasource'

and mapnik.register_default_input_plugins() just gives me the same problem.

hallahan avatar Feb 08 '14 00:02 hallahan

Oh, so I guess I thought wrong. If you don't have the function mapnik.register_datasource then your node-mapnik is not bleeding edge. So then you must actually be missing the Mapnik postgis plugin. It is called postgis.input and should be located in this directory:

ls -l `mapnik-config --input-plugins`

If you are still on OS X then brew install mapnik should build the postgis.input by default if postgresql is installed. Otherwise you need to do brew install mapnik --with-postgresql as is visible if you do brew info mapnik.

springmeyer avatar Feb 08 '14 00:02 springmeyer

I actually reinstalled everything from a fresh OS X image, and I'm getting the same problem. When I list input plugins, I have:

Nicholass-MacBook-Pro:node-mapnik-sample-code nick$ ls -l `mapnik-config --input-plugins`
total 3384
-r--r--r--  1 nick  staff  287544 Feb  9 20:42 csv.input
-r--r--r--  1 nick  staff  182004 Feb  9 20:42 gdal.input
-r--r--r--  1 nick  staff  157548 Feb  9 20:42 geojson.input
-r--r--r--  1 nick  staff  204244 Feb  9 20:42 ogr.input
-r--r--r--  1 nick  staff  268432 Feb  9 20:42 raster.input
-r--r--r--  1 nick  staff  332568 Feb  9 20:42 shape.input
-r--r--r--  1 nick  staff  283968 Feb  9 20:42 sqlite.input

I did flag the --with-postgresql I did this before actually installing Postgres. I was thinking that this would actually install Postgres for me, but it appears that it did not. I then installed via postgresapp.com.

hallahan avatar Feb 10 '14 05:02 hallahan

Looking at brew info mapnik, I have an x by the postgresql. What can I do after the fact to install postgres support after it's been installed? Perhaps I should brew uninstall mapnik and then reinstall?

hallahan avatar Feb 10 '14 06:02 hallahan