Title: UMN MapServer
1UMN MapServer
- ??????? ????????
- ???????????????????????????????????
- ????????????????????????????
2UMN MapServer
- ?????????? ??????????????
- ??????????????????? ?????????? ??????????????????
- ??????????????? ?????????????????????????????????
- ???????? CGI Script ( PHP, Python, Perl, Ruby,
Java, and C ) - ?????????????????????
- ????????????????????????????????????????????
- ???????????????????????????? ??????? ??????? ???
??????? - ????????????????????? 4.10.2
- ??????????????? http//mapserver.gis.umn.edu/
3MapServer Basic Functionality
- Map Creation
- Map Component(eg. Legend, Scalbar and reference
map) - Simple feature Query
- On-the-fly projection
- Annotation including scaling, rotation, outline
and drop shadows
4MapServer Features
- Advanced cartographic output
- Scale dependent feature drawing and application
execution - Feature labeling
- TrueType fonts
- Map element automation (scalebar, reference map,
and legend) - Thematic mapping using logical- or regular
expression-based classes - Support for popular scripting and development
environments - PHP, Python, Perl, Ruby, Java, and C
- Cross-platform support
- Linux, Windows, Mac OS X, Solaris, and more
- A multitude of raster and vector data formats
- Map projection support
- On-the-fly map projection
5MapServer Input Data Format
- Raster
- TIFF, GeoTIFF, PNG, JPEG, GIF
- GDAL
- Verctor
- ShapeFile
- OGR(MIF, TAB, DGN, ArcInfo, GML)
- PostGIS, SDE, Oracle Spatial
- Other
- OGC
6MapServer Output Data Format
- Raster
- PNG, JPEG, GIF, WBMP
- Verctor
- Flash, PDF, GML(WFL)
- Other
- OGC WMS
7System Requirement
- Operation System
- Web Server
- CGI
- Database
8MapServer Installation
- Web Server
- MapServer 4.10.2
- Mapscript 4.10 with PHP 5.2.1 and up
- PostgreSQL 8.1
- PostGIS
9MS4W
- ???????????????????? ms4w_2.2.4.zip
- unzip ms4w_2.2.4.zip ????? root directory ???
drive ?????????? - doubleclick ???apache-install.bat ?????????
Apache ???????? - ????????????????????? Apache ??????????????
D\ms4w\Apache\conf\httpd.conf - line 53 Listen 80 ? Listen 8010
10MapServer Installation
- For Windows
- ms4w_2.2.4.zip
- Web Server Apache 2.2.4
- PHP 5.2.3 with Mapscript 4.10
- MapServer 4.10.2
- PostgreSQL 8.1
- PostGIS
11http//localhost8010
12http//localhost/cgi-bin/mapserv.exe
???????????????? MapServer
13UMN MapServer
14MapServer
15Map File
MAP
Size, Extent
16????????????????????? Map File
- MapFiles ?????????????????(not case-sensitive)Â
- ????????????????????????????????(non-alphanumeric
characters) ???? MapServer keyword
????????????????????????? ( quoted)Â - ????? Layers ?? Map File ???????????? 50 Layers
????????? layers ????????????????? map.h
???????????? layer ????????????? MS_MAXLAYERS
???? compile - File paths ???????????????? absolute paths ????
paths relative ???????????????????????? Map File
???? data files ???????????? relative ???
SHAPEPATH - ???????????? Map File ??????? hierarchical
structure ????? Map object ???? "root" ???
objects ????????????????? Map object
17Map file D\ms4w\Apache\htdocs\day1\ex-01.map
- MAP
- NAME HELLO
- STATUS ON
- EXTENT 0 0 1 1
- SIZE 500 300
- IMAGECOLOR 200 150 255
- IMAGETYPE png
- LAYER
- NAME "credits"
- TYPE POINT
- FEATURE
- POINTS 0 0 END
- TEXT 'Hello world.'
- END
- CLASS
-
- END
- END
- END
CLASS LABEL TYPE BITMAP COLOR 255
0 0 END end of label END end of class
18Map file Output
http//localhost/cgi-bin/mapserv.exe ?map./../ht
docs/day1/ex-01.mapmodemap
19MAP Object
- General Map Settings
- NAME Â
- UNITS feetincheskilometersmetersmilesddÂ
- EXTENT minx miny maxx maxy
- How to get extent
- - ogrinfo province.shp al -summary
- - SELECT extent(the_geom) from province
- STATUS onoff
-
20???????? Extent
Quantum GIS Layer - - gtProperties
21???????? Extent (Vector)
- ogrinfo
- ogrinfo filename.shp layername so enter
22???????? Extent (Vector)
- PostGIS
- SELECT extent(the_geom) FROM province
23???????? Extent (Raster)
- gdalinfo
- gdalinfo filename.tifenter
24???????? Extent
- ??????? Quantum GIS
- CD/software/Qgis/qgis-0.8.0_setup.exe
- FW Tools
- CD/software/ms4/FWTools105.exe
25???????? Extent (Vector)
- ogrinfo
- ogrinfo d\ms4\shp\province.shp province -
so enter
26???????? Extent (Vector)
- PostGIS
-
- SELECT extent(the_geom) FROM province
27Map file D\ms4w\Apache\htdocs\day1\ex-02.map
- MAP
- NAME THAI
- STATUS ON
- EXTENT 0 0 4000 3000
- SIZE 400 300
- IMAGECOLOR 200 255 255
- WEB
- IMAGEPATH /ms4w/apache/htdoc/tmp/
- IMAGEURL ./../tmp/
- END
- LAYER
- NAME PROVINCE
- TYPE POLYGON
- STATUS DEFAULT
- DATA /ms4/shp/province.shp
- LABELITEM CHANGWAT
- CLASS
- NAME ???????
28Map file Output
http//localhost/cgi-bin/mapserv.exe ?map./../
htdocs/day1/ex-02.map modemaplayersall
29Browse Mode
http//localhost/cgi-bin/mapserv.exe ?map./../
htdocs/day1/ex-01.map modebrowselayersal
l
mapserv() Web application error. No template
provided.
30Browse Mode
MAP NAME HELLO STATUS ON EXTENT -1 -1 1
1 SIZE 400 400 IMAGECOLOR 200 150
255 IMAGETYPE png WEB TEMPLATE
ex-01.html IMAGEPATH
"/ms4w/apache/htdocs/tmp/" IMAGEURL
"./../tmp/" END LAYER ...
... END
31Browse Mode
http//localhost/cgi-bin/mapserv.exe ?map./../
htdocs/day1/ex-01.map modebrowselayersal
l
Content-type text/html msReturnPage() Unable to
access file. ex-01.html
32Browse Mode
- ????? ex-01.html
- lthtmlgt
- ltbodygt
- ltIMG SRCimg BORDER"0"gt
- lt/bodygt
- lt/htmlgt
33Browse Mode
- msSaveImageGD() Unable to access file.
- Unable to open file /ms4w/apache/htdocs/tmp/HE
LLO1189416292664.png for writing - ????????????
- ????? Folder /ms4w/apache/htdocs/tmp/
34Browse mode
- ??????????????? Page
- Rt. Click ?????? -gt Properties
- ??????? Path ??????
- IMAGEURL "./../tmp/"
35MapSurfer
- MapSurfer http//172.20.26.100/mapsurfer.zip
- Unzip to /ms4w/Apache/htdocs/
36http//172.20.26.100/mapsurfer.zip
37http//localhost8010/mapsurfer/
mapper.html
layers.html
refmap.html
info.html
38MapSurfer
- ????? Map File
- TEMPLATEPATTERN printable.htmlloader.html
- Web Interface
- WEB
- TEMPLATE "printable.html"
- EMPTY "/mapsurfer/info.html"
- IMAGEPATH "/ms4w/Apache/htdocs/tmp/"
- IMAGEURL "./../tmp/"
- END
39MapSurfer
- Mapsurfer/mapper.html
- Line 21 var mapfile '../htdocs/mapsurfer/test.
map' - Line 22 var extent new Array(325216 ,620850,
1213687, 2263257) - Line 23 var layers new Array('province,
district') - // fullview action
- Line 41 actions4 'myMap.redraw(new
Array(325216 ,620850, - 1213687, 2263257)) swap(\'fullview\',
\'fullview_off\')' - // socal action
- Line 43 actions5 'myMap.redraw(new
Array(412507 ,1517078,594970,1731143))
swap(\'socal\', \'socal_off\')'
40MapSurfer
- Mapsurfer/layers.html
- ???????????????(Layers)
- ltform name"layerselect"gt
- ltinput name"province"
- typecheckbox checked
- onClickloadLayers() gt
- ???????ltbrgt
- lt/formgt
41MapSurfer - query map
42MapSurfer - query map
quake_footer.html
lt/tablegt
43p.Mapper
- P.Mapper cd/software/ms4w/pmapper_ms4w-3.1-b4.
zip - Unzip to ms4w
- Edit /ms4w/apache/httpd/httpd.conf
- Alias /pmapper "/ms4w/apps/pmapper"
- ltDirectory "/ms4w/apps/pmapper"gt
- AllowOverride None
- Options Indexes FollowSymLinks Multiviews
- Order allow,deny
- Allow from all
- lt/Directorygt
- Restart service Apache
44D\ms4w\apps\pmapper\config\default\php_config.php
45Data Access and Performance
- Native
- Shapefile
- Geo Tiff image
- PostGIS
- GDAL/OGR
- Map
- etc.
46MAP Object
- General Output Settings
- IMAGETYPE gifpngjpegwbmpgtiffswfuserdefined
- SIZE x y in pixels Â
- WEB see WEB object
47WEB Object
- WEBÂ IMAGEPATH /ms4w/Apache/htdocs/
- Â IMAGEURL "/tmp/"Â ERROR /ms4w/Apache/htdocs/ms_
error.htm -  EMPTY /ms4w/Apache/htdocs/ms_empty.htm LOG
/ms4w/Apache/htdocs/logs/mapserver.log - END
48LAYER Object
- General Layer Settings
- NAME
- limited to 20 characters.
- This name is the link between the MapFile and web
interfaces that refer to this name. - They must be identical.
- The name should be unique.
- STATUS onoffdefault
- TYPE pointlinepolygoncircleannotationraster
query - MINSCALE Minimum scale at which this layer is
drawn. - MAXSCALE Maximum scale at which this layer is
drawn. - CLASSITEM Item name in attribute table to use
- for CLASS lookups.
49CLASS Object
- NAME
- EXPRESSION
- String comparisons
- EXPRESSION water
- regular expressions
- EXPRESSION /water/
- simple logical expressions
- ,gt,lt,lt,gt,,or,and,lt,gt,ge,le,eq
- (POPULATION gt 50000 AND 'LANGUAGE' eq
'FRENCH') - string functions
- EXPRESSION (length('NAME_E') lt 8)
50CLASS Object
- COLOR r g b
- OUTLINECOLOR r g b
- BACKGROUNDCOLOR r g b
51Symbols
52Sample MapFiles
Shape Files LAYER Â NAME "Parcels" Â STATUS ON Â
DATA "surveying/parcels.shp" Â TYPE POLYGON Â
CLASS Â Â Â Â Â COLOR 255 255 204 Â Â Â Â Â OUTLINECOLOR
0 0 0 Â END END
53Sample MapFiles
MapInfo Files LAYER NAME "POI TYPE POINT
MINSCALE 0 MAXSCALE 2000 STATUS ON
CONNECTIONTYPE OGR CONNECTION
"..\data\poi.TAB Â CLASS Â Â COLOR 255 0
0 END END
54Sample MapFiles
PostGIS DB LAYER NAME "POI TYPE
POINT MINSCALE 0 MAXSCALE 2000
STATUS ON CONNECTIONTYPE postgis
CONNECTION "userwood dbnameforestry
hostcanada DATA "the_geom from stands" Â
  CLASS      COLOR 255 0 0   END
END
55Sample MapFiles
Raster Files LAYER NAME "POI
TYPE RASTER MINSCALE 0 MAXSCALE
2000 STATUS ON DATA
./../map/school.tif  CLASS     Â
COLOR 255 0 0 Â Â END END
56??????? PostgreSQLPostGIS
- CD/software/postgreSQL
- ??????? PostgreSQL
- Postgresql-8.2.3-1.zip
- ??????? PostGIS
- postgis-pg82-setup-1.2.1-1.exe
- ?????????????
- Psql U postgres postgis
- \i D/ms4/postGIS/province.sql