Create a map with local OpenStreetMap -
OpenStreetMap maps can be inserted into its site available online or recreating TILE through software that make up the render to be poi consultabili in locale senza aver la necessità di una connessione ad internet.
-
-
- Mettiamo ad esempio il caso che questo servizio ci serva per la creazione di uno strumento interattivo per musei e che il museo non possegga una connessione ad internet per l'integrazione di questo servizio (faccio questo esempio perché mi è capitato), in questo caso basta fare una copia in locale della porzione di mappa che ci interessa.
-
-
Questo è quello che cercherò di mostrarvi oggi!!! -
Per prima cosa è necessario scaricare e installare i seguenti software:
http://www.postgresql.org/download/ )
molto semplice da installare per ulteriori informazioni sull'installazione consultate il seguente link:
http://database.html.it/articoli/leggi/1689/postgresql-su-windows-procedura-di-installazione/
Una volta installato andate in start - > programmi -> PostgreSQL 8.4 aprite l'applicazione "Application Stack Builder" e scaricate l'estensione Postgis che si trova sotto la voce "spatial extensions".
Ora inserite il programmino osm2pgsql.exe ( - http://artem.old-dev.openstreetmap.org/files/ not download the zipped) inside the folder "bin" which is located at: C: \\ Program Files \\ PostgreSQL \\ 8.4 \\
python2.5
NB install python2.5 and earlier versions
Mapnik 0.6.1 which is our render engine
http://media.mapnik.org/mapnik_0.6.1-win32_py25.zip -
Ora convertiremo il file OSM (che è un file di backup del database di OpenStreetmap) in un database con estensione geografica.
Creeremo un nuovo ruolo all'interno di Postgres a cui daremo il nome dell'account windows e un nuovo database di nome 'gis'.
In privilegi di ruolo spunteremo tutto
Let's create the database:
We will go on the database (key right) -> new database
Name: gis
Owner: role name created before
Encoding: UTF8
Model: template_postgis
Tablespace: pg_default
will add some requirements to the database via a query:
GRANT ALL ON DATABASE gis TO public; TO GRANT ALL ON DATABASE gis "windows account" COMMENT ON DATABASE gis
IS 'MDGs'; -
-
-
-
-
-
The next step is going to change the pg_hba.conf file so that access to the server can be done without using a password, otherwise the special software osm2psql not be able to access it.
File-> Open pg_hba.conf
select the file in my case has the following path:
C: \\ Program Files \\ PostgreSQL \\ 8.4 \\ data Once opened, we modify the method in 'trust' and we reload the server.
At this point you have to download the MDGs which will contain all information about nodes, ways and relations between them the entire planet or one area that you will render. Here
files MDGs:
http://debian.gfoss.it/maps/
http://planet.openstreetmap.org/planet-latest.osm.bz2
Downloaded the file just start the DOS command osm2pgsql, for example, if the special software is located at: C: \\ Program Files \\ PostgreSQL \\ 8.4 \\ bin
Just run the following commands DOS:
cd C: \\ Program Files \\ PostgreSQL \\ 8.4 \\ bin osm2pgsql.exe-v E: \\ Openstreetmap \\ planet.osm
This data will be loaded within the database you created earlier.
With the use of the database had been created, you can render the tiles.
To do this you need to install python2.5 and Mapnik:
First, install Python is an executable and do not need an explanation for the installation
Once installed python you follow the steps described on this page to install Mapnik:
http://trac.mapnik.org/wiki/WindowsInstallation
A questo punto
creeremo una nuova cartella all'interno di mapnik di nome 'osm' con all'interno:
- Una cartella di nome boundaries che conterrà i file presenti negli archivi 'processed_p.zip' e 'world_boundaries-spherical.tgz'
Scaricabili dai seguenti siti:
http://hypercube.telascience.org/~kleptog/processed_p.zip
http://tile.openstreetmap.org/world_boundaries-spherical.tgz
Una cartella vuota di nome 'tiles' che sarà poi riempita dai tiles che si andranno a renderizzare.
Una cartella 'symbols' in cui copieremo tutti quei simboli usati durante il render per creare strade punti di interesse etc.
- I simboli si trovano all'interno del sito:
http://svn.openstreetmap.org/applications/rendering/mapnik/symbols
All'interno della cartella 'osm' copieremo i file python di configurazione (generate_tiles.py, set-mapnik-env, osm-template.xml, customize-mapnik-map) scaricabili dal seguente sito:
http://svn.openstreetmap.org/applications/rendering/mapnik/
Modificheremo i file di configurazione a seconda delle nostre esigenze come descrittoci all'interno dei file readme.txt This site
If you were not able to configure the python file with just use one of the many editors to replace the file osm-template. xml variables with our data.
For example:
SYMBOLS_DIR = C: / mapnik-0_5_1/osm/symbols
WORLD_BOUNDARIES_DIR = C: / mapnik-0_5_1/osm/boundaries
dbhost = "localhost"
DBPORT = "5432"
DBNAME = 'gis'
Sym `dbuser =`
DBPASS = ""
PREFIX = "planet_osm"
After replacing these variables with your data, you will need to change some things in the file generate_tiles.py:
bottom of the file instead of:
if __name__ == "__main__":
home = os.environ ['HOME']
try:
mapfile = os.environ [ 'MAPNIK_MAP_FILE'] except KeyError
: mapfile = home + "/ osm-local.xml"
try:
tile_dir = os.environ ['MAPNIK_TILE_DIR'] except KeyError
: tile_dir = home + "/ osm / tiles /"
must enter for example:
if __name__ == " __main__ ":
home =" C: / mapnik_0_6_1/osm "
mapfile = home +" / osm-template.xml "
tile_dir = home +" / tiles / "
After all this will be possible to start the script generate_tiles.py
The comments are welcome FOR ANY CORRECTIONS AND UPDATES ON THIS TOPIC. FOR ANY DIFFICULTIES 'SARO' very glad to where I will be 'POSSIBLE.