You are not logged in.

Announcement

*** NOTICE: forum.openstreetmap.org is being retired. Please request a category for your community in the new ones as soon as possible using this process, which will allow you to propose your community moderators.
Please create new topics on the new site at community.openstreetmap.org. We expect the migration of data will take a few weeks, you can follow its progress here.***

#1 2017-01-18 16:56:06

biliuta
Member
Registered: 2017-01-18
Posts: 3

Add postgis database information to xml generated by carto

I'm a noob regarding mapnik and GIS systems in general. I have installed the latest mapnik renderer fallowing the information on their website and exported a .pbf file to a local PostGis DB using this command:

osm2pgsql --style ../openstreetmap-carto/openstreetmap-carto.style --create --database gis -U maps -W -H 192.168.220.137 bucharest.osm.pbf

After this I generated a XML style sheet using

carto -a "3.0.0" ../openstreetmap-carto/project.mml > mapnik.xml

Now I would like to use this mapnik.xml in a python script to render a part of the exported map from PostGIS as a test.

#!/usr/bin/env python

from mapnik import *

mapfile = 'mapnik.xml'
map_output = 'mymap33.png'

m = Map(2048, 2048)
load_map(m, mapfile)
bbox=(Box2d( 26.08901,44.420234,26.125488,44.435067))

#m.zoom_to_box(bbox) 
render_to_file(m, map_output)

The problem is that the mapnik.xml has no information about my PostGIS DB (I looked in the file and I saw a lot of queries in element but no host name, user name or password). How do I add more info about my PostGIS DB to this style sheet?

Offline

#2 2017-01-19 16:36:23

biliuta
Member
Registered: 2017-01-18
Posts: 3

Re: Add postgis database information to xml generated by carto

Solved this problem using env variables https://www.postgresql.org/docs/current … nvars.html
But now I get some xml parsing errors:

Mapnik LOG> 2017-01-19 05:47:47: Unable to process some data while parsing 'mapnik.xml':
* attribute 'minimum-scale-denominator' with value '750000' at line 0
* attribute 'maximum-scale-denominator' with value '750000' at line 0
* attribute 'maximum-scale-denominator' with value '3000000' at line 0
* attribute 'minimum-scale-denominator' with value '750000' at line 0
* attribute 'maximum-scale-denominator' with value '500000000' at line 0
* attribute 'minimum-scale-denominator' with value '50000000' at line 0
* attribute 'maximum-scale-denominator' with value '6500000' at line 0
* attribute 'minimum-scale-denominator' with value '750000' at line 0
* attribute 'maximum-scale-denominator' with value '750000' at line 0
* attribute 'maximum-scale-denominator' with value '50000' at line 0
* attribute 'maximum-scale-denominator' with value '100000' at line 0
* attribute 'maximum-scale-denominator' with value '3000000' at line 0
* attribute 'minimum-scale-denominator' with value '200000' at line 0
* attribute 'maximum-scale-denominator' with value '50000000' at line 0
* attribute 'maximum-scale-denominator' with value '50000000' at line 0

So far I traced the error to this function in load_map.cpp : void map_parser::find_unused_nodes_recursive(xml_node const& node, std::string & error_message)

I got stuck and don't know how to continue .... any suggestions ?

Offline

Board footer

Powered by FluxBB