Konfigurationsprobleme Mapnik/PostgreSQL (Linux)
Geschrieben von rayquaza (Gast) am 05. Januar 2013 19:59:46: [flux]
Ich versuche seit einigen Tagen Mapnik auf meinem ArchLinux zum Kachelrendern zu bringen - bisher leider relativ erfolglos.
Inzwischen habe ich es soweit geschaft, dass mir aus einer OSM-Datei (Geofabrik-Extract "Regierungsbezirk Karlsruhe") alle railway=*-Ways gezeichnet werden, aber auch dabei passt irgendwas noch nicht:
Die schwarzen Linien meiner Tiles sollten identisch mit denen der Gravitystorm Transport Map sein. Der Python-Code den ich dazu genutzt habe ist folgender:
#!/usr/bin/env␣python2
#␣BASF: left␣␣␣=␣8.4046 bottom␣=␣49.5254 right␣␣=␣8.426 top␣␣␣␣=␣49.546
minzoom=␣15 maxzoom=␣16
mapfile␣=␣'style.xml'
from␣mapnik␣import␣* from␣time␣import␣gmtime,␣strftime import␣os import␣math def␣latlon2tilenum(lat_deg,␣lon_deg,␣zoom): lat_rad␣=␣math.radians(lat_deg) n␣=␣2.0␣**␣zoom xtile␣=␣int((lon_deg␣+␣180.0)␣/␣360.0␣*␣n) ytile␣=␣int((1.0␣-␣math.log(math.tan(lat_rad)␣+␣(1␣/␣math.cos(lat_rad)))␣/␣math.pi)␣/␣2.0␣*␣n) return␣(xtile,␣ytile) def␣tilenum2latlon(xtile,␣ytile,␣zoom): n␣=␣2.0␣**␣zoom lon_deg␣=␣xtile␣/␣n␣*␣360.0␣-␣180.0 lat_rad␣=␣math.atan(math.sinh(math.pi␣*␣(1␣-␣2␣*␣ytile␣/␣n))) lat_deg␣=␣math.degrees(lat_rad) return␣(lat_deg,␣lon_deg)
for␣Z␣in␣range(minzoom,␣maxzoom): mintile␣=␣latlon2tilenum(top,␣␣␣␣left,␣␣Z) maxtile␣=␣latlon2tilenum(bottom,␣right,␣Z)
for␣␣X␣␣in␣␣range(mintile[0],␣maxtile[0]): for␣Y␣in␣range(mintile[1],␣maxtile[1]): if␣not␣os.path.exists('tiles/'␣+␣str(Z)␣+␣'/'␣+␣str(X)): os.makedirs('tiles/'␣+␣str(Z)␣+␣'/'␣+␣str(X)) map_output␣=␣'tiles/'␣+␣str(Z)␣+␣'/'␣+␣str(X)␣+␣'/'␣+␣str(Y)␣+␣'.png' m␣=␣Map(256,256) load_map(m,mapfile) bbox=(Envelope( tilenum2latlon(X,Y,Z)[1], tilenum2latlon(X+1,Y+1,Z)[0], tilenum2latlon(X+1,Y+1,Z)[1], tilenum2latlon(X,Y,Z)[0]␣)) m.zoom_to_box(bbox) render_to_file(m,map_output) print␣strftime("%Y-%m-%d␣%H:%M:%S",␣gmtime()),":␣Kachel␣fertig:␣",Z,",",X,",",Y
print␣"Kacheln␣fertig␣erstellt.␣Scale:␣",␣m.scale()
Style.xml (Ausschnitt):
<?xml␣version="1.0"␣encoding="utf-8"?> <!--<Map␣background-color="#f2efe9"␣srs="+proj=latlong␣+datum=WGS84">--> <Map␣srs="+proj=latlong␣+datum=WGS84"> <FontSet␣name="book-fonts"> <Font␣face-name="DejaVu␣Sans␣Book"␣/> </FontSet> <Style␣name="highways"> <Rule> <Filter>[railway]␣>␣''</Filter> <LineSymbolizer␣stroke="#f00"␣stroke-width="1"/> </Rule> <Rule> <Filter>[railway]␣=␣'rail'</Filter> <LineSymbolizer␣stroke="#000"␣stroke-width="2"␣stroke-linejoin="round"␣stroke-linecap="round"/> </Rule> </Style> <Layer␣name="highways"␣status="on"␣srs="+proj=latlong␣+datum=WGS84"> <StyleName>highways</StyleName> <Datasource> <Parameter␣name="type">osm</Parameter> <Parameter␣name="file">render.osm</Parameter> </Datasource> </Layer> </Map>
Da die Gerüchte über einen Geschwindigkeitsvorteil bei Nutzung einer Datenbank wahrscheinlich stimmen möchte ich die Daten eigentlich in einer solchen speichern. Ich habe daher folgendes versucht:
• PostGIS (und damit auch PostgreSQL) wurde bereits als Abhängigkeit von Mapnik installiert
• osm2pgsql aus dem AUR installiert
• sudo su postgres
• initdb -D /usr/local/pgsql/data
• pg_ctl start -D /usr/local/pgsql/data
• createuser ray
Wenn ich dann (wieder als normaler Benutzer) versuche, die OSM-Daten zu importieren erhalte ich folgendes:
[ray@systemname␣~]$␣osm2pgsql␣render.osm osm2pgsql␣SVN␣version␣0.81.0␣(64bit␣id␣space)
Using␣projection␣SRS␣900913␣(Spherical␣Mercator) Setting␣up␣table:␣planet_osm_point HINWEIS:␣␣Tabelle␣»planet_osm_point«␣existiert␣nicht,␣wird␣übersprungen HINWEIS:␣␣Tabelle␣»planet_osm_point_tmp«␣existiert␣nicht,␣wird␣übersprungen SELECT␣AddGeometryColumn('planet_osm_point',␣'way',␣900913,␣'POINT',␣2␣); failed:␣FEHLER:␣␣Funktion␣addgeometrycolumn(unknown,␣unknown,␣integer,␣unknown,␣integer)␣existiert␣nicht LINE␣1:␣SELECT␣AddGeometryColumn('planet_osm_point',␣'way',␣900913,␣... ^ HINT:␣␣Keine␣Funktion␣stimmt␣mit␣dem␣angegebenen␣Namen␣und␣den␣Argumenttypen␣überein.␣Sie␣müssen␣möglicherweise␣ausdrückliche␣Typumwandlungen␣hinzufügen.
Error␣occurred,␣cleaning␣up
Was mache ich falsch?
mfg~ray
Antworten:
- Re: Konfigurationsprobleme Mapnik/PostgreSQL (Linux) · maxbe (Gast) · 05.01.2013 23:30 [flux]
- Re: Konfigurationsprobleme Mapnik/PostgreSQL (Linux) · rayquaza (Gast) · 05.01.2013 23:45 [flux]
- Re: Konfigurationsprobleme Mapnik/PostgreSQL (Linux) · maxbe (Gast) · 06.01.2013 00:00 [flux]
- Re: Konfigurationsprobleme Mapnik/PostgreSQL (Linux) · rayquaza (Gast) · 06.01.2013 00:36 [flux]
- Re: Konfigurationsprobleme Mapnik/PostgreSQL (Linux) · wambacher (Gast) · 06.01.2013 00:44 [flux]
- Re: Konfigurationsprobleme Mapnik/PostgreSQL (Linux) · rayquaza (Gast) · 06.01.2013 00:50 [flux]
- Re: Konfigurationsprobleme Mapnik/PostgreSQL (Linux) · Balgofil (Gast) · 06.01.2013 14:45 [flux]
- Re: Konfigurationsprobleme Mapnik/PostgreSQL (Linux) · rayquaza (Gast) · 06.01.2013 17:46 [flux]
- Re: Konfigurationsprobleme Mapnik/PostgreSQL (Linux) · ikonor (Gast) · 06.01.2013 18:34 [flux]
- Re: Konfigurationsprobleme Mapnik/PostgreSQL (Linux) · Balgofil (Gast) · 07.01.2013 19:07 [flux]
- Re: Konfigurationsprobleme Mapnik/PostgreSQL (Linux) · rayquaza (Gast) · 07.01.2013 21:21 [flux]
- Re: Konfigurationsprobleme Mapnik/PostgreSQL (Linux) · Balgofil (Gast) · 08.01.2013 16:58 [flux]
- Re: Konfigurationsprobleme Mapnik/PostgreSQL (Linux) · rayquaza (Gast) · 10.01.2013 05:09 [flux]
- Re: Konfigurationsprobleme Mapnik/PostgreSQL (Linux) · okilimu (Gast) · 10.01.2013 07:46 [flux]
- Re: Konfigurationsprobleme Mapnik/PostgreSQL (Linux) · rayquaza (Gast) · 10.01.2013 09:15 [flux]