-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathintroduction.html
1239 lines (1195 loc) · 80.9 KB
/
introduction.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en" data-content_root="./">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<title>An Introduction to MapServer — MapServer 8.4.0 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="_static/sphinx.css?v=6c7b17ac" />
<link rel="stylesheet" type="text/css" href="_static/copybutton.css?v=76b2166b" />
<link rel="stylesheet" type="text/css" href="_static/custom.css?v=dd298242" />
<link rel="stylesheet" type="text/css" href="_static/ribbon.css?v=ea091bf4" />
<script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=ea47c46f"></script>
<script src="_static/doctools.js?v=9bcbadda"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/clipboard.min.js?v=a7894cd8"></script>
<script src="_static/copybutton.js?v=f281be69"></script>
<link rel="icon" href="_static/mapserver.ico"/>
<link rel="author" title="About these documents" href="about.html" />
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="copyright" title="Copyright" href="copyright.html" />
<link rel="next" title="MapServer Tutorial" href="tutorial/index.html" />
<link rel="prev" title="MapServer 8.4.0 Documentation" href="documentation.html" />
</head><body>
<!-- for main branch only, do not backport this -->
<table width="100%" style="width: 100%; background-color: white;">
<tr>
<td rowspan="2" style="padding: 10px 0px 10px 10px;">
<a href="index.html" title="Home"><img src="_static/banner.png" alt="MapServer banner" border="0" /></a>
</td>
<td style="padding: 10px 10px 0px 0px; text-align: right; vertical-align: top;">
<a href="index.html" title="Home">Home</a> |
<a href="products.html" title="Products (MapServer core, MapCache, TinyOWS">Products</a> |
<a href="https://github.com/mapserver/mapserver/issues/" title="Issue Tracker (MapServer core)">Issue Tracker</a> |
<a href="community/service_providers.html" title="Professional Service Providers">Service Providers</a> |
<a href="faq.html" title="Frequently Asked Questions">FAQ</a> |
<a href="https://fosstodon.org/@mapserver" title="Mastodon" target="_blank">Mastodon</a> |
<a href="download.html" title="Download Source or Binaries">Download </a> |
<a class="badge" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KRJ2X44N3HA6U&source=url" target="_blank">
<img src="https://img.shields.io/badge/donate-%E2%9D%A4%C2%A0-ff69b4.svg?style=flat" alt="Donate to MapServer">
</a>
</td>
</tr>
<tr>
<td style="padding: 0px 10px 0px 0px; text-align: right; vertical-align: bottom;">
<img src="_static/flagicons/en.png" alt="en" title="en" border="0" width="18px" height="13px"/>
<a href="ar/introduction.html"><img src="_static/flagicons/ar.png" alt="ar" title="ar" border="0" /></a>
<a href="de/introduction.html"><img src="_static/flagicons/de.png" alt="de" title="de" border="0" /></a>
<a href="el/introduction.html"><img src="_static/flagicons/el.png" alt="el" title="el" border="0" /></a>
<a href="es/introduction.html"><img src="_static/flagicons/es.png" alt="es" title="es" border="0" /></a>
<a href="fr/introduction.html"><img src="_static/flagicons/fr.png" alt="fr" title="fr" border="0" /></a>
<a href="id/introduction.html"><img src="_static/flagicons/id.png" alt="id" title="id" border="0" /></a>
<a href="it/introduction.html"><img src="_static/flagicons/it.png" alt="it" title="it" border="0" /></a>
<a href="ja/introduction.html"><img src="_static/flagicons/ja.png" alt="ja" title="ja" border="0" /></a>
<a href="nl_NL/introduction.html"><img src="_static/flagicons/nl_NL.png" alt="nl_NL" title="nl_NL" border="0" /></a>
<a href="pl/introduction.html"><img src="_static/flagicons/pl.png" alt="pl" title="pl" border="0" /></a>
<a href="ru/introduction.html"><img src="_static/flagicons/ru.png" alt="ru" title="ru" border="0" /></a>
<a href="sq/introduction.html"><img src="_static/flagicons/sq.png" alt="sq" title="sq" border="0" /></a>
<a href="tr/introduction.html"><img src="_static/flagicons/tr.png" alt="tr" title="tr" border="0" /></a>
</td>
</tr>
</table>
<div class="related" role="navigation" aria-label="Related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="tutorial/index.html" title="MapServer Tutorial"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="documentation.html" title="MapServer 8.4.0 Documentation"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">Home</a> »</li>
<li class="nav-item nav-item-1"><a href="documentation.html" accesskey="U">MapServer 8.4.0 Documentation</a> »</li>
<li class="nav-item nav-item-this"><a href="">An Introduction to MapServer</a></li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="an-introduction-to-mapserver">
<span id="introduction"></span><h1><a class="toc-backref" href="#contents" role="doc-backlink">An Introduction to MapServer</a><a class="headerlink" href="#an-introduction-to-mapserver" title="Link to this heading">¶</a></h1>
<dl class="field-list simple">
<dt class="field-odd">Author<span class="colon">:</span></dt>
<dd class="field-odd"><p>Jeff McKenna</p>
</dd>
<dt class="field-even">Contact<span class="colon">:</span></dt>
<dd class="field-even"><p>jmckenna at gatewaygeomatics.com</p>
</dd>
<dt class="field-odd">Author<span class="colon">:</span></dt>
<dd class="field-odd"><p>David Fawcett</p>
</dd>
<dt class="field-even">Contact<span class="colon">:</span></dt>
<dd class="field-even"><p>david.fawcett at moea.state.mn.us</p>
</dd>
<dt class="field-odd">Author<span class="colon">:</span></dt>
<dd class="field-odd"><p>Howard Butler</p>
</dd>
<dt class="field-even">Contact<span class="colon">:</span></dt>
<dd class="field-even"><p>hobu.inc at gmail.com</p>
</dd>
<dt class="field-odd">Last Updated<span class="colon">:</span></dt>
<dd class="field-odd"><p>2024-07-08</p>
</dd>
</dl>
<nav class="contents" id="contents">
<p class="topic-title">Contents</p>
<ul class="simple">
<li><p><a class="reference internal" href="#an-introduction-to-mapserver" id="id7">An Introduction to MapServer</a></p>
<ul>
<li><p><a class="reference internal" href="#mapserver-overview" id="id8">MapServer Overview</a></p></li>
<li><p><a class="reference internal" href="#anatomy-of-a-mapserver-application" id="id9">Anatomy of a MapServer Application</a></p></li>
<li><p><a class="reference internal" href="#installation-and-requirements" id="id10">Installation and Requirements</a></p>
<ul>
<li><p><a class="reference internal" href="#hardware-requirements" id="id11">Hardware Requirements</a></p></li>
<li><p><a class="reference internal" href="#software-requirements" id="id12">Software Requirements</a></p></li>
<li><p><a class="reference internal" href="#skills" id="id13">Skills</a></p></li>
<li><p><a class="reference internal" href="#secure-your-installation" id="id14">Secure your installation</a></p></li>
<li><p><a class="reference internal" href="#windows-installation" id="id15">Windows Installation</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#introduction-to-the-mapfile" id="id16">Introduction to the Mapfile</a></p>
<ul>
<li><p><a class="reference internal" href="#map-object" id="id17">MAP Object</a></p></li>
<li><p><a class="reference internal" href="#layer-object" id="id18">LAYER Object</a></p></li>
<li><p><a class="reference internal" href="#class-and-style-objects" id="id19">CLASS and STYLE Objects</a></p></li>
<li><p><a class="reference internal" href="#symbols" id="id20">SYMBOLs</a></p></li>
<li><p><a class="reference internal" href="#label" id="id21">LABEL</a></p></li>
<li><p><a class="reference internal" href="#class-expressions" id="id22">CLASS Expressions</a></p></li>
<li><p><a class="reference internal" href="#include" id="id23">INCLUDE</a></p></li>
<li><p><a class="reference internal" href="#get-mapserver-running" id="id24">Get MapServer Running</a></p></li>
<li><p><a class="reference internal" href="#get-demo-running" id="id25">Get Demo Running</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#making-the-site-your-own" id="id26">Making the Site Your Own</a></p>
<ul>
<li><p><a class="reference internal" href="#adding-data-to-your-site" id="id27">Adding Data to Your Site</a></p></li>
<li><p><a class="reference internal" href="#vector-data" id="id28">Vector Data</a></p></li>
<li><p><a class="reference internal" href="#raster-data" id="id29">Raster Data</a></p></li>
<li><p><a class="reference internal" href="#projections" id="id30">Projections</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#enhancing-your-site" id="id31">Enhancing your site</a></p>
<ul>
<li><p><a class="reference internal" href="#adding-query-capability" id="id32">Adding Query Capability</a></p></li>
<li><p><a class="reference internal" href="#attribute-queries" id="id33">Attribute queries</a></p></li>
<li><p><a class="reference internal" href="#spatial-queries" id="id34">Spatial queries</a></p></li>
<li><p><a class="reference internal" href="#interfaces" id="id35">Interfaces</a></p></li>
<li><p><a class="reference internal" href="#data-optimization" id="id36">Data Optimization</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#how-do-i-get-help" id="id37">How do I get Help?</a></p>
<ul>
<li><p><a class="reference internal" href="#documentation" id="id38">Documentation</a></p></li>
<li><p><a class="reference internal" href="#users-mailing-list" id="id39">Users Mailing List</a></p></li>
<li><p><a class="reference internal" href="#matrix-irc" id="id40">Matrix/IRC</a></p></li>
<li><p><a class="reference internal" href="#reporting-bugs" id="id41">Reporting bugs</a></p></li>
<li><p><a class="reference internal" href="#tutorial" id="id42">Tutorial</a></p></li>
<li><p><a class="reference internal" href="#test-suite" id="id43">Test Suite</a></p></li>
<li><p><a class="reference internal" href="#books" id="id44">Books</a></p></li>
</ul>
</li>
</ul>
</li>
</ul>
</nav>
<section id="mapserver-overview">
<h2><a class="toc-backref" href="#contents" role="doc-backlink">MapServer Overview</a><a class="headerlink" href="#mapserver-overview" title="Link to this heading">¶</a></h2>
<p>MapServer is a popular Open Source project whose purpose is to display
dynamic spatial maps over the Internet. Some of its major features
include:</p>
<ul class="simple">
<li><p>support for display and querying of hundreds of raster, vector, and database
formats</p></li>
<li><p>ability to run on various operating systems (Windows, Linux, Mac OS X, etc.)</p></li>
<li><p>support for popular scripting languages and development environments
(PHP, Python, Perl, Ruby, Java, .NET)</p></li>
<li><p>on-the-fly projections</p></li>
<li><p>high quality rendering</p></li>
<li><p>fully customizable application output</p></li>
<li><p>many ready-to-use Open Source application environments</p></li>
</ul>
<p>In its most basic form, MapServer is a <a class="reference internal" href="glossary.html#term-CGI"><span class="xref std std-term">CGI</span></a> program that sits inactive
on your Web server. When a request is sent to MapServer, it uses information
passed in the request URL and the <a class="reference internal" href="mapfile/index.html#mapfile"><span class="std std-ref">Mapfile</span></a> to create an image
of the requested map. The request may also return images for legends, scale
bars, reference maps, and values passed as CGI variables.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p>The <a class="reference internal" href="glossary.html#gloss"><span class="std std-ref">Glossary</span></a> contains an overview of many of the jargon terms in this
document.</p>
</div>
<p>MapServer can be extended and customized through <a class="reference internal" href="mapscript/index.html#mapscript"><span class="std std-ref">MapScript</span></a>
or <a class="reference internal" href="mapfile/template.html#template"><span class="std std-ref">templating</span></a>. It can be built to support many different
<a class="reference internal" href="input/vector/index.html#vector"><span class="std std-ref">vector</span></a> and <a class="reference internal" href="input/raster.html#raster"><span class="std std-ref">raster</span></a> input data formats, and it
can generate a multitude of <a class="reference internal" href="output/index.html#output"><span class="std std-ref">output</span></a> formats. Most pre-compiled
MapServer distributions contain most all of its features.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="installation/unix.html#unix"><span class="std std-ref">Compiling on Unix</span></a> and <a class="reference internal" href="installation/win32.html#win32"><span class="std std-ref">Compiling on Win32</span></a></p>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p><a class="reference internal" href="glossary.html#term-MapScript"><span class="xref std std-term">MapScript</span></a> provides a scripting interface for MapServer for
the construction of Web and stand-alone applications. MapScript
can be used independently of CGI MapServer, and it is a loadable
module that adds MapServer capability to your favorite scripting
language. MapScript currently exists in <a class="reference internal" href="mapscript/php/index.html#php-mapscript"><span class="std std-ref">PHP</span></a>, Perl, <a class="reference internal" href="mapscript/python.html#python"><span class="std std-ref">Python</span></a>, Ruby, Tcl, Java,
and .NET flavors.</p>
<p>This guide will not explicitly discuss MapScript, check out the
<a class="reference internal" href="mapscript/index.html#mapscript"><span class="std std-ref">MapScript Reference</span></a> for more information.</p>
</div>
</section>
<section id="anatomy-of-a-mapserver-application">
<h2><a class="toc-backref" href="#contents" role="doc-backlink">Anatomy of a MapServer Application</a><a class="headerlink" href="#anatomy-of-a-mapserver-application" title="Link to this heading">¶</a></h2>
<figure class="align-default" id="id1">
<img alt="MapServer Basic Architecture" src="_images/architecture.png" />
<figcaption>
<p><span class="caption-text">The basic architecture of MapServer applications.</span><a class="headerlink" href="#id1" title="Link to this image">¶</a></p>
</figcaption>
</figure>
<p>A simple MapServer application consists of:</p>
<ul>
<li><p><strong>Map File</strong> - a structured text configuration file for your MapServer
application. It defines the area of your map, tells the MapServer program
where your data is and where to output images. It also defines your map
layers, including their data source, projections, and symbology.
It must have a .map extension or MapServer will not recognize it.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="mapfile/index.html#mapfile"><span class="std std-ref">MapServer Mapfile Reference</span></a></p>
</div>
</li>
<li><p><strong>Geographic Data</strong> - MapServer can utilize many geographic data source types.
The default format is the ESRI Shape format. Many other data formats can be
supported, this is discussed further below in <a class="reference internal" href="#adding-data-to-your-site">Adding data to your site</a>.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="input/vector/index.html#vector"><span class="std std-ref">Vector Input Reference</span></a> and <a class="reference internal" href="input/raster.html#raster"><span class="std std-ref">Raster Input
Reference</span></a></p>
</div>
</li>
<li><p><strong>HTML Pages</strong> - the interface between the user and MapServer .
They normally sit in Web root. In it’s simplest form, MapServer can
be called to place a static map image on a HTML page. To make the
map interactive, the image is placed in an HTML form on a page.</p>
<p><a class="reference internal" href="glossary.html#term-CGI"><span class="xref std std-term">CGI</span></a> programs are ‘stateless’, every request they get is new
and they don’t remember anything about the last time that they were
hit by your application. For this reason, every time your
application sends a request to MapServer, it needs to pass context
information (what layers are on, where you are on the map,
application mode, etc.) in hidden form variables or URL variables.</p>
<p>A simple MapServer <a class="reference internal" href="cgi/index.html#cgi"><span class="std std-ref">CGI</span></a> application may include two HTML pages:</p>
<ul>
<li><p><strong>Initialization File</strong> - uses a form with hidden variables to send an
initial query to the web server and MapServer. This form could be placed
on another page or be replaced by passing the initialization information
as variables in a URL.</p></li>
<li><p><strong>Template File</strong> - controls how the maps and legends output by
MapServer will appear in the browser. By referencing MapServer
CGI variables in the template HTML, you allow MapServer to
populate them with values related to the current state of your
application (e.g. map image name, reference image name, map
extent, etc.) as it creates the HTML page for the browser to
read. The template also determines how the user can interact with
the MapServer application (browse, zoom, pan, query).</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="mapfile/template.html#template"><span class="std std-ref">Templating</span></a></p>
</div>
</li>
</ul>
</li>
<li><p><strong>MapServer CGI</strong> - The binary or executable file that receives requests and
returns images, data, etc. It sits in the cgi-bin or scripts directory of
the web server. The Web server user must have execute rights for the
directory that it sits in, and for security reasons, it should not be in
the web root. By default, this program is called <a class="reference internal" href="cgi/mapserv.html#mapserv"><span class="std std-ref">mapserv</span></a></p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>It is strongly recommended to review the security steps for the <em>MAP=</em>
call to the MapServer executable, by setting <em>MS_MAP_PATTERN</em> or
<em>MS_MAP_NO_PATH</em> or hiding the <em>MAP=</em> parameter on public servers,
as recommended in the document <a class="reference internal" href="optimization/limit_mapfile_access.html#limit-mapfile-access"><span class="std std-ref">Limit Mapfile Access</span></a>. All possible
environment variables to secure your server are listed in <a class="reference internal" href="optimization/environment_variables.html#environment-variables"><span class="std std-ref">Environment Variables</span></a>.</p>
</div>
</li>
<li><p><strong>Web/HTTP Server</strong> - serves up the HTML pages when hit by the
user’s browser. You need a working Web (HTTP) server, such as
<a class="reference external" href="http://httpd.apache.org">Apache</a> or Microsoft Internet
Information Server, on the machine on which you are installing
MapServer.</p></li>
</ul>
</section>
<section id="installation-and-requirements">
<h2><a class="toc-backref" href="#contents" role="doc-backlink">Installation and Requirements</a><a class="headerlink" href="#installation-and-requirements" title="Link to this heading">¶</a></h2>
<section id="hardware-requirements">
<h3><a class="toc-backref" href="#contents" role="doc-backlink">Hardware Requirements</a><a class="headerlink" href="#hardware-requirements" title="Link to this heading">¶</a></h3>
<p>MapServer runs on Linux, Windows, Mac OS X, Solaris, and more.
To compile or install some of the required programs, you may need
administrative rights to the machine. People commonly ask questions about
minimum hardware specifications for MapServer applications, but the answers
are really specific to the individual application. For development and
learning purposes, a very minimal machine will work fine. For deployment,
you will want to investigate <a class="reference internal" href="optimization/index.html#optimization"><span class="std std-ref">Optimization</span></a> of everything from your
data to server configuration.</p>
</section>
<section id="software-requirements">
<h3><a class="toc-backref" href="#contents" role="doc-backlink">Software Requirements</a><a class="headerlink" href="#software-requirements" title="Link to this heading">¶</a></h3>
<p>You need a working and properly configured Web (HTTP) server, such as <a class="reference external" href="https://httpd.apache.org/">Apache</a> or Microsoft Internet Information Server, on the
machine on which you are installing MapServer.</p>
<p>If you are on a Windows machine, and you don’t have a web server installed,
it is recommended that you use <a class="reference external" href="https://ms4w.com">MS4W</a>,
which will install a pre-configured web server, MapServer, MapCache, PHP,
TinyOWS, and many more utilities. Windows users can optionally check out the
<a class="reference external" href="https://trac.osgeo.org/osgeo4w/">OSGeo4W</a> installer as well.</p>
<p>This introduction will assume you are using an MS4W installation
to follow along. Obtaining MapServer on <a class="reference internal" href="download.html#linux"><span class="std std-ref">Linux</span></a> or
<a class="reference internal" href="download.html#osx"><span class="std std-ref">Mac OS X</span></a> should be straightforward. Visit <a class="reference internal" href="download.html#download"><span class="std std-ref">Download</span></a> for
installing pre-compiled MapServer builds on Mac OS X and Linux.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>The <a class="reference external" href="https://live.osgeo.org/en/index.html">OSGeo-Live</a>
virtual machine contains MapServer ready to use as well.</p>
</div>
<p>You will also need a Web browser, and a text editor (vi, emacs, notepad++, textpad,
homesite) to modify your HTML and <a class="reference internal" href="mapfile/index.html#mapfile"><span class="std std-ref">mapfiles</span></a>.</p>
<div class="admonition tip">
<p class="admonition-title">Tip</p>
<p>Notepad++ users can follow these <a class="reference external" href="https://ms4w.com/trac/wiki/Notepad%2B%2BMapServerStyle">steps</a> to add syntax coloring to .map files.</p>
</div>
</section>
<section id="skills">
<h3><a class="toc-backref" href="#contents" role="doc-backlink">Skills</a><a class="headerlink" href="#skills" title="Link to this heading">¶</a></h3>
<p>In addition to learning how the different components of a MapServer
application work together and learning Map File syntax, building a basic
application requires some conceptual understanding and proficiency in several
skill areas.</p>
<p>You need to be able to create or at least modify <a class="reference external" href="https://www.w3.org/MarkUp/Guide/">HTML</a> pages and understand how HTML forms work.
Since the primary purpose of a MapServer application is to create maps, you
will also need to understand the basics of geographic data and likely, map
projections. As your applications get more complex, skills in SQL,
DHTML/Javascript, Java, databases, expressions, compiling, and scripting may
be very useful.</p>
</section>
<section id="secure-your-installation">
<h3><a class="toc-backref" href="#contents" role="doc-backlink">Secure your installation</a><a class="headerlink" href="#secure-your-installation" title="Link to this heading">¶</a></h3>
<p>During your installation and configuration, it is strongly recommended to review the
security steps for the <em>MAP=</em> call to the MapServer executable, by setting
<em>MS_MAP_PATTERN</em> or <em>MS_MAP_NO_PATH</em> or hiding the <em>MAP=</em> parameter on
public servers, as recommended in the document <a class="reference internal" href="optimization/limit_mapfile_access.html#limit-mapfile-access"><span class="std std-ref">Limit Mapfile Access</span></a>. All possible
environment variables to secure your server are listed in <a class="reference internal" href="optimization/environment_variables.html#environment-variables"><span class="std std-ref">Environment Variables</span></a>.</p>
</section>
<section id="windows-installation">
<h3><a class="toc-backref" href="#contents" role="doc-backlink">Windows Installation</a><a class="headerlink" href="#windows-installation" title="Link to this heading">¶</a></h3>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Pre-compiled binaries for MapServer are available from a variety of
sources, refer to the <a class="reference internal" href="download.html#windows"><span class="std std-ref">Windows</span></a> section of the Downloads page.</p>
</div>
<p>MS4W (MapServer for Windows) is the long-time installer that contains
the Apache Web server, MapServer, and all of its dependencies and tools; MS4W
also contains several add-on packages, that contain over 60+ pre-configured
MapServer configuration files (mapfiles) and data. The
following steps illustrate how to install MS4W:</p>
<ol class="arabic">
<li><p>Download MS4W (this example will use the <cite>-setup.exe</cite> file) from
<a class="reference external" href="https://ms4w.com/">https://ms4w.com/</a></p></li>
<li><p>Execute (double-click) the .exe</p></li>
<li><p>Click the “Agree” button, to accept the license.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>MS4W uses the very open <a class="reference external" href="https://ms4w.com/LICENSE.html">MIT/X license</a>.</p>
</div>
<img alt="_images/ms4w-license.jpg" src="_images/ms4w-license.jpg" />
</li>
<li><p>Select packages to install. Be sure to also select the “<cite>MapServer Itasca Demo Application</cite>”,
as we will be using this demo later.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>You can optionally install other packages, by clicking the checkbox
beside the package name.</p>
</div>
<img alt="_images/ms4w-packages.jpg" src="_images/ms4w-packages.jpg" />
</li>
<li><p>Click the “Next” button</p></li>
<li><p>Click the “Browse…” button, to choose an installation path. You can safely
leave the default (C:/), and the installer will create <cite>C:/ms4w</cite>.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Folders with spaces are supported, if you are using the <cite>-setup.exe</cite> installer.</p>
</div>
<img alt="_images/ms4w-install-folder.jpg" src="_images/ms4w-install-folder.jpg" />
</li>
<li><p>Click the “Next” button</p></li>
<li><p>Enter a port number to use for the Apache service. In most cases you
can leave the port as <cite>80</cite>, unless something is using that port such as
an IIS service.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>You can specify any number above <cite>1024</cite>, such as <cite>8081</cite> or <cite>8082</cite>.</p>
</div>
<img alt="_images/ms4w-port.jpg" src="_images/ms4w-port.jpg" />
</li>
</ol>
<ol class="arabic" start="10">
<li><p>Click the “Install” button</p>
<img alt="_images/ms4w-install.jpg" src="_images/ms4w-install.jpg" />
</li>
<li><p>Once you see a message of “<cite>Installer Complete</cite>”, then click the “Close” button</p>
<img alt="_images/ms4w-install-complete.jpg" src="_images/ms4w-install-complete.jpg" />
</li>
<li><p>On your desktop, click on the “MS4W-Localhost” shortcut, and your browser
should open <a class="reference external" href="http://127.0.0.1">http://127.0.0.1</a> that loads an MS4W introduction page.</p>
<img alt="_images/ms4w-browser.jpg" src="_images/ms4w-browser.jpg" />
</li>
<li><p>Verify that MapServer is working, by clicking on the <cite>/cgi-bin/mapserv.exe</cite> link
in the “Features” section of the page.</p></li>
</ol>
<blockquote>
<div><div class="admonition note">
<p class="admonition-title">Note</p>
<p>If MapServer is working properly, you will receive a message stating: “<cite>No query
information to decode. QUERY_STRING is set, but empty.</cite>”</p>
</div>
<img alt="_images/ms4w-cgi-success.jpg" src="_images/ms4w-cgi-success.jpg" />
</div></blockquote>
</section>
</section>
<section id="introduction-to-the-mapfile">
<h2><a class="toc-backref" href="#contents" role="doc-backlink">Introduction to the Mapfile</a><a class="headerlink" href="#introduction-to-the-mapfile" title="Link to this heading">¶</a></h2>
<p>The .map file is the basic configuration file for data access and styling for
MapServer. The file is an ASCII text file, and is made up of different
objects. Each object has a variety of parameters available for it. All .map
file (or mapfile) parameters are documented in the <a class="reference internal" href="mapfile/index.html#mapfile"><span class="std std-ref">mapfile reference</span></a>. A simple mapfile example displaying only one layer follows, as well
as the map image output:</p>
<div class="admonition tip">
<p class="admonition-title">Tip</p>
<p>Notepad++ users can follow these <a class="reference external" href="https://ms4w.com/trac/wiki/Notepad%2B%2BMapServerStyle">steps</a> to add syntax coloring to .map files.</p>
</div>
<div class="highlight-mapfile notranslate"><div class="highlight"><pre><span></span><span class="k">MAP</span>
<span class="k">NAME</span> <span class="s">"sample"</span>
<span class="k">STATUS</span> <span class="nb">ON</span>
<span class="k">SIZE</span> <span class="mi">600</span> <span class="mi">400</span>
<span class="k">SYMBOLSET</span> <span class="s">"../etc/symbols.txt"</span>
<span class="k">EXTENT</span> <span class="p">-</span><span class="mi">180</span> <span class="p">-</span><span class="mi">90</span> <span class="mi">180</span> <span class="mi">90</span>
<span class="k">UNITS</span> <span class="nb">DD</span>
<span class="k">SHAPEPATH</span> <span class="s">"../data"</span>
<span class="k">IMAGECOLOR</span> <span class="mi">255</span> <span class="mi">255</span> <span class="mi">255</span>
<span class="k">FONTSET</span> <span class="s">"../etc/fonts.txt"</span>
<span class="c">#</span>
<span class="c"># Start of web interface definition</span>
<span class="c">#</span>
<span class="k">WEB</span>
<span class="k">IMAGEPATH</span> <span class="s">"/ms4w/tmp/ms_tmp/"</span>
<span class="k">IMAGEURL</span> <span class="s">"/ms_tmp/"</span>
<span class="k">END</span> <span class="c"># WEB</span>
<span class="c">#</span>
<span class="c"># Start of layer definitions</span>
<span class="c">#</span>
<span class="k">LAYER</span>
<span class="k">NAME</span> <span class="s">'global-raster'</span>
<span class="k">TYPE</span> <span class="nb">RASTER</span>
<span class="k">STATUS</span> <span class="nb">DEFAULT</span>
<span class="k">DATA</span> <span class="err">bluemarb</span><span class="ow">le</span><span class="p">.</span><span class="nb">gif</span>
<span class="k">END</span> <span class="c"># LAYER</span>
<span class="k">END</span> <span class="c"># MAP</span>
</pre></div>
</div>
<figure class="align-default" id="id2">
<img alt="Rendered Bluemarble Image" src="_images/bluemarble-rendered.jpg" />
<figcaption>
<p><span class="caption-text">Rendered Bluemarble Image</span><a class="headerlink" href="#id2" title="Link to this image">¶</a></p>
</figcaption>
</figure>
<div class="admonition note">
<p class="admonition-title">Note</p>
<ul class="simple">
<li><p>Comments in a mapfile are specified with a ‘#’ character. Since
version 7.2 MapServer also supports single or multi-line C-style
comments, as <cite>/* … */</cite></p></li>
<li><p>MapServer parses mapfiles from top to bottom, therefore layers at the
end of the mapfile will be drawn last (meaning they will be displayed on
top of other layers)</p></li>
<li><p>Using relative paths is always recommended</p></li>
<li><p>Paths should be quoted (single or double quotes are accepted)</p></li>
<li><p>The above example is built on the following directory structure:</p>
<ul>
<li><p>The mapfile could be placed anywhere, as long as it is
accessible to the web server. Normally, one would try to
avoid placing it at a location that makes it accessible on the
web. Let us say it is placed in /home/msuser/mapfiles/</p></li>
<li><p>The location of the font file is given relative to the map
file, in this case: /home/msuser/etc/fonts.txt</p></li>
<li><p>The location of the datasets (<cite>bluemarble.gif</cite>) is given
relative to the map file, in this case: /home/msuser/data/</p></li>
<li><p>The location of the symbol file is given relative to the map
file, in this case: /home/msuser/etc/symbols.txt</p></li>
<li><p>The files generated by MapServer will be placed in the
directory /ms4w/tmp/ms_tmp/. The web server must be able to
place files in this directory. The web server must make this
directory available as /ms_tmp (if the web server is on
<cite>www.ms.org</cite>, the web address to the directory must be:
<cite>httpd://www.ms.org/ms_tmp/</cite>.</p></li>
</ul>
</li>
</ul>
</div>
<section id="map-object">
<h3><a class="toc-backref" href="#contents" role="doc-backlink">MAP Object</a><a class="headerlink" href="#map-object" title="Link to this heading">¶</a></h3>
<div class="highlight-mapfile notranslate"><div class="highlight"><pre><span></span><span class="k">MAP</span>
<span class="k">NAME</span> <span class="s">"sample"</span>
<span class="k">EXTENT</span> <span class="p">-</span><span class="mi">180</span> <span class="p">-</span><span class="mi">90</span> <span class="mi">180</span> <span class="mi">90</span> <span class="c"># Geographic</span>
<span class="k">SIZE</span> <span class="mi">800</span> <span class="mi">400</span>
<span class="k">IMAGECOLOR</span> <span class="mi">128</span> <span class="mi">128</span> <span class="mi">255</span>
<span class="k">END</span> <span class="c"># MAP</span>
</pre></div>
</div>
<ul class="simple">
<li><p>EXTENT is the output extent in the units of the output map</p></li>
<li><p>SIZE is the width and height of the map image in pixels</p></li>
<li><p>IMAGECOLOR is the default image background color</p></li>
</ul>
<div class="admonition tip">
<p class="admonition-title">Tip</p>
<p>MapServer accepts colors in RGB values, or as a hexadecimal string.</p>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>MapServer currently uses a pixel-center based extent model which is
a bit different from what GDAL or WMS use.</p>
</div>
</section>
<section id="layer-object">
<h3><a class="toc-backref" href="#contents" role="doc-backlink">LAYER Object</a><a class="headerlink" href="#layer-object" title="Link to this heading">¶</a></h3>
<ul class="simple">
<li><p>starting with MapServer 5.0, there is no limit to the number of layers in a
mapfile</p></li>
<li><p>the <cite>DATA</cite> parameter is relative to the <cite>SHAPEPATH</cite> parameter of the
<a class="reference internal" href="mapfile/map.html#map"><span class="std std-ref">MAP</span></a> object</p></li>
<li><p>if no <cite>DATA</cite> extension is provided in the filename, MapServer will
assume it is ESRI Shape format (.shp)</p></li>
</ul>
<section id="raster-layers">
<h4>Raster Layers<a class="headerlink" href="#raster-layers" title="Link to this heading">¶</a></h4>
<div class="highlight-mapfile notranslate"><div class="highlight"><pre><span></span><span class="k">LAYER</span>
<span class="k">NAME</span> <span class="s">"bathymetry"</span>
<span class="k">TYPE</span> <span class="nb">RASTER</span>
<span class="k">STATUS</span> <span class="nb">DEFAULT</span>
<span class="k">DATA</span> <span class="s">"bath_mapserver.tif"</span>
<span class="k">END</span> <span class="c"># LAYER</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="input/raster.html#raster"><span class="std std-ref">Raster Data</span></a></p>
</div>
</section>
<section id="vector-layers">
<h4>Vector Layers<a class="headerlink" href="#vector-layers" title="Link to this heading">¶</a></h4>
<p>Vector layers of <cite>TYPE</cite> <cite>point</cite>, <cite>line</cite>, or <cite>polygon</cite> can be
displayed. The following example shows how to display only lines from
a <cite>TYPE</cite> polygon layer, using the <cite>OUTLINECOLOR</cite> parameter:</p>
<div class="highlight-mapfile notranslate"><div class="highlight"><pre><span></span><span class="k">LAYER</span>
<span class="k">NAME</span> <span class="s">"world_poly"</span>
<span class="k">DATA</span> <span class="s">'shapefile/countries_area.shp'</span>
<span class="k">STATUS</span> <span class="nb">ON</span>
<span class="k">TYPE</span> <span class="nb">POLYGON</span>
<span class="k">CLASS</span>
<span class="k">NAME</span> <span class="s">'The World'</span>
<span class="k">STYLE</span>
<span class="k">OUTLINECOLOR</span> <span class="mi">0</span> <span class="mi">0</span> <span class="mi">0</span>
<span class="k">END</span> <span class="c"># STYLE</span>
<span class="k">END</span> <span class="c"># CLASS</span>
<span class="k">END</span> <span class="c"># LAYER</span>
</pre></div>
</div>
<div class="admonition tip">
<p class="admonition-title">Tip</p>
<p>MapServer accepts colors in RGB values, or as a hexadecimal string.</p>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="input/vector/index.html#vector"><span class="std std-ref">Vector Data</span></a></p>
</div>
<figure class="align-default" id="id3">
<img alt="Rendered Bluemarble Image" src="_images/bluemarble-boundaries.jpg" />
<figcaption>
<p><span class="caption-text">Rendered Bluemarble image with vector boundaries</span><a class="headerlink" href="#id3" title="Link to this image">¶</a></p>
</figcaption>
</figure>
</section>
</section>
<section id="class-and-style-objects">
<h3><a class="toc-backref" href="#contents" role="doc-backlink">CLASS and STYLE Objects</a><a class="headerlink" href="#class-and-style-objects" title="Link to this heading">¶</a></h3>
<ul class="simple">
<li><p>typical styling information is stored within the <a class="reference internal" href="mapfile/class.html#class"><span class="std std-ref">CLASS</span></a> and
<a class="reference internal" href="mapfile/style.html#style"><span class="std std-ref">STYLE</span></a> objects of a <a class="reference internal" href="mapfile/layer.html#layer"><span class="std std-ref">LAYER</span></a></p></li>
<li><p>starting with MapServer 5.0, there is no limit to the number of classes or
styles in a mapfile</p></li>
<li><p>the following example shows how to display a road line with two colors by
using overlaid <cite>STYLE</cite> objects</p></li>
</ul>
<div class="highlight-mapfile notranslate"><div class="highlight"><pre><span></span><span class="k">CLASS</span>
<span class="k">NAME</span> <span class="s">"Primary Roads"</span>
<span class="k">STYLE</span>
<span class="k">SYMBOL</span> <span class="s">"circle"</span>
<span class="k">COLOR</span> <span class="mi">178</span> <span class="mi">114</span> <span class="mi">1</span>
<span class="k">SIZE</span> <span class="mi">15</span>
<span class="k">END</span> <span class="c"># STYLE</span>
<span class="k">STYLE</span>
<span class="k">SYMBOL</span> <span class="s">"circle"</span>
<span class="k">COLOR</span> <span class="mi">254</span> <span class="mi">161</span> <span class="mi">0</span>
<span class="k">SIZE</span> <span class="mi">7</span>
<span class="k">END</span> <span class="c"># STYLE</span>
<span class="k">END</span> <span class="c"># CLASS</span>
</pre></div>
</div>
<div class="admonition tip">
<p class="admonition-title">Tip</p>
<p>MapServer accepts colors in RGB values, or as a hexadecimal string.</p>
</div>
<figure class="align-default" id="id4">
<img alt="Rendered Bluemarble Image" src="_images/bluemarble-style.jpg" />
<figcaption>
<p><span class="caption-text">Rendered Bluemarble image with styled roads</span><a class="headerlink" href="#id4" title="Link to this image">¶</a></p>
</figcaption>
</figure>
</section>
<section id="symbols">
<h3><a class="toc-backref" href="#contents" role="doc-backlink">SYMBOLs</a><a class="headerlink" href="#symbols" title="Link to this heading">¶</a></h3>
<ul class="simple">
<li><p>can be defined directly in the mapfile, or in a separate file</p></li>
<li><p>the separate file method must use the <cite>SYMBOLSET</cite> parameter in the
<cite>MAP</cite> object:</p></li>
</ul>
<div class="highlight-mapfile notranslate"><div class="highlight"><pre><span></span><span class="k">MAP</span>
<span class="k">NAME</span> <span class="s">"sample"</span>
<span class="k">EXTENT</span> <span class="p">-</span><span class="mi">180</span> <span class="p">-</span><span class="mi">90</span> <span class="mi">180</span> <span class="mi">90</span> <span class="c"># Geographic</span>
<span class="k">SIZE</span> <span class="mi">800</span> <span class="mi">400</span>
<span class="k">IMAGECOLOR</span> <span class="mi">128</span> <span class="mi">128</span> <span class="mi">255</span>
<span class="k">SYMBOLSET</span> <span class="s">"../etc/symbols.txt"</span>
<span class="k">END</span> <span class="c"># MAP</span>
</pre></div>
</div>
<p>where symbols.txt might contain:</p>
<div class="highlight-mapfile notranslate"><div class="highlight"><pre><span></span><span class="k">SYMBOL</span>
<span class="k">NAME</span> <span class="s">"ski"</span>
<span class="k">TYPE</span> <span class="nb">PIXMAP</span>
<span class="k">IMAGE</span> <span class="s">"ski.png"</span>
<span class="k">END</span> <span class="c"># SYMBOL</span>
</pre></div>
</div>
<p>and the mapfile would contain:</p>
<div class="highlight-mapfile notranslate"><div class="highlight"><pre><span></span><span class="k">LAYER</span>
<span class="p">...</span>
<span class="k">CLASS</span>
<span class="k">NAME</span> <span class="s">"Ski Area"</span>
<span class="k">STYLE</span>
<span class="k">SYMBOL</span> <span class="s">"ski"</span>
<span class="k">END</span> <span class="c"># STYLE</span>
<span class="k">END</span> <span class="c"># CLASS</span>
<span class="k">END</span> <span class="c"># LAYER</span>
</pre></div>
</div>
<figure class="align-default" id="id5">
<img alt="Rendered Bluemarble Image Skier" src="_images/bluemarble-ski.jpg" />
<figcaption>
<p><span class="caption-text">Rendered Bluemarble image with skier symbol</span><a class="headerlink" href="#id5" title="Link to this image">¶</a></p>
</figcaption>
</figure>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="mapfile/symbology/construction.html#sym-construction"><span class="std std-ref">Cartographical Symbol Construction with MapServer</span></a>, <a class="reference internal" href="mapfile/symbology/examples.html#sym-examples"><span class="std std-ref">Symbology Examples</span></a>, and <a class="reference internal" href="mapfile/symbol.html#symbol"><span class="std std-ref">SYMBOL</span></a></p>
</div>
</section>
<section id="label">
<h3><a class="toc-backref" href="#contents" role="doc-backlink">LABEL</a><a class="headerlink" href="#label" title="Link to this heading">¶</a></h3>
<ul class="simple">
<li><p>defined within a <a class="reference internal" href="mapfile/class.html#class"><span class="std std-ref">CLASS</span></a> object</p></li>
<li><p>the <cite>LABELITEM</cite> parameters in the <a class="reference internal" href="mapfile/layer.html#layer"><span class="std std-ref">LAYER</span></a> object can be used to
specify an attribute in the data to be used for labeling. The label
is displayed by the <cite>FONT</cite>, declared in the <a class="reference internal" href="mapfile/fontset.html#fontset"><span class="std std-ref">FONTSET</span></a> file (set
in the <a class="reference internal" href="mapfile/map.html#map"><span class="std std-ref">MAP</span></a> object). The <a class="reference internal" href="mapfile/fontset.html#fontset"><span class="std std-ref">FONTSET</span></a> file contains
references to the available font names. <cite>ENCODING</cite> describes which
encoding is used in the file (see <a class="reference internal" href="mapfile/encoding.html#encoding"><span class="std std-ref">Display of International Characters in MapServer</span></a>).</p></li>
</ul>
<p>An example <a class="reference internal" href="mapfile/label.html#label"><span class="std std-ref">LABEL</span></a> object that references one of the above fonts might
look like:</p>
<div class="highlight-mapfile notranslate"><div class="highlight"><pre><span></span><span class="k">LABEL</span>
<span class="k">FONT</span> <span class="s">"sans-bold"</span>
<span class="k">TYPE</span> <span class="nb">truetype</span>
<span class="k">ENCODING</span> <span class="s">"UTF-8"</span>
<span class="k">SIZE</span> <span class="mi">10</span>
<span class="k">POSITION</span> <span class="nb">LC</span>
<span class="k">PARTIALS</span> <span class="nb">FALSE</span>
<span class="k">COLOR</span> <span class="mi">100</span> <span class="mi">100</span> <span class="mi">100</span>
<span class="k">OUTLINECOLOR</span> <span class="mi">242</span> <span class="mi">236</span> <span class="mi">230</span>
<span class="k">END</span> <span class="c"># LABEL</span>
</pre></div>
</div>
<figure class="align-default" id="id6">
<img alt="Rendered Bluemarble Image Skier" src="_images/bluemarble-ski-label.jpg" />
<figcaption>
<p><span class="caption-text">Rendered Bluemarble image with skier symbol and a label</span><a class="headerlink" href="#id6" title="Link to this image">¶</a></p>
</figcaption>
</figure>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="mapfile/label.html#label"><span class="std std-ref">LABEL</span></a>, <a class="reference internal" href="mapfile/fontset.html#fontset"><span class="std std-ref">FONTSET</span></a></p>
</div>
</section>
<section id="class-expressions">
<h3><a class="toc-backref" href="#contents" role="doc-backlink">CLASS Expressions</a><a class="headerlink" href="#class-expressions" title="Link to this heading">¶</a></h3>
<p>MapServer supports three types of <a class="reference internal" href="mapfile/class.html#class"><span class="std std-ref">CLASS</span></a> <a class="reference internal" href="mapfile/expressions.html#expressions"><span class="std std-ref">Expressions</span></a> in a
<a class="reference internal" href="mapfile/layer.html#layer"><span class="std std-ref">LAYER</span></a> (<cite>CLASSITEM</cite> in <cite>LAYER</cite> determines the attribute to be
used for the two first types of expressions):</p>
<ol class="arabic">
<li><p>String comparisons</p>
<blockquote>
<div><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">EXPRESSION</span> <span class="s2">"africa"</span>
</pre></div>
</div>
</div></blockquote>
</li>
<li><p>Regular expressions</p>
<blockquote>
<div><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">EXPRESSION</span> <span class="o">/^</span><span class="mi">9</span><span class="o">|^</span><span class="mi">10</span><span class="o">/</span>
</pre></div>
</div>
</div></blockquote>
</li>
<li><p>Logical expressions</p>
<blockquote>
<div><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">EXPRESSION</span> <span class="p">([</span><span class="n">POPULATION</span><span class="p">]</span> <span class="o">></span> <span class="mi">50000</span> <span class="n">AND</span> <span class="s1">'[LANGUAGE]'</span> <span class="n">eq</span> <span class="s1">'FRENCH'</span><span class="p">)</span>
</pre></div>
</div>
</div></blockquote>
</li>
</ol>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Logical expressions should be avoided wherever possible as they are very
costly in terms of drawing time.</p>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="mapfile/expressions.html#expressions"><span class="std std-ref">Expressions</span></a></p>
</div>
</section>
<section id="include">
<h3><a class="toc-backref" href="#contents" role="doc-backlink">INCLUDE</a><a class="headerlink" href="#include" title="Link to this heading">¶</a></h3>
<p>Added to MapServer 4.10, any part of the mapfile can now be stored in a
separate file and added to the main mapfile using the <a class="reference internal" href="mapfile/include.html#include"><span class="std std-ref">INCLUDE</span></a>
parameter. The filename to be included can have any extension, and it is
always relative to the main .map file.
Here are some potential uses:</p>
<ul class="simple">
<li><p><a class="reference internal" href="mapfile/layer.html#layer"><span class="std std-ref">LAYER</span></a>s can be stored in files and included to any number of
applications</p></li>
<li><p><a class="reference internal" href="mapfile/style.html#style"><span class="std std-ref">STYLE</span></a>s can also be stored and included in multiple applications</p></li>
</ul>
<p>The following is an example of using mapfile <a class="reference internal" href="mapfile/include.html#include"><span class="std std-ref">includes</span></a> to include a layer definition in a separate file:</p>
<p>If ‘shadedrelief.lay’ contains:</p>
<div class="highlight-mapfile notranslate"><div class="highlight"><pre><span></span><span class="k">LAYER</span>
<span class="k">NAME</span> <span class="s">'shadedrelief'</span>
<span class="k">STATUS</span> <span class="nb">ON</span>
<span class="k">TYPE</span> <span class="nb">RASTER</span>
<span class="k">DATA</span> <span class="s">'GLOBALeb3colshade.jpg'</span>
<span class="k">END</span> <span class="c"># LAYER</span>
</pre></div>
</div>
<p>therefore the main mapfile would contain:</p>
<div class="highlight-mapfile notranslate"><div class="highlight"><pre><span></span><span class="k">MAP</span>
<span class="p">...</span>
<span class="k">INCLUDE</span> <span class="s">"shadedrelief.lay"</span>
<span class="p">...</span>
<span class="k">END</span> <span class="c"># MAP</span>
</pre></div>
</div>
<p>The following is an example of a mapfile where all <a class="reference internal" href="mapfile/layer.html#layer"><span class="std std-ref">LAYER</span></a> s are in
separate .lay files, and all other objects (<a class="reference internal" href="mapfile/web.html#web"><span class="std std-ref">WEB</span></a>, <a class="reference internal" href="mapfile/reference.html#reference"><span class="std std-ref">REFERENCE</span></a>,
<a class="reference internal" href="mapfile/scalebar.html#scalebar"><span class="std std-ref">SCALEBAR</span></a>, etc.) are stored in a “.ref” file:</p>
<div class="highlight-mapfile notranslate"><div class="highlight"><pre><span></span><span class="k">MAP</span>
<span class="k">NAME</span> <span class="s">"base"</span>
<span class="c">#</span>
<span class="c"># include reference objects</span>
<span class="c">#</span>
<span class="k">INCLUDE</span> <span class="s">"../templates/template.ref"</span>
<span class="c">#</span>
<span class="c"># Start of layer definitions</span>
<span class="c">#</span>
<span class="k">INCLUDE</span> <span class="s">"../layers/usa/usa_outline.lay"</span>
<span class="k">INCLUDE</span> <span class="s">"../layers/canada/base/1m/provinces.lay"</span>
<span class="k">INCLUDE</span> <span class="s">"../layers/canada/base/1m/roads_atlas_of_canada_1m.lay"</span>
<span class="k">INCLUDE</span> <span class="s">"../layers/canada/base/1m/roads_atlas_of_canada_1m_shields.lay"</span>
<span class="k">INCLUDE</span> <span class="s">"../layers/canada/base/1m/populated_places.lay"</span>
<span class="k">END</span> <span class="c"># MAP</span>
</pre></div>
</div>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p><a class="reference internal" href="mapfile/index.html#mapfile"><span class="std std-ref">Mapfiles</span></a> must have the <cite>.map</cite> extension or
MapServer will not recognize them. Include files can have any extension
you want, however.</p>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="mapfile/include.html#include"><span class="std std-ref">INCLUDE</span></a></p>
</div>
</section>
<section id="get-mapserver-running">
<h3><a class="toc-backref" href="#contents" role="doc-backlink">Get MapServer Running</a><a class="headerlink" href="#get-mapserver-running" title="Link to this heading">¶</a></h3>
<p>You can test if MapServer is working by running the MapServer
executable (<cite>mapserv</cite>) with the -v parameter on the command line
(./mapserv -v).</p>
<p>MS4W users that installed through the <cite>-setup.exe</cite>
installer, can use the <cite>MS4W-Shell</cite> shortcut on the desktop, and then run
<cite>mapserv -v</cite> at the commandline. MS4W users who did not use the <cite>-setup.exe</cite>
installer can open a Command Prompt window, cd to their installation folder, and
then execute <cite>setenv.bat</cite>, before testing a <cite>mapserv -v</cite> command.</p>
<p>Depending on your configuration, the output could be
something like this:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">MapServer</span> <span class="n">version</span> <span class="mf">7.0.1</span> <span class="p">(</span><span class="n">MS4W</span> <span class="mf">3.1.4</span><span class="p">)</span> <span class="n">OUTPUT</span><span class="o">=</span><span class="n">PNG</span> <span class="n">OUTPUT</span><span class="o">=</span><span class="n">JPEG</span> <span class="n">OUTPUT</span><span class="o">=</span><span class="n">KML</span>
<span class="n">SUPPORTS</span><span class="o">=</span><span class="n">PROJ</span> <span class="n">SUPPORTS</span><span class="o">=</span><span class="n">AGG</span> <span class="n">SUPPORTS</span><span class="o">=</span><span class="n">FREETYPE</span> <span class="n">SUPPORTS</span><span class="o">=</span><span class="n">CAIRO</span> <span class="n">SUPPORTS</span><span class="o">=</span><span class="n">ICONV</span>
<span class="n">SUPPORTS</span><span class="o">=</span><span class="n">FRIBIDI</span> <span class="n">SUPPORTS</span><span class="o">=</span><span class="n">WMS_SERVER</span> <span class="n">SUPPORTS</span><span class="o">=</span><span class="n">WMS_CLIENT</span> <span class="n">SUPPORTS</span><span class="o">=</span><span class="n">WFS_SERVER</span>
<span class="n">SUPPORTS</span><span class="o">=</span><span class="n">WFS_CLIENT</span> <span class="n">SUPPORTS</span><span class="o">=</span><span class="n">WCS_SERVER</span> <span class="n">SUPPORTS</span><span class="o">=</span><span class="n">SOS_SERVER</span> <span class="n">SUPPORTS</span><span class="o">=</span><span class="n">FASTCGI</span>
<span class="n">SUPPORTS</span><span class="o">=</span><span class="n">THREADS</span> <span class="n">SUPPORTS</span><span class="o">=</span><span class="n">GEOS</span> <span class="n">INPUT</span><span class="o">=</span><span class="n">JPEG</span> <span class="n">INPUT</span><span class="o">=</span><span class="n">POSTGIS</span> <span class="n">INPUT</span><span class="o">=</span><span class="n">OGR</span> <span class="n">INPUT</span><span class="o">=</span><span class="n">GDAL</span>
<span class="n">INPUT</span><span class="o">=</span><span class="n">SHAPEFILE</span>
</pre></div>
</div>
<p>You can also send a HTTP request directly to the MapServer CGI program without
passing any configuration variables (e.g.
<a class="reference external" href="http://127.0.0.1/cgi-bin/mapserv.exe">http://127.0.0.1/cgi-bin/mapserv.exe</a>). If you receive the message,
‘No query information to decode. <cite>QUERY_STRING</cite> not set.’, your installation is
working.</p>
</section>
<section id="get-demo-running">
<h3><a class="toc-backref" href="#contents" role="doc-backlink">Get Demo Running</a><a class="headerlink" href="#get-demo-running" title="Link to this heading">¶</a></h3>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>MS4W users do not have to do this step, as the above instructions already
installed the demo. You should see a “<cite>MapServer Itasca Demo Application</cite>”
section on the bottom of the page (after clicking the <cite>MS4W-Localhost</cite> shortcut).</p>
</div>
<p>Download the <a class="reference external" href="https://download.osgeo.org/mapserver/docs/workshop-5.4.zip">MapServer Demo</a>.
UnZip it and follow the directions in ReadMe.txt. You will need to
move the demo files to their appropriate locations on your web
server, and modify the Map File and HTML pages to reflect the paths
and URLs of your server. Next, point your browser to init.html and
hit the ‘initialize button’. If you get errors, verify that you have
correctly modified the demo files.</p>
</section>
</section>
<section id="making-the-site-your-own">
<h2><a class="toc-backref" href="#contents" role="doc-backlink">Making the Site Your Own</a><a class="headerlink" href="#making-the-site-your-own" title="Link to this heading">¶</a></h2>
<p>Now that you have a working MapServer demo, you can use the demo to display
your own data. Add new <cite>LAYER</cite>s to your Map file that refer to your own
geographic data layers (you will probably want to delete the existing layers
or set their status to <cite>OFF</cite>).</p>
<p>Unless you are adding layers that fall within the same geographic area
as the demo, modify <a class="reference internal" href="mapfile/map.html#map"><span class="std std-ref">MAP</span></a> <cite>EXTENT</cite> to match the extent of your
data. To determine the extent of your data, you can use <a class="reference external" href="https://gdal.org/programs/ogrinfo.html">ogrinfo</a>. If you have access to a GIS,
you could use that as well. The <a class="reference internal" href="mapfile/map.html#map"><span class="std std-ref">MAP</span></a> <cite>EXTENT</cite> needs to be in the
units of your output projection.</p>
<p>If you add geographic data layers with different geographical
reference systems, you will need to modify your Map File to add a
<a class="reference internal" href="mapfile/projection.html#projection"><span class="std std-ref">PROJECTION</span></a> block to the <a class="reference internal" href="mapfile/map.html#map"><span class="std std-ref">MAP</span></a> (defines the output
projection / geographical reference system) and each of the
<a class="reference internal" href="mapfile/layer.html#layer"><span class="std std-ref">LAYER</span></a>s (defines the geographical reference system of the layer
dataset).</p>
<section id="adding-data-to-your-site">
<h3><a class="toc-backref" href="#contents" role="doc-backlink">Adding Data to Your Site</a><a class="headerlink" href="#adding-data-to-your-site" title="Link to this heading">¶</a></h3>
<p>MapServer supports several data input formats ‘natively’, and many more if
it is compiled with the Open Source libraries <a class="reference internal" href="glossary.html#term-GDAL"><span class="xref std std-term">GDAL</span></a> and <a class="reference internal" href="glossary.html#term-OGR"><span class="xref std std-term">OGR</span></a>.</p>
</section>
<section id="vector-data">
<h3><a class="toc-backref" href="#contents" role="doc-backlink">Vector Data</a><a class="headerlink" href="#vector-data" title="Link to this heading">¶</a></h3>
<p>Vector data includes features made up of points, lines, and polygons.
MapServer support the ESRI Shape format by default, but it can be compiled to
support spatially enabled databases such as
<a class="reference external" href="https://postgis.net/">PostgreSQL-PostGIS</a>,
and file formats such as
<a class="reference external" href="https://en.wikipedia.org/wiki/Geography_Markup_Language">Geography Markup Language (GML)</a>,
<a class="reference external" href="https://www.pitneybowes.com/ca/en/location-intelligence/geographic-information-systems/mapinfo-pro.html">MapInfo</a>, delimited text files, and more
formats with <a class="reference internal" href="input/vector/ogr.html#ogr"><span class="std std-ref">OGR Vector Layers Through MapServer</span></a>.</p>
<p>See the <a class="reference internal" href="input/vector/index.html#vector"><span class="std std-ref">Vector Data reference</span></a> for examples on how to
add different geographic data sources to your MapServer project.</p>
</section>
<section id="raster-data">
<h3><a class="toc-backref" href="#contents" role="doc-backlink">Raster Data</a><a class="headerlink" href="#raster-data" title="Link to this heading">¶</a></h3>
<p>Raster data is image or grid data.
Through <a class="reference external" href="https://gdal.org/">GDAL</a>, MapServer supports
most raster formats - see the
<a class="reference external" href="https://gdal.org/drivers/raster/index.html">GDAL format list</a>.
More specific information can be found in the
<a class="reference internal" href="input/raster.html#raster"><span class="std std-ref">Raster Data reference</span></a>.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Since version 6.2 MapServer relies on GDAL for all raster access.</p>
</div>
</section>
<section id="projections">
<h3><a class="toc-backref" href="#contents" role="doc-backlink">Projections</a><a class="headerlink" href="#projections" title="Link to this heading">¶</a></h3>
<p>Because the earth is round and your monitor (or paper map) is flat, distortions
will occur when you display geographic data in a two-dimensional image.
Projections allow you to represent geographic data on a flat surface. In
doing so, some of the original properties (e.g. area, direction, distance,
scale or conformity) of the data will be distorted. Different projections
excel at accurately portraying different properties.</p>
<p>With MapServer, if you keep all of your spatial data sets in the same
projection (or unprojected Latitude and Longitude), you do not need to
include any projection info in your Map File. In building your first
MapServer application, this simplification is recommended.</p>
<p>On-the-fly projection can be accomplished when MapServer is compiled with
<a class="reference internal" href="glossary.html#term-PROJ"><span class="xref std std-term">PROJ</span></a> support. Instructions on how to enable PROJ support on
Windows can be found on the <a class="reference external" href="https://github.com/MapServer/MapServer/wiki/WindowsProjHowto">Wiki</a>.</p>
</section>
</section>
<section id="enhancing-your-site">
<h2><a class="toc-backref" href="#contents" role="doc-backlink">Enhancing your site</a><a class="headerlink" href="#enhancing-your-site" title="Link to this heading">¶</a></h2>
<section id="adding-query-capability">
<h3><a class="toc-backref" href="#contents" role="doc-backlink">Adding Query Capability</a><a class="headerlink" href="#adding-query-capability" title="Link to this heading">¶</a></h3>
<p>There are two primary ways to query spatial data. Both methods return data
through the use of templates and CGI variable replacement. A <a class="reference internal" href="mapfile/querymap.html#querymap"><span class="std std-ref">QUERYMAP</span></a>
can be used to map the results of the query.</p>
<p>To be queryable, each mapfile <a class="reference internal" href="mapfile/layer.html#layer"><span class="std std-ref">LAYER</span></a> must have a <a class="reference internal" href="mapfile/template.html#template"><span class="std std-ref">TEMPLATE</span></a> defined, or each <a class="reference internal" href="mapfile/class.html#class"><span class="std std-ref">CLASS</span></a> within the LAYER must have a
TEMPLATE defined. More information about the CGI variables used to define
queries can be found in the <a class="reference internal" href="cgi/index.html#cgi"><span class="std std-ref">MapServer CGI Reference</span></a>.</p>
</section>
<section id="attribute-queries">
<h3><a class="toc-backref" href="#contents" role="doc-backlink">Attribute queries</a><a class="headerlink" href="#attribute-queries" title="Link to this heading">¶</a></h3>
<p>The user selects features based on data associated with that feature.
‘Show me all of the lakes where depth is greater than 100 feet’, with
‘depth’ being a field in the Shape dataset or the spatial database.
Attribute queries are accomplished by passing query definition information
to MapServer in the URL (or form post). Mode=itemquery returns a single
result, and mode=itemnquery returns multiple result sets.</p>
<p>The request must also include a QLAYER, which identifies the layer to be
queried, and a QSTRING which contains the query string. Optionally, QITEM, can
be used in conjunction with QSTRING to define the field to be queried.
Attribute queries only apply within the <cite>EXTENT</cite> set in the map file.</p>
</section>
<section id="spatial-queries">
<h3><a class="toc-backref" href="#contents" role="doc-backlink">Spatial queries</a><a class="headerlink" href="#spatial-queries" title="Link to this heading">¶</a></h3>
<p>The user selects features based on a click on the map or a user-defined
selection box. Again the request is passed through a URL or form post.
By setting mode=QUERY, a user click will return the one closest feature.
In mode=NQUERY, all features found by a map click or user-defined selection
box are returned. Additional query options can be found in the <a class="reference internal" href="cgi/index.html#cgi"><span class="std std-ref">CGI</span></a>
documentation.</p>
</section>
<section id="interfaces">
<h3><a class="toc-backref" href="#contents" role="doc-backlink">Interfaces</a><a class="headerlink" href="#interfaces" title="Link to this heading">¶</a></h3>