[OSM-dev] Permission denied errors connecting to postgres from Mapnik

Nick Whitelegg nick at hogweed.org
Thu Mar 8 19:33:22 GMT 2007


Hello Artem and everyone,

> permission denied connecting to postgis from mapnik

OK I removed the permission denied errors by changing the host parameter to:

<Parameter name="host">/var/run/postgresql</Parameter>

Was this actually correct?

However now when I run the test render program I get an empty image.
With the postgis database, should I be using lat/lon or something else?
My code is included below. My osm.xml and pg-hba.conf files are at:

http://www.free-map.org.uk/postgis/

One day I'll get this sorted :-) I'm sure I'm just doing *something* wrong and 
after it's fixed, I'll have no further problems with this.

Thanks,
Nick

#include <mapnik/map.hpp>
#include <mapnik/layer.hpp>
#include <mapnik/envelope.hpp>
#include <mapnik/agg_renderer.hpp>
#include <mapnik/image_util.hpp>
#include <mapnik/load_map.hpp>
#include <mapnik/datasource_cache.hpp>
#include <mapnik/font_engine_freetype.hpp>

using namespace mapnik;

int main()
{

    datasource_cache::instance()->register_datasources
        ("/usr/local/lib/mapnik/input");
    freetype_engine::instance()->register_font
            ("/usr/local/lib/mapnik/fonts/Vera.ttf");
    Map m (640,480);
    load_map(m,"osm.xml");
    //Layer osmlayer = m.getLayer(0);
    //Envelope<double> bbox=osmlayer.envelope();
    Envelope<double> bbox (-0.75,51.02,-0.7,51.07);
    m.zoomToBox(bbox);

    Image32 buf (m.getWidth(), m.getHeight());
    agg_renderer<Image32> r(m,buf);
    r.apply();

    //ImageUtils::save_to_file("demo.png","png",buf);
    save_to_file<ImageData32>("demo.png","png",buf.data());

    return 0;
}




More information about the dev mailing list