Skip to content
Jacolin edited this page Aug 10, 2018 · 7 revisions

DON'T change ANYTHING here as this page will be included into the MapServer Documentation.

see https://mapserver.org/basemaps/

Install

Data

Database Cration

$ sudo -u postgres createdb osm
$ sudo -u postgres psql -d osm -c "CREATE EXTENSION postgis;"
$ sudo -u postgres createuser -D -l -R -S -P "www-data"
$ sudo -u postgres psql -d osm -c 'GRANT ALL ON ALL TABLES IN SCHEMA public TO "www-data";'

Imposm Installation

Source: http://imposm.org/docs/imposm/latest/install.html

$ cd # switch to user home
$ mkdir osm_pbf
$ cd osm_pbf
$ sudo apt-get install build-essential python-dev  protobuf-compiler libprotobuf-dev libtokyocabinet-dev python-psycopg2 libgeos-c1
$ virtualenv venv
$ venv/bin/pip install imposm

Data Import

Source: http://imposm.org/docs/imposm/latest/tutorial.html#writing

$ cd /tmp
$ wget http://download.geofabrik.de/europe/france/poitou-charentes-latest.osm.pbf
$ wget http://download.geofabrik.de/europe/france/centre-latest.osm.pbf #if you need another location
$ pwd 
/tmp/
$ ls -1
centre-latest.osm.pbf 
poitou-charentes-latest.osm.pbf
$ source venv/bin/activate
$ imposm -m /path/to/basemaps/imposm-mapping.py --read poitou-charentes-latest.osm.pbf 
$ imposm -m /path/to/basemaps/imposm-mapping.py --read --merge-cache centre-latest.osm.pbf 
$ imposm -m /path/to/basemaps/imposm-mapping.py --write -d osm --connection postgis://www-data:www-data@localhost/osm --proj EPSG:2154
$ imposm -m /path/to/basemaps/imposm-mapping.py --optimize --connection postgis://www-data:www-data@localhost/osm
# Following command is probably not useful
$ sudo -u postgres psql -d osm -c "CREATE VIEW osm_new_waterways_gen1 AS SELECT * FROM osm_new_waterways;CREATE VIEW osm_new_waterways_gen0 AS SELECT * FROM osm_new_waterways;"
$ sudo -u postgres psql -d osm -c "GRANT ALL ON ALL TABLES IN SCHEMA public TO \"www-data\";"

Project

Project source: https://github.com/mapserver/basemaps

$ cd  /var/www/somewhere/
$ git clone [email protected]:mapserver/basemaps.git
$ cd basemaps

Create your own custom makefile

$ vim aname.mk (edit the following file with custom variable):

OSM_SRID = 2154
OSM_DB_CONNECTION = host=localhost dbname=osm user=www-data password=www-data port=5432

include Makefile

Build the mapfile

$ make -f aname.mk

$ vim osm.conf
<VirtualHost *:80>                                                                                                                 
   ErrorLog ${APACHE_LOG_DIR}/osm_error.log
   CustomLog ${APACHE_LOG_DIR}/osm_access.log combined
   
   ScriptAlias /osm-default /usr/lib/cgi-bin/mapserv                                                                                
   <Location /osm-default>                                                                                                          
#    Order Deny,Allow
#    Deny from all
#    Allow from 127.0.1.1 ::1                                                                                                      
  
    SetEnv MS_MAPFILE /path/to/basemaps/osm-default.map                                    
  </Location>
</VirtualHost> 

$ cp osm.conf /etc/apache/site-available/conf/
$ sudo a2ensite osm
$ sudo /etc/init.d/apache2 graceful

http://localhost/osm-default?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities

Clone this wiki locally