View Single Post
Posts: 223 | Thanked: 323 times | Joined on Dec 2010
#6
I made a Python script that fetches and transforms map images from Kansalaisen karttapaikka and Retkikartta to Mappero suitable from. Fetching is done by using fetch_map and transforming with GDAL. The script can be used from command line or with Apache/mod_python you can use it to create tile source that can be used in Mappero. Transforming one tile takes from 3 to over 10 seconds on N900 (<1sec with 3GHz Pentium 4) so you won't probably want to set tile server running on N900 (and there isn't required version of gdal libraries in maemo repositories so you would have to compile that yourself).

Installation instructions for Linux (with Apache and mod_python already installed):
1) Install required packages proj-bin, libgdal1-1.7.0, python-gdal and python-imaging ("apt-get install proj-bin libgdal1-1.7.0 python-gdal python-imaging").
2) Download fetch_map(http://olammi.iki.fi/sw/fetch_map/download.php) and attached "map.py.gz". Gunzip and copy map.py to some dir on your web server and extract all files from fetch_map dir in fetch_map zip to same directory.
3) Change MAP_CACHE_DIR and use absolute path name(default is "./map_cache" and it doesn't work correctly with mod_python) and allow writing to that directory.
4) Now it should work. You can try to fetch a tile for example with "map.py?kkp2/7/72/36.png". Because of the transformations text in farther zoom levels is not very well readable but closer zoom levels are fine.

If installation succeeded you can add following tile sources/map repositories to Mappero (for every tile source set tile type: XYZ_INV and image type: PNG)

Kansalaisen karttapaikka
http://YourServerIP/MapDir/map.py?kkp/%0d/%d/%d.png
Zoom levels: 6-17

Kansalaisen karttapaikka2
http://YourServerIP/MapDir/map.py?kkp2/%0d/%d/%d.png
Zoom levels: 5-17

Retkikartta
http://YourServerIP/MapDir/map.py?rka/%0d/%d/%d.png
Zoom level: 8-16

Retkikartta2
http://YourServerIP/MapDir/map.py?rka2/%0d/%d/%d.png
Zoom level: 7-16

Kansalaisen karttapaikka airplane pictures
http://YourServerIP/MapDir/map.py?orto/%0d/%d/%d.png
Zoom levels: 6-17

Kansalaisen karttapaikka airplane pictures2
http://YourServerIP/MapDir/map.py?orto2/%0d/%d/%d.png
Zoom levels: 5-17

"orto" uses airplane pictures from Kansalaisen karttapaikka at closer zoom levels and farther zoom levels are same as in "kpa". In number 2 sources tiles are created from images that are zoomed in and in numberless sources tiles are created by zooming out. So 2's maybe have better quality but those also need more performance to create tiles.

---
Asennusohjeet Windowsiin:
1) Asenna Python 2.7 (http://www.python.org/ftp/python/2.7.1/python-2.7.1.msi)
2) Asenna Python Imaging Library (http://effbot.org/media/downloads/PI...in32-py2.7.exe)
3) Asenna osoitteesta (http://www.lfd.uci.edu/~gohlke/pythonlibs/) löytyvät GDAL-1.7.3.win32-py2.7.exe ja numpy-1.5.1.win32-py2.7.exe.
4) Asenna CherryPy (http://download.cherrypy.org/cherryp....1.2.win32.exe)
5) Lisää uusi järjestelmämuuttuja ( Käynnistä > Asetukset > Ohjauspaneeli > Järjestelmä > Lisäasetukset > Ympäristömuuttujat > Järjestelmämuuttujat > Uusi )
Nimi : GDAL_DATA
Arvo : "C:\Python27\Lib\site-packages\osgeo\data\gdal"
6) Muokkaa Path-järjestelmämuuttujaa lisäämällä sen arvon loppuun ";C:\Python27"
7) Kopio liitteenä oleva map-win.py.gz-tiedosto ja pura se (vaikka Winrarilla) kansioon, johon haluat skriptin asentaa (esim. c:\fmap). Tee tähän kansioon myös map_cache-niminen alikansio.
8) Kopio fetch_map (http://olammi.iki.fi/sw/fetch_map/fetch_map_v30k.zip) ja pura zipistä löytyvästä fetch_map-kansiosta kaikki tiedostot samaan kansioon, kuin edellisessä kohdassa.
9) Kopioi zippi osoitteesta (http://download.osgeo.org/proj/proj446_win32_bin.zip) ja pura proj/bin/-kansiosta proj.exe samaan kansioon kuin edellä.
10) Muokkaa map-win.py-tiedostossa rivillä 19 olevan MAP_CACHE_DIR-muuttujan arvoksi kohdassa 7 tehdyn map_cache-kansion sijanti. ( esim. MAP_CACHE_DIR = 'C:/fmap/map_cache/', huom. käytä vinoviivoja )
11) Käynnistä palvelin tuplaklikkaamalla map-win.py:tä. Jos kaikki toimii, ohjelman ikkunan pitäisi jäädä näkyviin.
12) Lisää Mapperoon muuten samat Tile/Map-repositoryt kuin Linux-ohjeessa, mutta käytä seuraavanlaisia osoitteita
Retkikartta
http://YourServerIP/fmap/rka/%0d/%d/%d.png
Retkikartta 2
http://YourServerIP/fmap/rka2/%0d/%d/%d.png
Kansalaisen karttapaikka
http://YourServerIP/fmap/kkp/%0d/%d/%d.png
jne.

Näillä ohjeilla siis pystytetään web-palvelin, josta Mappero voi hakea karttapaloja. Kun Mappero pyytää karttapalan, hakee palvelin ensin karttapalan Kansalaisen karttapaikasta/Retkikartta.fi:stä, muuntaa sen Mapperon käyttämään muotoon ja lähettää Mapperolle. Eli koneen, jossa palvelin pyörii pitää saada yhteys Internetiin ja N900:sta pitää saada yhteys palvelimeen. Palvelin kuuntelee kaikissa koneeseen asetetuissa IP-osoitteissa(portissa 80).

Esim. jos palvelin ja N900:nen on yhdistetty samaan WLAN-reitittimeen, joka sallii liikenteen siihen kytkettyjen laitteiden välillä (ja palvelinkoneessa on palomuurissa sallittu liikenne porttiin 80), pitäisi N900:sesta saada yhteys palvelimeen. Tällöin "YourServerIP"-kohtaan laitettavan IP-osoitteen saa selville (Käynnistä->Suorita->Avaa: "cmd"->OK->ipconfig).
Attached Files
File Type: gz map.py.gz (6.7 KB, 426 views)
File Type: gz map-win.py.gz (6.6 KB, 309 views)

Last edited by orava; 2010-12-19 at 20:38. Reason: windows ohjeet
 

The Following 13 Users Say Thank You to orava For This Useful Post: