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

Artem Pavlenko artem at mapnik.org
Thu Mar 8 19:44:07 GMT 2007


Hi Nick,
You're loading map which is Mercartor projection, you should either  
change osm.xml to have : +proj=latlong +datum=WGS84 or change your  
query bounging box to something more appropriate (in meters).

If you have mapnik-python installed you could try something like this  
to convert lat/long :


 >>> from mapnik import *
 >>> p = Projection("+proj=merc +datum=WGS84")
 >>> p.forward(Coord(<your_lon>,<your_lat>))

...

HTH
Cheers
Artem

On 8 Mar 2007, at 19:33, Nick Whitelegg wrote:

> 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