MapIt - Installation and Configuration Download

Transcript
PECAS Model Development
MapIt Installation and Configuration
Tech Memo 2 – WORKING DRAFT
Calgary, Alberta
April 2012
PECAS Model Development: MapIt - Installation and Configuration
System Documentation Technical Note
File: MapIt documentation.docx
10.18.2011/ARM/GFM/JEA
1. What is MapIt?
MapIt is a tool developed by HBA Specto that provides support to a group of tasks involved in every
day PECAS modelling work. MapIt allows users to visualize PECAS model results in the form of maps
at the LUZ (land use zones) and TAZ (transportation analysis zones). MapIt runs on a webserver and
interacts with a database, so that multiple users can simultaneously use it to investigate model run
results.
Users define their own query in terms of: scenarios (one or two), which file (ActivityLocations,
ExchangeResults, others), which attributes (prices, quantities, utilities, etc.), start year and end year.
MapIt then shows a list of options depending on the file selected. For example, MapIt shows activity
groups or commodity groups based on the file previously chosen.
Two features make MapIt essential in PECAS modelling work:
 It compares the results from 2 different scenarios (for instance W00 and C01).
 It combines values from different years.
Although MapIt generates rudimentary maps, its main purpose is to combine PECAS outputs into
layers in a geodatabase and in shape files. Users can then use the GIS and visualization tools they
are comfortable with to view PECAS output.
Figure 1. MapIt interface
MapIt is used by HBA staff to build numeric comparisons between scenarios and years and store the
instructions for the comparison in the database. Users can download these comparisons as GIS
shape files, or view them from the GIS database. These comparisons are used in calibration and
development (plan an implement future changes or improvements in the models) and in policy
evaluation and analysis.
2
PECAS Model Development: MapIt - Installation and Configuration
System Documentation Technical Note
File: MapIt documentation.docx
10.18.2011/ARM/GFM/JEA
The purpose of this brief document is to describe the MapIt installation and configuration on our
client’s computer. The description includes how to get the source code, what are the prerequisite
software packagess and their corresponding installation, how to load shape files into the database,
how to configure MapIt setting files, how to create the map files for MapServer, how to configure
Apache and how to run MapIt. Figure 1 shows MapIt interface and some user options.
2. Getting the source code:
1. Install the Tortoise SVN software
2. Create a folder where you want to install the program? e.g. C:\djangoProjects
3. With the right bottom click on the folder “djangoProjects” and check out the code from SVN
Mac Users: change to your development directory and type
svn co http://svn.hbaspecto.com/svn/pecas/PECASSoftware/trunk/web_output
in terminal
You will need to write for the URL of repository:
http://svn.hbaspecto.com/svn/pecas/PECASSoftware/trunk/web_output
And for the checkout directory:
e.g. C:\djangoProjects\web_output
Figure 2. SVN Code Checkout
You will see the Tortoise copying the code to the specified folder like in this window:
3
PECAS Model Development: MapIt - Installation and Configuration
System Documentation Technical Note
File: MapIt documentation.docx
10.18.2011/ARM/GFM/JEA
Figure 3. SVN windows copying files into specified folder
And you will end up with the files and programs that you need in the following path:
C:/djangoProjects/web_output which from now will be called the “project path”
Figure 4. final content of the specified folder
3. Prerequisites Software:
1. PostgreSQL 8.4 (pgAdmin III) with PostGIS enabled. (Later versions of PostgreSQL also work,
although at this writing the latest 64 bit Windows distribution does not include the required
PostGIS library, so under Windows you have to use the 32 bit distribution if you want to use the
latest version.)
2. Python-2.66 32bit (Python 2.7 and later versions work, but Python 3.x is not compatible)
4
PECAS Model Development: MapIt - Installation and Configuration
System Documentation Technical Note
File: MapIt documentation.docx
3.
4.
5.
6.
10.18.2011/ARM/GFM/JEA
psycopg2 (e.g. for windows Psycopg2-2.0.14.win32-py2.6-pg8.4.3 )
Django 1.2.1
MapServer 2.3 (e.g. for Windows ms4w_2.3.1)
Google Visualization Python (gviz_api)
Note: You can get the all the software you need (except PostgreSQL) from:
C:\djangoProject\Web_output \SoftwareToInstall-essentials.rar
Mac Users: You can use MacPorts to install everything. Install the prerequisites for mac ports as
instructed on http://www.macports.org/ (XCode and its command line utilities.) With macports
installed you can install postgresql, except the port for postgresql does not include the required
tablefunc module. To fix this, you should first type
sudo port edit --editor "open -e" postgresql91
And find the line that begins with “set contribs”. In that line there is a list of modules, add the
tablefunc module to the list. Save the file, then you can type
sudo port install postgresql91
to install postgres, and
sudo port install postgresql91-server
sudo port load postgresql91-server
to start it running.
In this guide, we will assume that PostgreSQL is already installed, then going down the list the next
program to install is python.
3.1
Python & Psycopg
Installing python 2.6.6 and psycopg is straight forward. You only need to double click on the installer in
the SoftwareToInstall-essentials folder.
Mac Users: with macports installed, type:
sudo port install python26
and
sudo port install py26-psycopg2
Note there are python 27 versions of these, but as of this writing there is no python 27
integration with apache and mod_wsgi, so we are installing the python 26 versions.
3.2
Django 1.2
From this point many programs are going to be installed using the CMD (command prompt) and it is
recommendable to open CMD as an Administrator. One way to do this in windows vista or in windows 7
is going to the search programs and files bar, type CMD and instead of press enter, press
CTR+SHIFT+ENTER. That will launch the user account control option. Press yes and that will take you to
the CMD windows as an Administrator.
Once in the CMD, to install Django, change to C:\djangoProjects\web_output\SoftwareToInstallessentials\Django-1.2.1
5
PECAS Model Development: MapIt - Installation and Configuration
System Documentation Technical Note
File: MapIt documentation.docx
10.18.2011/ARM/GFM/JEA
Run the following command:
C:\djangoProjects\web_output\SoftwareToInstall-essentials\Django-1.2.1> C:\Python32\ python
setup.py install
Mac Users: sudo port install py26-django
As you can see it is needed to specify the path of the program we want to install, which is django.
But, also the path of python and the command “python setup.py install”.
WARNING: Make sure that the version of python used is actually the one that you installed earlier in
2.1. For more help on Django installation, please see:
http://docs.djangoproject.com/en/1.2/intro/tutorial01/#intro-tutorial01
Mac Users: to check your version of python, type
python --version
3.3
MapServer
To install MapServer, run the ms4w setup program in C:\djangoProject\web_output\SoftwareToInstallessentials\ (e.g. ms4w-3.0.4-setup.exe) and install ms4w to the C:\ drive. Then, run the following
command:
C:\ms4w> apache-install.bat
Mac Users: sudo port install mapserver +proj +postgis
For more help, please see: http://maptools.org/ms4w/index.phtml?page=README_INSTALL.html#bextracting-ms4w-for-the-first-time
WARNING: if there is any trouble please check that the comments (signed as #) inside of the file
httpd_weboutput.conf in the path C:\ms4w\httpd.d start at the beginning of the line
3.4
Gvis_api
This program is used to generate the bar charts for an individual zone. To install it, run the following
command:
C:\djangoProject\web_output\google-visualization-python> C:\Python32\ python setup.py
install
Mac Users: cd google-visualization-python; sudo python setup.py install
4. Setting up the database
You may already have a database setup, which you used for the PECAS Space Development (SD) module.
Mapit uses two schemas in the database, the “output” schema and the “analysis” schema, which can
coexist in the same database as the SD schemas. However the SD database may not have some of the
functionality (PostGIS, crosstab functions, etc.) so it is better to create a new database.
6
PECAS Model Development: MapIt - Installation and Configuration
System Documentation Technical Note
File: MapIt documentation.docx
10.18.2011/ARM/GFM/JEA
To set up a new database for MapIt, you need to follow the steps below:
1- Open the program pgAdmin. It will probably ask for the user password, which usually is
usrPostgres
2- In pgAdmin, right click on Databases icon, and choose “New Database …” option.
3- Fill in the New Database form as in the figure below. Be sure to select “ and click OK.
7
PECAS Model Development: MapIt - Installation and Configuration
System Documentation Technical Note
File: MapIt documentation.docx
10.18.2011/ARM/GFM/JEA
Figure 5. new Database forms (NEED NEW WINDOWS SCREENSHOT WITH POSTGIS_TEMPLATE)
Now that you have created (or chosen) your database for mapit, you need to
4- Right click on the newly created Database (in this case MapIt), and choose “Restore”
5- In Restore Database form, choose the C:\djangoProjects\web_output\SoftwareToInstallessentials\MapIt_DB_template.backup. It is important to check (no owner option and verbose
messages). Then, click OK. (See figure 6)
(THIS TEMPLATE HAS NO INDICES, SHOULD ONE WITH INDICES OR A SCRIPT TO CREATE THEM)
8
PECAS Model Development: MapIt - Installation and Configuration
System Documentation Technical Note
File: MapIt documentation.docx
10.18.2011/ARM/GFM/JEA
Figure 6. Restore in mapit database
When the Restore finishes, you should be able to see three (3) schemas, namely:



output: used to store the models’ run
analysis: used to store MapIt views and crosstabbed data
public: used to store the zone shapefiles (TAZ and LUZ) and some system tables
You will end up with a view as shown in Figure 7:
Figure 7. Schemas in mapit database
5. Load shapefiles to database
1- Make sure you have the shapefiles for TAZs and LUZs. They must be in WGS84 spatial reference
which is in PostGIS SRID=4326. (If not, you can convert them after, see below.)
9
PECAS Model Development: MapIt - Installation and Configuration
System Documentation Technical Note
File: MapIt documentation.docx
10.18.2011/ARM/GFM/JEA
2- Use the PostGIS shapefile loader plugin to load the shapefiles to the public schema
Figure 8. Importing shape files to PostGIS
WARNING: Depending on the version, you need to specify which file to add, specify the path and the
name of the geometry column as “the_geom” as indicated on the window, and the SRID number of
your shapefile, then press Import. You need to find the projection of your shapefile, and the
corresponding SRID. http://www.bostongis.com/PrinterFriendly.aspx?content_name=postgis_tut01 has
some information on finding an SRID. If your shapefile is not in SRID 4326, do not call the column
the_geom, rather call it the_geom_mysrid, then execute commands similar to the following (TEST THIS)
to update the projection:
select AddGeometryColumn(‘tazs’, ‘the_geom’, 4326, ‘MULTIPOLYGON, 2);
update tazs set the_geom = ST_Transform(the_geom_mysrid, 4326);
10
PECAS Model Development: MapIt - Installation and Configuration
System Documentation Technical Note
File: MapIt documentation.docx
10.18.2011/ARM/GFM/JEA
WARNING: The name of the columns with the geometry in your luzs and tazs tables should be the same
as indicated in Figure 8, “the_geom”. If they are not the same, changes should be done clicking with the
right button on the column name and going to properties to change it to “the_geom”. This is shown in
Figure 9. And the final column names are shown in Figure 10.
Figure 9. Changing the name of the column with the geometry in the luzs and tazs tables
Figure 10. Column names “the geom” for luzs and tazs
3- Apply the Land Area script: From pgAdmin 3: open and run the following SQL script:
C:\djangoProjects\web_output\SQL Changes\addLand_area to SpatialLayers.sql
4- Make note of the extent: similar to the previous step, run the query in
C:\djangoProjects\web_output\SQL Changes\calculateLayerExtent.sql
11
PECAS Model Development: MapIt - Installation and Configuration
System Documentation Technical Note
File: MapIt documentation.docx
10.18.2011/ARM/GFM/JEA
Write the resulted numbers down as you will need to put them in settings.py file
5- Each polygon in the TAZ and LUZ has to have a point associated with it for drawing charts on the
polygon. Open the query C:\djangoProjects\web_output\SQL Changes\addGraphPointGeom.sql
and run it. (If there is an error about topology, you can change the text “ST_PointOnSurface” to
“ST_Centroid”, and the graphs will appear at the centroid of the zone, which in some cases may
not be on the zone.)
[NEED TO SET COMMODITY NUMBERS, COMMODITY TYPES, ACTIVITY NUMBERS, ACTIVITY
TYPES. COMMODITYNUMBERS.CSV AND ACTIVITYNUMBERS.CSV CAN BE IMPORTED FROM
MODEL OUTPUTS, TYPES NEED TO BE DEFINED BY THE USER.]
6. Configure MapIt settings file
1- In Web_output folder, make a copy of “default_settings.py” file, and call it: mapit_settings.py
2- Edit the mapit_setting.py, and make changes as appropriate (See Appendix 1 to follow the
CHANGE ME comments highlighted in color)
3- Save and close
WARNING: The name of the database is mapit, and by default postgres is configured to not accept
connections by IP address, so if the database is on the same machine as mapit use 'localhost' as a IP
address
WARNING: in the “default_settings.py” there is a "fieldNameforJoin" that should be specified, and it
is the luz or taz number column name. This field should be integer instead of numeric. If the only
pre-existing one is numeric should be changed to integer inside of Postgres.
7. Create the Map files for MapServer
1- Edit the “mapFilesCreator.py” file in Web_output folder
2- Make sure that the script is importing mapit_setting file that was created in Section 5. In other
words, the mapFilesCreator.py must have the following line in it:
import mapit_settings as settings
3- In command prompt, run the script:
C: \dignagoProject\web_output> C:\Python32\ python mapFilesCreator.py
When mapFilesCreator runs, it will create Mapfiles for luz and taz shapefiles in specific directories.
There will be a contextlayers.map file which is empty. You can edit this file to define background layers
of situational context in mapserver layer format. Such context could include water bodies, major transit
lines and freeways.
If you want to use font symbols in this layer, edit the file
C:/djangoProjects/web_output/fontset.txt to point to the truetype fonts on your system (e.g. in the
windows system directory). Layers that you want to show up in the dot density maps should be listed in
the mapit_settings.py file as a list of comma separated layers CONTEXT_LAYERS. Keep a copy of this file
as well, as it will be overwritten if you rerun the mapFilesCreator (e.g. after upgrading your mapit
12
PECAS Model Development: MapIt - Installation and Configuration
System Documentation Technical Note
File: MapIt documentation.docx
10.18.2011/ARM/GFM/JEA
installation). (See more detail of the changes that need to be made in the Appendix 2 at the end of this
document)
8. Configure Apache
1- In C:\djangoProjects\web_output\apache folder, make a copy of “default_django.wsgi” file, and
call it: “mapit_django.wsgi”
2- Edit mapit_django.wsgi file, and make changes that reflects your new path and mapit_settings
file.
3- Save and close mapit_django.wsgi file.
4- Then, copy the httpd_weboutput.conf file from
c:/djangoProjects/web_output/apache/httpd.conf to C:\ms4w\httpd.d\httpd_weboutput.conf
and edit it.
WARNING: Comments must be at the beginning of the line in this type of file
5- Make sure that you point correctly to mapit_django.wsgi file in the following line:
WSGIScriptAlias / C:/djangoProjects/web_output/apache/django.wsgi
6- Make sure that all the paths in httpd_weboutput.conf file are correct.
7- Save and close httpd_weboutput.conf file.
8- Install mod_wsgi. Copy the appropriate mod_wsgi.so file (e.g mod_wsgi-win32-ap22py27-3.3.so
for Windows with Python 2.7) from C:/djangoProjects/SoftwareToInstall-Essentials to
c:\ms4w\Apache\modules\mod_wsgi.so . Be sure to rename the file to mod_wsgi.so after
copying it. If neither of these work (e.g. you have Python 2.6 installed on Windows) download
the appropriate mod_wsgi.so file from http://code.google.com/p/modwsgi/
WARNING: You will need to restart Apache from Windows Services after any changes made to
mapit_settings.py. If apache fails to restart from windows services, try to restart it by opening a
command prompt and running the program c:\ms4w\apache-restart.bat. If you double click on this
.bat file you will not see any error messages, so you need to start the command prompt separately,
and run the .bat from the command line.
Mac Users: Installing mapserver installs apache but does not start it, and it also does not install
mod_wsgi.
To install mod_wsgi:
sudo port install mod_wsgi
Note the following message
########################################################
# To enable mod_wsgi add
13
PECAS Model Development: MapIt - Installation and Configuration
System Documentation Technical Note
File: MapIt documentation.docx
10.18.2011/ARM/GFM/JEA
# LoadModule wsgi_module modules/mod_wsgi.so
# to your apache2 config file:
# /opt/local/apache2/conf/httpd.conf
########################################################
Edit the file /opt/local/apache2/conf/httpd.conf to make the changes suggested above, and also
add a line at the bottom
include “/<your installation directory>/httpd_weboutput.conf"
Copy the file httpd_weboutput.conf from inside the windows ms4w directory to your installation
directory, and make the necessary changes to it. Once this is done you can delete the windows
ms4w directory.
To start the apache that was installed with Mapserver, do
cd /opt/local/apache2/bin; sudo ./apachectl start
to have apache start at every boot, type
sudo launchctl load -w /Library/LaunchDaemons/org.macports.apache2.plist
If you need to restart apache (because you’ve changed the configuration files) type
sudo /opt/local/apache2/bin/apachectl restart
You may have permissions problems, do
sudo chmod -R a+rwx mapfiles/
9. Restart Apache Service
1234-
10.
Right click on My Computer, and then choose Manage.
Choose Services and Applications >> Services >> ApacheMS4WWebServer
Right click on ApacheMS4WWebServer, and choose restart
Make sure that the new status of ApacheMS4WWebServer says “Started”. If it does not start,
run the program c:\msrw\apache-restart.bat from a command prompt to see the error
message.
Mac Users: To restart apache (because you’ve changed the configuration files) type
sudo /opt/local/apache2/bin/apachectl restart
Run MapIt
If you followed this manual you should be able to access and run MapIt by typing this URL in a web
browser: http://<IP address of MapServer>/mapit.
14
PECAS Model Development: MapIt - Installation and Configuration
System Documentation Technical Note
File: MapIt documentation.docx
10.18.2011/ARM/GFM/JEA
For example, if MapServer is installed on SantaMonica (IP: 192.168.90.105). Then, MapIt URL is:
http://192.168.90.105/mapit or if MapServer is installed in your machine, then MapIt URL is
http://localhost/mapit
Appendix 1 (changes in mapit_settings.py file)
# Django settings for web_output project.
import os
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', '[email protected]'),
)
PROJECT_BASE_PATH = 'C:\djangoProjects' #CHANGE ME
PROJECT_NAME = 'web_output' #CHANGE ME
PROJECT_FULL_PATH = os.path.dirname(os.path.abspath(__file__))
MAP_SERVER_IP = "localhost" #CHANGE ME. IP Address of the machine in which MapServer is installed
MODEL_NAME = 'BALTIMORE' #CHANGE ME
MANAGERS = ADMINS
# for windows
MAPSERVERRELATIVEPATH = '../cgi-bin/mapserv.exe'
# for mac and unix
# MAPSERVERRELATIVEPATH = '../cgi-bin/mapserv'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'baltimore_db',
#CHANGE ME. Database Name
'USER': 'usrPostgres',
#CHANGE ME. User name
'PASSWORD': 'usrPostgres',
#CHANGE ME. User password
'HOST': 'localhost',
#CHANGE ME. The ip address of the database
'PORT': '5432',
#CHANGE ME. Default port is 5432
}
}
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
15
PECAS Model Development: MapIt - Installation and Configuration
System Documentation Technical Note
File: MapIt documentation.docx
10.18.2011/ARM/GFM/JEA
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'America/Chicago'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale
USE_L10N = True
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = ''
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = ''
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/media/'
# Make this unique, and don't share it with anybody.
SECRET_KEY = 'v*x*kw-yrp3cf)v)*[email protected]^#@&mo%te2ijw44fsered('
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
16
PECAS Model Development: MapIt - Installation and Configuration
System Documentation Technical Note
File: MapIt documentation.docx
10.18.2011/ARM/GFM/JEA
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)
ROOT_URLCONF = PROJECT_NAME+'.urls'
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
os.path.join(PROJECT_FULL_PATH, "templates")
)
INSTALLED_APPS = (
#'django.contrib.auth',
#'django.contrib.contenttypes',
#'django.contrib.sessions',
#'django.contrib.sites',
#'django.contrib.messages',
# Uncomment the next line to enable the admin:
# 'django.contrib.admin',
PROJECT_NAME+'.mapit',
#'output',
)
"""
The application specific parameters start here
Modify as suitable...
"""
PGPATH="C:/Program Files (x86)/PostgreSQL/8.4/bin/"
#PGPATH ="D:/Program Files/PostgreSQL/9.0/bin/" #CHANGE ME. PostgreSQL bin forlder path
OUTPUT_FILES_SCHEMA = "output" #Default
ANALYSIS_SCHEMA = r"analysis" #Default
LUZ
= {"layerName"
: "luzs_4326", #CHANGE ME. LUZ layer name
"fieldNameforJoin" : "luz_num", #CHANGE ME. luz number column name
"pkField"
: "gid",
#Default. Primary key of the luz shapefile
"landAreaField" : "land_area", #Default. land_area column
"geomtryField" : "the_geom", # TODO: Hardcoded in map_details query. Don't change
this.
"SRID"
}
TAZ
: "4326", # recommended for OpenLayers performance. Don't change this.
= {"layerName"
: "tazs_4326", #CHANGE ME. TAZ layer name
17
PECAS Model Development: MapIt - Installation and Configuration
System Documentation Technical Note
File: MapIt documentation.docx
10.18.2011/ARM/GFM/JEA
"fieldNameforJoin" : "taz_num", #CHANGE ME. taz number column name
"pkField"
: "gid",
#Default. Primary key of the taz shapefile
"landAreaField" : "land_area", #Default. land_area column
"geomtryField" : "the_geom", # TODO: Hardcoded in map_details query. Don't change
this.
"SRID"
}
: "4326", # recommended for OpenLayers performance. Don't change this.
SPATAIL_LAYER_EXTENT = [-77.3118739983803, 38.7127610002057, -76.0604099996577,
39.7211840011159] #CAHNGE ME. Get values from the extent query in SQL Changes folder
MAPFILE_PATH
= os.path.join(PROJECT_FULL_PATH, r"mapfiles", MODEL_NAME)
#mapfilePath
= "mapfiles/"
SHAPEFILE_PATH
= os.path.join(PROJECT_FULL_PATH, r"shapefiles"+os.sep)
#shapefilePath = "shapefiles/"
BARCHART_LAYER_NAME = "barcharts_layer"
# Parameters for Map files # added on Oct19, 2010
MAPFILE_NAME
= "mapfile"
MAP_UNITS
= "meters"
SPATAIL_LAYER_SCHEMA = "public" #Default
# Here you can list the layers in your context file, for mapit to load in the dot density maps, comma
separated layer names with no spaces among them
CONTEXT_LAYERS
= "MajorRoads,Transit" #CHANGE ME
IMAGEPATH
=os.path.join(PROJECT_FULL_PATH,"images/")
# IMAGEURL is used in MapServer template to point to the mapserverImage created in the path
IMAGEURL
="http://"+MAP_SERVER_IP+"/mapimages/"
TEMPLATE
=os.path.join(PROJECT_FULL_PATH,"templates/mapit/mapserv_template.html")
Appendix 2 (changes in mapFilesCreator.py file)
As it was explain before in section 7 of this document, when you run mapFilesCreator.py as part of the
MapIt installation, mapit_settings.py will be overwritten. As a result, once you make changes in
mapit_settings.py you need to make a copy of this file. But, besides that, some changes should be made
in two map files: contextlater.map and dot_density.map. The changes needed are highlighted in color in
tis appendix 2.
Changes in contextlayers.map:
#This MapFile was created with HBA Specto MapIt plugin
LAYER
NAME 'Counties_Coast'
TYPE POLYGON
18
PECAS Model Development: MapIt - Installation and Configuration
System Documentation Technical Note
File: MapIt documentation.docx
10.18.2011/ARM/GFM/JEA
DUMP false
EXTENT -77.3118739983803 38.7127610002057 -76.0604099996577 39.7211840011159
CONNECTIONTYPE postgis
CONNECTION "dbname='baltimore_db' host=localhost port=5432 user='usrPostgres'
password='usrPostgres'"
DATA 'the_geom FROM public.counties_coast USING UNIQUE gid USING srid=4326'
METADATA
'ows_title' 'Counties_Coast'
#This title needs to be listed in CONTEXT_LAYERS in the settings file before it gets loaded as
context in the dot density maps
'wms_title' 'Counties_Coast'
END
STATUS OFF
TRANSPARENCY 100
PROJECTION
"init=epsg:4326"
END
CLASS
NAME 'Counties_Coast'
STYLE
WIDTH 1.96
COLOR 0 170 255
END
END
END
LAYER
NAME 'Transit'
TYPE LINE
DUMP false
EXTENT -77.3118739983803 38.7127610002057 -76.0604099996577 39.7211840011159
CONNECTIONTYPE postgis
CONNECTION "dbname='baltimore_db' host=localhost port=5432 user='usrPostgres'
password='usrPostgres'"
DATA 'the_geom FROM public.transit USING UNIQUE gid USING srid=4326'
METADATA
'ows_title' 'Transit'
#This title needs to be listed in CONTEXT_LAYERS in the settings file before it gets loaded as
context in the dot density maps
'wms_title' 'Transit'
END
STATUS OFF
TRANSPARENCY 100
PROJECTION
"init=epsg:4326"
19
PECAS Model Development: MapIt - Installation and Configuration
System Documentation Technical Note
File: MapIt documentation.docx
10.18.2011/ARM/GFM/JEA
END
CLASS
NAME 'Transit'
STYLE
WIDTH 2.5
COLOR 0 170 0
END
END
END
# EXAMPLE OF A ROADWAY LAYER
LAYER
NAME 'MajorRoads'
TYPE LINE
DUMP false
EXTENT -77.3118739983803 38.7127610002057 -76.0604099996577 39.7211840011159
CONNECTIONTYPE postgis
CONNECTION "dbname='baltimore_db' host=localhost port=5432 user='usrPostgres'
password='usrPostgres'"
DATA 'the_geom FROM public.majorroads USING UNIQUE gid USING srid=4326'
METADATA
'ows_title' 'MajorRoads'
#This title needs to be listed in CONTEXT_LAYERS in the settings file before it gets loaded as context
in the dot density maps
'wms_title' 'MajorRoads'
END
STATUS OFF
TRANSPARENCY 100
PROJECTION
"init=epsg:4326"
END
CLASS
NAME 'MajorRoads'
STYLE
WIDTH 1.96
COLOR 255 0 0
END
END
END
WARNING: the same structure is repeated based on the number of layers. Each layer description follows
the same pattern. If the user is not sure about how to represent colors or line width, the easiest way to
produce this information is opening the file in a GIS program (for exampleQuantum GIS) and exporting
the file as a map file. Once you open the file with a text editor, a very similar structure is presented to
describe the file. The user only has to make a couple of changes accordingly.
20
PECAS Model Development: MapIt - Installation and Configuration
System Documentation Technical Note
File: MapIt documentation.docx
10.18.2011/ARM/GFM/JEA
Changes in dot_density.map:
#This MapFile was created with HBA Specto MapIt plugin
MAP
NAME "luzs_4326"
# Map image size
SIZE 1000 800
UNITS meters
FONTSET 'C:/djangoProjects/web_output/fontset.txt'
EXTENT -77.3118739984 38.7127610002 -76.0604099997 39.7211840011
PROJECTION
"init=epsg:4326"
END
#CONFIG "MS_ERRORFILE" "C:/djangoProjects/web_output/logs/mapserver.log"
#DEBUG 5
#TEMPLATEPATTERN 'mapserv_template*'
# Background color for the map canvas -- change as desired
IMAGECOLOR 255 255 255
IMAGEQUALITY 95
IMAGETYPE agg
OUTPUTFORMAT
NAME agg
DRIVER AGG/PNG
IMAGEMODE RGB
END
# Legend
LEGEND
IMAGECOLOR 255 255 255
STATUS ON
KEYSIZE 18 12
LABEL
TYPE BITMAP
SIZE MEDIUM
COLOR 0 0 89
END
END
SYMBOL
NAME "dot"
TYPE ellipse
POINTS 2 2 END
END
21
PECAS Model Development: MapIt - Installation and Configuration
System Documentation Technical Note
File: MapIt documentation.docx
10.18.2011/ARM/GFM/JEA
# Web interface definition. Only the template parameter
# is required to display a map. See MapServer documentation
WEB
# Set IMAGEPATH to the path where MapServer should
# write its output.
IMAGEPATH 'C:\djangoProjects\web_output\images/'
# Set IMAGEURL to the url that points to IMAGEPATH
# as defined in your web server configuration
IMAGEURL 'http://localhost/mapimages/'
METADATA
"wfs_title"
"scen1_120501_170604" ## REQUIRED
"wfs_onlineresource" "http://192.168.90.117:8766/cgibin/mapserv?map=/Users/jea/Development/web_output/temp/detailed_view_dot_density.map&" ##
Recommended
"wfs_srs"
"EPSG:4326 EPSG:4269 EPSG:3978 EPSG:3857" ## Recommended
"wfs_abstract"
"Atlanta MAPIT WFS Service." ## Recommended
"wfs_enable_request" "*" # necessary
"wms_title"
"scen1_120501_170604"
"wms_onlineresource" "http://192.168.90.117:8766/cgibin/mapserv?map=/Users/jea/Development/web_output/temp/detailed_view_dot_density.map&"
"wms_enable_request" "*"
END
#Scale range at which web interface will operate
# Template and header/footer settings
# Only the template parameter is required to display a map. See MapServer documentation
# e.g. TEMPLATE /Website/ModelResults/mapserv_template.html
TEMPLATE 'C:\djangoProjects\web_output\templates/mapit/mapserv_template.html'
END
include "contextlayers.map"
LAYER
NAME 'region'
TYPE POLYGON
DUMP false
EXTENT -77.3118739984 38.7127610002 -76.0604099997 39.7211840011
CONNECTIONTYPE postgis
CONNECTION "dbname='baltimore_db' host=localhost port=5432 user='usrPostgres'
password='usrPostgres'"
DATA 'the_geom FROM public."luzs_4326" USING UNIQUE gid USING srid=4326'
METADATA
'ows_title' 'region'
"wms_title" "region"
22
PECAS Model Development: MapIt - Installation and Configuration
System Documentation Technical Note
File: MapIt documentation.docx
10.18.2011/ARM/GFM/JEA
END
STATUS OFF
TRANSPARENCY 20
PROJECTION
"init=epsg:4326"
END
CLASS
NAME 'luzs'
STYLE
SYMBOL 0
SIZE 7.0
OUTLINECOLOR -1 -1 -1
COLOR 170 170 60
END
END
END
LAYER
NAME 'luzs'
TYPE POLYGON
DUMP false
EXTENT -77.3118739984 38.7127610002 -76.0604099997 39.7211840011
CONNECTIONTYPE postgis
CONNECTION "dbname='baltimore_db' host=localhost port=5432 user='usrPostgres'
password='usrPostgres'"
DATA 'the_geom FROM public."luzs_4326" USING UNIQUE gid USING srid=4326'
METADATA
'ows_title' 'luzs'
"wms_title" "luzs"
END
STATUS OFF
TRANSPARENCY 20
PROJECTION
"init=epsg:4326"
END
CLASS
NAME 'luzs'
STYLE
SYMBOL 0
SIZE 7.0
OUTLINECOLOR 0 0 0
COLOR -1 -1 -1
END
END
END
23
PECAS Model Development: MapIt - Installation and Configuration
System Documentation Technical Note
File: MapIt documentation.docx
10.18.2011/ARM/GFM/JEA
LAYER
NAME "dots detailed_view"
METADATA
'ows_title' 'dots detailed_view'
"wms_title" "dots detailed_view"
END
TYPE POINT
CONNECTIONTYPE postgis
CONNECTION "dbname='baltimore_db' host=localhost port=5432 user='usrPostgres'
password='usrPostgres'"
DATA 'the_geom FROM analysis."detailed_view-change-dots" USING UNIQUE gid USING
srid=4326'
STATUS ON
CLASS
EXPRESSION ([value] >0)
STYLE
SYMBOL "dot"
COLOR 0 0 255
END
END
CLASS
EXPRESSION ([value] <0)
STYLE
SYMBOL "dot"
COLOR 251 0 0
END
END
END
END
WARNING: the same structure is repeated based on the number of layers that the user need to locate in
the view change dot link. Each layer description follows the same pattern. If the user is not sure about
how to represent colors or line width, the easiest way to produce this information is opening the file in a
GIS program (for exampleQuantum GIS) and exporting the file as a map file. Once you open the file with
a text editor, a very similar structure is presented to describe the file. The user only has to make a
couple of changes accordingly.
24